babylon.module.d.ts 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837159838159839159840159841159842159843159844159845159846159847159848159849159850159851159852159853159854159855159856159857159858159859159860159861159862159863159864159865159866159867159868159869159870159871159872159873159874159875159876159877159878159879159880159881159882159883159884159885159886159887159888159889159890159891159892159893159894159895159896159897159898159899159900159901159902159903159904159905159906159907159908159909159910159911159912159913159914159915159916159917159918159919159920159921159922159923159924159925159926159927159928159929159930159931159932159933159934159935159936159937159938159939159940159941159942159943159944159945159946159947159948159949159950159951159952159953159954159955159956159957159958159959159960159961159962159963159964159965159966159967159968159969159970159971159972159973159974159975159976159977159978159979159980159981159982159983159984159985159986159987159988159989159990159991159992159993159994159995159996159997159998159999160000160001160002160003160004160005160006160007160008160009160010160011160012160013160014160015160016160017160018160019160020160021160022160023160024160025160026160027160028160029160030160031160032160033160034160035160036160037160038160039160040160041160042160043160044160045160046160047160048160049160050160051160052160053160054160055160056160057160058160059160060160061160062160063160064160065160066160067160068160069160070160071160072160073160074160075160076160077160078160079160080160081160082160083160084160085160086160087160088160089160090160091160092160093160094160095160096160097160098160099160100160101160102160103160104160105160106160107160108160109160110160111160112160113160114160115160116160117160118160119160120160121160122160123160124160125160126160127160128160129160130160131160132160133160134160135160136160137160138160139160140160141160142160143160144160145160146160147160148160149160150160151160152160153160154160155160156160157160158160159160160160161160162160163160164160165160166160167160168160169160170160171160172160173160174160175160176160177160178160179160180160181160182160183160184160185160186160187160188160189160190160191160192160193160194160195160196160197160198160199160200160201160202160203160204160205160206160207160208160209160210160211160212160213160214160215160216160217160218160219160220160221160222160223160224160225160226160227160228160229160230160231160232160233160234160235160236160237160238160239160240160241160242160243160244160245160246160247160248160249160250160251160252160253160254160255160256160257160258160259160260160261160262160263160264160265160266160267160268160269160270160271160272160273160274160275160276160277160278160279160280160281160282160283160284160285160286160287160288160289160290160291160292160293160294160295160296160297160298160299160300160301160302160303160304160305160306160307160308160309160310160311160312160313160314160315160316160317160318160319160320160321160322160323160324160325160326160327160328160329160330160331160332160333160334160335160336160337160338160339160340160341160342160343160344160345160346160347160348160349160350160351160352160353160354160355160356160357160358160359160360160361160362160363160364160365160366160367160368160369160370160371160372160373160374160375160376160377160378160379160380160381160382160383160384160385160386160387160388160389160390160391160392160393160394160395160396160397160398160399160400160401160402160403160404160405160406160407160408160409160410160411160412160413160414160415160416160417160418160419160420160421160422160423160424160425160426160427160428160429160430160431160432160433160434160435160436160437160438160439160440160441160442160443160444160445160446160447160448160449160450160451160452160453160454160455160456160457160458160459160460160461160462160463160464160465160466160467160468160469160470160471160472160473160474160475160476160477160478160479160480160481160482160483160484160485160486160487160488160489160490160491160492160493160494160495160496160497160498160499160500160501160502160503160504160505160506160507160508160509160510160511160512160513160514160515160516160517160518160519160520160521160522160523160524160525160526160527160528160529160530160531160532160533160534160535160536160537160538160539160540160541160542160543160544160545160546160547160548160549160550160551160552160553160554160555160556160557160558160559160560160561160562160563160564160565160566160567160568160569160570160571160572160573160574160575160576160577160578160579160580160581160582160583160584160585160586160587160588160589160590160591160592160593160594160595160596160597160598160599160600160601160602160603160604160605160606160607160608160609160610160611160612160613160614160615160616160617160618160619160620160621160622160623160624160625160626160627160628160629160630160631160632160633160634160635160636160637160638160639160640160641160642160643160644160645160646160647160648160649160650160651160652160653160654160655160656160657160658160659160660160661160662160663160664160665160666160667160668160669160670160671160672160673160674160675160676160677160678160679160680160681160682160683160684160685160686160687160688160689160690160691160692160693160694160695160696160697160698160699160700160701160702160703160704160705160706160707160708160709160710160711160712160713160714160715160716160717160718160719160720160721160722160723160724160725160726160727160728160729160730160731160732160733160734160735160736160737160738160739160740160741160742160743160744160745160746160747160748160749160750160751160752160753160754160755160756160757160758160759160760160761160762160763160764160765160766160767160768160769160770160771160772160773160774160775160776160777160778160779160780160781160782160783160784160785160786160787160788160789160790160791160792160793160794160795160796160797160798160799160800160801160802160803160804160805160806160807160808160809160810160811160812160813160814160815160816160817160818160819160820160821160822160823160824160825160826160827160828160829160830160831160832160833160834160835160836160837160838160839160840160841160842160843160844160845160846160847160848160849160850160851160852160853160854160855160856160857160858160859160860160861160862160863160864160865160866160867160868160869160870160871160872160873160874160875160876160877160878160879160880160881160882160883160884160885160886160887160888160889160890160891160892160893160894160895160896160897160898160899160900160901160902160903160904160905160906160907160908160909160910160911160912160913160914160915160916160917160918160919160920160921160922160923160924160925160926160927160928160929160930160931160932160933160934160935160936160937160938160939160940160941160942160943160944160945160946160947160948160949160950160951160952160953160954160955160956160957160958160959160960160961160962160963160964160965160966160967160968160969160970160971160972160973160974160975160976160977160978160979160980160981160982160983160984160985160986160987160988160989160990160991160992160993160994160995160996160997160998160999161000161001161002161003161004161005161006161007161008161009161010161011161012161013161014161015161016161017161018161019161020161021161022161023161024161025161026161027161028161029161030161031161032161033161034161035161036161037161038161039161040161041161042161043161044161045161046161047161048161049161050161051161052161053161054161055161056161057161058161059161060161061161062161063161064161065161066161067161068161069161070161071161072161073161074161075161076161077161078161079161080161081161082161083161084161085161086161087161088161089161090161091161092161093161094161095161096161097161098161099161100161101161102161103161104161105161106161107161108161109161110161111161112161113161114161115161116161117161118161119161120161121161122161123161124161125161126161127161128161129161130161131161132161133161134161135161136161137161138161139161140161141161142161143161144161145161146161147161148161149161150161151161152161153161154161155161156161157161158161159161160161161161162161163161164161165161166161167161168161169161170161171161172161173161174161175161176161177161178161179161180161181161182161183161184161185161186161187161188161189161190161191161192161193161194161195161196161197161198161199161200161201161202161203161204161205161206161207161208161209161210161211161212161213161214161215161216161217161218161219161220161221161222161223161224161225161226161227161228161229161230161231161232161233161234161235161236161237161238161239161240161241161242161243161244161245161246161247161248161249161250161251161252161253161254161255161256161257161258161259161260161261161262161263161264161265161266161267161268161269161270161271161272161273161274161275161276161277161278161279161280161281161282161283161284161285161286161287161288161289161290161291161292161293161294161295161296161297161298161299161300161301161302161303161304161305161306161307161308161309161310161311161312161313161314161315161316161317161318161319161320161321161322161323161324161325161326161327161328161329161330161331161332161333161334161335161336161337161338161339161340161341161342161343161344161345161346161347161348161349161350161351161352161353161354161355161356161357161358161359161360161361161362161363161364161365161366161367161368161369161370161371161372161373161374161375161376161377161378161379161380161381161382161383161384161385161386161387161388161389161390161391161392161393161394161395161396161397161398161399161400161401161402161403161404161405161406161407161408161409161410161411161412161413161414161415161416161417161418161419161420161421161422161423161424161425161426161427161428161429161430161431161432161433161434161435161436161437161438161439161440161441161442161443161444161445161446161447161448161449161450161451161452161453161454161455161456161457161458161459161460161461161462161463161464161465161466161467161468161469161470161471161472161473161474161475161476161477161478161479161480161481161482161483161484161485161486161487161488161489161490161491161492161493161494161495161496161497161498161499161500161501161502161503161504161505161506161507161508161509161510161511161512161513161514161515161516161517161518161519161520161521161522161523161524161525161526161527161528161529161530161531161532161533161534161535161536161537161538161539161540161541161542161543161544161545161546161547161548161549161550161551161552161553161554161555161556161557161558161559161560161561161562161563161564161565161566161567161568161569161570161571161572161573161574161575161576161577161578161579161580161581161582161583161584161585161586161587161588161589161590161591161592161593161594161595161596161597161598161599161600161601161602161603161604161605161606161607161608161609161610161611161612161613161614161615161616161617161618161619161620161621161622161623161624161625161626161627161628161629161630161631161632161633161634161635161636161637161638161639161640161641161642161643161644161645161646161647161648161649161650161651161652161653161654161655161656161657161658161659161660161661161662161663161664161665161666161667161668161669161670161671161672161673161674161675161676161677161678161679161680161681161682161683161684161685161686161687161688161689161690161691161692161693161694161695161696161697161698161699161700161701161702161703161704161705161706161707161708161709161710161711161712161713161714161715161716161717161718161719161720161721161722161723161724161725161726161727161728161729161730161731161732161733161734161735161736161737161738161739161740161741161742161743161744161745161746161747161748161749161750161751161752161753161754161755161756161757161758161759161760161761161762161763161764161765161766161767161768161769161770161771161772161773161774161775161776161777161778161779161780161781161782161783161784161785161786161787161788161789161790161791161792161793161794161795161796161797161798161799161800161801161802161803161804161805161806161807161808161809161810161811161812161813161814161815161816161817161818161819161820161821161822161823161824161825161826161827161828161829161830161831161832161833161834161835161836161837161838161839161840161841161842161843161844161845161846161847161848161849161850161851161852161853161854161855161856161857161858161859161860161861161862161863161864161865161866161867161868161869161870161871161872161873161874161875161876161877161878161879161880161881161882161883161884161885161886161887161888161889161890161891161892161893161894161895161896161897161898161899161900161901161902161903161904161905161906161907161908161909161910161911161912161913161914161915161916161917161918161919161920161921161922161923161924161925161926161927161928161929161930161931161932161933161934161935161936161937161938161939161940161941161942161943161944161945161946161947161948161949161950161951161952161953161954161955161956161957161958161959161960161961161962161963161964161965161966161967161968161969161970161971161972161973161974161975161976161977161978161979161980161981161982161983161984161985161986161987161988161989161990161991161992161993161994161995161996161997161998161999162000162001162002162003162004162005162006162007162008162009162010162011162012162013162014162015162016162017162018162019162020162021162022162023162024162025162026162027162028162029162030162031162032162033162034162035162036162037162038162039162040162041162042162043162044162045162046162047162048162049162050162051162052162053162054162055162056162057162058162059162060162061162062162063162064162065162066162067162068162069162070162071162072162073162074162075162076162077162078162079162080162081162082162083162084162085162086162087162088162089162090162091162092162093162094162095162096162097162098162099162100162101162102162103162104162105162106162107162108162109162110162111162112162113162114162115162116162117162118162119162120162121162122162123162124162125162126162127162128162129162130162131162132162133162134162135162136162137162138162139162140162141162142162143162144162145162146162147162148162149162150162151162152162153162154162155162156162157162158162159162160162161162162162163162164162165162166162167162168162169162170162171162172162173162174162175162176162177162178162179162180162181162182162183162184162185162186162187162188162189162190162191162192162193162194162195162196162197162198162199162200162201162202162203162204162205162206162207162208162209162210162211162212162213162214162215162216162217162218162219162220162221162222162223162224162225162226162227162228162229162230162231162232162233162234162235162236162237162238162239162240162241162242162243162244162245162246162247162248162249162250162251162252162253162254162255162256162257162258162259162260162261162262162263162264162265162266162267162268162269162270162271162272162273162274162275162276162277162278162279162280162281162282162283162284162285162286162287162288162289162290162291162292162293162294162295162296162297162298162299162300162301162302162303162304162305162306162307162308162309162310162311162312162313162314162315162316162317162318162319162320162321162322162323162324162325162326162327162328162329162330162331162332162333162334162335162336162337162338162339162340162341162342162343162344162345162346162347162348162349162350162351162352162353162354162355162356162357162358162359162360162361162362162363162364162365162366162367162368162369162370162371162372162373162374162375162376162377162378162379162380162381162382162383162384162385162386162387162388162389162390162391162392162393162394162395162396162397162398162399162400162401162402162403162404162405162406162407162408162409162410162411162412162413162414162415162416162417162418162419162420162421162422162423162424162425162426162427162428162429162430162431162432162433162434162435162436162437162438162439162440162441162442162443162444162445162446162447162448162449162450162451162452162453162454162455162456162457162458162459162460162461162462162463162464162465162466162467162468162469162470162471162472162473162474162475162476162477162478162479162480162481162482162483162484162485162486162487162488162489162490162491162492162493162494162495162496162497162498162499162500162501162502162503162504162505162506162507162508162509162510162511162512162513162514162515162516162517162518162519162520162521162522162523162524162525162526162527162528162529162530162531162532162533162534162535162536162537162538162539162540162541162542162543162544162545162546162547162548162549162550162551162552162553162554162555162556162557162558162559162560162561162562162563162564162565162566162567162568162569162570162571162572162573162574162575162576162577162578162579162580162581162582162583162584162585162586162587162588162589162590162591162592162593162594162595162596162597162598162599162600162601162602162603162604162605162606162607162608162609162610162611162612162613162614162615162616162617162618162619162620162621162622162623162624162625162626162627162628162629162630162631162632162633162634162635162636162637162638162639162640162641162642162643162644162645162646162647162648162649162650162651162652162653162654162655162656162657162658162659162660162661162662162663162664162665162666162667162668162669162670162671162672162673162674162675162676162677162678162679162680162681162682162683162684162685162686162687162688162689162690162691162692162693162694162695162696162697162698162699162700162701162702162703162704162705162706162707162708162709162710162711162712162713162714162715162716162717162718162719162720162721162722162723162724162725162726162727162728162729162730162731162732162733162734162735162736162737162738162739162740162741162742162743162744162745162746162747162748162749162750162751162752162753162754162755162756162757162758162759162760162761162762162763162764162765162766162767162768162769162770162771162772162773162774162775162776162777162778162779162780162781162782162783162784162785162786162787162788162789162790162791162792162793162794162795162796162797162798162799162800162801162802162803162804162805162806162807162808162809162810162811162812162813162814162815162816162817162818162819162820162821162822162823162824162825162826162827162828162829162830162831162832162833162834162835162836162837162838162839162840162841162842162843162844162845162846162847162848162849162850162851162852162853162854162855162856162857162858162859162860162861162862162863162864162865162866162867162868162869162870162871162872162873162874162875162876162877162878162879162880162881162882162883162884162885162886162887162888162889162890162891162892162893162894162895162896162897162898162899162900162901162902162903162904162905162906162907162908162909162910162911162912162913162914162915162916162917162918162919162920162921162922162923162924162925162926162927162928162929162930162931162932162933162934162935162936162937162938162939162940162941162942162943162944162945162946162947162948162949162950162951162952162953162954162955162956162957162958162959162960162961162962162963162964162965162966162967162968162969162970162971162972162973162974162975162976162977162978162979162980162981162982162983162984162985162986162987162988162989162990162991162992162993162994162995162996162997162998162999163000163001163002163003163004163005163006163007163008163009163010163011163012163013163014163015163016163017163018163019163020163021163022163023163024163025163026163027163028163029163030163031163032163033163034163035163036163037163038163039163040163041163042163043163044163045163046163047163048163049163050163051163052163053163054163055163056163057163058163059163060163061163062163063163064163065163066163067163068163069163070163071163072163073163074163075163076163077163078163079163080163081163082163083163084163085163086163087163088163089163090163091163092163093163094163095163096163097163098163099163100163101163102163103163104163105163106163107163108163109163110163111163112163113163114163115163116163117163118163119163120163121163122163123163124163125163126163127163128163129163130163131163132163133163134163135163136163137163138163139163140163141163142163143163144163145163146163147163148163149163150163151163152163153163154163155163156163157163158163159163160163161163162163163163164163165163166163167163168163169163170163171163172163173163174163175163176163177163178163179163180163181163182163183163184163185163186163187163188163189163190163191163192163193163194163195163196163197163198163199163200163201163202163203163204163205163206163207163208163209163210163211163212163213163214163215163216163217163218163219163220163221163222163223163224163225163226163227163228163229163230163231163232163233163234163235163236163237163238163239163240163241163242163243163244163245163246163247163248163249163250163251163252163253163254163255163256163257163258163259163260163261163262163263163264163265163266163267163268163269163270163271163272163273163274163275163276163277163278163279163280163281163282163283163284163285163286163287163288163289163290163291163292163293163294163295163296163297163298163299163300163301163302163303163304163305163306163307163308163309163310163311163312163313163314163315163316163317163318163319163320163321163322163323163324163325163326163327163328163329163330163331163332163333163334163335163336163337163338163339163340163341163342163343163344163345163346163347163348163349163350163351163352163353163354163355163356163357163358163359163360163361163362163363163364163365163366163367163368163369163370163371163372163373163374163375163376163377163378163379163380163381163382163383163384163385163386163387163388163389163390163391163392163393163394163395163396163397163398163399163400163401163402163403163404163405163406163407163408163409163410163411163412163413163414163415163416163417163418163419163420163421163422163423163424163425163426163427163428163429163430163431163432163433163434163435163436163437163438163439163440163441163442163443163444163445163446163447163448163449163450163451163452163453163454163455163456163457163458163459163460163461163462163463163464163465163466163467163468163469163470163471163472163473163474163475163476163477163478163479163480163481163482163483163484163485163486163487163488163489163490163491163492163493163494163495163496163497163498163499163500163501163502163503163504163505163506163507163508163509163510163511163512163513163514163515163516163517163518163519163520163521163522163523163524163525163526163527163528163529163530163531163532163533163534163535163536163537163538163539163540163541163542163543163544163545163546163547163548163549163550163551163552163553163554163555163556163557163558163559163560163561163562163563163564163565163566163567163568163569163570163571163572163573163574163575163576163577163578163579163580163581163582163583163584163585163586163587163588163589163590163591163592163593163594163595163596163597163598163599163600163601163602163603163604163605163606163607163608163609163610163611163612163613163614163615163616163617163618163619163620163621163622163623163624163625163626163627163628163629163630163631163632163633163634163635163636163637163638163639163640163641163642163643163644163645163646163647163648163649163650163651163652163653163654163655163656163657163658163659163660163661163662163663163664163665163666163667163668163669163670163671163672163673163674163675163676163677163678163679163680163681163682163683163684163685163686163687163688163689163690163691163692163693163694163695163696163697163698163699163700163701163702163703163704163705163706163707163708163709163710163711163712163713163714163715163716163717163718163719163720163721163722163723163724163725163726163727163728163729163730163731163732163733163734163735163736163737163738163739163740163741163742163743163744163745163746163747163748163749163750163751163752163753163754163755163756163757163758163759163760163761163762163763163764163765163766163767163768163769163770163771163772163773163774163775163776163777163778163779163780163781163782163783163784163785163786163787163788163789163790163791163792163793163794163795163796163797163798163799163800163801163802163803163804163805163806163807163808163809163810163811163812163813163814163815163816163817163818163819163820163821163822163823163824163825163826163827163828163829163830163831163832163833163834163835163836163837163838163839163840163841163842163843163844163845163846163847163848163849163850163851163852163853163854163855163856163857163858163859163860163861163862163863163864163865163866163867163868163869163870163871163872163873163874163875163876163877163878163879163880163881163882163883163884163885163886163887163888163889163890163891163892163893163894163895163896163897163898163899163900163901163902163903163904163905163906163907163908163909163910163911163912163913163914163915163916163917163918163919163920163921163922163923163924163925163926163927163928163929163930163931163932163933163934163935163936163937163938163939163940163941163942163943163944163945163946163947163948163949163950163951163952163953163954163955163956163957163958163959163960163961163962163963163964163965163966163967163968163969163970163971163972163973163974163975163976163977163978163979163980163981163982163983163984163985163986163987163988163989163990163991163992163993163994163995163996163997163998163999164000164001164002164003164004164005164006164007164008164009164010164011164012164013164014164015164016164017164018164019164020164021164022164023164024164025164026164027164028164029164030164031164032164033164034164035164036164037164038164039164040164041164042164043164044164045164046164047164048164049164050164051164052164053164054164055164056164057164058164059164060164061164062164063164064164065164066164067164068164069164070164071164072164073164074164075164076164077164078164079164080164081164082164083164084164085164086164087164088164089164090164091164092164093164094164095164096164097164098164099164100164101164102164103164104164105164106164107164108164109164110164111164112164113164114164115164116164117164118164119164120164121164122164123164124164125164126164127164128164129164130164131164132164133164134164135164136164137164138164139164140164141164142164143164144164145164146164147164148164149164150164151164152164153164154164155164156164157164158164159164160164161164162164163164164164165164166164167164168164169164170164171164172164173164174164175164176164177164178164179164180164181164182164183164184164185164186164187164188164189164190164191164192164193164194164195164196164197164198164199164200164201164202164203164204164205164206164207164208164209164210164211164212164213164214164215164216164217164218164219164220164221164222164223164224164225164226164227164228164229164230164231164232164233164234164235164236164237164238164239164240164241164242164243164244164245164246164247164248164249164250164251164252164253164254164255164256164257164258164259164260164261164262164263164264164265164266164267164268164269164270164271164272164273164274164275164276164277164278164279164280164281164282164283164284164285164286164287164288164289164290164291164292164293164294164295164296164297164298164299164300164301164302164303164304164305164306164307164308164309164310164311164312164313164314164315164316164317164318164319164320164321164322164323164324164325164326164327164328164329164330164331164332164333164334164335164336164337164338164339164340164341164342164343164344164345164346164347164348164349164350164351164352164353164354164355164356164357164358164359164360164361164362164363164364164365164366164367164368164369164370164371164372164373164374164375164376164377164378164379164380164381164382164383164384164385164386164387164388164389164390164391164392164393164394164395164396164397164398164399164400164401164402164403164404164405164406164407164408164409164410164411164412164413164414164415164416164417164418164419164420164421164422164423164424164425164426164427164428164429164430164431164432164433164434164435164436164437164438164439164440164441164442164443164444164445164446164447164448164449164450164451164452164453164454164455164456164457164458164459164460164461164462164463164464164465164466164467164468164469164470164471164472164473164474164475164476164477164478164479164480164481164482164483164484164485164486164487164488164489164490164491164492164493164494164495164496164497164498164499164500164501164502164503164504164505164506164507164508164509164510164511164512164513164514164515164516164517164518164519164520164521164522164523164524164525164526164527164528164529164530164531164532164533164534164535164536164537164538164539164540164541164542164543164544164545164546164547164548164549164550164551164552164553164554164555164556164557164558164559164560164561164562164563164564164565164566164567164568164569164570164571164572164573164574164575164576164577164578164579164580164581164582164583164584164585164586164587164588164589164590164591164592164593164594164595164596164597164598164599164600164601164602164603164604164605164606164607164608164609164610164611164612164613164614164615164616164617164618164619164620164621164622164623164624164625164626164627164628164629164630164631164632164633164634164635164636164637164638164639164640164641164642164643164644164645164646164647164648164649164650164651164652164653164654164655164656164657164658164659164660164661164662164663164664164665164666164667164668164669164670164671164672164673164674164675164676164677164678164679164680164681164682164683164684164685164686164687164688164689164690164691164692164693164694164695164696164697164698164699164700164701164702164703164704164705164706164707164708164709164710164711164712164713164714164715164716164717164718164719164720164721164722164723164724164725164726164727164728164729164730164731164732164733164734164735164736164737164738164739164740164741164742164743164744164745164746164747164748164749164750164751164752164753164754164755164756164757164758164759164760164761164762164763164764164765164766164767164768164769164770164771164772164773164774164775164776164777164778164779164780164781164782164783164784164785164786164787164788164789164790164791164792164793164794164795164796164797164798164799164800164801164802164803164804164805164806164807164808164809164810164811164812164813164814164815164816164817164818164819164820164821164822164823164824164825164826164827164828164829164830164831164832164833164834164835164836164837164838164839164840164841164842164843164844164845164846164847164848164849164850164851164852164853164854164855164856164857164858164859164860164861164862164863164864164865164866164867164868164869164870164871164872164873164874164875164876164877164878164879164880164881164882164883164884164885164886164887164888164889164890164891164892164893164894164895164896164897164898164899164900164901164902164903164904164905164906164907164908164909164910164911164912164913164914164915164916164917164918164919164920164921164922164923164924164925164926164927164928164929164930164931164932164933164934164935164936164937164938164939164940164941164942164943164944164945164946164947164948164949164950164951164952164953164954164955164956164957164958164959164960164961164962164963164964164965164966164967164968164969164970164971164972164973164974164975164976164977164978164979164980164981164982164983164984164985164986164987164988164989164990164991164992164993164994164995164996164997164998164999165000165001165002165003165004165005165006165007165008165009165010165011165012165013165014165015165016165017165018165019165020165021165022165023165024165025165026165027165028165029165030165031165032165033165034165035165036165037165038165039165040165041165042165043165044165045165046165047165048165049165050165051165052165053165054165055165056165057165058165059165060165061165062165063165064165065165066165067165068165069165070165071165072165073165074165075165076165077165078165079165080165081165082165083165084165085165086165087165088165089165090165091165092165093165094165095165096165097165098165099165100165101165102165103165104165105165106165107165108165109165110165111165112165113165114165115165116165117165118165119165120165121165122165123165124165125165126165127165128165129165130165131165132165133165134165135165136165137165138165139165140165141165142165143165144165145165146165147165148165149165150165151165152165153165154165155165156165157165158165159165160165161165162165163165164165165165166165167165168165169165170165171165172165173165174165175165176165177165178165179165180165181165182165183165184165185165186165187165188165189165190165191165192165193165194165195165196165197165198165199165200165201165202165203165204165205165206165207165208165209165210165211165212165213165214165215165216165217165218165219165220165221165222165223165224165225165226165227165228165229165230165231165232165233165234165235165236165237165238165239165240165241165242165243165244165245165246165247165248165249165250165251165252165253165254165255165256165257165258165259165260165261165262165263165264165265165266165267165268165269165270165271165272165273165274165275165276165277165278165279165280165281165282165283165284165285165286165287165288165289165290165291165292165293165294165295165296165297165298165299165300165301165302165303165304165305165306165307165308165309165310165311165312165313165314165315165316165317165318165319165320165321165322165323165324165325165326165327165328165329165330165331165332165333165334165335165336165337165338165339165340165341165342165343165344165345165346165347165348165349165350165351165352165353165354165355165356165357165358165359165360165361165362165363165364165365165366165367165368165369165370165371165372165373165374165375165376165377165378165379165380165381165382165383165384165385165386165387165388165389165390165391165392165393165394165395165396165397165398165399165400165401165402165403165404165405165406165407165408165409165410165411165412165413165414165415165416165417165418165419165420165421165422165423165424165425165426165427165428165429165430165431165432165433165434165435165436165437165438165439165440165441165442165443165444165445165446165447165448165449165450165451165452165453165454165455165456165457165458165459165460165461165462165463165464165465165466165467165468165469165470165471165472165473165474165475165476165477165478165479165480165481165482165483165484165485165486165487165488165489165490165491165492165493165494165495165496165497165498165499165500165501165502165503165504165505165506165507165508165509165510165511165512165513165514165515165516165517165518165519165520165521165522165523165524165525165526165527165528165529165530165531165532165533165534165535165536165537165538165539165540165541165542165543165544165545165546165547165548165549165550165551165552165553165554165555165556165557165558165559165560165561165562165563165564165565165566165567165568165569165570165571165572165573165574165575165576165577165578165579165580165581165582165583165584165585165586165587165588165589165590165591165592165593165594165595165596165597165598165599165600165601165602165603165604165605165606165607165608165609165610165611165612165613165614165615165616165617165618165619165620165621165622165623165624165625165626165627165628165629165630165631165632165633165634165635165636165637165638165639165640165641165642165643165644165645165646165647165648165649165650165651165652165653165654165655165656165657165658165659165660165661165662165663165664165665165666165667165668165669165670165671165672165673165674165675165676165677165678165679165680165681165682165683165684165685165686165687165688165689165690165691165692165693165694165695165696165697165698165699165700165701165702165703165704165705165706165707165708165709165710165711165712165713165714165715165716165717165718165719165720165721165722165723165724165725165726165727165728165729165730165731165732165733165734165735165736165737165738165739165740165741165742165743165744165745165746165747165748165749165750165751165752165753165754165755165756165757165758165759165760165761165762165763165764165765165766165767165768165769165770165771165772165773165774165775165776165777165778165779165780165781165782165783165784165785165786165787165788165789165790165791165792165793165794165795165796165797165798165799165800165801165802165803165804165805165806165807165808165809165810165811165812165813165814165815165816165817165818165819165820165821165822165823165824165825165826165827165828165829165830165831165832165833165834165835165836165837165838165839165840165841165842165843165844165845165846165847165848165849165850165851165852165853165854165855165856165857165858165859165860165861165862165863165864165865165866165867165868165869165870165871165872165873165874165875165876165877165878165879165880165881165882165883165884165885165886165887165888165889165890165891165892165893165894165895165896165897165898165899165900165901165902165903165904165905165906165907165908165909165910165911165912165913165914165915165916165917165918165919165920165921165922165923165924165925165926165927165928165929165930165931165932165933165934165935165936165937165938165939165940165941165942165943165944165945165946165947165948165949165950165951165952165953165954165955165956165957165958165959165960165961165962165963165964165965165966165967165968165969165970165971165972165973165974165975165976165977165978165979165980165981165982165983165984165985165986165987165988165989165990165991165992165993165994165995165996165997165998165999166000166001166002166003166004166005166006166007166008166009166010166011166012166013166014166015166016166017166018166019166020166021166022166023166024166025166026166027166028166029166030166031166032166033166034166035166036166037166038166039166040166041166042166043166044166045166046166047166048166049166050166051166052166053166054166055166056166057166058166059166060166061166062166063166064166065166066166067166068166069166070166071166072166073166074166075166076166077166078166079166080166081166082166083166084166085166086166087166088166089166090166091166092166093166094166095166096166097166098166099166100166101166102166103166104166105166106166107166108166109166110166111166112166113166114166115166116166117166118166119166120166121166122166123166124166125166126166127166128166129166130166131166132166133166134166135166136166137166138166139166140166141166142166143166144166145166146166147166148166149166150166151166152166153166154166155166156166157166158166159166160166161166162166163166164166165166166166167166168166169166170166171166172166173166174166175166176166177166178166179166180166181166182166183166184166185166186166187166188166189166190166191166192166193166194166195166196166197166198166199166200166201166202166203166204166205166206166207166208166209166210166211166212166213166214166215166216166217166218166219166220166221166222166223166224166225166226166227166228166229166230166231166232166233166234166235166236166237166238166239166240166241166242166243166244166245166246166247166248166249166250166251166252166253166254166255166256166257166258166259166260166261166262166263166264166265166266166267166268166269166270166271166272166273166274166275166276166277166278166279166280166281166282166283166284166285166286166287166288166289166290166291166292166293166294166295166296166297166298166299166300166301166302166303166304166305166306166307166308166309166310166311166312166313166314166315166316166317166318166319166320166321166322166323166324166325166326166327166328166329166330166331166332166333166334166335166336166337166338166339166340166341166342166343166344166345166346166347166348166349166350166351166352166353166354166355166356166357166358166359166360166361166362166363166364166365166366166367166368166369166370166371166372166373166374166375166376166377166378166379166380166381166382166383166384166385166386166387166388166389166390166391166392166393166394166395166396166397166398166399166400166401166402166403166404166405166406166407166408166409166410166411166412166413166414166415166416166417166418166419166420166421166422166423166424166425166426166427166428166429166430166431166432166433166434166435166436166437166438166439166440166441166442166443166444166445166446166447166448166449166450166451166452166453166454166455166456166457166458166459166460166461166462166463166464166465166466166467166468166469166470166471166472166473166474166475166476166477166478166479166480166481166482166483166484166485166486166487166488166489166490166491166492166493166494166495166496166497166498166499166500166501166502166503166504166505166506166507166508166509166510166511166512166513166514166515166516166517166518166519166520166521166522166523166524166525166526166527166528166529166530166531166532166533166534166535166536166537166538166539166540166541166542166543166544166545166546166547166548166549166550166551166552166553166554166555166556166557166558166559166560166561166562166563166564166565166566166567166568166569166570166571166572166573166574166575166576166577166578166579166580166581166582166583166584166585166586166587166588166589166590166591166592166593166594166595166596166597166598166599166600166601166602166603166604166605166606166607166608166609166610166611166612166613166614166615166616166617166618166619166620166621166622166623166624166625166626166627166628166629166630166631166632166633166634166635166636166637166638166639166640166641166642166643166644166645166646166647166648166649166650166651166652166653166654166655166656166657166658166659166660166661166662166663166664166665166666166667166668166669166670166671166672166673166674166675166676166677166678166679166680166681166682166683166684166685166686166687166688166689166690166691166692166693166694166695166696166697166698166699166700166701166702166703166704166705166706166707166708166709166710166711166712166713166714166715166716166717166718166719166720166721166722166723166724166725166726166727166728166729166730166731166732166733166734166735166736166737166738166739166740166741166742166743166744166745166746166747166748166749166750166751166752166753166754166755166756166757166758166759166760166761166762166763166764166765166766166767166768166769166770166771166772166773166774166775166776166777166778166779166780166781166782166783166784166785166786166787166788166789166790166791166792166793166794166795166796166797166798166799166800166801166802166803166804166805166806166807166808166809166810166811166812166813166814166815166816166817166818166819166820166821166822166823166824166825166826166827166828166829166830166831166832166833166834166835166836166837166838166839166840166841166842166843166844166845166846166847166848166849166850166851166852166853166854166855166856166857166858166859166860166861166862166863166864166865166866166867166868166869166870166871166872166873166874166875166876166877166878166879166880166881166882166883166884166885166886166887166888166889166890166891166892166893166894166895166896166897166898166899166900166901166902166903166904166905166906166907166908166909166910166911166912166913166914166915166916166917166918166919166920166921166922166923166924166925166926166927166928166929166930166931166932166933166934166935166936166937166938166939166940166941166942166943166944166945166946166947166948166949166950166951166952166953166954166955166956166957166958166959166960166961166962166963166964166965166966166967166968166969166970166971166972166973166974166975166976166977166978166979166980166981166982166983166984166985166986166987166988166989166990166991166992166993166994166995166996166997166998166999167000167001167002167003167004167005167006167007167008167009167010167011167012167013167014167015167016167017167018167019167020167021167022167023167024167025167026167027167028167029167030167031167032167033167034167035167036167037167038167039167040167041167042167043167044167045167046167047167048167049167050167051167052167053167054167055167056167057167058167059167060167061167062167063167064167065167066167067167068167069167070167071167072167073167074167075167076167077167078167079167080167081167082167083167084167085167086167087167088167089167090167091167092167093167094167095167096167097167098167099167100167101167102167103167104167105167106167107167108167109167110167111167112167113167114167115167116167117167118167119167120167121167122167123167124167125167126167127167128167129167130167131167132167133167134167135167136167137167138167139167140167141167142167143167144167145167146167147167148167149167150167151167152167153167154167155167156167157167158167159167160167161167162167163167164167165167166167167167168167169167170167171167172167173167174167175167176167177167178167179167180167181167182167183167184167185167186167187167188167189167190167191167192167193167194167195167196167197167198167199167200167201167202167203167204167205167206167207167208167209167210167211167212167213167214167215167216167217167218167219167220167221167222167223167224167225167226167227167228167229167230167231167232167233167234167235167236167237167238167239167240167241167242167243167244167245167246167247167248167249167250167251167252167253167254167255167256167257167258167259167260167261167262167263167264167265167266167267167268167269167270167271167272167273167274167275167276167277167278167279167280167281167282167283167284167285167286167287167288167289167290167291167292167293167294167295167296167297167298167299167300167301167302167303167304167305167306167307167308167309167310167311167312167313167314167315167316167317167318167319167320167321167322167323167324167325167326167327167328167329167330167331167332167333167334167335167336167337167338167339167340167341167342167343167344167345167346167347167348167349167350167351167352167353167354167355167356167357167358167359167360167361167362167363167364167365167366167367167368167369167370167371167372167373167374167375167376167377167378167379167380167381167382167383167384167385167386167387167388167389167390167391167392167393167394167395167396167397167398167399167400167401167402167403167404167405167406167407167408167409167410167411167412167413167414167415167416167417167418167419167420167421167422167423167424167425167426167427167428167429167430167431167432167433167434167435
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. /**
  334. * Message to display when a message has been logged too many times
  335. */
  336. static MessageLimitReached: string;
  337. private static _LogCache;
  338. private static _LogLimitOutputs;
  339. /**
  340. * Gets a value indicating the number of loading errors
  341. * @ignorenaming
  342. */
  343. static errorsCount: number;
  344. /**
  345. * Callback called when a new log is added
  346. */
  347. static OnNewCacheEntry: (entry: string) => void;
  348. private static _CheckLimit;
  349. private static _GenerateLimitMessage;
  350. private static _AddLogEntry;
  351. private static _FormatMessage;
  352. private static _LogDisabled;
  353. private static _LogEnabled;
  354. private static _WarnDisabled;
  355. private static _WarnEnabled;
  356. private static _ErrorDisabled;
  357. private static _ErrorEnabled;
  358. /**
  359. * Log a message to the console
  360. */
  361. static Log: (message: string, limit?: number) => void;
  362. /**
  363. * Write a warning message to the console
  364. */
  365. static Warn: (message: string, limit?: number) => void;
  366. /**
  367. * Write an error message to the console
  368. */
  369. static Error: (message: string, limit?: number) => void;
  370. /**
  371. * Gets current log cache (list of logs)
  372. */
  373. static get LogCache(): string;
  374. /**
  375. * Clears the log cache
  376. */
  377. static ClearLogCache(): void;
  378. /**
  379. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  380. */
  381. static set LogLevels(level: number);
  382. }
  383. }
  384. declare module "babylonjs/Misc/typeStore" {
  385. /** @hidden */
  386. export class _TypeStore {
  387. /** @hidden */
  388. static RegisteredTypes: {
  389. [key: string]: Object;
  390. };
  391. /** @hidden */
  392. static GetClass(fqdn: string): any;
  393. }
  394. }
  395. declare module "babylonjs/Misc/stringTools" {
  396. /**
  397. * Helper to manipulate strings
  398. */
  399. export class StringTools {
  400. /**
  401. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static EndsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  409. * @param str Source string
  410. * @param suffix Suffix to search for in the source string
  411. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  412. */
  413. static StartsWith(str: string, suffix: string): boolean;
  414. /**
  415. * Decodes a buffer into a string
  416. * @param buffer The buffer to decode
  417. * @returns The decoded string
  418. */
  419. static Decode(buffer: Uint8Array | Uint16Array): string;
  420. /**
  421. * Encode a buffer to a base64 string
  422. * @param buffer defines the buffer to encode
  423. * @returns the encoded string
  424. */
  425. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  426. /**
  427. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  428. * @param num the number to convert and pad
  429. * @param length the expected length of the string
  430. * @returns the padded string
  431. */
  432. static PadNumber(num: number, length: number): string;
  433. }
  434. }
  435. declare module "babylonjs/Misc/deepCopier" {
  436. /**
  437. * Class containing a set of static utilities functions for deep copy.
  438. */
  439. export class DeepCopier {
  440. /**
  441. * Tries to copy an object by duplicating every property
  442. * @param source defines the source object
  443. * @param destination defines the target object
  444. * @param doNotCopyList defines a list of properties to avoid
  445. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  446. */
  447. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  448. }
  449. }
  450. declare module "babylonjs/Misc/precisionDate" {
  451. /**
  452. * Class containing a set of static utilities functions for precision date
  453. */
  454. export class PrecisionDate {
  455. /**
  456. * Gets either window.performance.now() if supported or Date.now() else
  457. */
  458. static get Now(): number;
  459. }
  460. }
  461. declare module "babylonjs/Misc/devTools" {
  462. /** @hidden */
  463. export class _DevTools {
  464. static WarnImport(name: string): string;
  465. }
  466. }
  467. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  468. /**
  469. * Interface used to define the mechanism to get data from the network
  470. */
  471. export interface IWebRequest {
  472. /**
  473. * Returns client's response url
  474. */
  475. responseURL: string;
  476. /**
  477. * Returns client's status
  478. */
  479. status: number;
  480. /**
  481. * Returns client's status as a text
  482. */
  483. statusText: string;
  484. }
  485. }
  486. declare module "babylonjs/Misc/webRequest" {
  487. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  488. import { Nullable } from "babylonjs/types";
  489. /**
  490. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  491. */
  492. export class WebRequest implements IWebRequest {
  493. private readonly _xhr;
  494. /**
  495. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  496. * i.e. when loading files, where the server/service expects an Authorization header
  497. */
  498. static CustomRequestHeaders: {
  499. [key: string]: string;
  500. };
  501. /**
  502. * Add callback functions in this array to update all the requests before they get sent to the network
  503. */
  504. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  505. private _injectCustomRequestHeaders;
  506. /**
  507. * Gets or sets a function to be called when loading progress changes
  508. */
  509. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  510. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  511. /**
  512. * Returns client's state
  513. */
  514. get readyState(): number;
  515. /**
  516. * Returns client's status
  517. */
  518. get status(): number;
  519. /**
  520. * Returns client's status as a text
  521. */
  522. get statusText(): string;
  523. /**
  524. * Returns client's response
  525. */
  526. get response(): any;
  527. /**
  528. * Returns client's response url
  529. */
  530. get responseURL(): string;
  531. /**
  532. * Returns client's response as text
  533. */
  534. get responseText(): string;
  535. /**
  536. * Gets or sets the expected response type
  537. */
  538. get responseType(): XMLHttpRequestResponseType;
  539. set responseType(value: XMLHttpRequestResponseType);
  540. /** @hidden */
  541. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  542. /** @hidden */
  543. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  544. /**
  545. * Cancels any network activity
  546. */
  547. abort(): void;
  548. /**
  549. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  550. * @param body defines an optional request body
  551. */
  552. send(body?: Document | BodyInit | null): void;
  553. /**
  554. * Sets the request method, request URL
  555. * @param method defines the method to use (GET, POST, etc..)
  556. * @param url defines the url to connect with
  557. */
  558. open(method: string, url: string): void;
  559. /**
  560. * Sets the value of a request header.
  561. * @param name The name of the header whose value is to be set
  562. * @param value The value to set as the body of the header
  563. */
  564. setRequestHeader(name: string, value: string): void;
  565. /**
  566. * Get the string containing the text of a particular header's value.
  567. * @param name The name of the header
  568. * @returns The string containing the text of the given header name
  569. */
  570. getResponseHeader(name: string): Nullable<string>;
  571. }
  572. }
  573. declare module "babylonjs/Misc/fileRequest" {
  574. import { Observable } from "babylonjs/Misc/observable";
  575. /**
  576. * File request interface
  577. */
  578. export interface IFileRequest {
  579. /**
  580. * Raised when the request is complete (success or error).
  581. */
  582. onCompleteObservable: Observable<IFileRequest>;
  583. /**
  584. * Aborts the request for a file.
  585. */
  586. abort: () => void;
  587. }
  588. }
  589. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  590. /**
  591. * Define options used to create a render target texture
  592. */
  593. export class RenderTargetCreationOptions {
  594. /**
  595. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  596. */
  597. createMipMaps?: boolean;
  598. /**
  599. * Specifies if mipmaps must be generated
  600. */
  601. generateMipMaps?: boolean;
  602. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  603. generateDepthBuffer?: boolean;
  604. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  605. generateStencilBuffer?: boolean;
  606. /** Defines texture type (int by default) */
  607. type?: number;
  608. /** Defines sampling mode (trilinear by default) */
  609. samplingMode?: number;
  610. /** Defines format (RGBA by default) */
  611. format?: number;
  612. /** Defines sample count (1 by default) */
  613. samples?: number;
  614. }
  615. }
  616. declare module "babylonjs/Engines/constants" {
  617. /** Defines the cross module used constants to avoid circular dependncies */
  618. export class Constants {
  619. /** Defines that alpha blending is disabled */
  620. static readonly ALPHA_DISABLE: number;
  621. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  622. static readonly ALPHA_ADD: number;
  623. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  624. static readonly ALPHA_COMBINE: number;
  625. /** Defines that alpha blending is DEST - SRC * DEST */
  626. static readonly ALPHA_SUBTRACT: number;
  627. /** Defines that alpha blending is SRC * DEST */
  628. static readonly ALPHA_MULTIPLY: number;
  629. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  630. static readonly ALPHA_MAXIMIZED: number;
  631. /** Defines that alpha blending is SRC + DEST */
  632. static readonly ALPHA_ONEONE: number;
  633. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  634. static readonly ALPHA_PREMULTIPLIED: number;
  635. /**
  636. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  637. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  638. */
  639. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  640. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  641. static readonly ALPHA_INTERPOLATE: number;
  642. /**
  643. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  644. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  645. */
  646. static readonly ALPHA_SCREENMODE: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA + DST ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEONE: number;
  652. /**
  653. * Defines that alpha blending is SRC * DST ALPHA + DST
  654. * Alpha will be set to 0
  655. */
  656. static readonly ALPHA_ALPHATOCOLOR: number;
  657. /**
  658. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  659. */
  660. static readonly ALPHA_REVERSEONEMINUS: number;
  661. /**
  662. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  663. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  664. */
  665. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  666. /**
  667. * Defines that alpha blending is SRC + DST
  668. * Alpha will be set to SRC ALPHA
  669. */
  670. static readonly ALPHA_ONEONE_ONEZERO: number;
  671. /**
  672. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  673. * Alpha will be set to DST ALPHA
  674. */
  675. static readonly ALPHA_EXCLUSION: number;
  676. /** Defines that alpha blending equation a SUM */
  677. static readonly ALPHA_EQUATION_ADD: number;
  678. /** Defines that alpha blending equation a SUBSTRACTION */
  679. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  680. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  681. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  682. /** Defines that alpha blending equation a MAX operation */
  683. static readonly ALPHA_EQUATION_MAX: number;
  684. /** Defines that alpha blending equation a MIN operation */
  685. static readonly ALPHA_EQUATION_MIN: number;
  686. /**
  687. * Defines that alpha blending equation a DARKEN operation:
  688. * It takes the min of the src and sums the alpha channels.
  689. */
  690. static readonly ALPHA_EQUATION_DARKEN: number;
  691. /** Defines that the ressource is not delayed*/
  692. static readonly DELAYLOADSTATE_NONE: number;
  693. /** Defines that the ressource was successfully delay loaded */
  694. static readonly DELAYLOADSTATE_LOADED: number;
  695. /** Defines that the ressource is currently delay loading */
  696. static readonly DELAYLOADSTATE_LOADING: number;
  697. /** Defines that the ressource is delayed and has not started loading */
  698. static readonly DELAYLOADSTATE_NOTLOADED: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  700. static readonly NEVER: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  702. static readonly ALWAYS: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  704. static readonly LESS: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  706. static readonly EQUAL: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  708. static readonly LEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  710. static readonly GREATER: number;
  711. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  712. static readonly GEQUAL: number;
  713. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  714. static readonly NOTEQUAL: number;
  715. /** Passed to stencilOperation to specify that stencil value must be kept */
  716. static readonly KEEP: number;
  717. /** Passed to stencilOperation to specify that stencil value must be zero */
  718. static readonly ZERO: number;
  719. /** Passed to stencilOperation to specify that stencil value must be replaced */
  720. static readonly REPLACE: number;
  721. /** Passed to stencilOperation to specify that stencil value must be incremented */
  722. static readonly INCR: number;
  723. /** Passed to stencilOperation to specify that stencil value must be decremented */
  724. static readonly DECR: number;
  725. /** Passed to stencilOperation to specify that stencil value must be inverted */
  726. static readonly INVERT: number;
  727. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  728. static readonly INCR_WRAP: number;
  729. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  730. static readonly DECR_WRAP: number;
  731. /** Texture is not repeating outside of 0..1 UVs */
  732. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  733. /** Texture is repeating outside of 0..1 UVs */
  734. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  735. /** Texture is repeating and mirrored */
  736. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  737. /** ALPHA */
  738. static readonly TEXTUREFORMAT_ALPHA: number;
  739. /** LUMINANCE */
  740. static readonly TEXTUREFORMAT_LUMINANCE: number;
  741. /** LUMINANCE_ALPHA */
  742. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  743. /** RGB */
  744. static readonly TEXTUREFORMAT_RGB: number;
  745. /** RGBA */
  746. static readonly TEXTUREFORMAT_RGBA: number;
  747. /** RED */
  748. static readonly TEXTUREFORMAT_RED: number;
  749. /** RED (2nd reference) */
  750. static readonly TEXTUREFORMAT_R: number;
  751. /** RG */
  752. static readonly TEXTUREFORMAT_RG: number;
  753. /** RED_INTEGER */
  754. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  755. /** RED_INTEGER (2nd reference) */
  756. static readonly TEXTUREFORMAT_R_INTEGER: number;
  757. /** RG_INTEGER */
  758. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  759. /** RGB_INTEGER */
  760. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  761. /** RGBA_INTEGER */
  762. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  763. /** BGRA */
  764. static readonly TEXTUREFORMAT_BGRA: number;
  765. /** Depth 24 bits + Stencil 8 bits */
  766. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  767. /** Depth 32 bits float */
  768. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  769. /** Compressed BC7 */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  771. /** Compressed BC6 unsigned float */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  773. /** Compressed BC6 signed float */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  775. /** Compressed BC3 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  777. /** Compressed BC2 */
  778. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  779. /** Compressed BC1 */
  780. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  781. /** UNSIGNED_BYTE */
  782. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  783. /** UNSIGNED_BYTE (2nd reference) */
  784. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  785. /** FLOAT */
  786. static readonly TEXTURETYPE_FLOAT: number;
  787. /** HALF_FLOAT */
  788. static readonly TEXTURETYPE_HALF_FLOAT: number;
  789. /** BYTE */
  790. static readonly TEXTURETYPE_BYTE: number;
  791. /** SHORT */
  792. static readonly TEXTURETYPE_SHORT: number;
  793. /** UNSIGNED_SHORT */
  794. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  795. /** INT */
  796. static readonly TEXTURETYPE_INT: number;
  797. /** UNSIGNED_INT */
  798. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  799. /** UNSIGNED_SHORT_4_4_4_4 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  801. /** UNSIGNED_SHORT_5_5_5_1 */
  802. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  803. /** UNSIGNED_SHORT_5_6_5 */
  804. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  805. /** UNSIGNED_INT_2_10_10_10_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  807. /** UNSIGNED_INT_24_8 */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  809. /** UNSIGNED_INT_10F_11F_11F_REV */
  810. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  811. /** UNSIGNED_INT_5_9_9_9_REV */
  812. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  813. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  814. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  815. /** nearest is mag = nearest and min = nearest and no mip */
  816. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  817. /** mag = nearest and min = nearest and mip = none */
  818. static readonly TEXTURE_NEAREST_NEAREST: number;
  819. /** Bilinear is mag = linear and min = linear and no mip */
  820. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  821. /** mag = linear and min = linear and mip = none */
  822. static readonly TEXTURE_LINEAR_LINEAR: number;
  823. /** Trilinear is mag = linear and min = linear and mip = linear */
  824. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  825. /** Trilinear is mag = linear and min = linear and mip = linear */
  826. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  827. /** mag = nearest and min = nearest and mip = nearest */
  828. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  829. /** mag = nearest and min = linear and mip = nearest */
  830. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  831. /** mag = nearest and min = linear and mip = linear */
  832. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  833. /** mag = nearest and min = linear and mip = none */
  834. static readonly TEXTURE_NEAREST_LINEAR: number;
  835. /** nearest is mag = nearest and min = nearest and mip = linear */
  836. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  837. /** mag = linear and min = nearest and mip = nearest */
  838. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = linear */
  840. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  841. /** Bilinear is mag = linear and min = linear and mip = nearest */
  842. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  843. /** mag = linear and min = nearest and mip = none */
  844. static readonly TEXTURE_LINEAR_NEAREST: number;
  845. /** Explicit coordinates mode */
  846. static readonly TEXTURE_EXPLICIT_MODE: number;
  847. /** Spherical coordinates mode */
  848. static readonly TEXTURE_SPHERICAL_MODE: number;
  849. /** Planar coordinates mode */
  850. static readonly TEXTURE_PLANAR_MODE: number;
  851. /** Cubic coordinates mode */
  852. static readonly TEXTURE_CUBIC_MODE: number;
  853. /** Projection coordinates mode */
  854. static readonly TEXTURE_PROJECTION_MODE: number;
  855. /** Skybox coordinates mode */
  856. static readonly TEXTURE_SKYBOX_MODE: number;
  857. /** Inverse Cubic coordinates mode */
  858. static readonly TEXTURE_INVCUBIC_MODE: number;
  859. /** Equirectangular coordinates mode */
  860. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  861. /** Equirectangular Fixed coordinates mode */
  862. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  863. /** Equirectangular Fixed Mirrored coordinates mode */
  864. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  865. /** Offline (baking) quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  867. /** High quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  869. /** Medium quality for texture filtering */
  870. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  871. /** Low quality for texture filtering */
  872. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  873. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  874. static readonly SCALEMODE_FLOOR: number;
  875. /** Defines that texture rescaling will look for the nearest power of 2 size */
  876. static readonly SCALEMODE_NEAREST: number;
  877. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  878. static readonly SCALEMODE_CEILING: number;
  879. /**
  880. * The dirty texture flag value
  881. */
  882. static readonly MATERIAL_TextureDirtyFlag: number;
  883. /**
  884. * The dirty light flag value
  885. */
  886. static readonly MATERIAL_LightDirtyFlag: number;
  887. /**
  888. * The dirty fresnel flag value
  889. */
  890. static readonly MATERIAL_FresnelDirtyFlag: number;
  891. /**
  892. * The dirty attribute flag value
  893. */
  894. static readonly MATERIAL_AttributesDirtyFlag: number;
  895. /**
  896. * The dirty misc flag value
  897. */
  898. static readonly MATERIAL_MiscDirtyFlag: number;
  899. /**
  900. * The dirty prepass flag value
  901. */
  902. static readonly MATERIAL_PrePassDirtyFlag: number;
  903. /**
  904. * The all dirty flag value
  905. */
  906. static readonly MATERIAL_AllDirtyFlag: number;
  907. /**
  908. * Returns the triangle fill mode
  909. */
  910. static readonly MATERIAL_TriangleFillMode: number;
  911. /**
  912. * Returns the wireframe mode
  913. */
  914. static readonly MATERIAL_WireFrameFillMode: number;
  915. /**
  916. * Returns the point fill mode
  917. */
  918. static readonly MATERIAL_PointFillMode: number;
  919. /**
  920. * Returns the point list draw mode
  921. */
  922. static readonly MATERIAL_PointListDrawMode: number;
  923. /**
  924. * Returns the line list draw mode
  925. */
  926. static readonly MATERIAL_LineListDrawMode: number;
  927. /**
  928. * Returns the line loop draw mode
  929. */
  930. static readonly MATERIAL_LineLoopDrawMode: number;
  931. /**
  932. * Returns the line strip draw mode
  933. */
  934. static readonly MATERIAL_LineStripDrawMode: number;
  935. /**
  936. * Returns the triangle strip draw mode
  937. */
  938. static readonly MATERIAL_TriangleStripDrawMode: number;
  939. /**
  940. * Returns the triangle fan draw mode
  941. */
  942. static readonly MATERIAL_TriangleFanDrawMode: number;
  943. /**
  944. * Stores the clock-wise side orientation
  945. */
  946. static readonly MATERIAL_ClockWiseSideOrientation: number;
  947. /**
  948. * Stores the counter clock-wise side orientation
  949. */
  950. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  951. /**
  952. * Nothing
  953. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_NothingTrigger: number;
  956. /**
  957. * On pick
  958. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPickTrigger: number;
  961. /**
  962. * On left pick
  963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnLeftPickTrigger: number;
  966. /**
  967. * On right pick
  968. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnRightPickTrigger: number;
  971. /**
  972. * On center pick
  973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnCenterPickTrigger: number;
  976. /**
  977. * On pick down
  978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnPickDownTrigger: number;
  981. /**
  982. * On double pick
  983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnDoublePickTrigger: number;
  986. /**
  987. * On pick up
  988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  989. */
  990. static readonly ACTION_OnPickUpTrigger: number;
  991. /**
  992. * On pick out.
  993. * This trigger will only be raised if you also declared a OnPickDown
  994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  995. */
  996. static readonly ACTION_OnPickOutTrigger: number;
  997. /**
  998. * On long press
  999. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1000. */
  1001. static readonly ACTION_OnLongPressTrigger: number;
  1002. /**
  1003. * On pointer over
  1004. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1005. */
  1006. static readonly ACTION_OnPointerOverTrigger: number;
  1007. /**
  1008. * On pointer out
  1009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1010. */
  1011. static readonly ACTION_OnPointerOutTrigger: number;
  1012. /**
  1013. * On every frame
  1014. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1015. */
  1016. static readonly ACTION_OnEveryFrameTrigger: number;
  1017. /**
  1018. * On intersection enter
  1019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1020. */
  1021. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1022. /**
  1023. * On intersection exit
  1024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1025. */
  1026. static readonly ACTION_OnIntersectionExitTrigger: number;
  1027. /**
  1028. * On key down
  1029. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1030. */
  1031. static readonly ACTION_OnKeyDownTrigger: number;
  1032. /**
  1033. * On key up
  1034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1035. */
  1036. static readonly ACTION_OnKeyUpTrigger: number;
  1037. /**
  1038. * Billboard mode will only apply to Y axis
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1041. /**
  1042. * Billboard mode will apply to all axes
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1045. /**
  1046. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1047. */
  1048. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1049. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1050. * Test order :
  1051. * Is the bounding sphere outside the frustum ?
  1052. * If not, are the bounding box vertices outside the frustum ?
  1053. * It not, then the cullable object is in the frustum.
  1054. */
  1055. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1056. /** Culling strategy : Bounding Sphere Only.
  1057. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1058. * It's also less accurate than the standard because some not visible objects can still be selected.
  1059. * Test : is the bounding sphere outside the frustum ?
  1060. * If not, then the cullable object is in the frustum.
  1061. */
  1062. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1063. /** Culling strategy : Optimistic Inclusion.
  1064. * This in an inclusion test first, then the standard exclusion test.
  1065. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1066. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1067. * Anyway, it's as accurate as the standard strategy.
  1068. * Test :
  1069. * Is the cullable object bounding sphere center in the frustum ?
  1070. * If not, apply the default culling strategy.
  1071. */
  1072. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1073. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1074. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1075. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1076. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1077. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1078. * Test :
  1079. * Is the cullable object bounding sphere center in the frustum ?
  1080. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1081. */
  1082. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1083. /**
  1084. * No logging while loading
  1085. */
  1086. static readonly SCENELOADER_NO_LOGGING: number;
  1087. /**
  1088. * Minimal logging while loading
  1089. */
  1090. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1091. /**
  1092. * Summary logging while loading
  1093. */
  1094. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1095. /**
  1096. * Detailled logging while loading
  1097. */
  1098. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1099. /**
  1100. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1101. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1102. */
  1103. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1104. /**
  1105. * Constant used to retrieve the position texture index in the textures array in the prepass
  1106. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1107. */
  1108. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1109. /**
  1110. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1111. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1112. */
  1113. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1114. /**
  1115. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1116. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1117. */
  1118. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1119. /**
  1120. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1121. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1122. */
  1123. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1124. /**
  1125. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1126. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1127. */
  1128. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1129. /**
  1130. * Constant used to retrieve albedo index in the textures array in the prepass
  1131. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1132. */
  1133. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1134. /**
  1135. * Prefixes used by the engine for custom effects
  1136. */
  1137. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Materials/Textures/hardwareTextureWrapper" {
  1141. /** @hidden */
  1142. export interface HardwareTextureWrapper {
  1143. underlyingResource: any;
  1144. set(hardwareTexture: any): void;
  1145. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1146. reset(): void;
  1147. release(): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1151. import { Nullable } from "babylonjs/types";
  1152. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1153. /**
  1154. * This represents the required contract to create a new type of texture loader.
  1155. */
  1156. export interface IInternalTextureLoader {
  1157. /**
  1158. * Defines wether the loader supports cascade loading the different faces.
  1159. */
  1160. supportCascades: boolean;
  1161. /**
  1162. * This returns if the loader support the current file information.
  1163. * @param extension defines the file extension of the file being loaded
  1164. * @param mimeType defines the optional mime type of the file being loaded
  1165. * @returns true if the loader can load the specified file
  1166. */
  1167. canLoad(extension: string, mimeType?: string): boolean;
  1168. /**
  1169. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1170. * @param data contains the texture data
  1171. * @param texture defines the BabylonJS internal texture
  1172. * @param createPolynomials will be true if polynomials have been requested
  1173. * @param onLoad defines the callback to trigger once the texture is ready
  1174. * @param onError defines the callback to trigger in case of error
  1175. * @param options options to be passed to the loader
  1176. */
  1177. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1178. /**
  1179. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1180. * @param data contains the texture data
  1181. * @param texture defines the BabylonJS internal texture
  1182. * @param callback defines the method to call once ready to upload
  1183. * @param options options to be passed to the loader
  1184. */
  1185. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1186. }
  1187. }
  1188. declare module "babylonjs/Maths/math.like" {
  1189. import { float, int, DeepImmutable } from "babylonjs/types";
  1190. /**
  1191. * @hidden
  1192. */
  1193. export interface IColor4Like {
  1194. r: float;
  1195. g: float;
  1196. b: float;
  1197. a: float;
  1198. }
  1199. /**
  1200. * @hidden
  1201. */
  1202. export interface IColor3Like {
  1203. r: float;
  1204. g: float;
  1205. b: float;
  1206. }
  1207. /**
  1208. * @hidden
  1209. */
  1210. export interface IVector4Like {
  1211. x: float;
  1212. y: float;
  1213. z: float;
  1214. w: float;
  1215. }
  1216. /**
  1217. * @hidden
  1218. */
  1219. export interface IVector3Like {
  1220. x: float;
  1221. y: float;
  1222. z: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IVector2Like {
  1228. x: float;
  1229. y: float;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IMatrixLike {
  1235. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1236. updateFlag: int;
  1237. }
  1238. /**
  1239. * @hidden
  1240. */
  1241. export interface IViewportLike {
  1242. x: float;
  1243. y: float;
  1244. width: float;
  1245. height: float;
  1246. }
  1247. /**
  1248. * @hidden
  1249. */
  1250. export interface IPlaneLike {
  1251. normal: IVector3Like;
  1252. d: float;
  1253. normalize(): void;
  1254. }
  1255. }
  1256. declare module "babylonjs/Engines/IPipelineContext" {
  1257. import { Nullable } from "babylonjs/types";
  1258. import { Effect } from "babylonjs/Materials/effect";
  1259. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  1260. /**
  1261. * Class used to store and describe the pipeline context associated with an effect
  1262. */
  1263. export interface IPipelineContext {
  1264. /**
  1265. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1266. */
  1267. isAsync: boolean;
  1268. /**
  1269. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1270. */
  1271. isReady: boolean;
  1272. /** @hidden */
  1273. _name?: string;
  1274. /** @hidden */
  1275. _getVertexShaderCode(): string | null;
  1276. /** @hidden */
  1277. _getFragmentShaderCode(): string | null;
  1278. /** @hidden */
  1279. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1280. /** @hidden */
  1281. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1282. [key: string]: number;
  1283. }, uniformsNames: string[], uniforms: {
  1284. [key: string]: Nullable<WebGLUniformLocation>;
  1285. }, samplerList: string[], samplers: {
  1286. [key: string]: number;
  1287. }, attributesNames: string[], attributes: number[]): void;
  1288. /** Releases the resources associated with the pipeline. */
  1289. dispose(): void;
  1290. /**
  1291. * Sets an integer value on a uniform variable.
  1292. * @param uniformName Name of the variable.
  1293. * @param value Value to be set.
  1294. */
  1295. setInt(uniformName: string, value: number): void;
  1296. /**
  1297. * Sets an int2 value on a uniform variable.
  1298. * @param uniformName Name of the variable.
  1299. * @param x First int in int2.
  1300. * @param y Second int in int2.
  1301. */
  1302. setInt2(uniformName: string, x: number, y: number): void;
  1303. /**
  1304. * Sets an int3 value on a uniform variable.
  1305. * @param uniformName Name of the variable.
  1306. * @param x First int in int3.
  1307. * @param y Second int in int3.
  1308. * @param z Third int in int3.
  1309. */
  1310. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1311. /**
  1312. * Sets an int4 value on a uniform variable.
  1313. * @param uniformName Name of the variable.
  1314. * @param x First int in int4.
  1315. * @param y Second int in int4.
  1316. * @param z Third int in int4.
  1317. * @param w Fourth int in int4.
  1318. */
  1319. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1320. /**
  1321. * Sets an int array on a uniform variable.
  1322. * @param uniformName Name of the variable.
  1323. * @param array array to be set.
  1324. */
  1325. setIntArray(uniformName: string, array: Int32Array): void;
  1326. /**
  1327. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1328. * @param uniformName Name of the variable.
  1329. * @param array array to be set.
  1330. */
  1331. setIntArray2(uniformName: string, array: Int32Array): void;
  1332. /**
  1333. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1334. * @param uniformName Name of the variable.
  1335. * @param array array to be set.
  1336. */
  1337. setIntArray3(uniformName: string, array: Int32Array): void;
  1338. /**
  1339. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1340. * @param uniformName Name of the variable.
  1341. * @param array array to be set.
  1342. */
  1343. setIntArray4(uniformName: string, array: Int32Array): void;
  1344. /**
  1345. * Sets an array on a uniform variable.
  1346. * @param uniformName Name of the variable.
  1347. * @param array array to be set.
  1348. */
  1349. setArray(uniformName: string, array: number[] | Float32Array): void;
  1350. /**
  1351. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1352. * @param uniformName Name of the variable.
  1353. * @param array array to be set.
  1354. */
  1355. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1356. /**
  1357. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1358. * @param uniformName Name of the variable.
  1359. * @param array array to be set.
  1360. */
  1361. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1362. /**
  1363. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1364. * @param uniformName Name of the variable.
  1365. * @param array array to be set.
  1366. */
  1367. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1368. /**
  1369. * Sets matrices on a uniform variable.
  1370. * @param uniformName Name of the variable.
  1371. * @param matrices matrices to be set.
  1372. */
  1373. setMatrices(uniformName: string, matrices: Float32Array): void;
  1374. /**
  1375. * Sets matrix on a uniform variable.
  1376. * @param uniformName Name of the variable.
  1377. * @param matrix matrix to be set.
  1378. */
  1379. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1380. /**
  1381. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1382. * @param uniformName Name of the variable.
  1383. * @param matrix matrix to be set.
  1384. */
  1385. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1386. /**
  1387. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1388. * @param uniformName Name of the variable.
  1389. * @param matrix matrix to be set.
  1390. */
  1391. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1392. /**
  1393. * Sets a float on a uniform variable.
  1394. * @param uniformName Name of the variable.
  1395. * @param value value to be set.
  1396. */
  1397. setFloat(uniformName: string, value: number): void;
  1398. /**
  1399. * Sets a Vector2 on a uniform variable.
  1400. * @param uniformName Name of the variable.
  1401. * @param vector2 vector2 to be set.
  1402. */
  1403. setVector2(uniformName: string, vector2: IVector2Like): void;
  1404. /**
  1405. * Sets a float2 on a uniform variable.
  1406. * @param uniformName Name of the variable.
  1407. * @param x First float in float2.
  1408. * @param y Second float in float2.
  1409. */
  1410. setFloat2(uniformName: string, x: number, y: number): void;
  1411. /**
  1412. * Sets a Vector3 on a uniform variable.
  1413. * @param uniformName Name of the variable.
  1414. * @param vector3 Value to be set.
  1415. */
  1416. setVector3(uniformName: string, vector3: IVector3Like): void;
  1417. /**
  1418. * Sets a float3 on a uniform variable.
  1419. * @param uniformName Name of the variable.
  1420. * @param x First float in float3.
  1421. * @param y Second float in float3.
  1422. * @param z Third float in float3.
  1423. */
  1424. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1425. /**
  1426. * Sets a Vector4 on a uniform variable.
  1427. * @param uniformName Name of the variable.
  1428. * @param vector4 Value to be set.
  1429. */
  1430. setVector4(uniformName: string, vector4: IVector4Like): void;
  1431. /**
  1432. * Sets a float4 on a uniform variable.
  1433. * @param uniformName Name of the variable.
  1434. * @param x First float in float4.
  1435. * @param y Second float in float4.
  1436. * @param z Third float in float4.
  1437. * @param w Fourth float in float4.
  1438. */
  1439. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1440. /**
  1441. * Sets a Color3 on a uniform variable.
  1442. * @param uniformName Name of the variable.
  1443. * @param color3 Value to be set.
  1444. */
  1445. setColor3(uniformName: string, color3: IColor3Like): void;
  1446. /**
  1447. * Sets a Color4 on a uniform variable.
  1448. * @param uniformName Name of the variable.
  1449. * @param color3 Value to be set.
  1450. * @param alpha Alpha value to be set.
  1451. */
  1452. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1453. /**
  1454. * Sets a Color4 on a uniform variable
  1455. * @param uniformName defines the name of the variable
  1456. * @param color4 defines the value to be set
  1457. */
  1458. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1459. }
  1460. }
  1461. declare module "babylonjs/Meshes/dataBuffer" {
  1462. /**
  1463. * Class used to store gfx data (like WebGLBuffer)
  1464. */
  1465. export class DataBuffer {
  1466. private static _Counter;
  1467. /**
  1468. * Gets or sets the number of objects referencing this buffer
  1469. */
  1470. references: number;
  1471. /** Gets or sets the size of the underlying buffer */
  1472. capacity: number;
  1473. /**
  1474. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1475. */
  1476. is32Bits: boolean;
  1477. /**
  1478. * Gets the underlying buffer
  1479. */
  1480. get underlyingResource(): any;
  1481. /**
  1482. * Gets the unique id of this buffer
  1483. */
  1484. readonly uniqueId: number;
  1485. /**
  1486. * Constructs the buffer
  1487. */
  1488. constructor();
  1489. }
  1490. }
  1491. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1492. import { Nullable } from "babylonjs/types";
  1493. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1494. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1495. /** @hidden */
  1496. export interface IShaderProcessor {
  1497. attributeProcessor?: (attribute: string, preProcessors: {
  1498. [key: string]: string;
  1499. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1501. [key: string]: string;
  1502. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1503. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1504. [key: string]: string;
  1505. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1506. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1507. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1508. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1509. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1510. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1511. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1512. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1513. vertexCode: string;
  1514. fragmentCode: string;
  1515. };
  1516. }
  1517. }
  1518. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1519. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1520. import { Nullable } from "babylonjs/types";
  1521. /** @hidden */
  1522. export interface ShaderProcessingContext {
  1523. }
  1524. /** @hidden */
  1525. export interface ProcessingOptions {
  1526. defines: string[];
  1527. indexParameters: any;
  1528. isFragment: boolean;
  1529. shouldUseHighPrecisionShader: boolean;
  1530. supportsUniformBuffers: boolean;
  1531. shadersRepository: string;
  1532. includesShadersStore: {
  1533. [key: string]: string;
  1534. };
  1535. processor: Nullable<IShaderProcessor>;
  1536. version: string;
  1537. platformName: string;
  1538. lookForClosingBracketForUniformBuffer?: boolean;
  1539. processingContext: Nullable<ShaderProcessingContext>;
  1540. }
  1541. }
  1542. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1543. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1544. /** @hidden */
  1545. export class ShaderCodeNode {
  1546. line: string;
  1547. children: ShaderCodeNode[];
  1548. additionalDefineKey?: string;
  1549. additionalDefineValue?: string;
  1550. isValid(preprocessors: {
  1551. [key: string]: string;
  1552. }): boolean;
  1553. process(preprocessors: {
  1554. [key: string]: string;
  1555. }, options: ProcessingOptions): string;
  1556. }
  1557. }
  1558. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1559. /** @hidden */
  1560. export class ShaderCodeCursor {
  1561. private _lines;
  1562. lineIndex: number;
  1563. get currentLine(): string;
  1564. get canRead(): boolean;
  1565. set lines(value: string[]);
  1566. }
  1567. }
  1568. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1569. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1570. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1571. /** @hidden */
  1572. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1573. process(preprocessors: {
  1574. [key: string]: string;
  1575. }, options: ProcessingOptions): string;
  1576. }
  1577. }
  1578. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1579. /** @hidden */
  1580. export class ShaderDefineExpression {
  1581. isTrue(preprocessors: {
  1582. [key: string]: string;
  1583. }): boolean;
  1584. private static _OperatorPriority;
  1585. private static _Stack;
  1586. static postfixToInfix(postfix: string[]): string;
  1587. static infixToPostfix(infix: string): string[];
  1588. }
  1589. }
  1590. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1591. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1592. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1593. /** @hidden */
  1594. export class ShaderCodeTestNode extends ShaderCodeNode {
  1595. testExpression: ShaderDefineExpression;
  1596. isValid(preprocessors: {
  1597. [key: string]: string;
  1598. }): boolean;
  1599. }
  1600. }
  1601. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1602. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1603. /** @hidden */
  1604. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1605. define: string;
  1606. not: boolean;
  1607. constructor(define: string, not?: boolean);
  1608. isTrue(preprocessors: {
  1609. [key: string]: string;
  1610. }): boolean;
  1611. }
  1612. }
  1613. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1614. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1615. /** @hidden */
  1616. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1617. leftOperand: ShaderDefineExpression;
  1618. rightOperand: ShaderDefineExpression;
  1619. isTrue(preprocessors: {
  1620. [key: string]: string;
  1621. }): boolean;
  1622. }
  1623. }
  1624. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1625. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1626. /** @hidden */
  1627. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1628. leftOperand: ShaderDefineExpression;
  1629. rightOperand: ShaderDefineExpression;
  1630. isTrue(preprocessors: {
  1631. [key: string]: string;
  1632. }): boolean;
  1633. }
  1634. }
  1635. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1636. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1637. /** @hidden */
  1638. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1639. define: string;
  1640. operand: string;
  1641. testValue: string;
  1642. constructor(define: string, operand: string, testValue: string);
  1643. isTrue(preprocessors: {
  1644. [key: string]: string;
  1645. }): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Offline/IOfflineProvider" {
  1649. /**
  1650. * Class used to enable access to offline support
  1651. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1652. */
  1653. export interface IOfflineProvider {
  1654. /**
  1655. * Gets a boolean indicating if scene must be saved in the database
  1656. */
  1657. enableSceneOffline: boolean;
  1658. /**
  1659. * Gets a boolean indicating if textures must be saved in the database
  1660. */
  1661. enableTexturesOffline: boolean;
  1662. /**
  1663. * Open the offline support and make it available
  1664. * @param successCallback defines the callback to call on success
  1665. * @param errorCallback defines the callback to call on error
  1666. */
  1667. open(successCallback: () => void, errorCallback: () => void): void;
  1668. /**
  1669. * Loads an image from the offline support
  1670. * @param url defines the url to load from
  1671. * @param image defines the target DOM image
  1672. */
  1673. loadImage(url: string, image: HTMLImageElement): void;
  1674. /**
  1675. * Loads a file from offline support
  1676. * @param url defines the URL to load from
  1677. * @param sceneLoaded defines a callback to call on success
  1678. * @param progressCallBack defines a callback to call when progress changed
  1679. * @param errorCallback defines a callback to call on error
  1680. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1681. */
  1682. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1683. }
  1684. }
  1685. declare module "babylonjs/Misc/filesInputStore" {
  1686. /**
  1687. * Class used to help managing file picking and drag'n'drop
  1688. * File Storage
  1689. */
  1690. export class FilesInputStore {
  1691. /**
  1692. * List of files ready to be loaded
  1693. */
  1694. static FilesToLoad: {
  1695. [key: string]: File;
  1696. };
  1697. }
  1698. }
  1699. declare module "babylonjs/Misc/retryStrategy" {
  1700. import { WebRequest } from "babylonjs/Misc/webRequest";
  1701. /**
  1702. * Class used to define a retry strategy when error happens while loading assets
  1703. */
  1704. export class RetryStrategy {
  1705. /**
  1706. * Function used to defines an exponential back off strategy
  1707. * @param maxRetries defines the maximum number of retries (3 by default)
  1708. * @param baseInterval defines the interval between retries
  1709. * @returns the strategy function to use
  1710. */
  1711. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1712. }
  1713. }
  1714. declare module "babylonjs/Misc/baseError" {
  1715. /**
  1716. * @ignore
  1717. * Application error to support additional information when loading a file
  1718. */
  1719. export abstract class BaseError extends Error {
  1720. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1721. }
  1722. }
  1723. declare module "babylonjs/Misc/fileTools" {
  1724. import { WebRequest } from "babylonjs/Misc/webRequest";
  1725. import { Nullable } from "babylonjs/types";
  1726. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1727. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1728. import { BaseError } from "babylonjs/Misc/baseError";
  1729. /** @ignore */
  1730. export class LoadFileError extends BaseError {
  1731. request?: WebRequest;
  1732. file?: File;
  1733. /**
  1734. * Creates a new LoadFileError
  1735. * @param message defines the message of the error
  1736. * @param request defines the optional web request
  1737. * @param file defines the optional file
  1738. */
  1739. constructor(message: string, object?: WebRequest | File);
  1740. }
  1741. /** @ignore */
  1742. export class RequestFileError extends BaseError {
  1743. request: WebRequest;
  1744. /**
  1745. * Creates a new LoadFileError
  1746. * @param message defines the message of the error
  1747. * @param request defines the optional web request
  1748. */
  1749. constructor(message: string, request: WebRequest);
  1750. }
  1751. /** @ignore */
  1752. export class ReadFileError extends BaseError {
  1753. file: File;
  1754. /**
  1755. * Creates a new ReadFileError
  1756. * @param message defines the message of the error
  1757. * @param file defines the optional file
  1758. */
  1759. constructor(message: string, file: File);
  1760. }
  1761. /**
  1762. * @hidden
  1763. */
  1764. export class FileTools {
  1765. /**
  1766. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1767. */
  1768. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1769. /**
  1770. * Gets or sets the base URL to use to load assets
  1771. */
  1772. static BaseUrl: string;
  1773. /**
  1774. * Default behaviour for cors in the application.
  1775. * It can be a string if the expected behavior is identical in the entire app.
  1776. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1777. */
  1778. static CorsBehavior: string | ((url: string | string[]) => string);
  1779. /**
  1780. * Gets or sets a function used to pre-process url before using them to load assets
  1781. */
  1782. static PreprocessUrl: (url: string) => string;
  1783. /**
  1784. * Removes unwanted characters from an url
  1785. * @param url defines the url to clean
  1786. * @returns the cleaned url
  1787. */
  1788. private static _CleanUrl;
  1789. /**
  1790. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1791. * @param url define the url we are trying
  1792. * @param element define the dom element where to configure the cors policy
  1793. */
  1794. static SetCorsBehavior(url: string | string[], element: {
  1795. crossOrigin: string | null;
  1796. }): void;
  1797. /**
  1798. * Loads an image as an HTMLImageElement.
  1799. * @param input url string, ArrayBuffer, or Blob to load
  1800. * @param onLoad callback called when the image successfully loads
  1801. * @param onError callback called when the image fails to load
  1802. * @param offlineProvider offline provider for caching
  1803. * @param mimeType optional mime type
  1804. * @returns the HTMLImageElement of the loaded image
  1805. */
  1806. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1807. /**
  1808. * Reads a file from a File object
  1809. * @param file defines the file to load
  1810. * @param onSuccess defines the callback to call when data is loaded
  1811. * @param onProgress defines the callback to call during loading process
  1812. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1813. * @param onError defines the callback to call when an error occurs
  1814. * @returns a file request object
  1815. */
  1816. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1817. /**
  1818. * Loads a file from a url
  1819. * @param url url to load
  1820. * @param onSuccess callback called when the file successfully loads
  1821. * @param onProgress callback called while file is loading (if the server supports this mode)
  1822. * @param offlineProvider defines the offline provider for caching
  1823. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1824. * @param onError callback called when the file fails to load
  1825. * @returns a file request object
  1826. */
  1827. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1828. /**
  1829. * Loads a file
  1830. * @param url url to load
  1831. * @param onSuccess callback called when the file successfully loads
  1832. * @param onProgress callback called while file is loading (if the server supports this mode)
  1833. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1834. * @param onError callback called when the file fails to load
  1835. * @param onOpened callback called when the web request is opened
  1836. * @returns a file request object
  1837. */
  1838. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1839. /**
  1840. * Checks if the loaded document was accessed via `file:`-Protocol.
  1841. * @returns boolean
  1842. */
  1843. static IsFileURL(): boolean;
  1844. }
  1845. }
  1846. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1847. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1848. import { WebRequest } from "babylonjs/Misc/webRequest";
  1849. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1851. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1852. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1853. /** @hidden */
  1854. export class ShaderProcessor {
  1855. static Initialize(options: ProcessingOptions): void;
  1856. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1857. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1858. vertexCode: string;
  1859. fragmentCode: string;
  1860. };
  1861. private static _ProcessPrecision;
  1862. private static _ExtractOperation;
  1863. private static _BuildSubExpression;
  1864. private static _BuildExpression;
  1865. private static _MoveCursorWithinIf;
  1866. private static _MoveCursor;
  1867. private static _EvaluatePreProcessors;
  1868. private static _PreparePreProcessors;
  1869. private static _ProcessShaderConversion;
  1870. private static _ProcessIncludes;
  1871. /**
  1872. * Loads a file from a url
  1873. * @param url url to load
  1874. * @param onSuccess callback called when the file successfully loads
  1875. * @param onProgress callback called while file is loading (if the server supports this mode)
  1876. * @param offlineProvider defines the offline provider for caching
  1877. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1878. * @param onError callback called when the file fails to load
  1879. * @returns a file request object
  1880. * @hidden
  1881. */
  1882. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1883. }
  1884. }
  1885. declare module "babylonjs/Materials/iEffectFallbacks" {
  1886. import { Effect } from "babylonjs/Materials/effect";
  1887. /**
  1888. * Interface used to define common properties for effect fallbacks
  1889. */
  1890. export interface IEffectFallbacks {
  1891. /**
  1892. * Removes the defines that should be removed when falling back.
  1893. * @param currentDefines defines the current define statements for the shader.
  1894. * @param effect defines the current effect we try to compile
  1895. * @returns The resulting defines with defines of the current rank removed.
  1896. */
  1897. reduce(currentDefines: string, effect: Effect): string;
  1898. /**
  1899. * Removes the fallback from the bound mesh.
  1900. */
  1901. unBindMesh(): void;
  1902. /**
  1903. * Checks to see if more fallbacks are still availible.
  1904. */
  1905. hasMoreFallbacks: boolean;
  1906. }
  1907. }
  1908. declare module "babylonjs/Maths/math.size" {
  1909. /**
  1910. * Interface for the size containing width and height
  1911. */
  1912. export interface ISize {
  1913. /**
  1914. * Width
  1915. */
  1916. width: number;
  1917. /**
  1918. * Heighht
  1919. */
  1920. height: number;
  1921. }
  1922. /**
  1923. * Size containing widht and height
  1924. */
  1925. export class Size implements ISize {
  1926. /**
  1927. * Width
  1928. */
  1929. width: number;
  1930. /**
  1931. * Height
  1932. */
  1933. height: number;
  1934. /**
  1935. * Creates a Size object from the given width and height (floats).
  1936. * @param width width of the new size
  1937. * @param height height of the new size
  1938. */
  1939. constructor(width: number, height: number);
  1940. /**
  1941. * Returns a string with the Size width and height
  1942. * @returns a string with the Size width and height
  1943. */
  1944. toString(): string;
  1945. /**
  1946. * "Size"
  1947. * @returns the string "Size"
  1948. */
  1949. getClassName(): string;
  1950. /**
  1951. * Returns the Size hash code.
  1952. * @returns a hash code for a unique width and height
  1953. */
  1954. getHashCode(): number;
  1955. /**
  1956. * Updates the current size from the given one.
  1957. * @param src the given size
  1958. */
  1959. copyFrom(src: Size): void;
  1960. /**
  1961. * Updates in place the current Size from the given floats.
  1962. * @param width width of the new size
  1963. * @param height height of the new size
  1964. * @returns the updated Size.
  1965. */
  1966. copyFromFloats(width: number, height: number): Size;
  1967. /**
  1968. * Updates in place the current Size from the given floats.
  1969. * @param width width to set
  1970. * @param height height to set
  1971. * @returns the updated Size.
  1972. */
  1973. set(width: number, height: number): Size;
  1974. /**
  1975. * Multiplies the width and height by numbers
  1976. * @param w factor to multiple the width by
  1977. * @param h factor to multiple the height by
  1978. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1979. */
  1980. multiplyByFloats(w: number, h: number): Size;
  1981. /**
  1982. * Clones the size
  1983. * @returns a new Size copied from the given one.
  1984. */
  1985. clone(): Size;
  1986. /**
  1987. * True if the current Size and the given one width and height are strictly equal.
  1988. * @param other the other size to compare against
  1989. * @returns True if the current Size and the given one width and height are strictly equal.
  1990. */
  1991. equals(other: Size): boolean;
  1992. /**
  1993. * The surface of the Size : width * height (float).
  1994. */
  1995. get surface(): number;
  1996. /**
  1997. * Create a new size of zero
  1998. * @returns a new Size set to (0.0, 0.0)
  1999. */
  2000. static Zero(): Size;
  2001. /**
  2002. * Sums the width and height of two sizes
  2003. * @param otherSize size to add to this size
  2004. * @returns a new Size set as the addition result of the current Size and the given one.
  2005. */
  2006. add(otherSize: Size): Size;
  2007. /**
  2008. * Subtracts the width and height of two
  2009. * @param otherSize size to subtract to this size
  2010. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2011. */
  2012. subtract(otherSize: Size): Size;
  2013. /**
  2014. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2015. * @param start starting size to lerp between
  2016. * @param end end size to lerp between
  2017. * @param amount amount to lerp between the start and end values
  2018. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2019. */
  2020. static Lerp(start: Size, end: Size, amount: number): Size;
  2021. }
  2022. }
  2023. declare module "babylonjs/Materials/Textures/thinTexture" {
  2024. import { Nullable } from "babylonjs/types";
  2025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  2026. import { ISize } from "babylonjs/Maths/math.size";
  2027. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  2028. /**
  2029. * Base class of all the textures in babylon.
  2030. * It groups all the common properties required to work with Thin Engine.
  2031. */
  2032. export class ThinTexture {
  2033. protected _wrapU: number;
  2034. /**
  2035. * | Value | Type | Description |
  2036. * | ----- | ------------------ | ----------- |
  2037. * | 0 | CLAMP_ADDRESSMODE | |
  2038. * | 1 | WRAP_ADDRESSMODE | |
  2039. * | 2 | MIRROR_ADDRESSMODE | |
  2040. */
  2041. get wrapU(): number;
  2042. set wrapU(value: number);
  2043. protected _wrapV: number;
  2044. /**
  2045. * | Value | Type | Description |
  2046. * | ----- | ------------------ | ----------- |
  2047. * | 0 | CLAMP_ADDRESSMODE | |
  2048. * | 1 | WRAP_ADDRESSMODE | |
  2049. * | 2 | MIRROR_ADDRESSMODE | |
  2050. */
  2051. get wrapV(): number;
  2052. set wrapV(value: number);
  2053. /**
  2054. * | Value | Type | Description |
  2055. * | ----- | ------------------ | ----------- |
  2056. * | 0 | CLAMP_ADDRESSMODE | |
  2057. * | 1 | WRAP_ADDRESSMODE | |
  2058. * | 2 | MIRROR_ADDRESSMODE | |
  2059. */
  2060. wrapR: number;
  2061. /**
  2062. * With compliant hardware and browser (supporting anisotropic filtering)
  2063. * this defines the level of anisotropic filtering in the texture.
  2064. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2065. */
  2066. anisotropicFilteringLevel: number;
  2067. /**
  2068. * Define the current state of the loading sequence when in delayed load mode.
  2069. */
  2070. delayLoadState: number;
  2071. /**
  2072. * How a texture is mapped.
  2073. * Unused in thin texture mode.
  2074. */
  2075. get coordinatesMode(): number;
  2076. /**
  2077. * Define if the texture is a cube texture or if false a 2d texture.
  2078. */
  2079. get isCube(): boolean;
  2080. set isCube(value: boolean);
  2081. /**
  2082. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2083. */
  2084. get is3D(): boolean;
  2085. set is3D(value: boolean);
  2086. /**
  2087. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2088. */
  2089. get is2DArray(): boolean;
  2090. set is2DArray(value: boolean);
  2091. /**
  2092. * Get the class name of the texture.
  2093. * @returns "ThinTexture"
  2094. */
  2095. getClassName(): string;
  2096. /** @hidden */
  2097. _texture: Nullable<InternalTexture>;
  2098. protected _engine: Nullable<ThinEngine>;
  2099. private _cachedSize;
  2100. private _cachedBaseSize;
  2101. /**
  2102. * Instantiates a new ThinTexture.
  2103. * Base class of all the textures in babylon.
  2104. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2105. * @param internalTexture Define the internalTexture to wrap
  2106. */
  2107. constructor(internalTexture: Nullable<InternalTexture>);
  2108. /**
  2109. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2110. * @returns true if fully ready
  2111. */
  2112. isReady(): boolean;
  2113. /**
  2114. * Triggers the load sequence in delayed load mode.
  2115. */
  2116. delayLoad(): void;
  2117. /**
  2118. * Get the underlying lower level texture from Babylon.
  2119. * @returns the insternal texture
  2120. */
  2121. getInternalTexture(): Nullable<InternalTexture>;
  2122. /**
  2123. * Get the size of the texture.
  2124. * @returns the texture size.
  2125. */
  2126. getSize(): ISize;
  2127. /**
  2128. * Get the base size of the texture.
  2129. * It can be different from the size if the texture has been resized for POT for instance
  2130. * @returns the base size
  2131. */
  2132. getBaseSize(): ISize;
  2133. /**
  2134. * Update the sampling mode of the texture.
  2135. * Default is Trilinear mode.
  2136. *
  2137. * | Value | Type | Description |
  2138. * | ----- | ------------------ | ----------- |
  2139. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2140. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2141. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2142. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2143. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2144. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2145. * | 7 | NEAREST_LINEAR | |
  2146. * | 8 | NEAREST_NEAREST | |
  2147. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2148. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2149. * | 11 | LINEAR_LINEAR | |
  2150. * | 12 | LINEAR_NEAREST | |
  2151. *
  2152. * > _mag_: magnification filter (close to the viewer)
  2153. * > _min_: minification filter (far from the viewer)
  2154. * > _mip_: filter used between mip map levels
  2155. *@param samplingMode Define the new sampling mode of the texture
  2156. */
  2157. updateSamplingMode(samplingMode: number): void;
  2158. /**
  2159. * Release and destroy the underlying lower level texture aka internalTexture.
  2160. */
  2161. releaseInternalTexture(): void;
  2162. /**
  2163. * Dispose the texture and release its associated resources.
  2164. */
  2165. dispose(): void;
  2166. }
  2167. }
  2168. declare module "babylonjs/Misc/smartArray" {
  2169. /**
  2170. * Defines an array and its length.
  2171. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2172. */
  2173. export interface ISmartArrayLike<T> {
  2174. /**
  2175. * The data of the array.
  2176. */
  2177. data: Array<T>;
  2178. /**
  2179. * The active length of the array.
  2180. */
  2181. length: number;
  2182. }
  2183. /**
  2184. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2185. */
  2186. export class SmartArray<T> implements ISmartArrayLike<T> {
  2187. /**
  2188. * The full set of data from the array.
  2189. */
  2190. data: Array<T>;
  2191. /**
  2192. * The active length of the array.
  2193. */
  2194. length: number;
  2195. protected _id: number;
  2196. /**
  2197. * Instantiates a Smart Array.
  2198. * @param capacity defines the default capacity of the array.
  2199. */
  2200. constructor(capacity: number);
  2201. /**
  2202. * Pushes a value at the end of the active data.
  2203. * @param value defines the object to push in the array.
  2204. */
  2205. push(value: T): void;
  2206. /**
  2207. * Iterates over the active data and apply the lambda to them.
  2208. * @param func defines the action to apply on each value.
  2209. */
  2210. forEach(func: (content: T) => void): void;
  2211. /**
  2212. * Sorts the full sets of data.
  2213. * @param compareFn defines the comparison function to apply.
  2214. */
  2215. sort(compareFn: (a: T, b: T) => number): void;
  2216. /**
  2217. * Resets the active data to an empty array.
  2218. */
  2219. reset(): void;
  2220. /**
  2221. * Releases all the data from the array as well as the array.
  2222. */
  2223. dispose(): void;
  2224. /**
  2225. * Concats the active data with a given array.
  2226. * @param array defines the data to concatenate with.
  2227. */
  2228. concat(array: any): void;
  2229. /**
  2230. * Returns the position of a value in the active data.
  2231. * @param value defines the value to find the index for
  2232. * @returns the index if found in the active data otherwise -1
  2233. */
  2234. indexOf(value: T): number;
  2235. /**
  2236. * Returns whether an element is part of the active data.
  2237. * @param value defines the value to look for
  2238. * @returns true if found in the active data otherwise false
  2239. */
  2240. contains(value: T): boolean;
  2241. private static _GlobalId;
  2242. }
  2243. /**
  2244. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2245. * The data in this array can only be present once
  2246. */
  2247. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2248. private _duplicateId;
  2249. /**
  2250. * Pushes a value at the end of the active data.
  2251. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2252. * @param value defines the object to push in the array.
  2253. */
  2254. push(value: T): void;
  2255. /**
  2256. * Pushes a value at the end of the active data.
  2257. * If the data is already present, it won t be added again
  2258. * @param value defines the object to push in the array.
  2259. * @returns true if added false if it was already present
  2260. */
  2261. pushNoDuplicate(value: T): boolean;
  2262. /**
  2263. * Resets the active data to an empty array.
  2264. */
  2265. reset(): void;
  2266. /**
  2267. * Concats the active data with a given array.
  2268. * This ensures no dupplicate will be present in the result.
  2269. * @param array defines the data to concatenate with.
  2270. */
  2271. concatWithNoDuplicate(array: any): void;
  2272. }
  2273. }
  2274. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2275. /**
  2276. * Class used to evalaute queries containing `and` and `or` operators
  2277. */
  2278. export class AndOrNotEvaluator {
  2279. /**
  2280. * Evaluate a query
  2281. * @param query defines the query to evaluate
  2282. * @param evaluateCallback defines the callback used to filter result
  2283. * @returns true if the query matches
  2284. */
  2285. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2286. private static _HandleParenthesisContent;
  2287. private static _SimplifyNegation;
  2288. }
  2289. }
  2290. declare module "babylonjs/Misc/tags" {
  2291. /**
  2292. * Class used to store custom tags
  2293. */
  2294. export class Tags {
  2295. /**
  2296. * Adds support for tags on the given object
  2297. * @param obj defines the object to use
  2298. */
  2299. static EnableFor(obj: any): void;
  2300. /**
  2301. * Removes tags support
  2302. * @param obj defines the object to use
  2303. */
  2304. static DisableFor(obj: any): void;
  2305. /**
  2306. * Gets a boolean indicating if the given object has tags
  2307. * @param obj defines the object to use
  2308. * @returns a boolean
  2309. */
  2310. static HasTags(obj: any): boolean;
  2311. /**
  2312. * Gets the tags available on a given object
  2313. * @param obj defines the object to use
  2314. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2315. * @returns the tags
  2316. */
  2317. static GetTags(obj: any, asString?: boolean): any;
  2318. /**
  2319. * Adds tags to an object
  2320. * @param obj defines the object to use
  2321. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2322. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2323. */
  2324. static AddTagsTo(obj: any, tagsString: string): void;
  2325. /**
  2326. * @hidden
  2327. */
  2328. static _AddTagTo(obj: any, tag: string): void;
  2329. /**
  2330. * Removes specific tags from a specific object
  2331. * @param obj defines the object to use
  2332. * @param tagsString defines the tags to remove
  2333. */
  2334. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2335. /**
  2336. * @hidden
  2337. */
  2338. static _RemoveTagFrom(obj: any, tag: string): void;
  2339. /**
  2340. * Defines if tags hosted on an object match a given query
  2341. * @param obj defines the object to use
  2342. * @param tagsQuery defines the tag query
  2343. * @returns a boolean
  2344. */
  2345. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2346. }
  2347. }
  2348. declare module "babylonjs/Maths/math.scalar" {
  2349. /**
  2350. * Scalar computation library
  2351. */
  2352. export class Scalar {
  2353. /**
  2354. * Two pi constants convenient for computation.
  2355. */
  2356. static TwoPi: number;
  2357. /**
  2358. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2359. * @param a number
  2360. * @param b number
  2361. * @param epsilon (default = 1.401298E-45)
  2362. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2363. */
  2364. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2365. /**
  2366. * Returns a string : the upper case translation of the number i to hexadecimal.
  2367. * @param i number
  2368. * @returns the upper case translation of the number i to hexadecimal.
  2369. */
  2370. static ToHex(i: number): string;
  2371. /**
  2372. * Returns -1 if value is negative and +1 is value is positive.
  2373. * @param value the value
  2374. * @returns the value itself if it's equal to zero.
  2375. */
  2376. static Sign(value: number): number;
  2377. /**
  2378. * Returns the value itself if it's between min and max.
  2379. * Returns min if the value is lower than min.
  2380. * Returns max if the value is greater than max.
  2381. * @param value the value to clmap
  2382. * @param min the min value to clamp to (default: 0)
  2383. * @param max the max value to clamp to (default: 1)
  2384. * @returns the clamped value
  2385. */
  2386. static Clamp(value: number, min?: number, max?: number): number;
  2387. /**
  2388. * the log2 of value.
  2389. * @param value the value to compute log2 of
  2390. * @returns the log2 of value.
  2391. */
  2392. static Log2(value: number): number;
  2393. /**
  2394. * the floor part of a log2 value.
  2395. * @param value the value to compute log2 of
  2396. * @returns the log2 of value.
  2397. */
  2398. static ILog2(value: number): number;
  2399. /**
  2400. * Loops the value, so that it is never larger than length and never smaller than 0.
  2401. *
  2402. * This is similar to the modulo operator but it works with floating point numbers.
  2403. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2404. * With t = 5 and length = 2.5, the result would be 0.0.
  2405. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2406. * @param value the value
  2407. * @param length the length
  2408. * @returns the looped value
  2409. */
  2410. static Repeat(value: number, length: number): number;
  2411. /**
  2412. * Normalize the value between 0.0 and 1.0 using min and max values
  2413. * @param value value to normalize
  2414. * @param min max to normalize between
  2415. * @param max min to normalize between
  2416. * @returns the normalized value
  2417. */
  2418. static Normalize(value: number, min: number, max: number): number;
  2419. /**
  2420. * Denormalize the value from 0.0 and 1.0 using min and max values
  2421. * @param normalized value to denormalize
  2422. * @param min max to denormalize between
  2423. * @param max min to denormalize between
  2424. * @returns the denormalized value
  2425. */
  2426. static Denormalize(normalized: number, min: number, max: number): number;
  2427. /**
  2428. * Calculates the shortest difference between two given angles given in degrees.
  2429. * @param current current angle in degrees
  2430. * @param target target angle in degrees
  2431. * @returns the delta
  2432. */
  2433. static DeltaAngle(current: number, target: number): number;
  2434. /**
  2435. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2436. * @param tx value
  2437. * @param length length
  2438. * @returns The returned value will move back and forth between 0 and length
  2439. */
  2440. static PingPong(tx: number, length: number): number;
  2441. /**
  2442. * Interpolates between min and max with smoothing at the limits.
  2443. *
  2444. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2445. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2446. * @param from from
  2447. * @param to to
  2448. * @param tx value
  2449. * @returns the smooth stepped value
  2450. */
  2451. static SmoothStep(from: number, to: number, tx: number): number;
  2452. /**
  2453. * Moves a value current towards target.
  2454. *
  2455. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2456. * Negative values of maxDelta pushes the value away from target.
  2457. * @param current current value
  2458. * @param target target value
  2459. * @param maxDelta max distance to move
  2460. * @returns resulting value
  2461. */
  2462. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2463. /**
  2464. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2465. *
  2466. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2467. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2468. * @param current current value
  2469. * @param target target value
  2470. * @param maxDelta max distance to move
  2471. * @returns resulting angle
  2472. */
  2473. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2474. /**
  2475. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2476. * @param start start value
  2477. * @param end target value
  2478. * @param amount amount to lerp between
  2479. * @returns the lerped value
  2480. */
  2481. static Lerp(start: number, end: number, amount: number): number;
  2482. /**
  2483. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2484. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2485. * @param start start value
  2486. * @param end target value
  2487. * @param amount amount to lerp between
  2488. * @returns the lerped value
  2489. */
  2490. static LerpAngle(start: number, end: number, amount: number): number;
  2491. /**
  2492. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2493. * @param a start value
  2494. * @param b target value
  2495. * @param value value between a and b
  2496. * @returns the inverseLerp value
  2497. */
  2498. static InverseLerp(a: number, b: number, value: number): number;
  2499. /**
  2500. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2501. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2502. * @param value1 spline value
  2503. * @param tangent1 spline value
  2504. * @param value2 spline value
  2505. * @param tangent2 spline value
  2506. * @param amount input value
  2507. * @returns hermite result
  2508. */
  2509. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2510. /**
  2511. * Returns a random float number between and min and max values
  2512. * @param min min value of random
  2513. * @param max max value of random
  2514. * @returns random value
  2515. */
  2516. static RandomRange(min: number, max: number): number;
  2517. /**
  2518. * This function returns percentage of a number in a given range.
  2519. *
  2520. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2521. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2522. * @param number to convert to percentage
  2523. * @param min min range
  2524. * @param max max range
  2525. * @returns the percentage
  2526. */
  2527. static RangeToPercent(number: number, min: number, max: number): number;
  2528. /**
  2529. * This function returns number that corresponds to the percentage in a given range.
  2530. *
  2531. * PercentToRange(0.34,0,100) will return 34.
  2532. * @param percent to convert to number
  2533. * @param min min range
  2534. * @param max max range
  2535. * @returns the number
  2536. */
  2537. static PercentToRange(percent: number, min: number, max: number): number;
  2538. /**
  2539. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2540. * @param angle The angle to normalize in radian.
  2541. * @return The converted angle.
  2542. */
  2543. static NormalizeRadians(angle: number): number;
  2544. }
  2545. }
  2546. declare module "babylonjs/Maths/math.constants" {
  2547. /**
  2548. * Constant used to convert a value to gamma space
  2549. * @ignorenaming
  2550. */
  2551. export const ToGammaSpace: number;
  2552. /**
  2553. * Constant used to convert a value to linear space
  2554. * @ignorenaming
  2555. */
  2556. export const ToLinearSpace = 2.2;
  2557. /**
  2558. * Constant used to define the minimal number value in Babylon.js
  2559. * @ignorenaming
  2560. */
  2561. let Epsilon: number;
  2562. export { Epsilon };
  2563. }
  2564. declare module "babylonjs/Maths/math.viewport" {
  2565. /**
  2566. * Class used to represent a viewport on screen
  2567. */
  2568. export class Viewport {
  2569. /** viewport left coordinate */
  2570. x: number;
  2571. /** viewport top coordinate */
  2572. y: number;
  2573. /**viewport width */
  2574. width: number;
  2575. /** viewport height */
  2576. height: number;
  2577. /**
  2578. * Creates a Viewport object located at (x, y) and sized (width, height)
  2579. * @param x defines viewport left coordinate
  2580. * @param y defines viewport top coordinate
  2581. * @param width defines the viewport width
  2582. * @param height defines the viewport height
  2583. */
  2584. constructor(
  2585. /** viewport left coordinate */
  2586. x: number,
  2587. /** viewport top coordinate */
  2588. y: number,
  2589. /**viewport width */
  2590. width: number,
  2591. /** viewport height */
  2592. height: number);
  2593. /**
  2594. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2595. * @param renderWidth defines the rendering width
  2596. * @param renderHeight defines the rendering height
  2597. * @returns a new Viewport
  2598. */
  2599. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2600. /**
  2601. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2602. * @param renderWidth defines the rendering width
  2603. * @param renderHeight defines the rendering height
  2604. * @param ref defines the target viewport
  2605. * @returns the current viewport
  2606. */
  2607. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2608. /**
  2609. * Returns a new Viewport copied from the current one
  2610. * @returns a new Viewport
  2611. */
  2612. clone(): Viewport;
  2613. }
  2614. }
  2615. declare module "babylonjs/Misc/arrayTools" {
  2616. /**
  2617. * Class containing a set of static utilities functions for arrays.
  2618. */
  2619. export class ArrayTools {
  2620. /**
  2621. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2622. * @param size the number of element to construct and put in the array
  2623. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2624. * @returns a new array filled with new objects
  2625. */
  2626. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2627. }
  2628. }
  2629. declare module "babylonjs/Maths/math.plane" {
  2630. import { DeepImmutable } from "babylonjs/types";
  2631. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2632. /**
  2633. * Represents a plane by the equation ax + by + cz + d = 0
  2634. */
  2635. export class Plane {
  2636. private static _TmpMatrix;
  2637. /**
  2638. * Normal of the plane (a,b,c)
  2639. */
  2640. normal: Vector3;
  2641. /**
  2642. * d component of the plane
  2643. */
  2644. d: number;
  2645. /**
  2646. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2647. * @param a a component of the plane
  2648. * @param b b component of the plane
  2649. * @param c c component of the plane
  2650. * @param d d component of the plane
  2651. */
  2652. constructor(a: number, b: number, c: number, d: number);
  2653. /**
  2654. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2655. */
  2656. asArray(): number[];
  2657. /**
  2658. * @returns a new plane copied from the current Plane.
  2659. */
  2660. clone(): Plane;
  2661. /**
  2662. * @returns the string "Plane".
  2663. */
  2664. getClassName(): string;
  2665. /**
  2666. * @returns the Plane hash code.
  2667. */
  2668. getHashCode(): number;
  2669. /**
  2670. * Normalize the current Plane in place.
  2671. * @returns the updated Plane.
  2672. */
  2673. normalize(): Plane;
  2674. /**
  2675. * Applies a transformation the plane and returns the result
  2676. * @param transformation the transformation matrix to be applied to the plane
  2677. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2678. */
  2679. transform(transformation: DeepImmutable<Matrix>): Plane;
  2680. /**
  2681. * Compute the dot product between the point and the plane normal
  2682. * @param point point to calculate the dot product with
  2683. * @returns the dot product (float) of the point coordinates and the plane normal.
  2684. */
  2685. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2686. /**
  2687. * Updates the current Plane from the plane defined by the three given points.
  2688. * @param point1 one of the points used to contruct the plane
  2689. * @param point2 one of the points used to contruct the plane
  2690. * @param point3 one of the points used to contruct the plane
  2691. * @returns the updated Plane.
  2692. */
  2693. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2694. /**
  2695. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2696. * Note that for this function to work as expected you should make sure that:
  2697. * - direction and the plane normal are normalized
  2698. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2699. * @param direction the direction to check if the plane is facing
  2700. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2701. * @returns True if the plane is facing the given direction
  2702. */
  2703. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2704. /**
  2705. * Calculates the distance to a point
  2706. * @param point point to calculate distance to
  2707. * @returns the signed distance (float) from the given point to the Plane.
  2708. */
  2709. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2710. /**
  2711. * Creates a plane from an array
  2712. * @param array the array to create a plane from
  2713. * @returns a new Plane from the given array.
  2714. */
  2715. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2716. /**
  2717. * Creates a plane from three points
  2718. * @param point1 point used to create the plane
  2719. * @param point2 point used to create the plane
  2720. * @param point3 point used to create the plane
  2721. * @returns a new Plane defined by the three given points.
  2722. */
  2723. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2724. /**
  2725. * Creates a plane from an origin point and a normal
  2726. * @param origin origin of the plane to be constructed
  2727. * @param normal normal of the plane to be constructed
  2728. * @returns a new Plane the normal vector to this plane at the given origin point.
  2729. * Note : the vector "normal" is updated because normalized.
  2730. */
  2731. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2732. /**
  2733. * Calculates the distance from a plane and a point
  2734. * @param origin origin of the plane to be constructed
  2735. * @param normal normal of the plane to be constructed
  2736. * @param point point to calculate distance to
  2737. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2738. */
  2739. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2740. }
  2741. }
  2742. declare module "babylonjs/Engines/performanceConfigurator" {
  2743. /** @hidden */
  2744. export class PerformanceConfigurator {
  2745. /** @hidden */
  2746. static MatrixUse64Bits: boolean;
  2747. /** @hidden */
  2748. static MatrixTrackPrecisionChange: boolean;
  2749. /** @hidden */
  2750. static MatrixCurrentType: any;
  2751. /** @hidden */
  2752. static MatrixTrackedMatrices: Array<any> | null;
  2753. /** @hidden */
  2754. static SetMatrixPrecision(use64bits: boolean): void;
  2755. }
  2756. }
  2757. declare module "babylonjs/Maths/math.vector" {
  2758. import { Viewport } from "babylonjs/Maths/math.viewport";
  2759. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2760. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2761. import { Plane } from "babylonjs/Maths/math.plane";
  2762. /**
  2763. * Class representing a vector containing 2 coordinates
  2764. */
  2765. export class Vector2 {
  2766. /** defines the first coordinate */
  2767. x: number;
  2768. /** defines the second coordinate */
  2769. y: number;
  2770. /**
  2771. * Creates a new Vector2 from the given x and y coordinates
  2772. * @param x defines the first coordinate
  2773. * @param y defines the second coordinate
  2774. */
  2775. constructor(
  2776. /** defines the first coordinate */
  2777. x?: number,
  2778. /** defines the second coordinate */
  2779. y?: number);
  2780. /**
  2781. * Gets a string with the Vector2 coordinates
  2782. * @returns a string with the Vector2 coordinates
  2783. */
  2784. toString(): string;
  2785. /**
  2786. * Gets class name
  2787. * @returns the string "Vector2"
  2788. */
  2789. getClassName(): string;
  2790. /**
  2791. * Gets current vector hash code
  2792. * @returns the Vector2 hash code as a number
  2793. */
  2794. getHashCode(): number;
  2795. /**
  2796. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2797. * @param array defines the source array
  2798. * @param index defines the offset in source array
  2799. * @returns the current Vector2
  2800. */
  2801. toArray(array: FloatArray, index?: number): Vector2;
  2802. /**
  2803. * Update the current vector from an array
  2804. * @param array defines the destination array
  2805. * @param index defines the offset in the destination array
  2806. * @returns the current Vector3
  2807. */
  2808. fromArray(array: FloatArray, index?: number): Vector2;
  2809. /**
  2810. * Copy the current vector to an array
  2811. * @returns a new array with 2 elements: the Vector2 coordinates.
  2812. */
  2813. asArray(): number[];
  2814. /**
  2815. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2816. * @param source defines the source Vector2
  2817. * @returns the current updated Vector2
  2818. */
  2819. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2820. /**
  2821. * Sets the Vector2 coordinates with the given floats
  2822. * @param x defines the first coordinate
  2823. * @param y defines the second coordinate
  2824. * @returns the current updated Vector2
  2825. */
  2826. copyFromFloats(x: number, y: number): Vector2;
  2827. /**
  2828. * Sets the Vector2 coordinates with the given floats
  2829. * @param x defines the first coordinate
  2830. * @param y defines the second coordinate
  2831. * @returns the current updated Vector2
  2832. */
  2833. set(x: number, y: number): Vector2;
  2834. /**
  2835. * Add another vector with the current one
  2836. * @param otherVector defines the other vector
  2837. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2838. */
  2839. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2840. /**
  2841. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2842. * @param otherVector defines the other vector
  2843. * @param result defines the target vector
  2844. * @returns the unmodified current Vector2
  2845. */
  2846. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2847. /**
  2848. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2849. * @param otherVector defines the other vector
  2850. * @returns the current updated Vector2
  2851. */
  2852. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2853. /**
  2854. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2855. * @param otherVector defines the other vector
  2856. * @returns a new Vector2
  2857. */
  2858. addVector3(otherVector: Vector3): Vector2;
  2859. /**
  2860. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2861. * @param otherVector defines the other vector
  2862. * @returns a new Vector2
  2863. */
  2864. subtract(otherVector: Vector2): Vector2;
  2865. /**
  2866. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2867. * @param otherVector defines the other vector
  2868. * @param result defines the target vector
  2869. * @returns the unmodified current Vector2
  2870. */
  2871. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2872. /**
  2873. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2874. * @param otherVector defines the other vector
  2875. * @returns the current updated Vector2
  2876. */
  2877. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2878. /**
  2879. * Multiplies in place the current Vector2 coordinates by the given ones
  2880. * @param otherVector defines the other vector
  2881. * @returns the current updated Vector2
  2882. */
  2883. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2884. /**
  2885. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2886. * @param otherVector defines the other vector
  2887. * @returns a new Vector2
  2888. */
  2889. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2890. /**
  2891. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2892. * @param otherVector defines the other vector
  2893. * @param result defines the target vector
  2894. * @returns the unmodified current Vector2
  2895. */
  2896. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2897. /**
  2898. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2899. * @param x defines the first coordinate
  2900. * @param y defines the second coordinate
  2901. * @returns a new Vector2
  2902. */
  2903. multiplyByFloats(x: number, y: number): Vector2;
  2904. /**
  2905. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2906. * @param otherVector defines the other vector
  2907. * @returns a new Vector2
  2908. */
  2909. divide(otherVector: Vector2): Vector2;
  2910. /**
  2911. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2912. * @param otherVector defines the other vector
  2913. * @param result defines the target vector
  2914. * @returns the unmodified current Vector2
  2915. */
  2916. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2917. /**
  2918. * Divides the current Vector2 coordinates by the given ones
  2919. * @param otherVector defines the other vector
  2920. * @returns the current updated Vector2
  2921. */
  2922. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2923. /**
  2924. * Gets a new Vector2 with current Vector2 negated coordinates
  2925. * @returns a new Vector2
  2926. */
  2927. negate(): Vector2;
  2928. /**
  2929. * Negate this vector in place
  2930. * @returns this
  2931. */
  2932. negateInPlace(): Vector2;
  2933. /**
  2934. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2935. * @param result defines the Vector3 object where to store the result
  2936. * @returns the current Vector2
  2937. */
  2938. negateToRef(result: Vector2): Vector2;
  2939. /**
  2940. * Multiply the Vector2 coordinates by scale
  2941. * @param scale defines the scaling factor
  2942. * @returns the current updated Vector2
  2943. */
  2944. scaleInPlace(scale: number): Vector2;
  2945. /**
  2946. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2947. * @param scale defines the scaling factor
  2948. * @returns a new Vector2
  2949. */
  2950. scale(scale: number): Vector2;
  2951. /**
  2952. * Scale the current Vector2 values by a factor to a given Vector2
  2953. * @param scale defines the scale factor
  2954. * @param result defines the Vector2 object where to store the result
  2955. * @returns the unmodified current Vector2
  2956. */
  2957. scaleToRef(scale: number, result: Vector2): Vector2;
  2958. /**
  2959. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2960. * @param scale defines the scale factor
  2961. * @param result defines the Vector2 object where to store the result
  2962. * @returns the unmodified current Vector2
  2963. */
  2964. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2965. /**
  2966. * Gets a boolean if two vectors are equals
  2967. * @param otherVector defines the other vector
  2968. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2969. */
  2970. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2971. /**
  2972. * Gets a boolean if two vectors are equals (using an epsilon value)
  2973. * @param otherVector defines the other vector
  2974. * @param epsilon defines the minimal distance to consider equality
  2975. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2976. */
  2977. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2978. /**
  2979. * Gets a new Vector2 from current Vector2 floored values
  2980. * @returns a new Vector2
  2981. */
  2982. floor(): Vector2;
  2983. /**
  2984. * Gets a new Vector2 from current Vector2 floored values
  2985. * @returns a new Vector2
  2986. */
  2987. fract(): Vector2;
  2988. /**
  2989. * Gets the length of the vector
  2990. * @returns the vector length (float)
  2991. */
  2992. length(): number;
  2993. /**
  2994. * Gets the vector squared length
  2995. * @returns the vector squared length (float)
  2996. */
  2997. lengthSquared(): number;
  2998. /**
  2999. * Normalize the vector
  3000. * @returns the current updated Vector2
  3001. */
  3002. normalize(): Vector2;
  3003. /**
  3004. * Gets a new Vector2 copied from the Vector2
  3005. * @returns a new Vector2
  3006. */
  3007. clone(): Vector2;
  3008. /**
  3009. * Gets a new Vector2(0, 0)
  3010. * @returns a new Vector2
  3011. */
  3012. static Zero(): Vector2;
  3013. /**
  3014. * Gets a new Vector2(1, 1)
  3015. * @returns a new Vector2
  3016. */
  3017. static One(): Vector2;
  3018. /**
  3019. * Gets a new Vector2 set from the given index element of the given array
  3020. * @param array defines the data source
  3021. * @param offset defines the offset in the data source
  3022. * @returns a new Vector2
  3023. */
  3024. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  3025. /**
  3026. * Sets "result" from the given index element of the given array
  3027. * @param array defines the data source
  3028. * @param offset defines the offset in the data source
  3029. * @param result defines the target vector
  3030. */
  3031. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  3032. /**
  3033. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  3034. * @param value1 defines 1st point of control
  3035. * @param value2 defines 2nd point of control
  3036. * @param value3 defines 3rd point of control
  3037. * @param value4 defines 4th point of control
  3038. * @param amount defines the interpolation factor
  3039. * @returns a new Vector2
  3040. */
  3041. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  3042. /**
  3043. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  3044. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3045. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3046. * @param value defines the value to clamp
  3047. * @param min defines the lower limit
  3048. * @param max defines the upper limit
  3049. * @returns a new Vector2
  3050. */
  3051. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3052. /**
  3053. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3054. * @param value1 defines the 1st control point
  3055. * @param tangent1 defines the outgoing tangent
  3056. * @param value2 defines the 2nd control point
  3057. * @param tangent2 defines the incoming tangent
  3058. * @param amount defines the interpolation factor
  3059. * @returns a new Vector2
  3060. */
  3061. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3062. /**
  3063. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3064. * @param start defines the start vector
  3065. * @param end defines the end vector
  3066. * @param amount defines the interpolation factor
  3067. * @returns a new Vector2
  3068. */
  3069. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3070. /**
  3071. * Gets the dot product of the vector "left" and the vector "right"
  3072. * @param left defines first vector
  3073. * @param right defines second vector
  3074. * @returns the dot product (float)
  3075. */
  3076. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3077. /**
  3078. * Returns a new Vector2 equal to the normalized given vector
  3079. * @param vector defines the vector to normalize
  3080. * @returns a new Vector2
  3081. */
  3082. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3083. /**
  3084. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3085. * @param left defines 1st vector
  3086. * @param right defines 2nd vector
  3087. * @returns a new Vector2
  3088. */
  3089. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3090. /**
  3091. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3092. * @param left defines 1st vector
  3093. * @param right defines 2nd vector
  3094. * @returns a new Vector2
  3095. */
  3096. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3097. /**
  3098. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3099. * @param vector defines the vector to transform
  3100. * @param transformation defines the matrix to apply
  3101. * @returns a new Vector2
  3102. */
  3103. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3104. /**
  3105. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3106. * @param vector defines the vector to transform
  3107. * @param transformation defines the matrix to apply
  3108. * @param result defines the target vector
  3109. */
  3110. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3111. /**
  3112. * Determines if a given vector is included in a triangle
  3113. * @param p defines the vector to test
  3114. * @param p0 defines 1st triangle point
  3115. * @param p1 defines 2nd triangle point
  3116. * @param p2 defines 3rd triangle point
  3117. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3118. */
  3119. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3120. /**
  3121. * Gets the distance between the vectors "value1" and "value2"
  3122. * @param value1 defines first vector
  3123. * @param value2 defines second vector
  3124. * @returns the distance between vectors
  3125. */
  3126. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3127. /**
  3128. * Returns the squared distance between the vectors "value1" and "value2"
  3129. * @param value1 defines first vector
  3130. * @param value2 defines second vector
  3131. * @returns the squared distance between vectors
  3132. */
  3133. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3134. /**
  3135. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3136. * @param value1 defines first vector
  3137. * @param value2 defines second vector
  3138. * @returns a new Vector2
  3139. */
  3140. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3141. /**
  3142. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3143. * @param value1 defines first vector
  3144. * @param value2 defines second vector
  3145. * @param ref defines third vector
  3146. * @returns ref
  3147. */
  3148. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3149. /**
  3150. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3151. * @param p defines the middle point
  3152. * @param segA defines one point of the segment
  3153. * @param segB defines the other point of the segment
  3154. * @returns the shortest distance
  3155. */
  3156. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3157. }
  3158. /**
  3159. * Class used to store (x,y,z) vector representation
  3160. * A Vector3 is the main object used in 3D geometry
  3161. * It can represent etiher the coordinates of a point the space, either a direction
  3162. * Reminder: js uses a left handed forward facing system
  3163. */
  3164. export class Vector3 {
  3165. private static _UpReadOnly;
  3166. private static _ZeroReadOnly;
  3167. /** @hidden */
  3168. _x: number;
  3169. /** @hidden */
  3170. _y: number;
  3171. /** @hidden */
  3172. _z: number;
  3173. /** @hidden */
  3174. _isDirty: boolean;
  3175. /** Gets or sets the x coordinate */
  3176. get x(): number;
  3177. set x(value: number);
  3178. /** Gets or sets the y coordinate */
  3179. get y(): number;
  3180. set y(value: number);
  3181. /** Gets or sets the z coordinate */
  3182. get z(): number;
  3183. set z(value: number);
  3184. /**
  3185. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3186. * @param x defines the first coordinates (on X axis)
  3187. * @param y defines the second coordinates (on Y axis)
  3188. * @param z defines the third coordinates (on Z axis)
  3189. */
  3190. constructor(x?: number, y?: number, z?: number);
  3191. /**
  3192. * Creates a string representation of the Vector3
  3193. * @returns a string with the Vector3 coordinates.
  3194. */
  3195. toString(): string;
  3196. /**
  3197. * Gets the class name
  3198. * @returns the string "Vector3"
  3199. */
  3200. getClassName(): string;
  3201. /**
  3202. * Creates the Vector3 hash code
  3203. * @returns a number which tends to be unique between Vector3 instances
  3204. */
  3205. getHashCode(): number;
  3206. /**
  3207. * Creates an array containing three elements : the coordinates of the Vector3
  3208. * @returns a new array of numbers
  3209. */
  3210. asArray(): number[];
  3211. /**
  3212. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3213. * @param array defines the destination array
  3214. * @param index defines the offset in the destination array
  3215. * @returns the current Vector3
  3216. */
  3217. toArray(array: FloatArray, index?: number): Vector3;
  3218. /**
  3219. * Update the current vector from an array
  3220. * @param array defines the destination array
  3221. * @param index defines the offset in the destination array
  3222. * @returns the current Vector3
  3223. */
  3224. fromArray(array: FloatArray, index?: number): Vector3;
  3225. /**
  3226. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3227. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3228. */
  3229. toQuaternion(): Quaternion;
  3230. /**
  3231. * Adds the given vector to the current Vector3
  3232. * @param otherVector defines the second operand
  3233. * @returns the current updated Vector3
  3234. */
  3235. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3236. /**
  3237. * Adds the given coordinates to the current Vector3
  3238. * @param x defines the x coordinate of the operand
  3239. * @param y defines the y coordinate of the operand
  3240. * @param z defines the z coordinate of the operand
  3241. * @returns the current updated Vector3
  3242. */
  3243. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3244. /**
  3245. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3246. * @param otherVector defines the second operand
  3247. * @returns the resulting Vector3
  3248. */
  3249. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3250. /**
  3251. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3252. * @param otherVector defines the second operand
  3253. * @param result defines the Vector3 object where to store the result
  3254. * @returns the current Vector3
  3255. */
  3256. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3257. /**
  3258. * Subtract the given vector from the current Vector3
  3259. * @param otherVector defines the second operand
  3260. * @returns the current updated Vector3
  3261. */
  3262. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3263. /**
  3264. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3265. * @param otherVector defines the second operand
  3266. * @returns the resulting Vector3
  3267. */
  3268. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3269. /**
  3270. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3271. * @param otherVector defines the second operand
  3272. * @param result defines the Vector3 object where to store the result
  3273. * @returns the current Vector3
  3274. */
  3275. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3276. /**
  3277. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3278. * @param x defines the x coordinate of the operand
  3279. * @param y defines the y coordinate of the operand
  3280. * @param z defines the z coordinate of the operand
  3281. * @returns the resulting Vector3
  3282. */
  3283. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3284. /**
  3285. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3286. * @param x defines the x coordinate of the operand
  3287. * @param y defines the y coordinate of the operand
  3288. * @param z defines the z coordinate of the operand
  3289. * @param result defines the Vector3 object where to store the result
  3290. * @returns the current Vector3
  3291. */
  3292. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3293. /**
  3294. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3295. * @returns a new Vector3
  3296. */
  3297. negate(): Vector3;
  3298. /**
  3299. * Negate this vector in place
  3300. * @returns this
  3301. */
  3302. negateInPlace(): Vector3;
  3303. /**
  3304. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3305. * @param result defines the Vector3 object where to store the result
  3306. * @returns the current Vector3
  3307. */
  3308. negateToRef(result: Vector3): Vector3;
  3309. /**
  3310. * Multiplies the Vector3 coordinates by the float "scale"
  3311. * @param scale defines the multiplier factor
  3312. * @returns the current updated Vector3
  3313. */
  3314. scaleInPlace(scale: number): Vector3;
  3315. /**
  3316. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3317. * @param scale defines the multiplier factor
  3318. * @returns a new Vector3
  3319. */
  3320. scale(scale: number): Vector3;
  3321. /**
  3322. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3323. * @param scale defines the multiplier factor
  3324. * @param result defines the Vector3 object where to store the result
  3325. * @returns the current Vector3
  3326. */
  3327. scaleToRef(scale: number, result: Vector3): Vector3;
  3328. /**
  3329. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3330. * @param scale defines the scale factor
  3331. * @param result defines the Vector3 object where to store the result
  3332. * @returns the unmodified current Vector3
  3333. */
  3334. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3335. /**
  3336. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3337. * @param origin defines the origin of the projection ray
  3338. * @param plane defines the plane to project to
  3339. * @returns the projected vector3
  3340. */
  3341. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3342. /**
  3343. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3344. * @param origin defines the origin of the projection ray
  3345. * @param plane defines the plane to project to
  3346. * @param result defines the Vector3 where to store the result
  3347. */
  3348. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3349. /**
  3350. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3351. * @param otherVector defines the second operand
  3352. * @returns true if both vectors are equals
  3353. */
  3354. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3355. /**
  3356. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3357. * @param otherVector defines the second operand
  3358. * @param epsilon defines the minimal distance to define values as equals
  3359. * @returns true if both vectors are distant less than epsilon
  3360. */
  3361. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3362. /**
  3363. * Returns true if the current Vector3 coordinates equals the given floats
  3364. * @param x defines the x coordinate of the operand
  3365. * @param y defines the y coordinate of the operand
  3366. * @param z defines the z coordinate of the operand
  3367. * @returns true if both vectors are equals
  3368. */
  3369. equalsToFloats(x: number, y: number, z: number): boolean;
  3370. /**
  3371. * Multiplies the current Vector3 coordinates by the given ones
  3372. * @param otherVector defines the second operand
  3373. * @returns the current updated Vector3
  3374. */
  3375. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3376. /**
  3377. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3378. * @param otherVector defines the second operand
  3379. * @returns the new Vector3
  3380. */
  3381. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3382. /**
  3383. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3384. * @param otherVector defines the second operand
  3385. * @param result defines the Vector3 object where to store the result
  3386. * @returns the current Vector3
  3387. */
  3388. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3389. /**
  3390. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3391. * @param x defines the x coordinate of the operand
  3392. * @param y defines the y coordinate of the operand
  3393. * @param z defines the z coordinate of the operand
  3394. * @returns the new Vector3
  3395. */
  3396. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3397. /**
  3398. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3399. * @param otherVector defines the second operand
  3400. * @returns the new Vector3
  3401. */
  3402. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3403. /**
  3404. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3405. * @param otherVector defines the second operand
  3406. * @param result defines the Vector3 object where to store the result
  3407. * @returns the current Vector3
  3408. */
  3409. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3410. /**
  3411. * Divides the current Vector3 coordinates by the given ones.
  3412. * @param otherVector defines the second operand
  3413. * @returns the current updated Vector3
  3414. */
  3415. divideInPlace(otherVector: Vector3): Vector3;
  3416. /**
  3417. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3418. * @param other defines the second operand
  3419. * @returns the current updated Vector3
  3420. */
  3421. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3422. /**
  3423. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3424. * @param other defines the second operand
  3425. * @returns the current updated Vector3
  3426. */
  3427. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3428. /**
  3429. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3430. * @param x defines the x coordinate of the operand
  3431. * @param y defines the y coordinate of the operand
  3432. * @param z defines the z coordinate of the operand
  3433. * @returns the current updated Vector3
  3434. */
  3435. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3436. /**
  3437. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3438. * @param x defines the x coordinate of the operand
  3439. * @param y defines the y coordinate of the operand
  3440. * @param z defines the z coordinate of the operand
  3441. * @returns the current updated Vector3
  3442. */
  3443. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3444. /**
  3445. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3446. * Check if is non uniform within a certain amount of decimal places to account for this
  3447. * @param epsilon the amount the values can differ
  3448. * @returns if the the vector is non uniform to a certain number of decimal places
  3449. */
  3450. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3451. /**
  3452. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3453. */
  3454. get isNonUniform(): boolean;
  3455. /**
  3456. * Gets a new Vector3 from current Vector3 floored values
  3457. * @returns a new Vector3
  3458. */
  3459. floor(): Vector3;
  3460. /**
  3461. * Gets a new Vector3 from current Vector3 floored values
  3462. * @returns a new Vector3
  3463. */
  3464. fract(): Vector3;
  3465. /**
  3466. * Gets the length of the Vector3
  3467. * @returns the length of the Vector3
  3468. */
  3469. length(): number;
  3470. /**
  3471. * Gets the squared length of the Vector3
  3472. * @returns squared length of the Vector3
  3473. */
  3474. lengthSquared(): number;
  3475. /**
  3476. * Normalize the current Vector3.
  3477. * Please note that this is an in place operation.
  3478. * @returns the current updated Vector3
  3479. */
  3480. normalize(): Vector3;
  3481. /**
  3482. * Reorders the x y z properties of the vector in place
  3483. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3484. * @returns the current updated vector
  3485. */
  3486. reorderInPlace(order: string): this;
  3487. /**
  3488. * Rotates the vector around 0,0,0 by a quaternion
  3489. * @param quaternion the rotation quaternion
  3490. * @param result vector to store the result
  3491. * @returns the resulting vector
  3492. */
  3493. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3494. /**
  3495. * Rotates a vector around a given point
  3496. * @param quaternion the rotation quaternion
  3497. * @param point the point to rotate around
  3498. * @param result vector to store the result
  3499. * @returns the resulting vector
  3500. */
  3501. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3502. /**
  3503. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3504. * The cross product is then orthogonal to both current and "other"
  3505. * @param other defines the right operand
  3506. * @returns the cross product
  3507. */
  3508. cross(other: Vector3): Vector3;
  3509. /**
  3510. * Normalize the current Vector3 with the given input length.
  3511. * Please note that this is an in place operation.
  3512. * @param len the length of the vector
  3513. * @returns the current updated Vector3
  3514. */
  3515. normalizeFromLength(len: number): Vector3;
  3516. /**
  3517. * Normalize the current Vector3 to a new vector
  3518. * @returns the new Vector3
  3519. */
  3520. normalizeToNew(): Vector3;
  3521. /**
  3522. * Normalize the current Vector3 to the reference
  3523. * @param reference define the Vector3 to update
  3524. * @returns the updated Vector3
  3525. */
  3526. normalizeToRef(reference: Vector3): Vector3;
  3527. /**
  3528. * Creates a new Vector3 copied from the current Vector3
  3529. * @returns the new Vector3
  3530. */
  3531. clone(): Vector3;
  3532. /**
  3533. * Copies the given vector coordinates to the current Vector3 ones
  3534. * @param source defines the source Vector3
  3535. * @returns the current updated Vector3
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3538. /**
  3539. * Copies the given floats to the current Vector3 coordinates
  3540. * @param x defines the x coordinate of the operand
  3541. * @param y defines the y coordinate of the operand
  3542. * @param z defines the z coordinate of the operand
  3543. * @returns the current updated Vector3
  3544. */
  3545. copyFromFloats(x: number, y: number, z: number): Vector3;
  3546. /**
  3547. * Copies the given floats to the current Vector3 coordinates
  3548. * @param x defines the x coordinate of the operand
  3549. * @param y defines the y coordinate of the operand
  3550. * @param z defines the z coordinate of the operand
  3551. * @returns the current updated Vector3
  3552. */
  3553. set(x: number, y: number, z: number): Vector3;
  3554. /**
  3555. * Copies the given float to the current Vector3 coordinates
  3556. * @param v defines the x, y and z coordinates of the operand
  3557. * @returns the current updated Vector3
  3558. */
  3559. setAll(v: number): Vector3;
  3560. /**
  3561. * Get the clip factor between two vectors
  3562. * @param vector0 defines the first operand
  3563. * @param vector1 defines the second operand
  3564. * @param axis defines the axis to use
  3565. * @param size defines the size along the axis
  3566. * @returns the clip factor
  3567. */
  3568. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3569. /**
  3570. * Get angle between two vectors
  3571. * @param vector0 angle between vector0 and vector1
  3572. * @param vector1 angle between vector0 and vector1
  3573. * @param normal direction of the normal
  3574. * @return the angle between vector0 and vector1
  3575. */
  3576. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3577. /**
  3578. * Returns a new Vector3 set from the index "offset" of the given array
  3579. * @param array defines the source array
  3580. * @param offset defines the offset in the source array
  3581. * @returns the new Vector3
  3582. */
  3583. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3584. /**
  3585. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3586. * @param array defines the source array
  3587. * @param offset defines the offset in the source array
  3588. * @returns the new Vector3
  3589. * @deprecated Please use FromArray instead.
  3590. */
  3591. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3592. /**
  3593. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3594. * @param array defines the source array
  3595. * @param offset defines the offset in the source array
  3596. * @param result defines the Vector3 where to store the result
  3597. */
  3598. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3599. /**
  3600. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3601. * @param array defines the source array
  3602. * @param offset defines the offset in the source array
  3603. * @param result defines the Vector3 where to store the result
  3604. * @deprecated Please use FromArrayToRef instead.
  3605. */
  3606. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3607. /**
  3608. * Sets the given vector "result" with the given floats.
  3609. * @param x defines the x coordinate of the source
  3610. * @param y defines the y coordinate of the source
  3611. * @param z defines the z coordinate of the source
  3612. * @param result defines the Vector3 where to store the result
  3613. */
  3614. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3615. /**
  3616. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3617. * @returns a new empty Vector3
  3618. */
  3619. static Zero(): Vector3;
  3620. /**
  3621. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3622. * @returns a new unit Vector3
  3623. */
  3624. static One(): Vector3;
  3625. /**
  3626. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3627. * @returns a new up Vector3
  3628. */
  3629. static Up(): Vector3;
  3630. /**
  3631. * Gets a up Vector3 that must not be updated
  3632. */
  3633. static get UpReadOnly(): DeepImmutable<Vector3>;
  3634. /**
  3635. * Gets a zero Vector3 that must not be updated
  3636. */
  3637. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3638. /**
  3639. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3640. * @returns a new down Vector3
  3641. */
  3642. static Down(): Vector3;
  3643. /**
  3644. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3645. * @param rightHandedSystem is the scene right-handed (negative z)
  3646. * @returns a new forward Vector3
  3647. */
  3648. static Forward(rightHandedSystem?: boolean): Vector3;
  3649. /**
  3650. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3651. * @param rightHandedSystem is the scene right-handed (negative-z)
  3652. * @returns a new forward Vector3
  3653. */
  3654. static Backward(rightHandedSystem?: boolean): Vector3;
  3655. /**
  3656. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3657. * @returns a new right Vector3
  3658. */
  3659. static Right(): Vector3;
  3660. /**
  3661. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3662. * @returns a new left Vector3
  3663. */
  3664. static Left(): Vector3;
  3665. /**
  3666. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3667. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3668. * @param vector defines the Vector3 to transform
  3669. * @param transformation defines the transformation matrix
  3670. * @returns the transformed Vector3
  3671. */
  3672. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3673. /**
  3674. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3675. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3676. * @param vector defines the Vector3 to transform
  3677. * @param transformation defines the transformation matrix
  3678. * @param result defines the Vector3 where to store the result
  3679. */
  3680. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3681. /**
  3682. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3683. * This method computes tranformed coordinates only, not transformed direction vectors
  3684. * @param x define the x coordinate of the source vector
  3685. * @param y define the y coordinate of the source vector
  3686. * @param z define the z coordinate of the source vector
  3687. * @param transformation defines the transformation matrix
  3688. * @param result defines the Vector3 where to store the result
  3689. */
  3690. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3691. /**
  3692. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3693. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3694. * @param vector defines the Vector3 to transform
  3695. * @param transformation defines the transformation matrix
  3696. * @returns the new Vector3
  3697. */
  3698. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3699. /**
  3700. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3701. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3702. * @param vector defines the Vector3 to transform
  3703. * @param transformation defines the transformation matrix
  3704. * @param result defines the Vector3 where to store the result
  3705. */
  3706. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3707. /**
  3708. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3709. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3710. * @param x define the x coordinate of the source vector
  3711. * @param y define the y coordinate of the source vector
  3712. * @param z define the z coordinate of the source vector
  3713. * @param transformation defines the transformation matrix
  3714. * @param result defines the Vector3 where to store the result
  3715. */
  3716. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3717. /**
  3718. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3719. * @param value1 defines the first control point
  3720. * @param value2 defines the second control point
  3721. * @param value3 defines the third control point
  3722. * @param value4 defines the fourth control point
  3723. * @param amount defines the amount on the spline to use
  3724. * @returns the new Vector3
  3725. */
  3726. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3727. /**
  3728. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3729. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3730. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3731. * @param value defines the current value
  3732. * @param min defines the lower range value
  3733. * @param max defines the upper range value
  3734. * @returns the new Vector3
  3735. */
  3736. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3737. /**
  3738. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3739. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3740. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3741. * @param value defines the current value
  3742. * @param min defines the lower range value
  3743. * @param max defines the upper range value
  3744. * @param result defines the Vector3 where to store the result
  3745. */
  3746. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3747. /**
  3748. * Checks if a given vector is inside a specific range
  3749. * @param v defines the vector to test
  3750. * @param min defines the minimum range
  3751. * @param max defines the maximum range
  3752. */
  3753. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3754. /**
  3755. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3756. * @param value1 defines the first control point
  3757. * @param tangent1 defines the first tangent vector
  3758. * @param value2 defines the second control point
  3759. * @param tangent2 defines the second tangent vector
  3760. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3761. * @returns the new Vector3
  3762. */
  3763. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3764. /**
  3765. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3766. * @param start defines the start value
  3767. * @param end defines the end value
  3768. * @param amount max defines amount between both (between 0 and 1)
  3769. * @returns the new Vector3
  3770. */
  3771. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3772. /**
  3773. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3774. * @param start defines the start value
  3775. * @param end defines the end value
  3776. * @param amount max defines amount between both (between 0 and 1)
  3777. * @param result defines the Vector3 where to store the result
  3778. */
  3779. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3780. /**
  3781. * Returns the dot product (float) between the vectors "left" and "right"
  3782. * @param left defines the left operand
  3783. * @param right defines the right operand
  3784. * @returns the dot product
  3785. */
  3786. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3787. /**
  3788. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3789. * The cross product is then orthogonal to both "left" and "right"
  3790. * @param left defines the left operand
  3791. * @param right defines the right operand
  3792. * @returns the cross product
  3793. */
  3794. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3795. /**
  3796. * Sets the given vector "result" with the cross product of "left" and "right"
  3797. * The cross product is then orthogonal to both "left" and "right"
  3798. * @param left defines the left operand
  3799. * @param right defines the right operand
  3800. * @param result defines the Vector3 where to store the result
  3801. */
  3802. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3803. /**
  3804. * Returns a new Vector3 as the normalization of the given vector
  3805. * @param vector defines the Vector3 to normalize
  3806. * @returns the new Vector3
  3807. */
  3808. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3809. /**
  3810. * Sets the given vector "result" with the normalization of the given first vector
  3811. * @param vector defines the Vector3 to normalize
  3812. * @param result defines the Vector3 where to store the result
  3813. */
  3814. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3815. /**
  3816. * Project a Vector3 onto screen space
  3817. * @param vector defines the Vector3 to project
  3818. * @param world defines the world matrix to use
  3819. * @param transform defines the transform (view x projection) matrix to use
  3820. * @param viewport defines the screen viewport to use
  3821. * @returns the new Vector3
  3822. */
  3823. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3824. /**
  3825. * Project a Vector3 onto screen space to reference
  3826. * @param vector defines the Vector3 to project
  3827. * @param world defines the world matrix to use
  3828. * @param transform defines the transform (view x projection) matrix to use
  3829. * @param viewport defines the screen viewport to use
  3830. * @param result the vector in which the screen space will be stored
  3831. * @returns the new Vector3
  3832. */
  3833. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3834. /** @hidden */
  3835. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3836. /**
  3837. * Unproject from screen space to object space
  3838. * @param source defines the screen space Vector3 to use
  3839. * @param viewportWidth defines the current width of the viewport
  3840. * @param viewportHeight defines the current height of the viewport
  3841. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3842. * @param transform defines the transform (view x projection) matrix to use
  3843. * @returns the new Vector3
  3844. */
  3845. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3846. /**
  3847. * Unproject from screen space to object space
  3848. * @param source defines the screen space Vector3 to use
  3849. * @param viewportWidth defines the current width of the viewport
  3850. * @param viewportHeight defines the current height of the viewport
  3851. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3852. * @param view defines the view matrix to use
  3853. * @param projection defines the projection matrix to use
  3854. * @returns the new Vector3
  3855. */
  3856. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3857. /**
  3858. * Unproject from screen space to object space
  3859. * @param source defines the screen space Vector3 to use
  3860. * @param viewportWidth defines the current width of the viewport
  3861. * @param viewportHeight defines the current height of the viewport
  3862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3863. * @param view defines the view matrix to use
  3864. * @param projection defines the projection matrix to use
  3865. * @param result defines the Vector3 where to store the result
  3866. */
  3867. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3868. /**
  3869. * Unproject from screen space to object space
  3870. * @param sourceX defines the screen space x coordinate to use
  3871. * @param sourceY defines the screen space y coordinate to use
  3872. * @param sourceZ defines the screen space z coordinate to use
  3873. * @param viewportWidth defines the current width of the viewport
  3874. * @param viewportHeight defines the current height of the viewport
  3875. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3876. * @param view defines the view matrix to use
  3877. * @param projection defines the projection matrix to use
  3878. * @param result defines the Vector3 where to store the result
  3879. */
  3880. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3881. /**
  3882. * Gets the minimal coordinate values between two Vector3
  3883. * @param left defines the first operand
  3884. * @param right defines the second operand
  3885. * @returns the new Vector3
  3886. */
  3887. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3888. /**
  3889. * Gets the maximal coordinate values between two Vector3
  3890. * @param left defines the first operand
  3891. * @param right defines the second operand
  3892. * @returns the new Vector3
  3893. */
  3894. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3895. /**
  3896. * Returns the distance between the vectors "value1" and "value2"
  3897. * @param value1 defines the first operand
  3898. * @param value2 defines the second operand
  3899. * @returns the distance
  3900. */
  3901. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3902. /**
  3903. * Returns the squared distance between the vectors "value1" and "value2"
  3904. * @param value1 defines the first operand
  3905. * @param value2 defines the second operand
  3906. * @returns the squared distance
  3907. */
  3908. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3909. /**
  3910. * Returns a new Vector3 located at the center between "value1" and "value2"
  3911. * @param value1 defines the first operand
  3912. * @param value2 defines the second operand
  3913. * @returns the new Vector3
  3914. */
  3915. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3916. /**
  3917. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3918. * @param value1 defines first vector
  3919. * @param value2 defines second vector
  3920. * @param ref defines third vector
  3921. * @returns ref
  3922. */
  3923. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3924. /**
  3925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3927. * to something in order to rotate it from its local system to the given target system
  3928. * Note: axis1, axis2 and axis3 are normalized during this operation
  3929. * @param axis1 defines the first axis
  3930. * @param axis2 defines the second axis
  3931. * @param axis3 defines the third axis
  3932. * @returns a new Vector3
  3933. */
  3934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3935. /**
  3936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3937. * @param axis1 defines the first axis
  3938. * @param axis2 defines the second axis
  3939. * @param axis3 defines the third axis
  3940. * @param ref defines the Vector3 where to store the result
  3941. */
  3942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3943. }
  3944. /**
  3945. * Vector4 class created for EulerAngle class conversion to Quaternion
  3946. */
  3947. export class Vector4 {
  3948. /** x value of the vector */
  3949. x: number;
  3950. /** y value of the vector */
  3951. y: number;
  3952. /** z value of the vector */
  3953. z: number;
  3954. /** w value of the vector */
  3955. w: number;
  3956. /**
  3957. * Creates a Vector4 object from the given floats.
  3958. * @param x x value of the vector
  3959. * @param y y value of the vector
  3960. * @param z z value of the vector
  3961. * @param w w value of the vector
  3962. */
  3963. constructor(
  3964. /** x value of the vector */
  3965. x: number,
  3966. /** y value of the vector */
  3967. y: number,
  3968. /** z value of the vector */
  3969. z: number,
  3970. /** w value of the vector */
  3971. w: number);
  3972. /**
  3973. * Returns the string with the Vector4 coordinates.
  3974. * @returns a string containing all the vector values
  3975. */
  3976. toString(): string;
  3977. /**
  3978. * Returns the string "Vector4".
  3979. * @returns "Vector4"
  3980. */
  3981. getClassName(): string;
  3982. /**
  3983. * Returns the Vector4 hash code.
  3984. * @returns a unique hash code
  3985. */
  3986. getHashCode(): number;
  3987. /**
  3988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3989. * @returns the resulting array
  3990. */
  3991. asArray(): number[];
  3992. /**
  3993. * Populates the given array from the given index with the Vector4 coordinates.
  3994. * @param array array to populate
  3995. * @param index index of the array to start at (default: 0)
  3996. * @returns the Vector4.
  3997. */
  3998. toArray(array: FloatArray, index?: number): Vector4;
  3999. /**
  4000. * Update the current vector from an array
  4001. * @param array defines the destination array
  4002. * @param index defines the offset in the destination array
  4003. * @returns the current Vector3
  4004. */
  4005. fromArray(array: FloatArray, index?: number): Vector4;
  4006. /**
  4007. * Adds the given vector to the current Vector4.
  4008. * @param otherVector the vector to add
  4009. * @returns the updated Vector4.
  4010. */
  4011. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4012. /**
  4013. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  4014. * @param otherVector the vector to add
  4015. * @returns the resulting vector
  4016. */
  4017. add(otherVector: DeepImmutable<Vector4>): Vector4;
  4018. /**
  4019. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  4020. * @param otherVector the vector to add
  4021. * @param result the vector to store the result
  4022. * @returns the current Vector4.
  4023. */
  4024. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4025. /**
  4026. * Subtract in place the given vector from the current Vector4.
  4027. * @param otherVector the vector to subtract
  4028. * @returns the updated Vector4.
  4029. */
  4030. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4031. /**
  4032. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  4033. * @param otherVector the vector to add
  4034. * @returns the new vector with the result
  4035. */
  4036. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  4037. /**
  4038. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  4039. * @param otherVector the vector to subtract
  4040. * @param result the vector to store the result
  4041. * @returns the current Vector4.
  4042. */
  4043. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4044. /**
  4045. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4046. */
  4047. /**
  4048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4049. * @param x value to subtract
  4050. * @param y value to subtract
  4051. * @param z value to subtract
  4052. * @param w value to subtract
  4053. * @returns new vector containing the result
  4054. */
  4055. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4056. /**
  4057. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4058. * @param x value to subtract
  4059. * @param y value to subtract
  4060. * @param z value to subtract
  4061. * @param w value to subtract
  4062. * @param result the vector to store the result in
  4063. * @returns the current Vector4.
  4064. */
  4065. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4066. /**
  4067. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4068. * @returns a new vector with the negated values
  4069. */
  4070. negate(): Vector4;
  4071. /**
  4072. * Negate this vector in place
  4073. * @returns this
  4074. */
  4075. negateInPlace(): Vector4;
  4076. /**
  4077. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4078. * @param result defines the Vector3 object where to store the result
  4079. * @returns the current Vector4
  4080. */
  4081. negateToRef(result: Vector4): Vector4;
  4082. /**
  4083. * Multiplies the current Vector4 coordinates by scale (float).
  4084. * @param scale the number to scale with
  4085. * @returns the updated Vector4.
  4086. */
  4087. scaleInPlace(scale: number): Vector4;
  4088. /**
  4089. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4090. * @param scale the number to scale with
  4091. * @returns a new vector with the result
  4092. */
  4093. scale(scale: number): Vector4;
  4094. /**
  4095. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4096. * @param scale the number to scale with
  4097. * @param result a vector to store the result in
  4098. * @returns the current Vector4.
  4099. */
  4100. scaleToRef(scale: number, result: Vector4): Vector4;
  4101. /**
  4102. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4103. * @param scale defines the scale factor
  4104. * @param result defines the Vector4 object where to store the result
  4105. * @returns the unmodified current Vector4
  4106. */
  4107. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4108. /**
  4109. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4110. * @param otherVector the vector to compare against
  4111. * @returns true if they are equal
  4112. */
  4113. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4114. /**
  4115. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4116. * @param otherVector vector to compare against
  4117. * @param epsilon (Default: very small number)
  4118. * @returns true if they are equal
  4119. */
  4120. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4121. /**
  4122. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4123. * @param x x value to compare against
  4124. * @param y y value to compare against
  4125. * @param z z value to compare against
  4126. * @param w w value to compare against
  4127. * @returns true if equal
  4128. */
  4129. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4130. /**
  4131. * Multiplies in place the current Vector4 by the given one.
  4132. * @param otherVector vector to multiple with
  4133. * @returns the updated Vector4.
  4134. */
  4135. multiplyInPlace(otherVector: Vector4): Vector4;
  4136. /**
  4137. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4138. * @param otherVector vector to multiple with
  4139. * @returns resulting new vector
  4140. */
  4141. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4142. /**
  4143. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4144. * @param otherVector vector to multiple with
  4145. * @param result vector to store the result
  4146. * @returns the current Vector4.
  4147. */
  4148. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4149. /**
  4150. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4151. * @param x x value multiply with
  4152. * @param y y value multiply with
  4153. * @param z z value multiply with
  4154. * @param w w value multiply with
  4155. * @returns resulting new vector
  4156. */
  4157. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4158. /**
  4159. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4160. * @param otherVector vector to devide with
  4161. * @returns resulting new vector
  4162. */
  4163. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4164. /**
  4165. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4166. * @param otherVector vector to devide with
  4167. * @param result vector to store the result
  4168. * @returns the current Vector4.
  4169. */
  4170. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4171. /**
  4172. * Divides the current Vector3 coordinates by the given ones.
  4173. * @param otherVector vector to devide with
  4174. * @returns the updated Vector3.
  4175. */
  4176. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4177. /**
  4178. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4179. * @param other defines the second operand
  4180. * @returns the current updated Vector4
  4181. */
  4182. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4183. /**
  4184. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4185. * @param other defines the second operand
  4186. * @returns the current updated Vector4
  4187. */
  4188. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4189. /**
  4190. * Gets a new Vector4 from current Vector4 floored values
  4191. * @returns a new Vector4
  4192. */
  4193. floor(): Vector4;
  4194. /**
  4195. * Gets a new Vector4 from current Vector3 floored values
  4196. * @returns a new Vector4
  4197. */
  4198. fract(): Vector4;
  4199. /**
  4200. * Returns the Vector4 length (float).
  4201. * @returns the length
  4202. */
  4203. length(): number;
  4204. /**
  4205. * Returns the Vector4 squared length (float).
  4206. * @returns the length squared
  4207. */
  4208. lengthSquared(): number;
  4209. /**
  4210. * Normalizes in place the Vector4.
  4211. * @returns the updated Vector4.
  4212. */
  4213. normalize(): Vector4;
  4214. /**
  4215. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4216. * @returns this converted to a new vector3
  4217. */
  4218. toVector3(): Vector3;
  4219. /**
  4220. * Returns a new Vector4 copied from the current one.
  4221. * @returns the new cloned vector
  4222. */
  4223. clone(): Vector4;
  4224. /**
  4225. * Updates the current Vector4 with the given one coordinates.
  4226. * @param source the source vector to copy from
  4227. * @returns the updated Vector4.
  4228. */
  4229. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4230. /**
  4231. * Updates the current Vector4 coordinates with the given floats.
  4232. * @param x float to copy from
  4233. * @param y float to copy from
  4234. * @param z float to copy from
  4235. * @param w float to copy from
  4236. * @returns the updated Vector4.
  4237. */
  4238. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4239. /**
  4240. * Updates the current Vector4 coordinates with the given floats.
  4241. * @param x float to set from
  4242. * @param y float to set from
  4243. * @param z float to set from
  4244. * @param w float to set from
  4245. * @returns the updated Vector4.
  4246. */
  4247. set(x: number, y: number, z: number, w: number): Vector4;
  4248. /**
  4249. * Copies the given float to the current Vector3 coordinates
  4250. * @param v defines the x, y, z and w coordinates of the operand
  4251. * @returns the current updated Vector3
  4252. */
  4253. setAll(v: number): Vector4;
  4254. /**
  4255. * Returns a new Vector4 set from the starting index of the given array.
  4256. * @param array the array to pull values from
  4257. * @param offset the offset into the array to start at
  4258. * @returns the new vector
  4259. */
  4260. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4261. /**
  4262. * Updates the given vector "result" from the starting index of the given array.
  4263. * @param array the array to pull values from
  4264. * @param offset the offset into the array to start at
  4265. * @param result the vector to store the result in
  4266. */
  4267. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4268. /**
  4269. * Updates the given vector "result" from the starting index of the given Float32Array.
  4270. * @param array the array to pull values from
  4271. * @param offset the offset into the array to start at
  4272. * @param result the vector to store the result in
  4273. */
  4274. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4275. /**
  4276. * Updates the given vector "result" coordinates from the given floats.
  4277. * @param x float to set from
  4278. * @param y float to set from
  4279. * @param z float to set from
  4280. * @param w float to set from
  4281. * @param result the vector to the floats in
  4282. */
  4283. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4284. /**
  4285. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4286. * @returns the new vector
  4287. */
  4288. static Zero(): Vector4;
  4289. /**
  4290. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4291. * @returns the new vector
  4292. */
  4293. static One(): Vector4;
  4294. /**
  4295. * Returns a new normalized Vector4 from the given one.
  4296. * @param vector the vector to normalize
  4297. * @returns the vector
  4298. */
  4299. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4300. /**
  4301. * Updates the given vector "result" from the normalization of the given one.
  4302. * @param vector the vector to normalize
  4303. * @param result the vector to store the result in
  4304. */
  4305. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4306. /**
  4307. * Returns a vector with the minimum values from the left and right vectors
  4308. * @param left left vector to minimize
  4309. * @param right right vector to minimize
  4310. * @returns a new vector with the minimum of the left and right vector values
  4311. */
  4312. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4313. /**
  4314. * Returns a vector with the maximum values from the left and right vectors
  4315. * @param left left vector to maximize
  4316. * @param right right vector to maximize
  4317. * @returns a new vector with the maximum of the left and right vector values
  4318. */
  4319. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4320. /**
  4321. * Returns the distance (float) between the vectors "value1" and "value2".
  4322. * @param value1 value to calulate the distance between
  4323. * @param value2 value to calulate the distance between
  4324. * @return the distance between the two vectors
  4325. */
  4326. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4327. /**
  4328. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4329. * @param value1 value to calulate the distance between
  4330. * @param value2 value to calulate the distance between
  4331. * @return the distance between the two vectors squared
  4332. */
  4333. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4334. /**
  4335. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4336. * @param value1 value to calulate the center between
  4337. * @param value2 value to calulate the center between
  4338. * @return the center between the two vectors
  4339. */
  4340. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4341. /**
  4342. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4343. * @param value1 defines first vector
  4344. * @param value2 defines second vector
  4345. * @param ref defines third vector
  4346. * @returns ref
  4347. */
  4348. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4349. /**
  4350. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4351. * This methods computes transformed normalized direction vectors only.
  4352. * @param vector the vector to transform
  4353. * @param transformation the transformation matrix to apply
  4354. * @returns the new vector
  4355. */
  4356. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4357. /**
  4358. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4359. * This methods computes transformed normalized direction vectors only.
  4360. * @param vector the vector to transform
  4361. * @param transformation the transformation matrix to apply
  4362. * @param result the vector to store the result in
  4363. */
  4364. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4365. /**
  4366. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4367. * This methods computes transformed normalized direction vectors only.
  4368. * @param x value to transform
  4369. * @param y value to transform
  4370. * @param z value to transform
  4371. * @param w value to transform
  4372. * @param transformation the transformation matrix to apply
  4373. * @param result the vector to store the results in
  4374. */
  4375. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4376. /**
  4377. * Creates a new Vector4 from a Vector3
  4378. * @param source defines the source data
  4379. * @param w defines the 4th component (default is 0)
  4380. * @returns a new Vector4
  4381. */
  4382. static FromVector3(source: Vector3, w?: number): Vector4;
  4383. }
  4384. /**
  4385. * Class used to store quaternion data
  4386. * @see https://en.wikipedia.org/wiki/Quaternion
  4387. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4388. */
  4389. export class Quaternion {
  4390. /** @hidden */
  4391. _x: number;
  4392. /** @hidden */
  4393. _y: number;
  4394. /** @hidden */
  4395. _z: number;
  4396. /** @hidden */
  4397. _w: number;
  4398. /** @hidden */
  4399. _isDirty: boolean;
  4400. /** Gets or sets the x coordinate */
  4401. get x(): number;
  4402. set x(value: number);
  4403. /** Gets or sets the y coordinate */
  4404. get y(): number;
  4405. set y(value: number);
  4406. /** Gets or sets the z coordinate */
  4407. get z(): number;
  4408. set z(value: number);
  4409. /** Gets or sets the w coordinate */
  4410. get w(): number;
  4411. set w(value: number);
  4412. /**
  4413. * Creates a new Quaternion from the given floats
  4414. * @param x defines the first component (0 by default)
  4415. * @param y defines the second component (0 by default)
  4416. * @param z defines the third component (0 by default)
  4417. * @param w defines the fourth component (1.0 by default)
  4418. */
  4419. constructor(x?: number, y?: number, z?: number, w?: number);
  4420. /**
  4421. * Gets a string representation for the current quaternion
  4422. * @returns a string with the Quaternion coordinates
  4423. */
  4424. toString(): string;
  4425. /**
  4426. * Gets the class name of the quaternion
  4427. * @returns the string "Quaternion"
  4428. */
  4429. getClassName(): string;
  4430. /**
  4431. * Gets a hash code for this quaternion
  4432. * @returns the quaternion hash code
  4433. */
  4434. getHashCode(): number;
  4435. /**
  4436. * Copy the quaternion to an array
  4437. * @returns a new array populated with 4 elements from the quaternion coordinates
  4438. */
  4439. asArray(): number[];
  4440. /**
  4441. * Check if two quaternions are equals
  4442. * @param otherQuaternion defines the second operand
  4443. * @return true if the current quaternion and the given one coordinates are strictly equals
  4444. */
  4445. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4446. /**
  4447. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4448. * @param otherQuaternion defines the other quaternion
  4449. * @param epsilon defines the minimal distance to consider equality
  4450. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4451. */
  4452. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4453. /**
  4454. * Clone the current quaternion
  4455. * @returns a new quaternion copied from the current one
  4456. */
  4457. clone(): Quaternion;
  4458. /**
  4459. * Copy a quaternion to the current one
  4460. * @param other defines the other quaternion
  4461. * @returns the updated current quaternion
  4462. */
  4463. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4464. /**
  4465. * Updates the current quaternion with the given float coordinates
  4466. * @param x defines the x coordinate
  4467. * @param y defines the y coordinate
  4468. * @param z defines the z coordinate
  4469. * @param w defines the w coordinate
  4470. * @returns the updated current quaternion
  4471. */
  4472. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4473. /**
  4474. * Updates the current quaternion from the given float coordinates
  4475. * @param x defines the x coordinate
  4476. * @param y defines the y coordinate
  4477. * @param z defines the z coordinate
  4478. * @param w defines the w coordinate
  4479. * @returns the updated current quaternion
  4480. */
  4481. set(x: number, y: number, z: number, w: number): Quaternion;
  4482. /**
  4483. * Adds two quaternions
  4484. * @param other defines the second operand
  4485. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4486. */
  4487. add(other: DeepImmutable<Quaternion>): Quaternion;
  4488. /**
  4489. * Add a quaternion to the current one
  4490. * @param other defines the quaternion to add
  4491. * @returns the current quaternion
  4492. */
  4493. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4494. /**
  4495. * Subtract two quaternions
  4496. * @param other defines the second operand
  4497. * @returns a new quaternion as the subtraction result of the given one from the current one
  4498. */
  4499. subtract(other: Quaternion): Quaternion;
  4500. /**
  4501. * Multiplies the current quaternion by a scale factor
  4502. * @param value defines the scale factor
  4503. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4504. */
  4505. scale(value: number): Quaternion;
  4506. /**
  4507. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4508. * @param scale defines the scale factor
  4509. * @param result defines the Quaternion object where to store the result
  4510. * @returns the unmodified current quaternion
  4511. */
  4512. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4513. /**
  4514. * Multiplies in place the current quaternion by a scale factor
  4515. * @param value defines the scale factor
  4516. * @returns the current modified quaternion
  4517. */
  4518. scaleInPlace(value: number): Quaternion;
  4519. /**
  4520. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4521. * @param scale defines the scale factor
  4522. * @param result defines the Quaternion object where to store the result
  4523. * @returns the unmodified current quaternion
  4524. */
  4525. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4526. /**
  4527. * Multiplies two quaternions
  4528. * @param q1 defines the second operand
  4529. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4530. */
  4531. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4532. /**
  4533. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4534. * @param q1 defines the second operand
  4535. * @param result defines the target quaternion
  4536. * @returns the current quaternion
  4537. */
  4538. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4539. /**
  4540. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4541. * @param q1 defines the second operand
  4542. * @returns the currentupdated quaternion
  4543. */
  4544. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4545. /**
  4546. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4547. * @param ref defines the target quaternion
  4548. * @returns the current quaternion
  4549. */
  4550. conjugateToRef(ref: Quaternion): Quaternion;
  4551. /**
  4552. * Conjugates in place (1-q) the current quaternion
  4553. * @returns the current updated quaternion
  4554. */
  4555. conjugateInPlace(): Quaternion;
  4556. /**
  4557. * Conjugates in place (1-q) the current quaternion
  4558. * @returns a new quaternion
  4559. */
  4560. conjugate(): Quaternion;
  4561. /**
  4562. * Gets length of current quaternion
  4563. * @returns the quaternion length (float)
  4564. */
  4565. length(): number;
  4566. /**
  4567. * Normalize in place the current quaternion
  4568. * @returns the current updated quaternion
  4569. */
  4570. normalize(): Quaternion;
  4571. /**
  4572. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4573. * @param order is a reserved parameter and is ignored for now
  4574. * @returns a new Vector3 containing the Euler angles
  4575. */
  4576. toEulerAngles(order?: string): Vector3;
  4577. /**
  4578. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4579. * @param result defines the vector which will be filled with the Euler angles
  4580. * @returns the current unchanged quaternion
  4581. */
  4582. toEulerAnglesToRef(result: Vector3): Quaternion;
  4583. /**
  4584. * Updates the given rotation matrix with the current quaternion values
  4585. * @param result defines the target matrix
  4586. * @returns the current unchanged quaternion
  4587. */
  4588. toRotationMatrix(result: Matrix): Quaternion;
  4589. /**
  4590. * Updates the current quaternion from the given rotation matrix values
  4591. * @param matrix defines the source matrix
  4592. * @returns the current updated quaternion
  4593. */
  4594. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4595. /**
  4596. * Creates a new quaternion from a rotation matrix
  4597. * @param matrix defines the source matrix
  4598. * @returns a new quaternion created from the given rotation matrix values
  4599. */
  4600. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4601. /**
  4602. * Updates the given quaternion with the given rotation matrix values
  4603. * @param matrix defines the source matrix
  4604. * @param result defines the target quaternion
  4605. */
  4606. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4607. /**
  4608. * Returns the dot product (float) between the quaternions "left" and "right"
  4609. * @param left defines the left operand
  4610. * @param right defines the right operand
  4611. * @returns the dot product
  4612. */
  4613. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4614. /**
  4615. * Checks if the two quaternions are close to each other
  4616. * @param quat0 defines the first quaternion to check
  4617. * @param quat1 defines the second quaternion to check
  4618. * @returns true if the two quaternions are close to each other
  4619. */
  4620. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4621. /**
  4622. * Creates an empty quaternion
  4623. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4624. */
  4625. static Zero(): Quaternion;
  4626. /**
  4627. * Inverse a given quaternion
  4628. * @param q defines the source quaternion
  4629. * @returns a new quaternion as the inverted current quaternion
  4630. */
  4631. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4632. /**
  4633. * Inverse a given quaternion
  4634. * @param q defines the source quaternion
  4635. * @param result the quaternion the result will be stored in
  4636. * @returns the result quaternion
  4637. */
  4638. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4639. /**
  4640. * Creates an identity quaternion
  4641. * @returns the identity quaternion
  4642. */
  4643. static Identity(): Quaternion;
  4644. /**
  4645. * Gets a boolean indicating if the given quaternion is identity
  4646. * @param quaternion defines the quaternion to check
  4647. * @returns true if the quaternion is identity
  4648. */
  4649. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4650. /**
  4651. * Creates a quaternion from a rotation around an axis
  4652. * @param axis defines the axis to use
  4653. * @param angle defines the angle to use
  4654. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4655. */
  4656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4657. /**
  4658. * Creates a rotation around an axis and stores it into the given quaternion
  4659. * @param axis defines the axis to use
  4660. * @param angle defines the angle to use
  4661. * @param result defines the target quaternion
  4662. * @returns the target quaternion
  4663. */
  4664. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4665. /**
  4666. * Creates a new quaternion from data stored into an array
  4667. * @param array defines the data source
  4668. * @param offset defines the offset in the source array where the data starts
  4669. * @returns a new quaternion
  4670. */
  4671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4672. /**
  4673. * Updates the given quaternion "result" from the starting index of the given array.
  4674. * @param array the array to pull values from
  4675. * @param offset the offset into the array to start at
  4676. * @param result the quaternion to store the result in
  4677. */
  4678. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4679. /**
  4680. * Create a quaternion from Euler rotation angles
  4681. * @param x Pitch
  4682. * @param y Yaw
  4683. * @param z Roll
  4684. * @returns the new Quaternion
  4685. */
  4686. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4687. /**
  4688. * Updates a quaternion from Euler rotation angles
  4689. * @param x Pitch
  4690. * @param y Yaw
  4691. * @param z Roll
  4692. * @param result the quaternion to store the result
  4693. * @returns the updated quaternion
  4694. */
  4695. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4696. /**
  4697. * Create a quaternion from Euler rotation vector
  4698. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4699. * @returns the new Quaternion
  4700. */
  4701. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4702. /**
  4703. * Updates a quaternion from Euler rotation vector
  4704. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4705. * @param result the quaternion to store the result
  4706. * @returns the updated quaternion
  4707. */
  4708. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4709. /**
  4710. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4711. * @param vecFrom defines the direction vector from which to rotate
  4712. * @param vecTo defines the direction vector to which to rotate
  4713. * @param result the quaternion to store the result
  4714. * @returns the updated quaternion
  4715. */
  4716. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4717. /**
  4718. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4719. * @param yaw defines the rotation around Y axis
  4720. * @param pitch defines the rotation around X axis
  4721. * @param roll defines the rotation around Z axis
  4722. * @returns the new quaternion
  4723. */
  4724. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4725. /**
  4726. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4727. * @param yaw defines the rotation around Y axis
  4728. * @param pitch defines the rotation around X axis
  4729. * @param roll defines the rotation around Z axis
  4730. * @param result defines the target quaternion
  4731. */
  4732. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4733. /**
  4734. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4735. * @param alpha defines the rotation around first axis
  4736. * @param beta defines the rotation around second axis
  4737. * @param gamma defines the rotation around third axis
  4738. * @returns the new quaternion
  4739. */
  4740. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4741. /**
  4742. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4743. * @param alpha defines the rotation around first axis
  4744. * @param beta defines the rotation around second axis
  4745. * @param gamma defines the rotation around third axis
  4746. * @param result defines the target quaternion
  4747. */
  4748. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4749. /**
  4750. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4751. * @param axis1 defines the first axis
  4752. * @param axis2 defines the second axis
  4753. * @param axis3 defines the third axis
  4754. * @returns the new quaternion
  4755. */
  4756. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4757. /**
  4758. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4759. * @param axis1 defines the first axis
  4760. * @param axis2 defines the second axis
  4761. * @param axis3 defines the third axis
  4762. * @param ref defines the target quaternion
  4763. */
  4764. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4765. /**
  4766. * Interpolates between two quaternions
  4767. * @param left defines first quaternion
  4768. * @param right defines second quaternion
  4769. * @param amount defines the gradient to use
  4770. * @returns the new interpolated quaternion
  4771. */
  4772. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4773. /**
  4774. * Interpolates between two quaternions and stores it into a target quaternion
  4775. * @param left defines first quaternion
  4776. * @param right defines second quaternion
  4777. * @param amount defines the gradient to use
  4778. * @param result defines the target quaternion
  4779. */
  4780. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4781. /**
  4782. * Interpolate between two quaternions using Hermite interpolation
  4783. * @param value1 defines first quaternion
  4784. * @param tangent1 defines the incoming tangent
  4785. * @param value2 defines second quaternion
  4786. * @param tangent2 defines the outgoing tangent
  4787. * @param amount defines the target quaternion
  4788. * @returns the new interpolated quaternion
  4789. */
  4790. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4791. }
  4792. /**
  4793. * Class used to store matrix data (4x4)
  4794. */
  4795. export class Matrix {
  4796. /**
  4797. * Gets the precision of matrix computations
  4798. */
  4799. static get Use64Bits(): boolean;
  4800. private static _updateFlagSeed;
  4801. private static _identityReadOnly;
  4802. private _isIdentity;
  4803. private _isIdentityDirty;
  4804. private _isIdentity3x2;
  4805. private _isIdentity3x2Dirty;
  4806. /**
  4807. * Gets the update flag of the matrix which is an unique number for the matrix.
  4808. * It will be incremented every time the matrix data change.
  4809. * You can use it to speed the comparison between two versions of the same matrix.
  4810. */
  4811. updateFlag: number;
  4812. private readonly _m;
  4813. /**
  4814. * Gets the internal data of the matrix
  4815. */
  4816. get m(): DeepImmutable<Float32Array | Array<number>>;
  4817. /** @hidden */
  4818. _markAsUpdated(): void;
  4819. /** @hidden */
  4820. private _updateIdentityStatus;
  4821. /**
  4822. * Creates an empty matrix (filled with zeros)
  4823. */
  4824. constructor();
  4825. /**
  4826. * Check if the current matrix is identity
  4827. * @returns true is the matrix is the identity matrix
  4828. */
  4829. isIdentity(): boolean;
  4830. /**
  4831. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4832. * @returns true is the matrix is the identity matrix
  4833. */
  4834. isIdentityAs3x2(): boolean;
  4835. /**
  4836. * Gets the determinant of the matrix
  4837. * @returns the matrix determinant
  4838. */
  4839. determinant(): number;
  4840. /**
  4841. * Returns the matrix as a Float32Array or Array<number>
  4842. * @returns the matrix underlying array
  4843. */
  4844. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4845. /**
  4846. * Returns the matrix as a Float32Array or Array<number>
  4847. * @returns the matrix underlying array.
  4848. */
  4849. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4850. /**
  4851. * Inverts the current matrix in place
  4852. * @returns the current inverted matrix
  4853. */
  4854. invert(): Matrix;
  4855. /**
  4856. * Sets all the matrix elements to zero
  4857. * @returns the current matrix
  4858. */
  4859. reset(): Matrix;
  4860. /**
  4861. * Adds the current matrix with a second one
  4862. * @param other defines the matrix to add
  4863. * @returns a new matrix as the addition of the current matrix and the given one
  4864. */
  4865. add(other: DeepImmutable<Matrix>): Matrix;
  4866. /**
  4867. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4868. * @param other defines the matrix to add
  4869. * @param result defines the target matrix
  4870. * @returns the current matrix
  4871. */
  4872. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4873. /**
  4874. * Adds in place the given matrix to the current matrix
  4875. * @param other defines the second operand
  4876. * @returns the current updated matrix
  4877. */
  4878. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4879. /**
  4880. * Sets the given matrix to the current inverted Matrix
  4881. * @param other defines the target matrix
  4882. * @returns the unmodified current matrix
  4883. */
  4884. invertToRef(other: Matrix): Matrix;
  4885. /**
  4886. * add a value at the specified position in the current Matrix
  4887. * @param index the index of the value within the matrix. between 0 and 15.
  4888. * @param value the value to be added
  4889. * @returns the current updated matrix
  4890. */
  4891. addAtIndex(index: number, value: number): Matrix;
  4892. /**
  4893. * mutiply the specified position in the current Matrix by a value
  4894. * @param index the index of the value within the matrix. between 0 and 15.
  4895. * @param value the value to be added
  4896. * @returns the current updated matrix
  4897. */
  4898. multiplyAtIndex(index: number, value: number): Matrix;
  4899. /**
  4900. * Inserts the translation vector (using 3 floats) in the current matrix
  4901. * @param x defines the 1st component of the translation
  4902. * @param y defines the 2nd component of the translation
  4903. * @param z defines the 3rd component of the translation
  4904. * @returns the current updated matrix
  4905. */
  4906. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4907. /**
  4908. * Adds the translation vector (using 3 floats) in the current matrix
  4909. * @param x defines the 1st component of the translation
  4910. * @param y defines the 2nd component of the translation
  4911. * @param z defines the 3rd component of the translation
  4912. * @returns the current updated matrix
  4913. */
  4914. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4915. /**
  4916. * Inserts the translation vector in the current matrix
  4917. * @param vector3 defines the translation to insert
  4918. * @returns the current updated matrix
  4919. */
  4920. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4921. /**
  4922. * Gets the translation value of the current matrix
  4923. * @returns a new Vector3 as the extracted translation from the matrix
  4924. */
  4925. getTranslation(): Vector3;
  4926. /**
  4927. * Fill a Vector3 with the extracted translation from the matrix
  4928. * @param result defines the Vector3 where to store the translation
  4929. * @returns the current matrix
  4930. */
  4931. getTranslationToRef(result: Vector3): Matrix;
  4932. /**
  4933. * Remove rotation and scaling part from the matrix
  4934. * @returns the updated matrix
  4935. */
  4936. removeRotationAndScaling(): Matrix;
  4937. /**
  4938. * Multiply two matrices
  4939. * @param other defines the second operand
  4940. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4941. */
  4942. multiply(other: DeepImmutable<Matrix>): Matrix;
  4943. /**
  4944. * Copy the current matrix from the given one
  4945. * @param other defines the source matrix
  4946. * @returns the current updated matrix
  4947. */
  4948. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4949. /**
  4950. * Populates the given array from the starting index with the current matrix values
  4951. * @param array defines the target array
  4952. * @param offset defines the offset in the target array where to start storing values
  4953. * @returns the current matrix
  4954. */
  4955. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4956. /**
  4957. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4958. * @param other defines the second operand
  4959. * @param result defines the matrix where to store the multiplication
  4960. * @returns the current matrix
  4961. */
  4962. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4963. /**
  4964. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4965. * @param other defines the second operand
  4966. * @param result defines the array where to store the multiplication
  4967. * @param offset defines the offset in the target array where to start storing values
  4968. * @returns the current matrix
  4969. */
  4970. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4971. /**
  4972. * Check equality between this matrix and a second one
  4973. * @param value defines the second matrix to compare
  4974. * @returns true is the current matrix and the given one values are strictly equal
  4975. */
  4976. equals(value: DeepImmutable<Matrix>): boolean;
  4977. /**
  4978. * Clone the current matrix
  4979. * @returns a new matrix from the current matrix
  4980. */
  4981. clone(): Matrix;
  4982. /**
  4983. * Returns the name of the current matrix class
  4984. * @returns the string "Matrix"
  4985. */
  4986. getClassName(): string;
  4987. /**
  4988. * Gets the hash code of the current matrix
  4989. * @returns the hash code
  4990. */
  4991. getHashCode(): number;
  4992. /**
  4993. * Decomposes the current Matrix into a translation, rotation and scaling components
  4994. * @param scale defines the scale vector3 given as a reference to update
  4995. * @param rotation defines the rotation quaternion given as a reference to update
  4996. * @param translation defines the translation vector3 given as a reference to update
  4997. * @returns true if operation was successful
  4998. */
  4999. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  5000. /**
  5001. * Gets specific row of the matrix
  5002. * @param index defines the number of the row to get
  5003. * @returns the index-th row of the current matrix as a new Vector4
  5004. */
  5005. getRow(index: number): Nullable<Vector4>;
  5006. /**
  5007. * Sets the index-th row of the current matrix to the vector4 values
  5008. * @param index defines the number of the row to set
  5009. * @param row defines the target vector4
  5010. * @returns the updated current matrix
  5011. */
  5012. setRow(index: number, row: Vector4): Matrix;
  5013. /**
  5014. * Compute the transpose of the matrix
  5015. * @returns the new transposed matrix
  5016. */
  5017. transpose(): Matrix;
  5018. /**
  5019. * Compute the transpose of the matrix and store it in a given matrix
  5020. * @param result defines the target matrix
  5021. * @returns the current matrix
  5022. */
  5023. transposeToRef(result: Matrix): Matrix;
  5024. /**
  5025. * Sets the index-th row of the current matrix with the given 4 x float values
  5026. * @param index defines the row index
  5027. * @param x defines the x component to set
  5028. * @param y defines the y component to set
  5029. * @param z defines the z component to set
  5030. * @param w defines the w component to set
  5031. * @returns the updated current matrix
  5032. */
  5033. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  5034. /**
  5035. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  5036. * @param scale defines the scale factor
  5037. * @returns a new matrix
  5038. */
  5039. scale(scale: number): Matrix;
  5040. /**
  5041. * Scale the current matrix values by a factor to a given result matrix
  5042. * @param scale defines the scale factor
  5043. * @param result defines the matrix to store the result
  5044. * @returns the current matrix
  5045. */
  5046. scaleToRef(scale: number, result: Matrix): Matrix;
  5047. /**
  5048. * Scale the current matrix values by a factor and add the result to a given matrix
  5049. * @param scale defines the scale factor
  5050. * @param result defines the Matrix to store the result
  5051. * @returns the current matrix
  5052. */
  5053. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5054. /**
  5055. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5056. * @param ref matrix to store the result
  5057. */
  5058. toNormalMatrix(ref: Matrix): void;
  5059. /**
  5060. * Gets only rotation part of the current matrix
  5061. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5062. */
  5063. getRotationMatrix(): Matrix;
  5064. /**
  5065. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5066. * @param result defines the target matrix to store data to
  5067. * @returns the current matrix
  5068. */
  5069. getRotationMatrixToRef(result: Matrix): Matrix;
  5070. /**
  5071. * Toggles model matrix from being right handed to left handed in place and vice versa
  5072. */
  5073. toggleModelMatrixHandInPlace(): void;
  5074. /**
  5075. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5076. */
  5077. toggleProjectionMatrixHandInPlace(): void;
  5078. /**
  5079. * Creates a matrix from an array
  5080. * @param array defines the source array
  5081. * @param offset defines an offset in the source array
  5082. * @returns a new Matrix set from the starting index of the given array
  5083. */
  5084. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5085. /**
  5086. * Copy the content of an array into a given matrix
  5087. * @param array defines the source array
  5088. * @param offset defines an offset in the source array
  5089. * @param result defines the target matrix
  5090. */
  5091. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5092. /**
  5093. * Stores an array into a matrix after having multiplied each component by a given factor
  5094. * @param array defines the source array
  5095. * @param offset defines the offset in the source array
  5096. * @param scale defines the scaling factor
  5097. * @param result defines the target matrix
  5098. */
  5099. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5100. /**
  5101. * Gets an identity matrix that must not be updated
  5102. */
  5103. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5104. /**
  5105. * Stores a list of values (16) inside a given matrix
  5106. * @param initialM11 defines 1st value of 1st row
  5107. * @param initialM12 defines 2nd value of 1st row
  5108. * @param initialM13 defines 3rd value of 1st row
  5109. * @param initialM14 defines 4th value of 1st row
  5110. * @param initialM21 defines 1st value of 2nd row
  5111. * @param initialM22 defines 2nd value of 2nd row
  5112. * @param initialM23 defines 3rd value of 2nd row
  5113. * @param initialM24 defines 4th value of 2nd row
  5114. * @param initialM31 defines 1st value of 3rd row
  5115. * @param initialM32 defines 2nd value of 3rd row
  5116. * @param initialM33 defines 3rd value of 3rd row
  5117. * @param initialM34 defines 4th value of 3rd row
  5118. * @param initialM41 defines 1st value of 4th row
  5119. * @param initialM42 defines 2nd value of 4th row
  5120. * @param initialM43 defines 3rd value of 4th row
  5121. * @param initialM44 defines 4th value of 4th row
  5122. * @param result defines the target matrix
  5123. */
  5124. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5125. /**
  5126. * Creates new matrix from a list of values (16)
  5127. * @param initialM11 defines 1st value of 1st row
  5128. * @param initialM12 defines 2nd value of 1st row
  5129. * @param initialM13 defines 3rd value of 1st row
  5130. * @param initialM14 defines 4th value of 1st row
  5131. * @param initialM21 defines 1st value of 2nd row
  5132. * @param initialM22 defines 2nd value of 2nd row
  5133. * @param initialM23 defines 3rd value of 2nd row
  5134. * @param initialM24 defines 4th value of 2nd row
  5135. * @param initialM31 defines 1st value of 3rd row
  5136. * @param initialM32 defines 2nd value of 3rd row
  5137. * @param initialM33 defines 3rd value of 3rd row
  5138. * @param initialM34 defines 4th value of 3rd row
  5139. * @param initialM41 defines 1st value of 4th row
  5140. * @param initialM42 defines 2nd value of 4th row
  5141. * @param initialM43 defines 3rd value of 4th row
  5142. * @param initialM44 defines 4th value of 4th row
  5143. * @returns the new matrix
  5144. */
  5145. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5146. /**
  5147. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5148. * @param scale defines the scale vector3
  5149. * @param rotation defines the rotation quaternion
  5150. * @param translation defines the translation vector3
  5151. * @returns a new matrix
  5152. */
  5153. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5154. /**
  5155. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5156. * @param scale defines the scale vector3
  5157. * @param rotation defines the rotation quaternion
  5158. * @param translation defines the translation vector3
  5159. * @param result defines the target matrix
  5160. */
  5161. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5162. /**
  5163. * Creates a new identity matrix
  5164. * @returns a new identity matrix
  5165. */
  5166. static Identity(): Matrix;
  5167. /**
  5168. * Creates a new identity matrix and stores the result in a given matrix
  5169. * @param result defines the target matrix
  5170. */
  5171. static IdentityToRef(result: Matrix): void;
  5172. /**
  5173. * Creates a new zero matrix
  5174. * @returns a new zero matrix
  5175. */
  5176. static Zero(): Matrix;
  5177. /**
  5178. * Creates a new rotation matrix for "angle" radians around the X axis
  5179. * @param angle defines the angle (in radians) to use
  5180. * @return the new matrix
  5181. */
  5182. static RotationX(angle: number): Matrix;
  5183. /**
  5184. * Creates a new matrix as the invert of a given matrix
  5185. * @param source defines the source matrix
  5186. * @returns the new matrix
  5187. */
  5188. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5189. /**
  5190. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5191. * @param angle defines the angle (in radians) to use
  5192. * @param result defines the target matrix
  5193. */
  5194. static RotationXToRef(angle: number, result: Matrix): void;
  5195. /**
  5196. * Creates a new rotation matrix for "angle" radians around the Y axis
  5197. * @param angle defines the angle (in radians) to use
  5198. * @return the new matrix
  5199. */
  5200. static RotationY(angle: number): Matrix;
  5201. /**
  5202. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5203. * @param angle defines the angle (in radians) to use
  5204. * @param result defines the target matrix
  5205. */
  5206. static RotationYToRef(angle: number, result: Matrix): void;
  5207. /**
  5208. * Creates a new rotation matrix for "angle" radians around the Z axis
  5209. * @param angle defines the angle (in radians) to use
  5210. * @return the new matrix
  5211. */
  5212. static RotationZ(angle: number): Matrix;
  5213. /**
  5214. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5215. * @param angle defines the angle (in radians) to use
  5216. * @param result defines the target matrix
  5217. */
  5218. static RotationZToRef(angle: number, result: Matrix): void;
  5219. /**
  5220. * Creates a new rotation matrix for "angle" radians around the given axis
  5221. * @param axis defines the axis to use
  5222. * @param angle defines the angle (in radians) to use
  5223. * @return the new matrix
  5224. */
  5225. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5226. /**
  5227. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5228. * @param axis defines the axis to use
  5229. * @param angle defines the angle (in radians) to use
  5230. * @param result defines the target matrix
  5231. */
  5232. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5233. /**
  5234. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5235. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5236. * @param from defines the vector to align
  5237. * @param to defines the vector to align to
  5238. * @param result defines the target matrix
  5239. */
  5240. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5241. /**
  5242. * Creates a rotation matrix
  5243. * @param yaw defines the yaw angle in radians (Y axis)
  5244. * @param pitch defines the pitch angle in radians (X axis)
  5245. * @param roll defines the roll angle in radians (Z axis)
  5246. * @returns the new rotation matrix
  5247. */
  5248. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5249. /**
  5250. * Creates a rotation matrix and stores it in a given matrix
  5251. * @param yaw defines the yaw angle in radians (Y axis)
  5252. * @param pitch defines the pitch angle in radians (X axis)
  5253. * @param roll defines the roll angle in radians (Z axis)
  5254. * @param result defines the target matrix
  5255. */
  5256. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5257. /**
  5258. * Creates a scaling matrix
  5259. * @param x defines the scale factor on X axis
  5260. * @param y defines the scale factor on Y axis
  5261. * @param z defines the scale factor on Z axis
  5262. * @returns the new matrix
  5263. */
  5264. static Scaling(x: number, y: number, z: number): Matrix;
  5265. /**
  5266. * Creates a scaling matrix and stores it in a given matrix
  5267. * @param x defines the scale factor on X axis
  5268. * @param y defines the scale factor on Y axis
  5269. * @param z defines the scale factor on Z axis
  5270. * @param result defines the target matrix
  5271. */
  5272. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5273. /**
  5274. * Creates a translation matrix
  5275. * @param x defines the translation on X axis
  5276. * @param y defines the translation on Y axis
  5277. * @param z defines the translationon Z axis
  5278. * @returns the new matrix
  5279. */
  5280. static Translation(x: number, y: number, z: number): Matrix;
  5281. /**
  5282. * Creates a translation matrix and stores it in a given matrix
  5283. * @param x defines the translation on X axis
  5284. * @param y defines the translation on Y axis
  5285. * @param z defines the translationon Z axis
  5286. * @param result defines the target matrix
  5287. */
  5288. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5289. /**
  5290. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5291. * @param startValue defines the start value
  5292. * @param endValue defines the end value
  5293. * @param gradient defines the gradient factor
  5294. * @returns the new matrix
  5295. */
  5296. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5297. /**
  5298. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5299. * @param startValue defines the start value
  5300. * @param endValue defines the end value
  5301. * @param gradient defines the gradient factor
  5302. * @param result defines the Matrix object where to store data
  5303. */
  5304. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5305. /**
  5306. * Builds a new matrix whose values are computed by:
  5307. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5308. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5309. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5310. * @param startValue defines the first matrix
  5311. * @param endValue defines the second matrix
  5312. * @param gradient defines the gradient between the two matrices
  5313. * @returns the new matrix
  5314. */
  5315. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5316. /**
  5317. * Update a matrix to values which are computed by:
  5318. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5319. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5320. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5321. * @param startValue defines the first matrix
  5322. * @param endValue defines the second matrix
  5323. * @param gradient defines the gradient between the two matrices
  5324. * @param result defines the target matrix
  5325. */
  5326. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5327. /**
  5328. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5329. * This function works in left handed mode
  5330. * @param eye defines the final position of the entity
  5331. * @param target defines where the entity should look at
  5332. * @param up defines the up vector for the entity
  5333. * @returns the new matrix
  5334. */
  5335. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5336. /**
  5337. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5338. * This function works in left handed mode
  5339. * @param eye defines the final position of the entity
  5340. * @param target defines where the entity should look at
  5341. * @param up defines the up vector for the entity
  5342. * @param result defines the target matrix
  5343. */
  5344. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5345. /**
  5346. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5347. * This function works in right handed mode
  5348. * @param eye defines the final position of the entity
  5349. * @param target defines where the entity should look at
  5350. * @param up defines the up vector for the entity
  5351. * @returns the new matrix
  5352. */
  5353. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5354. /**
  5355. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5356. * This function works in right handed mode
  5357. * @param eye defines the final position of the entity
  5358. * @param target defines where the entity should look at
  5359. * @param up defines the up vector for the entity
  5360. * @param result defines the target matrix
  5361. */
  5362. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5363. /**
  5364. * Create a left-handed orthographic projection matrix
  5365. * @param width defines the viewport width
  5366. * @param height defines the viewport height
  5367. * @param znear defines the near clip plane
  5368. * @param zfar defines the far clip plane
  5369. * @returns a new matrix as a left-handed orthographic projection matrix
  5370. */
  5371. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5372. /**
  5373. * Store a left-handed orthographic projection to a given matrix
  5374. * @param width defines the viewport width
  5375. * @param height defines the viewport height
  5376. * @param znear defines the near clip plane
  5377. * @param zfar defines the far clip plane
  5378. * @param result defines the target matrix
  5379. */
  5380. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5381. /**
  5382. * Create a left-handed orthographic projection matrix
  5383. * @param left defines the viewport left coordinate
  5384. * @param right defines the viewport right coordinate
  5385. * @param bottom defines the viewport bottom coordinate
  5386. * @param top defines the viewport top coordinate
  5387. * @param znear defines the near clip plane
  5388. * @param zfar defines the far clip plane
  5389. * @returns a new matrix as a left-handed orthographic projection matrix
  5390. */
  5391. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5392. /**
  5393. * Stores a left-handed orthographic projection into a given matrix
  5394. * @param left defines the viewport left coordinate
  5395. * @param right defines the viewport right coordinate
  5396. * @param bottom defines the viewport bottom coordinate
  5397. * @param top defines the viewport top coordinate
  5398. * @param znear defines the near clip plane
  5399. * @param zfar defines the far clip plane
  5400. * @param result defines the target matrix
  5401. */
  5402. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5403. /**
  5404. * Creates a right-handed orthographic projection matrix
  5405. * @param left defines the viewport left coordinate
  5406. * @param right defines the viewport right coordinate
  5407. * @param bottom defines the viewport bottom coordinate
  5408. * @param top defines the viewport top coordinate
  5409. * @param znear defines the near clip plane
  5410. * @param zfar defines the far clip plane
  5411. * @returns a new matrix as a right-handed orthographic projection matrix
  5412. */
  5413. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5414. /**
  5415. * Stores a right-handed orthographic projection into a given matrix
  5416. * @param left defines the viewport left coordinate
  5417. * @param right defines the viewport right coordinate
  5418. * @param bottom defines the viewport bottom coordinate
  5419. * @param top defines the viewport top coordinate
  5420. * @param znear defines the near clip plane
  5421. * @param zfar defines the far clip plane
  5422. * @param result defines the target matrix
  5423. */
  5424. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5425. /**
  5426. * Creates a left-handed perspective projection matrix
  5427. * @param width defines the viewport width
  5428. * @param height defines the viewport height
  5429. * @param znear defines the near clip plane
  5430. * @param zfar defines the far clip plane
  5431. * @returns a new matrix as a left-handed perspective projection matrix
  5432. */
  5433. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5434. /**
  5435. * Creates a left-handed perspective projection matrix
  5436. * @param fov defines the horizontal field of view
  5437. * @param aspect defines the aspect ratio
  5438. * @param znear defines the near clip plane
  5439. * @param zfar defines the far clip plane
  5440. * @returns a new matrix as a left-handed perspective projection matrix
  5441. */
  5442. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5443. /**
  5444. * Stores a left-handed perspective projection into a given matrix
  5445. * @param fov defines the horizontal field of view
  5446. * @param aspect defines the aspect ratio
  5447. * @param znear defines the near clip plane
  5448. * @param zfar defines the far clip plane
  5449. * @param result defines the target matrix
  5450. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5451. */
  5452. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5453. /**
  5454. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5455. * @param fov defines the horizontal field of view
  5456. * @param aspect defines the aspect ratio
  5457. * @param znear defines the near clip plane
  5458. * @param zfar not used as infinity is used as far clip
  5459. * @param result defines the target matrix
  5460. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5461. */
  5462. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5463. /**
  5464. * Creates a right-handed perspective projection matrix
  5465. * @param fov defines the horizontal field of view
  5466. * @param aspect defines the aspect ratio
  5467. * @param znear defines the near clip plane
  5468. * @param zfar defines the far clip plane
  5469. * @returns a new matrix as a right-handed perspective projection matrix
  5470. */
  5471. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5472. /**
  5473. * Stores a right-handed perspective projection into a given matrix
  5474. * @param fov defines the horizontal field of view
  5475. * @param aspect defines the aspect ratio
  5476. * @param znear defines the near clip plane
  5477. * @param zfar defines the far clip plane
  5478. * @param result defines the target matrix
  5479. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5480. */
  5481. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5482. /**
  5483. * Stores a right-handed perspective projection into a given matrix
  5484. * @param fov defines the horizontal field of view
  5485. * @param aspect defines the aspect ratio
  5486. * @param znear defines the near clip plane
  5487. * @param zfar not used as infinity is used as far clip
  5488. * @param result defines the target matrix
  5489. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5490. */
  5491. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5492. /**
  5493. * Stores a perspective projection for WebVR info a given matrix
  5494. * @param fov defines the field of view
  5495. * @param znear defines the near clip plane
  5496. * @param zfar defines the far clip plane
  5497. * @param result defines the target matrix
  5498. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5499. */
  5500. static PerspectiveFovWebVRToRef(fov: {
  5501. upDegrees: number;
  5502. downDegrees: number;
  5503. leftDegrees: number;
  5504. rightDegrees: number;
  5505. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5506. /**
  5507. * Computes a complete transformation matrix
  5508. * @param viewport defines the viewport to use
  5509. * @param world defines the world matrix
  5510. * @param view defines the view matrix
  5511. * @param projection defines the projection matrix
  5512. * @param zmin defines the near clip plane
  5513. * @param zmax defines the far clip plane
  5514. * @returns the transformation matrix
  5515. */
  5516. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5517. /**
  5518. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5519. * @param matrix defines the matrix to use
  5520. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5521. */
  5522. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5523. /**
  5524. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5525. * @param matrix defines the matrix to use
  5526. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5527. */
  5528. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5529. /**
  5530. * Compute the transpose of a given matrix
  5531. * @param matrix defines the matrix to transpose
  5532. * @returns the new matrix
  5533. */
  5534. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5535. /**
  5536. * Compute the transpose of a matrix and store it in a target matrix
  5537. * @param matrix defines the matrix to transpose
  5538. * @param result defines the target matrix
  5539. */
  5540. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5541. /**
  5542. * Computes a reflection matrix from a plane
  5543. * @param plane defines the reflection plane
  5544. * @returns a new matrix
  5545. */
  5546. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5547. /**
  5548. * Computes a reflection matrix from a plane
  5549. * @param plane defines the reflection plane
  5550. * @param result defines the target matrix
  5551. */
  5552. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5553. /**
  5554. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5555. * @param xaxis defines the value of the 1st axis
  5556. * @param yaxis defines the value of the 2nd axis
  5557. * @param zaxis defines the value of the 3rd axis
  5558. * @param result defines the target matrix
  5559. */
  5560. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5561. /**
  5562. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5563. * @param quat defines the quaternion to use
  5564. * @param result defines the target matrix
  5565. */
  5566. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5567. }
  5568. /**
  5569. * @hidden
  5570. */
  5571. export class TmpVectors {
  5572. static Vector2: Vector2[];
  5573. static Vector3: Vector3[];
  5574. static Vector4: Vector4[];
  5575. static Quaternion: Quaternion[];
  5576. static Matrix: Matrix[];
  5577. }
  5578. }
  5579. declare module "babylonjs/Maths/math.path" {
  5580. import { DeepImmutable, Nullable } from "babylonjs/types";
  5581. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5582. /**
  5583. * Defines potential orientation for back face culling
  5584. */
  5585. export enum Orientation {
  5586. /**
  5587. * Clockwise
  5588. */
  5589. CW = 0,
  5590. /** Counter clockwise */
  5591. CCW = 1
  5592. }
  5593. /** Class used to represent a Bezier curve */
  5594. export class BezierCurve {
  5595. /**
  5596. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5597. * @param t defines the time
  5598. * @param x1 defines the left coordinate on X axis
  5599. * @param y1 defines the left coordinate on Y axis
  5600. * @param x2 defines the right coordinate on X axis
  5601. * @param y2 defines the right coordinate on Y axis
  5602. * @returns the interpolated value
  5603. */
  5604. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5605. }
  5606. /**
  5607. * Defines angle representation
  5608. */
  5609. export class Angle {
  5610. private _radians;
  5611. /**
  5612. * Creates an Angle object of "radians" radians (float).
  5613. * @param radians the angle in radians
  5614. */
  5615. constructor(radians: number);
  5616. /**
  5617. * Get value in degrees
  5618. * @returns the Angle value in degrees (float)
  5619. */
  5620. degrees(): number;
  5621. /**
  5622. * Get value in radians
  5623. * @returns the Angle value in radians (float)
  5624. */
  5625. radians(): number;
  5626. /**
  5627. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5628. * @param a defines first point as the origin
  5629. * @param b defines point
  5630. * @returns a new Angle
  5631. */
  5632. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5633. /**
  5634. * Gets a new Angle object from the given float in radians
  5635. * @param radians defines the angle value in radians
  5636. * @returns a new Angle
  5637. */
  5638. static FromRadians(radians: number): Angle;
  5639. /**
  5640. * Gets a new Angle object from the given float in degrees
  5641. * @param degrees defines the angle value in degrees
  5642. * @returns a new Angle
  5643. */
  5644. static FromDegrees(degrees: number): Angle;
  5645. }
  5646. /**
  5647. * This represents an arc in a 2d space.
  5648. */
  5649. export class Arc2 {
  5650. /** Defines the start point of the arc */
  5651. startPoint: Vector2;
  5652. /** Defines the mid point of the arc */
  5653. midPoint: Vector2;
  5654. /** Defines the end point of the arc */
  5655. endPoint: Vector2;
  5656. /**
  5657. * Defines the center point of the arc.
  5658. */
  5659. centerPoint: Vector2;
  5660. /**
  5661. * Defines the radius of the arc.
  5662. */
  5663. radius: number;
  5664. /**
  5665. * Defines the angle of the arc (from mid point to end point).
  5666. */
  5667. angle: Angle;
  5668. /**
  5669. * Defines the start angle of the arc (from start point to middle point).
  5670. */
  5671. startAngle: Angle;
  5672. /**
  5673. * Defines the orientation of the arc (clock wise/counter clock wise).
  5674. */
  5675. orientation: Orientation;
  5676. /**
  5677. * Creates an Arc object from the three given points : start, middle and end.
  5678. * @param startPoint Defines the start point of the arc
  5679. * @param midPoint Defines the midlle point of the arc
  5680. * @param endPoint Defines the end point of the arc
  5681. */
  5682. constructor(
  5683. /** Defines the start point of the arc */
  5684. startPoint: Vector2,
  5685. /** Defines the mid point of the arc */
  5686. midPoint: Vector2,
  5687. /** Defines the end point of the arc */
  5688. endPoint: Vector2);
  5689. }
  5690. /**
  5691. * Represents a 2D path made up of multiple 2D points
  5692. */
  5693. export class Path2 {
  5694. private _points;
  5695. private _length;
  5696. /**
  5697. * If the path start and end point are the same
  5698. */
  5699. closed: boolean;
  5700. /**
  5701. * Creates a Path2 object from the starting 2D coordinates x and y.
  5702. * @param x the starting points x value
  5703. * @param y the starting points y value
  5704. */
  5705. constructor(x: number, y: number);
  5706. /**
  5707. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5708. * @param x the added points x value
  5709. * @param y the added points y value
  5710. * @returns the updated Path2.
  5711. */
  5712. addLineTo(x: number, y: number): Path2;
  5713. /**
  5714. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5715. * @param midX middle point x value
  5716. * @param midY middle point y value
  5717. * @param endX end point x value
  5718. * @param endY end point y value
  5719. * @param numberOfSegments (default: 36)
  5720. * @returns the updated Path2.
  5721. */
  5722. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5723. /**
  5724. * Closes the Path2.
  5725. * @returns the Path2.
  5726. */
  5727. close(): Path2;
  5728. /**
  5729. * Gets the sum of the distance between each sequential point in the path
  5730. * @returns the Path2 total length (float).
  5731. */
  5732. length(): number;
  5733. /**
  5734. * Gets the points which construct the path
  5735. * @returns the Path2 internal array of points.
  5736. */
  5737. getPoints(): Vector2[];
  5738. /**
  5739. * Retreives the point at the distance aways from the starting point
  5740. * @param normalizedLengthPosition the length along the path to retreive the point from
  5741. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5742. */
  5743. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5744. /**
  5745. * Creates a new path starting from an x and y position
  5746. * @param x starting x value
  5747. * @param y starting y value
  5748. * @returns a new Path2 starting at the coordinates (x, y).
  5749. */
  5750. static StartingAt(x: number, y: number): Path2;
  5751. }
  5752. /**
  5753. * Represents a 3D path made up of multiple 3D points
  5754. */
  5755. export class Path3D {
  5756. /**
  5757. * an array of Vector3, the curve axis of the Path3D
  5758. */
  5759. path: Vector3[];
  5760. private _curve;
  5761. private _distances;
  5762. private _tangents;
  5763. private _normals;
  5764. private _binormals;
  5765. private _raw;
  5766. private _alignTangentsWithPath;
  5767. private readonly _pointAtData;
  5768. /**
  5769. * new Path3D(path, normal, raw)
  5770. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5771. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5772. * @param path an array of Vector3, the curve axis of the Path3D
  5773. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5774. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5775. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5776. */
  5777. constructor(
  5778. /**
  5779. * an array of Vector3, the curve axis of the Path3D
  5780. */
  5781. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5782. /**
  5783. * Returns the Path3D array of successive Vector3 designing its curve.
  5784. * @returns the Path3D array of successive Vector3 designing its curve.
  5785. */
  5786. getCurve(): Vector3[];
  5787. /**
  5788. * Returns the Path3D array of successive Vector3 designing its curve.
  5789. * @returns the Path3D array of successive Vector3 designing its curve.
  5790. */
  5791. getPoints(): Vector3[];
  5792. /**
  5793. * @returns the computed length (float) of the path.
  5794. */
  5795. length(): number;
  5796. /**
  5797. * Returns an array populated with tangent vectors on each Path3D curve point.
  5798. * @returns an array populated with tangent vectors on each Path3D curve point.
  5799. */
  5800. getTangents(): Vector3[];
  5801. /**
  5802. * Returns an array populated with normal vectors on each Path3D curve point.
  5803. * @returns an array populated with normal vectors on each Path3D curve point.
  5804. */
  5805. getNormals(): Vector3[];
  5806. /**
  5807. * Returns an array populated with binormal vectors on each Path3D curve point.
  5808. * @returns an array populated with binormal vectors on each Path3D curve point.
  5809. */
  5810. getBinormals(): Vector3[];
  5811. /**
  5812. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5813. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5814. */
  5815. getDistances(): number[];
  5816. /**
  5817. * Returns an interpolated point along this path
  5818. * @param position the position of the point along this path, from 0.0 to 1.0
  5819. * @returns a new Vector3 as the point
  5820. */
  5821. getPointAt(position: number): Vector3;
  5822. /**
  5823. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5824. * @param position the position of the point along this path, from 0.0 to 1.0
  5825. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5826. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5827. */
  5828. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5829. /**
  5830. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5831. * @param position the position of the point along this path, from 0.0 to 1.0
  5832. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5833. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5834. */
  5835. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5836. /**
  5837. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5838. * @param position the position of the point along this path, from 0.0 to 1.0
  5839. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5840. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5841. */
  5842. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5843. /**
  5844. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5845. * @param position the position of the point along this path, from 0.0 to 1.0
  5846. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5847. */
  5848. getDistanceAt(position: number): number;
  5849. /**
  5850. * Returns the array index of the previous point of an interpolated point along this path
  5851. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5852. * @returns the array index
  5853. */
  5854. getPreviousPointIndexAt(position: number): number;
  5855. /**
  5856. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5857. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5858. * @returns the sub position
  5859. */
  5860. getSubPositionAt(position: number): number;
  5861. /**
  5862. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5863. * @param target the vector of which to get the closest position to
  5864. * @returns the position of the closest virtual point on this path to the target vector
  5865. */
  5866. getClosestPositionTo(target: Vector3): number;
  5867. /**
  5868. * Returns a sub path (slice) of this path
  5869. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5870. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5871. * @returns a sub path (slice) of this path
  5872. */
  5873. slice(start?: number, end?: number): Path3D;
  5874. /**
  5875. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5876. * @param path path which all values are copied into the curves points
  5877. * @param firstNormal which should be projected onto the curve
  5878. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5879. * @returns the same object updated.
  5880. */
  5881. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5882. private _compute;
  5883. private _getFirstNonNullVector;
  5884. private _getLastNonNullVector;
  5885. private _normalVector;
  5886. /**
  5887. * Updates the point at data for an interpolated point along this curve
  5888. * @param position the position of the point along this curve, from 0.0 to 1.0
  5889. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5890. * @returns the (updated) point at data
  5891. */
  5892. private _updatePointAtData;
  5893. /**
  5894. * Updates the point at data from the specified parameters
  5895. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5896. * @param point the interpolated point
  5897. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5898. */
  5899. private _setPointAtData;
  5900. /**
  5901. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5902. */
  5903. private _updateInterpolationMatrix;
  5904. }
  5905. /**
  5906. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5907. * A Curve3 is designed from a series of successive Vector3.
  5908. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5909. */
  5910. export class Curve3 {
  5911. private _points;
  5912. private _length;
  5913. /**
  5914. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5915. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5916. * @param v1 (Vector3) the control point
  5917. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5918. * @param nbPoints (integer) the wanted number of points in the curve
  5919. * @returns the created Curve3
  5920. */
  5921. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5922. /**
  5923. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5924. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5925. * @param v1 (Vector3) the first control point
  5926. * @param v2 (Vector3) the second control point
  5927. * @param v3 (Vector3) the end point of the Cubic Bezier
  5928. * @param nbPoints (integer) the wanted number of points in the curve
  5929. * @returns the created Curve3
  5930. */
  5931. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5932. /**
  5933. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5934. * @param p1 (Vector3) the origin point of the Hermite Spline
  5935. * @param t1 (Vector3) the tangent vector at the origin point
  5936. * @param p2 (Vector3) the end point of the Hermite Spline
  5937. * @param t2 (Vector3) the tangent vector at the end point
  5938. * @param nbPoints (integer) the wanted number of points in the curve
  5939. * @returns the created Curve3
  5940. */
  5941. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5942. /**
  5943. * Returns a Curve3 object along a CatmullRom Spline curve :
  5944. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5945. * @param nbPoints (integer) the wanted number of points between each curve control points
  5946. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5947. * @returns the created Curve3
  5948. */
  5949. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5950. /**
  5951. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5952. * A Curve3 is designed from a series of successive Vector3.
  5953. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5954. * @param points points which make up the curve
  5955. */
  5956. constructor(points: Vector3[]);
  5957. /**
  5958. * @returns the Curve3 stored array of successive Vector3
  5959. */
  5960. getPoints(): Vector3[];
  5961. /**
  5962. * @returns the computed length (float) of the curve.
  5963. */
  5964. length(): number;
  5965. /**
  5966. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5967. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5968. * curveA and curveB keep unchanged.
  5969. * @param curve the curve to continue from this curve
  5970. * @returns the newly constructed curve
  5971. */
  5972. continue(curve: DeepImmutable<Curve3>): Curve3;
  5973. private _computeLength;
  5974. }
  5975. }
  5976. declare module "babylonjs/Animations/easing" {
  5977. /**
  5978. * This represents the main contract an easing function should follow.
  5979. * Easing functions are used throughout the animation system.
  5980. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5981. */
  5982. export interface IEasingFunction {
  5983. /**
  5984. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5985. * of the easing function.
  5986. * The link below provides some of the most common examples of easing functions.
  5987. * @see https://easings.net/
  5988. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5989. * @returns the corresponding value on the curve defined by the easing function
  5990. */
  5991. ease(gradient: number): number;
  5992. }
  5993. /**
  5994. * Base class used for every default easing function.
  5995. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5996. */
  5997. export class EasingFunction implements IEasingFunction {
  5998. /**
  5999. * Interpolation follows the mathematical formula associated with the easing function.
  6000. */
  6001. static readonly EASINGMODE_EASEIN: number;
  6002. /**
  6003. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6004. */
  6005. static readonly EASINGMODE_EASEOUT: number;
  6006. /**
  6007. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6008. */
  6009. static readonly EASINGMODE_EASEINOUT: number;
  6010. private _easingMode;
  6011. /**
  6012. * Sets the easing mode of the current function.
  6013. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6014. */
  6015. setEasingMode(easingMode: number): void;
  6016. /**
  6017. * Gets the current easing mode.
  6018. * @returns the easing mode
  6019. */
  6020. getEasingMode(): number;
  6021. /**
  6022. * @hidden
  6023. */
  6024. easeInCore(gradient: number): number;
  6025. /**
  6026. * Given an input gradient between 0 and 1, this returns the corresponding value
  6027. * of the easing function.
  6028. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6029. * @returns the corresponding value on the curve defined by the easing function
  6030. */
  6031. ease(gradient: number): number;
  6032. }
  6033. /**
  6034. * Easing function with a circle shape (see link below).
  6035. * @see https://easings.net/#easeInCirc
  6036. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6037. */
  6038. export class CircleEase extends EasingFunction implements IEasingFunction {
  6039. /** @hidden */
  6040. easeInCore(gradient: number): number;
  6041. }
  6042. /**
  6043. * Easing function with a ease back shape (see link below).
  6044. * @see https://easings.net/#easeInBack
  6045. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6046. */
  6047. export class BackEase extends EasingFunction implements IEasingFunction {
  6048. /** Defines the amplitude of the function */
  6049. amplitude: number;
  6050. /**
  6051. * Instantiates a back ease easing
  6052. * @see https://easings.net/#easeInBack
  6053. * @param amplitude Defines the amplitude of the function
  6054. */
  6055. constructor(
  6056. /** Defines the amplitude of the function */
  6057. amplitude?: number);
  6058. /** @hidden */
  6059. easeInCore(gradient: number): number;
  6060. }
  6061. /**
  6062. * Easing function with a bouncing shape (see link below).
  6063. * @see https://easings.net/#easeInBounce
  6064. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6065. */
  6066. export class BounceEase extends EasingFunction implements IEasingFunction {
  6067. /** Defines the number of bounces */
  6068. bounces: number;
  6069. /** Defines the amplitude of the bounce */
  6070. bounciness: number;
  6071. /**
  6072. * Instantiates a bounce easing
  6073. * @see https://easings.net/#easeInBounce
  6074. * @param bounces Defines the number of bounces
  6075. * @param bounciness Defines the amplitude of the bounce
  6076. */
  6077. constructor(
  6078. /** Defines the number of bounces */
  6079. bounces?: number,
  6080. /** Defines the amplitude of the bounce */
  6081. bounciness?: number);
  6082. /** @hidden */
  6083. easeInCore(gradient: number): number;
  6084. }
  6085. /**
  6086. * Easing function with a power of 3 shape (see link below).
  6087. * @see https://easings.net/#easeInCubic
  6088. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6089. */
  6090. export class CubicEase extends EasingFunction implements IEasingFunction {
  6091. /** @hidden */
  6092. easeInCore(gradient: number): number;
  6093. }
  6094. /**
  6095. * Easing function with an elastic shape (see link below).
  6096. * @see https://easings.net/#easeInElastic
  6097. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6098. */
  6099. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6100. /** Defines the number of oscillations*/
  6101. oscillations: number;
  6102. /** Defines the amplitude of the oscillations*/
  6103. springiness: number;
  6104. /**
  6105. * Instantiates an elastic easing function
  6106. * @see https://easings.net/#easeInElastic
  6107. * @param oscillations Defines the number of oscillations
  6108. * @param springiness Defines the amplitude of the oscillations
  6109. */
  6110. constructor(
  6111. /** Defines the number of oscillations*/
  6112. oscillations?: number,
  6113. /** Defines the amplitude of the oscillations*/
  6114. springiness?: number);
  6115. /** @hidden */
  6116. easeInCore(gradient: number): number;
  6117. }
  6118. /**
  6119. * Easing function with an exponential shape (see link below).
  6120. * @see https://easings.net/#easeInExpo
  6121. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6122. */
  6123. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6124. /** Defines the exponent of the function */
  6125. exponent: number;
  6126. /**
  6127. * Instantiates an exponential easing function
  6128. * @see https://easings.net/#easeInExpo
  6129. * @param exponent Defines the exponent of the function
  6130. */
  6131. constructor(
  6132. /** Defines the exponent of the function */
  6133. exponent?: number);
  6134. /** @hidden */
  6135. easeInCore(gradient: number): number;
  6136. }
  6137. /**
  6138. * Easing function with a power shape (see link below).
  6139. * @see https://easings.net/#easeInQuad
  6140. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6141. */
  6142. export class PowerEase extends EasingFunction implements IEasingFunction {
  6143. /** Defines the power of the function */
  6144. power: number;
  6145. /**
  6146. * Instantiates an power base easing function
  6147. * @see https://easings.net/#easeInQuad
  6148. * @param power Defines the power of the function
  6149. */
  6150. constructor(
  6151. /** Defines the power of the function */
  6152. power?: number);
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a power of 2 shape (see link below).
  6158. * @see https://easings.net/#easeInQuad
  6159. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6162. /** @hidden */
  6163. easeInCore(gradient: number): number;
  6164. }
  6165. /**
  6166. * Easing function with a power of 4 shape (see link below).
  6167. * @see https://easings.net/#easeInQuart
  6168. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6169. */
  6170. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6171. /** @hidden */
  6172. easeInCore(gradient: number): number;
  6173. }
  6174. /**
  6175. * Easing function with a power of 5 shape (see link below).
  6176. * @see https://easings.net/#easeInQuint
  6177. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6178. */
  6179. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6180. /** @hidden */
  6181. easeInCore(gradient: number): number;
  6182. }
  6183. /**
  6184. * Easing function with a sin shape (see link below).
  6185. * @see https://easings.net/#easeInSine
  6186. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6187. */
  6188. export class SineEase extends EasingFunction implements IEasingFunction {
  6189. /** @hidden */
  6190. easeInCore(gradient: number): number;
  6191. }
  6192. /**
  6193. * Easing function with a bezier shape (see link below).
  6194. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6195. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6196. */
  6197. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6198. /** Defines the x component of the start tangent in the bezier curve */
  6199. x1: number;
  6200. /** Defines the y component of the start tangent in the bezier curve */
  6201. y1: number;
  6202. /** Defines the x component of the end tangent in the bezier curve */
  6203. x2: number;
  6204. /** Defines the y component of the end tangent in the bezier curve */
  6205. y2: number;
  6206. /**
  6207. * Instantiates a bezier function
  6208. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6209. * @param x1 Defines the x component of the start tangent in the bezier curve
  6210. * @param y1 Defines the y component of the start tangent in the bezier curve
  6211. * @param x2 Defines the x component of the end tangent in the bezier curve
  6212. * @param y2 Defines the y component of the end tangent in the bezier curve
  6213. */
  6214. constructor(
  6215. /** Defines the x component of the start tangent in the bezier curve */
  6216. x1?: number,
  6217. /** Defines the y component of the start tangent in the bezier curve */
  6218. y1?: number,
  6219. /** Defines the x component of the end tangent in the bezier curve */
  6220. x2?: number,
  6221. /** Defines the y component of the end tangent in the bezier curve */
  6222. y2?: number);
  6223. /** @hidden */
  6224. easeInCore(gradient: number): number;
  6225. }
  6226. }
  6227. declare module "babylonjs/Maths/math.color" {
  6228. import { DeepImmutable, FloatArray } from "babylonjs/types";
  6229. /**
  6230. * Class used to hold a RGB color
  6231. */
  6232. export class Color3 {
  6233. /**
  6234. * Defines the red component (between 0 and 1, default is 0)
  6235. */
  6236. r: number;
  6237. /**
  6238. * Defines the green component (between 0 and 1, default is 0)
  6239. */
  6240. g: number;
  6241. /**
  6242. * Defines the blue component (between 0 and 1, default is 0)
  6243. */
  6244. b: number;
  6245. /**
  6246. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6247. * @param r defines the red component (between 0 and 1, default is 0)
  6248. * @param g defines the green component (between 0 and 1, default is 0)
  6249. * @param b defines the blue component (between 0 and 1, default is 0)
  6250. */
  6251. constructor(
  6252. /**
  6253. * Defines the red component (between 0 and 1, default is 0)
  6254. */
  6255. r?: number,
  6256. /**
  6257. * Defines the green component (between 0 and 1, default is 0)
  6258. */
  6259. g?: number,
  6260. /**
  6261. * Defines the blue component (between 0 and 1, default is 0)
  6262. */
  6263. b?: number);
  6264. /**
  6265. * Creates a string with the Color3 current values
  6266. * @returns the string representation of the Color3 object
  6267. */
  6268. toString(): string;
  6269. /**
  6270. * Returns the string "Color3"
  6271. * @returns "Color3"
  6272. */
  6273. getClassName(): string;
  6274. /**
  6275. * Compute the Color3 hash code
  6276. * @returns an unique number that can be used to hash Color3 objects
  6277. */
  6278. getHashCode(): number;
  6279. /**
  6280. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6281. * @param array defines the array where to store the r,g,b components
  6282. * @param index defines an optional index in the target array to define where to start storing values
  6283. * @returns the current Color3 object
  6284. */
  6285. toArray(array: FloatArray, index?: number): Color3;
  6286. /**
  6287. * Update the current color with values stored in an array from the starting index of the given array
  6288. * @param array defines the source array
  6289. * @param offset defines an offset in the source array
  6290. * @returns the current Color3 object
  6291. */
  6292. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6293. /**
  6294. * Returns a new Color4 object from the current Color3 and the given alpha
  6295. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6296. * @returns a new Color4 object
  6297. */
  6298. toColor4(alpha?: number): Color4;
  6299. /**
  6300. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6301. * @returns the new array
  6302. */
  6303. asArray(): number[];
  6304. /**
  6305. * Returns the luminance value
  6306. * @returns a float value
  6307. */
  6308. toLuminance(): number;
  6309. /**
  6310. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6311. * @param otherColor defines the second operand
  6312. * @returns the new Color3 object
  6313. */
  6314. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6315. /**
  6316. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6317. * @param otherColor defines the second operand
  6318. * @param result defines the Color3 object where to store the result
  6319. * @returns the current Color3
  6320. */
  6321. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6322. /**
  6323. * Determines equality between Color3 objects
  6324. * @param otherColor defines the second operand
  6325. * @returns true if the rgb values are equal to the given ones
  6326. */
  6327. equals(otherColor: DeepImmutable<Color3>): boolean;
  6328. /**
  6329. * Determines equality between the current Color3 object and a set of r,b,g values
  6330. * @param r defines the red component to check
  6331. * @param g defines the green component to check
  6332. * @param b defines the blue component to check
  6333. * @returns true if the rgb values are equal to the given ones
  6334. */
  6335. equalsFloats(r: number, g: number, b: number): boolean;
  6336. /**
  6337. * Multiplies in place each rgb value by scale
  6338. * @param scale defines the scaling factor
  6339. * @returns the updated Color3
  6340. */
  6341. scale(scale: number): Color3;
  6342. /**
  6343. * Multiplies the rgb values by scale and stores the result into "result"
  6344. * @param scale defines the scaling factor
  6345. * @param result defines the Color3 object where to store the result
  6346. * @returns the unmodified current Color3
  6347. */
  6348. scaleToRef(scale: number, result: Color3): Color3;
  6349. /**
  6350. * Scale the current Color3 values by a factor and add the result to a given Color3
  6351. * @param scale defines the scale factor
  6352. * @param result defines color to store the result into
  6353. * @returns the unmodified current Color3
  6354. */
  6355. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6356. /**
  6357. * Clamps the rgb values by the min and max values and stores the result into "result"
  6358. * @param min defines minimum clamping value (default is 0)
  6359. * @param max defines maximum clamping value (default is 1)
  6360. * @param result defines color to store the result into
  6361. * @returns the original Color3
  6362. */
  6363. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6364. /**
  6365. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6366. * @param otherColor defines the second operand
  6367. * @returns the new Color3
  6368. */
  6369. add(otherColor: DeepImmutable<Color3>): Color3;
  6370. /**
  6371. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6372. * @param otherColor defines the second operand
  6373. * @param result defines Color3 object to store the result into
  6374. * @returns the unmodified current Color3
  6375. */
  6376. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6377. /**
  6378. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6379. * @param otherColor defines the second operand
  6380. * @returns the new Color3
  6381. */
  6382. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6383. /**
  6384. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6385. * @param otherColor defines the second operand
  6386. * @param result defines Color3 object to store the result into
  6387. * @returns the unmodified current Color3
  6388. */
  6389. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6390. /**
  6391. * Copy the current object
  6392. * @returns a new Color3 copied the current one
  6393. */
  6394. clone(): Color3;
  6395. /**
  6396. * Copies the rgb values from the source in the current Color3
  6397. * @param source defines the source Color3 object
  6398. * @returns the updated Color3 object
  6399. */
  6400. copyFrom(source: DeepImmutable<Color3>): Color3;
  6401. /**
  6402. * Updates the Color3 rgb values from the given floats
  6403. * @param r defines the red component to read from
  6404. * @param g defines the green component to read from
  6405. * @param b defines the blue component to read from
  6406. * @returns the current Color3 object
  6407. */
  6408. copyFromFloats(r: number, g: number, b: number): Color3;
  6409. /**
  6410. * Updates the Color3 rgb values from the given floats
  6411. * @param r defines the red component to read from
  6412. * @param g defines the green component to read from
  6413. * @param b defines the blue component to read from
  6414. * @returns the current Color3 object
  6415. */
  6416. set(r: number, g: number, b: number): Color3;
  6417. /**
  6418. * Compute the Color3 hexadecimal code as a string
  6419. * @returns a string containing the hexadecimal representation of the Color3 object
  6420. */
  6421. toHexString(): string;
  6422. /**
  6423. * Computes a new Color3 converted from the current one to linear space
  6424. * @returns a new Color3 object
  6425. */
  6426. toLinearSpace(): Color3;
  6427. /**
  6428. * Converts current color in rgb space to HSV values
  6429. * @returns a new color3 representing the HSV values
  6430. */
  6431. toHSV(): Color3;
  6432. /**
  6433. * Converts current color in rgb space to HSV values
  6434. * @param result defines the Color3 where to store the HSV values
  6435. */
  6436. toHSVToRef(result: Color3): void;
  6437. /**
  6438. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6439. * @param convertedColor defines the Color3 object where to store the linear space version
  6440. * @returns the unmodified Color3
  6441. */
  6442. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6443. /**
  6444. * Computes a new Color3 converted from the current one to gamma space
  6445. * @returns a new Color3 object
  6446. */
  6447. toGammaSpace(): Color3;
  6448. /**
  6449. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6450. * @param convertedColor defines the Color3 object where to store the gamma space version
  6451. * @returns the unmodified Color3
  6452. */
  6453. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6454. private static _BlackReadOnly;
  6455. /**
  6456. * Convert Hue, saturation and value to a Color3 (RGB)
  6457. * @param hue defines the hue
  6458. * @param saturation defines the saturation
  6459. * @param value defines the value
  6460. * @param result defines the Color3 where to store the RGB values
  6461. */
  6462. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6463. /**
  6464. * Creates a new Color3 from the string containing valid hexadecimal values
  6465. * @param hex defines a string containing valid hexadecimal values
  6466. * @returns a new Color3 object
  6467. */
  6468. static FromHexString(hex: string): Color3;
  6469. /**
  6470. * Creates a new Color3 from the starting index of the given array
  6471. * @param array defines the source array
  6472. * @param offset defines an offset in the source array
  6473. * @returns a new Color3 object
  6474. */
  6475. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6476. /**
  6477. * Creates a new Color3 from the starting index element of the given array
  6478. * @param array defines the source array to read from
  6479. * @param offset defines the offset in the source array
  6480. * @param result defines the target Color3 object
  6481. */
  6482. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6483. /**
  6484. * Creates a new Color3 from integer values (< 256)
  6485. * @param r defines the red component to read from (value between 0 and 255)
  6486. * @param g defines the green component to read from (value between 0 and 255)
  6487. * @param b defines the blue component to read from (value between 0 and 255)
  6488. * @returns a new Color3 object
  6489. */
  6490. static FromInts(r: number, g: number, b: number): Color3;
  6491. /**
  6492. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6493. * @param start defines the start Color3 value
  6494. * @param end defines the end Color3 value
  6495. * @param amount defines the gradient value between start and end
  6496. * @returns a new Color3 object
  6497. */
  6498. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6499. /**
  6500. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6501. * @param left defines the start value
  6502. * @param right defines the end value
  6503. * @param amount defines the gradient factor
  6504. * @param result defines the Color3 object where to store the result
  6505. */
  6506. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6507. /**
  6508. * Returns a Color3 value containing a red color
  6509. * @returns a new Color3 object
  6510. */
  6511. static Red(): Color3;
  6512. /**
  6513. * Returns a Color3 value containing a green color
  6514. * @returns a new Color3 object
  6515. */
  6516. static Green(): Color3;
  6517. /**
  6518. * Returns a Color3 value containing a blue color
  6519. * @returns a new Color3 object
  6520. */
  6521. static Blue(): Color3;
  6522. /**
  6523. * Returns a Color3 value containing a black color
  6524. * @returns a new Color3 object
  6525. */
  6526. static Black(): Color3;
  6527. /**
  6528. * Gets a Color3 value containing a black color that must not be updated
  6529. */
  6530. static get BlackReadOnly(): DeepImmutable<Color3>;
  6531. /**
  6532. * Returns a Color3 value containing a white color
  6533. * @returns a new Color3 object
  6534. */
  6535. static White(): Color3;
  6536. /**
  6537. * Returns a Color3 value containing a purple color
  6538. * @returns a new Color3 object
  6539. */
  6540. static Purple(): Color3;
  6541. /**
  6542. * Returns a Color3 value containing a magenta color
  6543. * @returns a new Color3 object
  6544. */
  6545. static Magenta(): Color3;
  6546. /**
  6547. * Returns a Color3 value containing a yellow color
  6548. * @returns a new Color3 object
  6549. */
  6550. static Yellow(): Color3;
  6551. /**
  6552. * Returns a Color3 value containing a gray color
  6553. * @returns a new Color3 object
  6554. */
  6555. static Gray(): Color3;
  6556. /**
  6557. * Returns a Color3 value containing a teal color
  6558. * @returns a new Color3 object
  6559. */
  6560. static Teal(): Color3;
  6561. /**
  6562. * Returns a Color3 value containing a random color
  6563. * @returns a new Color3 object
  6564. */
  6565. static Random(): Color3;
  6566. }
  6567. /**
  6568. * Class used to hold a RBGA color
  6569. */
  6570. export class Color4 {
  6571. /**
  6572. * Defines the red component (between 0 and 1, default is 0)
  6573. */
  6574. r: number;
  6575. /**
  6576. * Defines the green component (between 0 and 1, default is 0)
  6577. */
  6578. g: number;
  6579. /**
  6580. * Defines the blue component (between 0 and 1, default is 0)
  6581. */
  6582. b: number;
  6583. /**
  6584. * Defines the alpha component (between 0 and 1, default is 1)
  6585. */
  6586. a: number;
  6587. /**
  6588. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6589. * @param r defines the red component (between 0 and 1, default is 0)
  6590. * @param g defines the green component (between 0 and 1, default is 0)
  6591. * @param b defines the blue component (between 0 and 1, default is 0)
  6592. * @param a defines the alpha component (between 0 and 1, default is 1)
  6593. */
  6594. constructor(
  6595. /**
  6596. * Defines the red component (between 0 and 1, default is 0)
  6597. */
  6598. r?: number,
  6599. /**
  6600. * Defines the green component (between 0 and 1, default is 0)
  6601. */
  6602. g?: number,
  6603. /**
  6604. * Defines the blue component (between 0 and 1, default is 0)
  6605. */
  6606. b?: number,
  6607. /**
  6608. * Defines the alpha component (between 0 and 1, default is 1)
  6609. */
  6610. a?: number);
  6611. /**
  6612. * Adds in place the given Color4 values to the current Color4 object
  6613. * @param right defines the second operand
  6614. * @returns the current updated Color4 object
  6615. */
  6616. addInPlace(right: DeepImmutable<Color4>): Color4;
  6617. /**
  6618. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6619. * @returns the new array
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * Stores from the starting index in the given array the Color4 successive values
  6624. * @param array defines the array where to store the r,g,b components
  6625. * @param index defines an optional index in the target array to define where to start storing values
  6626. * @returns the current Color4 object
  6627. */
  6628. toArray(array: number[], index?: number): Color4;
  6629. /**
  6630. * Update the current color with values stored in an array from the starting index of the given array
  6631. * @param array defines the source array
  6632. * @param offset defines an offset in the source array
  6633. * @returns the current Color4 object
  6634. */
  6635. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6636. /**
  6637. * Determines equality between Color4 objects
  6638. * @param otherColor defines the second operand
  6639. * @returns true if the rgba values are equal to the given ones
  6640. */
  6641. equals(otherColor: DeepImmutable<Color4>): boolean;
  6642. /**
  6643. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6644. * @param right defines the second operand
  6645. * @returns a new Color4 object
  6646. */
  6647. add(right: DeepImmutable<Color4>): Color4;
  6648. /**
  6649. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6650. * @param right defines the second operand
  6651. * @returns a new Color4 object
  6652. */
  6653. subtract(right: DeepImmutable<Color4>): Color4;
  6654. /**
  6655. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6656. * @param right defines the second operand
  6657. * @param result defines the Color4 object where to store the result
  6658. * @returns the current Color4 object
  6659. */
  6660. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6661. /**
  6662. * Creates a new Color4 with the current Color4 values multiplied by scale
  6663. * @param scale defines the scaling factor to apply
  6664. * @returns a new Color4 object
  6665. */
  6666. scale(scale: number): Color4;
  6667. /**
  6668. * Multiplies the current Color4 values by scale and stores the result in "result"
  6669. * @param scale defines the scaling factor to apply
  6670. * @param result defines the Color4 object where to store the result
  6671. * @returns the current unmodified Color4
  6672. */
  6673. scaleToRef(scale: number, result: Color4): Color4;
  6674. /**
  6675. * Scale the current Color4 values by a factor and add the result to a given Color4
  6676. * @param scale defines the scale factor
  6677. * @param result defines the Color4 object where to store the result
  6678. * @returns the unmodified current Color4
  6679. */
  6680. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6681. /**
  6682. * Clamps the rgb values by the min and max values and stores the result into "result"
  6683. * @param min defines minimum clamping value (default is 0)
  6684. * @param max defines maximum clamping value (default is 1)
  6685. * @param result defines color to store the result into.
  6686. * @returns the cuurent Color4
  6687. */
  6688. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6689. /**
  6690. * Multipy an Color4 value by another and return a new Color4 object
  6691. * @param color defines the Color4 value to multiply by
  6692. * @returns a new Color4 object
  6693. */
  6694. multiply(color: Color4): Color4;
  6695. /**
  6696. * Multipy a Color4 value by another and push the result in a reference value
  6697. * @param color defines the Color4 value to multiply by
  6698. * @param result defines the Color4 to fill the result in
  6699. * @returns the result Color4
  6700. */
  6701. multiplyToRef(color: Color4, result: Color4): Color4;
  6702. /**
  6703. * Creates a string with the Color4 current values
  6704. * @returns the string representation of the Color4 object
  6705. */
  6706. toString(): string;
  6707. /**
  6708. * Returns the string "Color4"
  6709. * @returns "Color4"
  6710. */
  6711. getClassName(): string;
  6712. /**
  6713. * Compute the Color4 hash code
  6714. * @returns an unique number that can be used to hash Color4 objects
  6715. */
  6716. getHashCode(): number;
  6717. /**
  6718. * Creates a new Color4 copied from the current one
  6719. * @returns a new Color4 object
  6720. */
  6721. clone(): Color4;
  6722. /**
  6723. * Copies the given Color4 values into the current one
  6724. * @param source defines the source Color4 object
  6725. * @returns the current updated Color4 object
  6726. */
  6727. copyFrom(source: Color4): Color4;
  6728. /**
  6729. * Copies the given float values into the current one
  6730. * @param r defines the red component to read from
  6731. * @param g defines the green component to read from
  6732. * @param b defines the blue component to read from
  6733. * @param a defines the alpha component to read from
  6734. * @returns the current updated Color4 object
  6735. */
  6736. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6737. /**
  6738. * Copies the given float values into the current one
  6739. * @param r defines the red component to read from
  6740. * @param g defines the green component to read from
  6741. * @param b defines the blue component to read from
  6742. * @param a defines the alpha component to read from
  6743. * @returns the current updated Color4 object
  6744. */
  6745. set(r: number, g: number, b: number, a: number): Color4;
  6746. /**
  6747. * Compute the Color4 hexadecimal code as a string
  6748. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6749. * @returns a string containing the hexadecimal representation of the Color4 object
  6750. */
  6751. toHexString(returnAsColor3?: boolean): string;
  6752. /**
  6753. * Computes a new Color4 converted from the current one to linear space
  6754. * @returns a new Color4 object
  6755. */
  6756. toLinearSpace(): Color4;
  6757. /**
  6758. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6759. * @param convertedColor defines the Color4 object where to store the linear space version
  6760. * @returns the unmodified Color4
  6761. */
  6762. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6763. /**
  6764. * Computes a new Color4 converted from the current one to gamma space
  6765. * @returns a new Color4 object
  6766. */
  6767. toGammaSpace(): Color4;
  6768. /**
  6769. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6770. * @param convertedColor defines the Color4 object where to store the gamma space version
  6771. * @returns the unmodified Color4
  6772. */
  6773. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6774. /**
  6775. * Creates a new Color4 from the string containing valid hexadecimal values
  6776. * @param hex defines a string containing valid hexadecimal values
  6777. * @returns a new Color4 object
  6778. */
  6779. static FromHexString(hex: string): Color4;
  6780. /**
  6781. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6782. * @param left defines the start value
  6783. * @param right defines the end value
  6784. * @param amount defines the gradient factor
  6785. * @returns a new Color4 object
  6786. */
  6787. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6788. /**
  6789. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6790. * @param left defines the start value
  6791. * @param right defines the end value
  6792. * @param amount defines the gradient factor
  6793. * @param result defines the Color4 object where to store data
  6794. */
  6795. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6796. /**
  6797. * Creates a new Color4 from a Color3 and an alpha value
  6798. * @param color3 defines the source Color3 to read from
  6799. * @param alpha defines the alpha component (1.0 by default)
  6800. * @returns a new Color4 object
  6801. */
  6802. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6803. /**
  6804. * Creates a new Color4 from the starting index element of the given array
  6805. * @param array defines the source array to read from
  6806. * @param offset defines the offset in the source array
  6807. * @returns a new Color4 object
  6808. */
  6809. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6810. /**
  6811. * Creates a new Color4 from the starting index element of the given array
  6812. * @param array defines the source array to read from
  6813. * @param offset defines the offset in the source array
  6814. * @param result defines the target Color4 object
  6815. */
  6816. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6817. /**
  6818. * Creates a new Color3 from integer values (< 256)
  6819. * @param r defines the red component to read from (value between 0 and 255)
  6820. * @param g defines the green component to read from (value between 0 and 255)
  6821. * @param b defines the blue component to read from (value between 0 and 255)
  6822. * @param a defines the alpha component to read from (value between 0 and 255)
  6823. * @returns a new Color3 object
  6824. */
  6825. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6826. /**
  6827. * Check the content of a given array and convert it to an array containing RGBA data
  6828. * If the original array was already containing count * 4 values then it is returned directly
  6829. * @param colors defines the array to check
  6830. * @param count defines the number of RGBA data to expect
  6831. * @returns an array containing count * 4 values (RGBA)
  6832. */
  6833. static CheckColors4(colors: number[], count: number): number[];
  6834. }
  6835. /**
  6836. * @hidden
  6837. */
  6838. export class TmpColors {
  6839. static Color3: Color3[];
  6840. static Color4: Color4[];
  6841. }
  6842. }
  6843. declare module "babylonjs/Animations/animationKey" {
  6844. /**
  6845. * Defines an interface which represents an animation key frame
  6846. */
  6847. export interface IAnimationKey {
  6848. /**
  6849. * Frame of the key frame
  6850. */
  6851. frame: number;
  6852. /**
  6853. * Value at the specifies key frame
  6854. */
  6855. value: any;
  6856. /**
  6857. * The input tangent for the cubic hermite spline
  6858. */
  6859. inTangent?: any;
  6860. /**
  6861. * The output tangent for the cubic hermite spline
  6862. */
  6863. outTangent?: any;
  6864. /**
  6865. * The animation interpolation type
  6866. */
  6867. interpolation?: AnimationKeyInterpolation;
  6868. }
  6869. /**
  6870. * Enum for the animation key frame interpolation type
  6871. */
  6872. export enum AnimationKeyInterpolation {
  6873. /**
  6874. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6875. */
  6876. STEP = 1
  6877. }
  6878. }
  6879. declare module "babylonjs/Animations/animationRange" {
  6880. /**
  6881. * Represents the range of an animation
  6882. */
  6883. export class AnimationRange {
  6884. /**The name of the animation range**/
  6885. name: string;
  6886. /**The starting frame of the animation */
  6887. from: number;
  6888. /**The ending frame of the animation*/
  6889. to: number;
  6890. /**
  6891. * Initializes the range of an animation
  6892. * @param name The name of the animation range
  6893. * @param from The starting frame of the animation
  6894. * @param to The ending frame of the animation
  6895. */
  6896. constructor(
  6897. /**The name of the animation range**/
  6898. name: string,
  6899. /**The starting frame of the animation */
  6900. from: number,
  6901. /**The ending frame of the animation*/
  6902. to: number);
  6903. /**
  6904. * Makes a copy of the animation range
  6905. * @returns A copy of the animation range
  6906. */
  6907. clone(): AnimationRange;
  6908. }
  6909. }
  6910. declare module "babylonjs/Animations/animationEvent" {
  6911. /**
  6912. * Composed of a frame, and an action function
  6913. */
  6914. export class AnimationEvent {
  6915. /** The frame for which the event is triggered **/
  6916. frame: number;
  6917. /** The event to perform when triggered **/
  6918. action: (currentFrame: number) => void;
  6919. /** Specifies if the event should be triggered only once**/
  6920. onlyOnce?: boolean | undefined;
  6921. /**
  6922. * Specifies if the animation event is done
  6923. */
  6924. isDone: boolean;
  6925. /**
  6926. * Initializes the animation event
  6927. * @param frame The frame for which the event is triggered
  6928. * @param action The event to perform when triggered
  6929. * @param onlyOnce Specifies if the event should be triggered only once
  6930. */
  6931. constructor(
  6932. /** The frame for which the event is triggered **/
  6933. frame: number,
  6934. /** The event to perform when triggered **/
  6935. action: (currentFrame: number) => void,
  6936. /** Specifies if the event should be triggered only once**/
  6937. onlyOnce?: boolean | undefined);
  6938. /** @hidden */
  6939. _clone(): AnimationEvent;
  6940. }
  6941. }
  6942. declare module "babylonjs/Behaviors/behavior" {
  6943. import { Nullable } from "babylonjs/types";
  6944. /**
  6945. * Interface used to define a behavior
  6946. */
  6947. export interface Behavior<T> {
  6948. /** gets or sets behavior's name */
  6949. name: string;
  6950. /**
  6951. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6952. */
  6953. init(): void;
  6954. /**
  6955. * Called when the behavior is attached to a target
  6956. * @param target defines the target where the behavior is attached to
  6957. */
  6958. attach(target: T): void;
  6959. /**
  6960. * Called when the behavior is detached from its target
  6961. */
  6962. detach(): void;
  6963. }
  6964. /**
  6965. * Interface implemented by classes supporting behaviors
  6966. */
  6967. export interface IBehaviorAware<T> {
  6968. /**
  6969. * Attach a behavior
  6970. * @param behavior defines the behavior to attach
  6971. * @returns the current host
  6972. */
  6973. addBehavior(behavior: Behavior<T>): T;
  6974. /**
  6975. * Remove a behavior from the current object
  6976. * @param behavior defines the behavior to detach
  6977. * @returns the current host
  6978. */
  6979. removeBehavior(behavior: Behavior<T>): T;
  6980. /**
  6981. * Gets a behavior using its name to search
  6982. * @param name defines the name to search
  6983. * @returns the behavior or null if not found
  6984. */
  6985. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6986. }
  6987. }
  6988. declare module "babylonjs/Misc/sliceTools" {
  6989. /**
  6990. * Class used to provide helpers for slicing
  6991. */
  6992. export class SliceTools {
  6993. /**
  6994. * Provides a slice function that will work even on IE
  6995. * @param data defines the array to slice
  6996. * @param start defines the start of the data (optional)
  6997. * @param end defines the end of the data (optional)
  6998. * @returns the new sliced array
  6999. */
  7000. static Slice<T>(data: T, start?: number, end?: number): T;
  7001. /**
  7002. * Provides a slice function that will work even on IE
  7003. * The difference between this and Slice is that this will force-convert to array
  7004. * @param data defines the array to slice
  7005. * @param start defines the start of the data (optional)
  7006. * @param end defines the end of the data (optional)
  7007. * @returns the new sliced array
  7008. */
  7009. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  7010. }
  7011. }
  7012. declare module "babylonjs/Meshes/buffer" {
  7013. import { Nullable, DataArray, FloatArray } from "babylonjs/types";
  7014. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7015. /**
  7016. * Class used to store data that will be store in GPU memory
  7017. */
  7018. export class Buffer {
  7019. private _engine;
  7020. private _buffer;
  7021. /** @hidden */
  7022. _data: Nullable<DataArray>;
  7023. private _updatable;
  7024. private _instanced;
  7025. private _divisor;
  7026. private _isAlreadyOwned;
  7027. /**
  7028. * Gets the byte stride.
  7029. */
  7030. readonly byteStride: number;
  7031. /**
  7032. * Constructor
  7033. * @param engine the engine
  7034. * @param data the data to use for this buffer
  7035. * @param updatable whether the data is updatable
  7036. * @param stride the stride (optional)
  7037. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7038. * @param instanced whether the buffer is instanced (optional)
  7039. * @param useBytes set to true if the stride in in bytes (optional)
  7040. * @param divisor sets an optional divisor for instances (1 by default)
  7041. */
  7042. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  7043. /**
  7044. * Create a new VertexBuffer based on the current buffer
  7045. * @param kind defines the vertex buffer kind (position, normal, etc.)
  7046. * @param offset defines offset in the buffer (0 by default)
  7047. * @param size defines the size in floats of attributes (position is 3 for instance)
  7048. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7049. * @param instanced defines if the vertex buffer contains indexed data
  7050. * @param useBytes defines if the offset and stride are in bytes *
  7051. * @param divisor sets an optional divisor for instances (1 by default)
  7052. * @returns the new vertex buffer
  7053. */
  7054. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7055. /**
  7056. * Gets a boolean indicating if the Buffer is updatable?
  7057. * @returns true if the buffer is updatable
  7058. */
  7059. isUpdatable(): boolean;
  7060. /**
  7061. * Gets current buffer's data
  7062. * @returns a DataArray or null
  7063. */
  7064. getData(): Nullable<DataArray>;
  7065. /**
  7066. * Gets underlying native buffer
  7067. * @returns underlying native buffer
  7068. */
  7069. getBuffer(): Nullable<DataBuffer>;
  7070. /**
  7071. * Gets the stride in float32 units (i.e. byte stride / 4).
  7072. * May not be an integer if the byte stride is not divisible by 4.
  7073. * @returns the stride in float32 units
  7074. * @deprecated Please use byteStride instead.
  7075. */
  7076. getStrideSize(): number;
  7077. /**
  7078. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7079. * @param data defines the data to store
  7080. */
  7081. create(data?: Nullable<DataArray>): void;
  7082. /** @hidden */
  7083. _rebuild(): void;
  7084. /**
  7085. * Update current buffer data
  7086. * @param data defines the data to store
  7087. */
  7088. update(data: DataArray): void;
  7089. /**
  7090. * Updates the data directly.
  7091. * @param data the new data
  7092. * @param offset the new offset
  7093. * @param vertexCount the vertex count (optional)
  7094. * @param useBytes set to true if the offset is in bytes
  7095. */
  7096. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7097. /** @hidden */
  7098. _increaseReferences(): void;
  7099. /**
  7100. * Release all resources
  7101. */
  7102. dispose(): void;
  7103. }
  7104. /**
  7105. * Specialized buffer used to store vertex data
  7106. */
  7107. export class VertexBuffer {
  7108. private static _Counter;
  7109. /** @hidden */
  7110. _buffer: Buffer;
  7111. private _kind;
  7112. private _size;
  7113. private _ownsBuffer;
  7114. private _instanced;
  7115. private _instanceDivisor;
  7116. /**
  7117. * The byte type.
  7118. */
  7119. static readonly BYTE: number;
  7120. /**
  7121. * The unsigned byte type.
  7122. */
  7123. static readonly UNSIGNED_BYTE: number;
  7124. /**
  7125. * The short type.
  7126. */
  7127. static readonly SHORT: number;
  7128. /**
  7129. * The unsigned short type.
  7130. */
  7131. static readonly UNSIGNED_SHORT: number;
  7132. /**
  7133. * The integer type.
  7134. */
  7135. static readonly INT: number;
  7136. /**
  7137. * The unsigned integer type.
  7138. */
  7139. static readonly UNSIGNED_INT: number;
  7140. /**
  7141. * The float type.
  7142. */
  7143. static readonly FLOAT: number;
  7144. /**
  7145. * Gets or sets the instance divisor when in instanced mode
  7146. */
  7147. get instanceDivisor(): number;
  7148. set instanceDivisor(value: number);
  7149. /**
  7150. * Gets the byte stride.
  7151. */
  7152. readonly byteStride: number;
  7153. /**
  7154. * Gets the byte offset.
  7155. */
  7156. readonly byteOffset: number;
  7157. /**
  7158. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7159. */
  7160. readonly normalized: boolean;
  7161. /**
  7162. * Gets the data type of each component in the array.
  7163. */
  7164. readonly type: number;
  7165. /**
  7166. * Gets the unique id of this vertex buffer
  7167. */
  7168. readonly uniqueId: number;
  7169. /**
  7170. * Constructor
  7171. * @param engine the engine
  7172. * @param data the data to use for this vertex buffer
  7173. * @param kind the vertex buffer kind
  7174. * @param updatable whether the data is updatable
  7175. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7176. * @param stride the stride (optional)
  7177. * @param instanced whether the buffer is instanced (optional)
  7178. * @param offset the offset of the data (optional)
  7179. * @param size the number of components (optional)
  7180. * @param type the type of the component (optional)
  7181. * @param normalized whether the data contains normalized data (optional)
  7182. * @param useBytes set to true if stride and offset are in bytes (optional)
  7183. * @param divisor defines the instance divisor to use (1 by default)
  7184. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7185. */
  7186. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7187. /** @hidden */
  7188. _rebuild(): void;
  7189. /**
  7190. * Returns the kind of the VertexBuffer (string)
  7191. * @returns a string
  7192. */
  7193. getKind(): string;
  7194. /**
  7195. * Gets a boolean indicating if the VertexBuffer is updatable?
  7196. * @returns true if the buffer is updatable
  7197. */
  7198. isUpdatable(): boolean;
  7199. /**
  7200. * Gets current buffer's data
  7201. * @returns a DataArray or null
  7202. */
  7203. getData(): Nullable<DataArray>;
  7204. /**
  7205. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7206. * @param totalVertices number of vertices in the buffer to take into account
  7207. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7208. * @returns a float array containing vertex data
  7209. */
  7210. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7211. /**
  7212. * Gets underlying native buffer
  7213. * @returns underlying native buffer
  7214. */
  7215. getBuffer(): Nullable<DataBuffer>;
  7216. /**
  7217. * Gets the stride in float32 units (i.e. byte stride / 4).
  7218. * May not be an integer if the byte stride is not divisible by 4.
  7219. * @returns the stride in float32 units
  7220. * @deprecated Please use byteStride instead.
  7221. */
  7222. getStrideSize(): number;
  7223. /**
  7224. * Returns the offset as a multiple of the type byte length.
  7225. * @returns the offset in bytes
  7226. * @deprecated Please use byteOffset instead.
  7227. */
  7228. getOffset(): number;
  7229. /**
  7230. * Returns the number of components per vertex attribute (integer)
  7231. * @returns the size in float
  7232. */
  7233. getSize(): number;
  7234. /**
  7235. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7236. * @returns true if this buffer is instanced
  7237. */
  7238. getIsInstanced(): boolean;
  7239. /**
  7240. * Returns the instancing divisor, zero for non-instanced (integer).
  7241. * @returns a number
  7242. */
  7243. getInstanceDivisor(): number;
  7244. /**
  7245. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7246. * @param data defines the data to store
  7247. */
  7248. create(data?: DataArray): void;
  7249. /**
  7250. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7251. * This function will create a new buffer if the current one is not updatable
  7252. * @param data defines the data to store
  7253. */
  7254. update(data: DataArray): void;
  7255. /**
  7256. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7257. * Returns the directly updated WebGLBuffer.
  7258. * @param data the new data
  7259. * @param offset the new offset
  7260. * @param useBytes set to true if the offset is in bytes
  7261. */
  7262. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7263. /**
  7264. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7265. */
  7266. dispose(): void;
  7267. /**
  7268. * Enumerates each value of this vertex buffer as numbers.
  7269. * @param count the number of values to enumerate
  7270. * @param callback the callback function called for each value
  7271. */
  7272. forEach(count: number, callback: (value: number, index: number) => void): void;
  7273. /**
  7274. * Positions
  7275. */
  7276. static readonly PositionKind: string;
  7277. /**
  7278. * Normals
  7279. */
  7280. static readonly NormalKind: string;
  7281. /**
  7282. * Tangents
  7283. */
  7284. static readonly TangentKind: string;
  7285. /**
  7286. * Texture coordinates
  7287. */
  7288. static readonly UVKind: string;
  7289. /**
  7290. * Texture coordinates 2
  7291. */
  7292. static readonly UV2Kind: string;
  7293. /**
  7294. * Texture coordinates 3
  7295. */
  7296. static readonly UV3Kind: string;
  7297. /**
  7298. * Texture coordinates 4
  7299. */
  7300. static readonly UV4Kind: string;
  7301. /**
  7302. * Texture coordinates 5
  7303. */
  7304. static readonly UV5Kind: string;
  7305. /**
  7306. * Texture coordinates 6
  7307. */
  7308. static readonly UV6Kind: string;
  7309. /**
  7310. * Colors
  7311. */
  7312. static readonly ColorKind: string;
  7313. /**
  7314. * Matrix indices (for bones)
  7315. */
  7316. static readonly MatricesIndicesKind: string;
  7317. /**
  7318. * Matrix weights (for bones)
  7319. */
  7320. static readonly MatricesWeightsKind: string;
  7321. /**
  7322. * Additional matrix indices (for bones)
  7323. */
  7324. static readonly MatricesIndicesExtraKind: string;
  7325. /**
  7326. * Additional matrix weights (for bones)
  7327. */
  7328. static readonly MatricesWeightsExtraKind: string;
  7329. /**
  7330. * Deduces the stride given a kind.
  7331. * @param kind The kind string to deduce
  7332. * @returns The deduced stride
  7333. */
  7334. static DeduceStride(kind: string): number;
  7335. /**
  7336. * Gets the byte length of the given type.
  7337. * @param type the type
  7338. * @returns the number of bytes
  7339. */
  7340. static GetTypeByteLength(type: number): number;
  7341. /**
  7342. * Enumerates each value of the given parameters as numbers.
  7343. * @param data the data to enumerate
  7344. * @param byteOffset the byte offset of the data
  7345. * @param byteStride the byte stride of the data
  7346. * @param componentCount the number of components per element
  7347. * @param componentType the type of the component
  7348. * @param count the number of values to enumerate
  7349. * @param normalized whether the data is normalized
  7350. * @param callback the callback function called for each value
  7351. */
  7352. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7353. private static _GetFloatValue;
  7354. }
  7355. }
  7356. declare module "babylonjs/Collisions/intersectionInfo" {
  7357. import { Nullable } from "babylonjs/types";
  7358. /**
  7359. * @hidden
  7360. */
  7361. export class IntersectionInfo {
  7362. bu: Nullable<number>;
  7363. bv: Nullable<number>;
  7364. distance: number;
  7365. faceId: number;
  7366. subMeshId: number;
  7367. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7368. }
  7369. }
  7370. declare module "babylonjs/Culling/boundingSphere" {
  7371. import { DeepImmutable } from "babylonjs/types";
  7372. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7373. import { Plane } from "babylonjs/Maths/math.plane";
  7374. /**
  7375. * Class used to store bounding sphere information
  7376. */
  7377. export class BoundingSphere {
  7378. /**
  7379. * Gets the center of the bounding sphere in local space
  7380. */
  7381. readonly center: Vector3;
  7382. /**
  7383. * Radius of the bounding sphere in local space
  7384. */
  7385. radius: number;
  7386. /**
  7387. * Gets the center of the bounding sphere in world space
  7388. */
  7389. readonly centerWorld: Vector3;
  7390. /**
  7391. * Radius of the bounding sphere in world space
  7392. */
  7393. radiusWorld: number;
  7394. /**
  7395. * Gets the minimum vector in local space
  7396. */
  7397. readonly minimum: Vector3;
  7398. /**
  7399. * Gets the maximum vector in local space
  7400. */
  7401. readonly maximum: Vector3;
  7402. private _worldMatrix;
  7403. private static readonly TmpVector3;
  7404. /**
  7405. * Creates a new bounding sphere
  7406. * @param min defines the minimum vector (in local space)
  7407. * @param max defines the maximum vector (in local space)
  7408. * @param worldMatrix defines the new world matrix
  7409. */
  7410. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7411. /**
  7412. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7413. * @param min defines the new minimum vector (in local space)
  7414. * @param max defines the new maximum vector (in local space)
  7415. * @param worldMatrix defines the new world matrix
  7416. */
  7417. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7418. /**
  7419. * Scale the current bounding sphere by applying a scale factor
  7420. * @param factor defines the scale factor to apply
  7421. * @returns the current bounding box
  7422. */
  7423. scale(factor: number): BoundingSphere;
  7424. /**
  7425. * Gets the world matrix of the bounding box
  7426. * @returns a matrix
  7427. */
  7428. getWorldMatrix(): DeepImmutable<Matrix>;
  7429. /** @hidden */
  7430. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7431. /**
  7432. * Tests if the bounding sphere is intersecting the frustum planes
  7433. * @param frustumPlanes defines the frustum planes to test
  7434. * @returns true if there is an intersection
  7435. */
  7436. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7437. /**
  7438. * Tests if the bounding sphere center is in between the frustum planes.
  7439. * Used for optimistic fast inclusion.
  7440. * @param frustumPlanes defines the frustum planes to test
  7441. * @returns true if the sphere center is in between the frustum planes
  7442. */
  7443. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7444. /**
  7445. * Tests if a point is inside the bounding sphere
  7446. * @param point defines the point to test
  7447. * @returns true if the point is inside the bounding sphere
  7448. */
  7449. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7450. /**
  7451. * Checks if two sphere intersct
  7452. * @param sphere0 sphere 0
  7453. * @param sphere1 sphere 1
  7454. * @returns true if the speres intersect
  7455. */
  7456. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7457. }
  7458. }
  7459. declare module "babylonjs/Culling/boundingBox" {
  7460. import { DeepImmutable } from "babylonjs/types";
  7461. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7462. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7463. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7464. import { Plane } from "babylonjs/Maths/math.plane";
  7465. /**
  7466. * Class used to store bounding box information
  7467. */
  7468. export class BoundingBox implements ICullable {
  7469. /**
  7470. * Gets the 8 vectors representing the bounding box in local space
  7471. */
  7472. readonly vectors: Vector3[];
  7473. /**
  7474. * Gets the center of the bounding box in local space
  7475. */
  7476. readonly center: Vector3;
  7477. /**
  7478. * Gets the center of the bounding box in world space
  7479. */
  7480. readonly centerWorld: Vector3;
  7481. /**
  7482. * Gets the extend size in local space
  7483. */
  7484. readonly extendSize: Vector3;
  7485. /**
  7486. * Gets the extend size in world space
  7487. */
  7488. readonly extendSizeWorld: Vector3;
  7489. /**
  7490. * Gets the OBB (object bounding box) directions
  7491. */
  7492. readonly directions: Vector3[];
  7493. /**
  7494. * Gets the 8 vectors representing the bounding box in world space
  7495. */
  7496. readonly vectorsWorld: Vector3[];
  7497. /**
  7498. * Gets the minimum vector in world space
  7499. */
  7500. readonly minimumWorld: Vector3;
  7501. /**
  7502. * Gets the maximum vector in world space
  7503. */
  7504. readonly maximumWorld: Vector3;
  7505. /**
  7506. * Gets the minimum vector in local space
  7507. */
  7508. readonly minimum: Vector3;
  7509. /**
  7510. * Gets the maximum vector in local space
  7511. */
  7512. readonly maximum: Vector3;
  7513. private _worldMatrix;
  7514. private static readonly TmpVector3;
  7515. /**
  7516. * @hidden
  7517. */
  7518. _tag: number;
  7519. /**
  7520. * Creates a new bounding box
  7521. * @param min defines the minimum vector (in local space)
  7522. * @param max defines the maximum vector (in local space)
  7523. * @param worldMatrix defines the new world matrix
  7524. */
  7525. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7526. /**
  7527. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7528. * @param min defines the new minimum vector (in local space)
  7529. * @param max defines the new maximum vector (in local space)
  7530. * @param worldMatrix defines the new world matrix
  7531. */
  7532. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7533. /**
  7534. * Scale the current bounding box by applying a scale factor
  7535. * @param factor defines the scale factor to apply
  7536. * @returns the current bounding box
  7537. */
  7538. scale(factor: number): BoundingBox;
  7539. /**
  7540. * Gets the world matrix of the bounding box
  7541. * @returns a matrix
  7542. */
  7543. getWorldMatrix(): DeepImmutable<Matrix>;
  7544. /** @hidden */
  7545. _update(world: DeepImmutable<Matrix>): void;
  7546. /**
  7547. * Tests if the bounding box is intersecting the frustum planes
  7548. * @param frustumPlanes defines the frustum planes to test
  7549. * @returns true if there is an intersection
  7550. */
  7551. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7552. /**
  7553. * Tests if the bounding box is entirely inside the frustum planes
  7554. * @param frustumPlanes defines the frustum planes to test
  7555. * @returns true if there is an inclusion
  7556. */
  7557. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7558. /**
  7559. * Tests if a point is inside the bounding box
  7560. * @param point defines the point to test
  7561. * @returns true if the point is inside the bounding box
  7562. */
  7563. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7564. /**
  7565. * Tests if the bounding box intersects with a bounding sphere
  7566. * @param sphere defines the sphere to test
  7567. * @returns true if there is an intersection
  7568. */
  7569. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7570. /**
  7571. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7572. * @param min defines the min vector to use
  7573. * @param max defines the max vector to use
  7574. * @returns true if there is an intersection
  7575. */
  7576. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7577. /**
  7578. * Tests if two bounding boxes are intersections
  7579. * @param box0 defines the first box to test
  7580. * @param box1 defines the second box to test
  7581. * @returns true if there is an intersection
  7582. */
  7583. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7584. /**
  7585. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7586. * @param minPoint defines the minimum vector of the bounding box
  7587. * @param maxPoint defines the maximum vector of the bounding box
  7588. * @param sphereCenter defines the sphere center
  7589. * @param sphereRadius defines the sphere radius
  7590. * @returns true if there is an intersection
  7591. */
  7592. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7593. /**
  7594. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7595. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7596. * @param frustumPlanes defines the frustum planes to test
  7597. * @return true if there is an inclusion
  7598. */
  7599. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7600. /**
  7601. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7602. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7603. * @param frustumPlanes defines the frustum planes to test
  7604. * @return true if there is an intersection
  7605. */
  7606. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7607. }
  7608. }
  7609. declare module "babylonjs/Collisions/collider" {
  7610. import { Nullable, IndicesArray } from "babylonjs/types";
  7611. import { Vector3 } from "babylonjs/Maths/math.vector";
  7612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7613. import { Plane } from "babylonjs/Maths/math.plane";
  7614. /** @hidden */
  7615. export class Collider {
  7616. /** Define if a collision was found */
  7617. collisionFound: boolean;
  7618. /**
  7619. * Define last intersection point in local space
  7620. */
  7621. intersectionPoint: Vector3;
  7622. /**
  7623. * Define last collided mesh
  7624. */
  7625. collidedMesh: Nullable<AbstractMesh>;
  7626. private _collisionPoint;
  7627. private _planeIntersectionPoint;
  7628. private _tempVector;
  7629. private _tempVector2;
  7630. private _tempVector3;
  7631. private _tempVector4;
  7632. private _edge;
  7633. private _baseToVertex;
  7634. private _destinationPoint;
  7635. private _slidePlaneNormal;
  7636. private _displacementVector;
  7637. /** @hidden */
  7638. _radius: Vector3;
  7639. /** @hidden */
  7640. _retry: number;
  7641. private _velocity;
  7642. private _basePoint;
  7643. private _epsilon;
  7644. /** @hidden */
  7645. _velocityWorldLength: number;
  7646. /** @hidden */
  7647. _basePointWorld: Vector3;
  7648. private _velocityWorld;
  7649. private _normalizedVelocity;
  7650. /** @hidden */
  7651. _initialVelocity: Vector3;
  7652. /** @hidden */
  7653. _initialPosition: Vector3;
  7654. private _nearestDistance;
  7655. private _collisionMask;
  7656. get collisionMask(): number;
  7657. set collisionMask(mask: number);
  7658. /**
  7659. * Gets the plane normal used to compute the sliding response (in local space)
  7660. */
  7661. get slidePlaneNormal(): Vector3;
  7662. /** @hidden */
  7663. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7664. /** @hidden */
  7665. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7666. /** @hidden */
  7667. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7668. /** @hidden */
  7669. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7670. /** @hidden */
  7671. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7672. /** @hidden */
  7673. _getResponse(pos: Vector3, vel: Vector3): void;
  7674. }
  7675. }
  7676. declare module "babylonjs/Culling/boundingInfo" {
  7677. import { DeepImmutable } from "babylonjs/types";
  7678. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7679. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7680. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7681. import { Plane } from "babylonjs/Maths/math.plane";
  7682. import { Collider } from "babylonjs/Collisions/collider";
  7683. /**
  7684. * Interface for cullable objects
  7685. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7686. */
  7687. export interface ICullable {
  7688. /**
  7689. * Checks if the object or part of the object is in the frustum
  7690. * @param frustumPlanes Camera near/planes
  7691. * @returns true if the object is in frustum otherwise false
  7692. */
  7693. isInFrustum(frustumPlanes: Plane[]): boolean;
  7694. /**
  7695. * Checks if a cullable object (mesh...) is in the camera frustum
  7696. * Unlike isInFrustum this cheks the full bounding box
  7697. * @param frustumPlanes Camera near/planes
  7698. * @returns true if the object is in frustum otherwise false
  7699. */
  7700. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7701. }
  7702. /**
  7703. * Info for a bounding data of a mesh
  7704. */
  7705. export class BoundingInfo implements ICullable {
  7706. /**
  7707. * Bounding box for the mesh
  7708. */
  7709. readonly boundingBox: BoundingBox;
  7710. /**
  7711. * Bounding sphere for the mesh
  7712. */
  7713. readonly boundingSphere: BoundingSphere;
  7714. private _isLocked;
  7715. private static readonly TmpVector3;
  7716. /**
  7717. * Constructs bounding info
  7718. * @param minimum min vector of the bounding box/sphere
  7719. * @param maximum max vector of the bounding box/sphere
  7720. * @param worldMatrix defines the new world matrix
  7721. */
  7722. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7723. /**
  7724. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7725. * @param min defines the new minimum vector (in local space)
  7726. * @param max defines the new maximum vector (in local space)
  7727. * @param worldMatrix defines the new world matrix
  7728. */
  7729. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7730. /**
  7731. * min vector of the bounding box/sphere
  7732. */
  7733. get minimum(): Vector3;
  7734. /**
  7735. * max vector of the bounding box/sphere
  7736. */
  7737. get maximum(): Vector3;
  7738. /**
  7739. * If the info is locked and won't be updated to avoid perf overhead
  7740. */
  7741. get isLocked(): boolean;
  7742. set isLocked(value: boolean);
  7743. /**
  7744. * Updates the bounding sphere and box
  7745. * @param world world matrix to be used to update
  7746. */
  7747. update(world: DeepImmutable<Matrix>): void;
  7748. /**
  7749. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7750. * @param center New center of the bounding info
  7751. * @param extend New extend of the bounding info
  7752. * @returns the current bounding info
  7753. */
  7754. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7755. /**
  7756. * Grows the bounding info to include the given point.
  7757. * @param point The point that will be included in the current bounding info
  7758. * @returns the current bounding info
  7759. */
  7760. encapsulate(point: Vector3): BoundingInfo;
  7761. /**
  7762. * Grows the bounding info to encapsulate the given bounding info.
  7763. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7764. * @returns the current bounding info
  7765. */
  7766. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7767. /**
  7768. * Scale the current bounding info by applying a scale factor
  7769. * @param factor defines the scale factor to apply
  7770. * @returns the current bounding info
  7771. */
  7772. scale(factor: number): BoundingInfo;
  7773. /**
  7774. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7775. * @param frustumPlanes defines the frustum to test
  7776. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7777. * @returns true if the bounding info is in the frustum planes
  7778. */
  7779. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7780. /**
  7781. * Gets the world distance between the min and max points of the bounding box
  7782. */
  7783. get diagonalLength(): number;
  7784. /**
  7785. * Checks if a cullable object (mesh...) is in the camera frustum
  7786. * Unlike isInFrustum this cheks the full bounding box
  7787. * @param frustumPlanes Camera near/planes
  7788. * @returns true if the object is in frustum otherwise false
  7789. */
  7790. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7791. /** @hidden */
  7792. _checkCollision(collider: Collider): boolean;
  7793. /**
  7794. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7795. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7796. * @param point the point to check intersection with
  7797. * @returns if the point intersects
  7798. */
  7799. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7800. /**
  7801. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7802. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7803. * @param boundingInfo the bounding info to check intersection with
  7804. * @param precise if the intersection should be done using OBB
  7805. * @returns if the bounding info intersects
  7806. */
  7807. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7808. }
  7809. }
  7810. declare module "babylonjs/Maths/math.functions" {
  7811. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7812. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7813. /**
  7814. * Extracts minimum and maximum values from a list of indexed positions
  7815. * @param positions defines the positions to use
  7816. * @param indices defines the indices to the positions
  7817. * @param indexStart defines the start index
  7818. * @param indexCount defines the end index
  7819. * @param bias defines bias value to add to the result
  7820. * @return minimum and maximum values
  7821. */
  7822. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7823. minimum: Vector3;
  7824. maximum: Vector3;
  7825. };
  7826. /**
  7827. * Extracts minimum and maximum values from a list of positions
  7828. * @param positions defines the positions to use
  7829. * @param start defines the start index in the positions array
  7830. * @param count defines the number of positions to handle
  7831. * @param bias defines bias value to add to the result
  7832. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7833. * @return minimum and maximum values
  7834. */
  7835. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7836. minimum: Vector3;
  7837. maximum: Vector3;
  7838. };
  7839. }
  7840. declare module "babylonjs/Misc/guid" {
  7841. /**
  7842. * Class used to manipulate GUIDs
  7843. */
  7844. export class GUID {
  7845. /**
  7846. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7847. * Be aware Math.random() could cause collisions, but:
  7848. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  7849. * @returns a pseudo random id
  7850. */
  7851. static RandomId(): string;
  7852. }
  7853. }
  7854. declare module "babylonjs/Materials/Textures/baseTexture" {
  7855. import { Observable } from "babylonjs/Misc/observable";
  7856. import { Nullable } from "babylonjs/types";
  7857. import { Scene } from "babylonjs/scene";
  7858. import { Matrix } from "babylonjs/Maths/math.vector";
  7859. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7860. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7861. import "babylonjs/Misc/fileTools";
  7862. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7863. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7864. /**
  7865. * Base class of all the textures in babylon.
  7866. * It groups all the common properties the materials, post process, lights... might need
  7867. * in order to make a correct use of the texture.
  7868. */
  7869. export class BaseTexture extends ThinTexture implements IAnimatable {
  7870. /**
  7871. * Default anisotropic filtering level for the application.
  7872. * It is set to 4 as a good tradeoff between perf and quality.
  7873. */
  7874. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7875. /**
  7876. * Gets or sets the unique id of the texture
  7877. */
  7878. uniqueId: number;
  7879. /**
  7880. * Define the name of the texture.
  7881. */
  7882. name: string;
  7883. /**
  7884. * Gets or sets an object used to store user defined information.
  7885. */
  7886. metadata: any;
  7887. /**
  7888. * For internal use only. Please do not use.
  7889. */
  7890. reservedDataStore: any;
  7891. private _hasAlpha;
  7892. /**
  7893. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7894. */
  7895. set hasAlpha(value: boolean);
  7896. get hasAlpha(): boolean;
  7897. /**
  7898. * Defines if the alpha value should be determined via the rgb values.
  7899. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7900. */
  7901. getAlphaFromRGB: boolean;
  7902. /**
  7903. * Intensity or strength of the texture.
  7904. * It is commonly used by materials to fine tune the intensity of the texture
  7905. */
  7906. level: number;
  7907. /**
  7908. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7909. * This is part of the texture as textures usually maps to one uv set.
  7910. */
  7911. coordinatesIndex: number;
  7912. protected _coordinatesMode: number;
  7913. /**
  7914. * How a texture is mapped.
  7915. *
  7916. * | Value | Type | Description |
  7917. * | ----- | ----------------------------------- | ----------- |
  7918. * | 0 | EXPLICIT_MODE | |
  7919. * | 1 | SPHERICAL_MODE | |
  7920. * | 2 | PLANAR_MODE | |
  7921. * | 3 | CUBIC_MODE | |
  7922. * | 4 | PROJECTION_MODE | |
  7923. * | 5 | SKYBOX_MODE | |
  7924. * | 6 | INVCUBIC_MODE | |
  7925. * | 7 | EQUIRECTANGULAR_MODE | |
  7926. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7927. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7928. */
  7929. set coordinatesMode(value: number);
  7930. get coordinatesMode(): number;
  7931. /**
  7932. * | Value | Type | Description |
  7933. * | ----- | ------------------ | ----------- |
  7934. * | 0 | CLAMP_ADDRESSMODE | |
  7935. * | 1 | WRAP_ADDRESSMODE | |
  7936. * | 2 | MIRROR_ADDRESSMODE | |
  7937. */
  7938. get wrapU(): number;
  7939. set wrapU(value: number);
  7940. /**
  7941. * | Value | Type | Description |
  7942. * | ----- | ------------------ | ----------- |
  7943. * | 0 | CLAMP_ADDRESSMODE | |
  7944. * | 1 | WRAP_ADDRESSMODE | |
  7945. * | 2 | MIRROR_ADDRESSMODE | |
  7946. */
  7947. get wrapV(): number;
  7948. set wrapV(value: number);
  7949. /**
  7950. * | Value | Type | Description |
  7951. * | ----- | ------------------ | ----------- |
  7952. * | 0 | CLAMP_ADDRESSMODE | |
  7953. * | 1 | WRAP_ADDRESSMODE | |
  7954. * | 2 | MIRROR_ADDRESSMODE | |
  7955. */
  7956. wrapR: number;
  7957. /**
  7958. * With compliant hardware and browser (supporting anisotropic filtering)
  7959. * this defines the level of anisotropic filtering in the texture.
  7960. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7961. */
  7962. anisotropicFilteringLevel: number;
  7963. private _isCube;
  7964. /**
  7965. * Define if the texture is a cube texture or if false a 2d texture.
  7966. */
  7967. get isCube(): boolean;
  7968. set isCube(value: boolean);
  7969. /**
  7970. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7971. */
  7972. get is3D(): boolean;
  7973. set is3D(value: boolean);
  7974. /**
  7975. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7976. */
  7977. get is2DArray(): boolean;
  7978. set is2DArray(value: boolean);
  7979. private _gammaSpace;
  7980. /**
  7981. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7982. * HDR texture are usually stored in linear space.
  7983. * This only impacts the PBR and Background materials
  7984. */
  7985. get gammaSpace(): boolean;
  7986. set gammaSpace(gamma: boolean);
  7987. /**
  7988. * Gets or sets whether or not the texture contains RGBD data.
  7989. */
  7990. get isRGBD(): boolean;
  7991. set isRGBD(value: boolean);
  7992. /**
  7993. * Is Z inverted in the texture (useful in a cube texture).
  7994. */
  7995. invertZ: boolean;
  7996. /**
  7997. * Are mip maps generated for this texture or not.
  7998. */
  7999. get noMipmap(): boolean;
  8000. /**
  8001. * @hidden
  8002. */
  8003. lodLevelInAlpha: boolean;
  8004. /**
  8005. * With prefiltered texture, defined the offset used during the prefiltering steps.
  8006. */
  8007. get lodGenerationOffset(): number;
  8008. set lodGenerationOffset(value: number);
  8009. /**
  8010. * With prefiltered texture, defined the scale used during the prefiltering steps.
  8011. */
  8012. get lodGenerationScale(): number;
  8013. set lodGenerationScale(value: number);
  8014. /**
  8015. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  8016. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  8017. * average roughness values.
  8018. */
  8019. get linearSpecularLOD(): boolean;
  8020. set linearSpecularLOD(value: boolean);
  8021. /**
  8022. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  8023. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  8024. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  8025. */
  8026. get irradianceTexture(): Nullable<BaseTexture>;
  8027. set irradianceTexture(value: Nullable<BaseTexture>);
  8028. /**
  8029. * Define if the texture is a render target.
  8030. */
  8031. isRenderTarget: boolean;
  8032. /**
  8033. * Define the unique id of the texture in the scene.
  8034. */
  8035. get uid(): string;
  8036. /** @hidden */
  8037. _prefiltered: boolean;
  8038. /**
  8039. * Return a string representation of the texture.
  8040. * @returns the texture as a string
  8041. */
  8042. toString(): string;
  8043. /**
  8044. * Get the class name of the texture.
  8045. * @returns "BaseTexture"
  8046. */
  8047. getClassName(): string;
  8048. /**
  8049. * Define the list of animation attached to the texture.
  8050. */
  8051. animations: import("babylonjs/Animations/animation").Animation[];
  8052. /**
  8053. * An event triggered when the texture is disposed.
  8054. */
  8055. onDisposeObservable: Observable<BaseTexture>;
  8056. private _onDisposeObserver;
  8057. /**
  8058. * Callback triggered when the texture has been disposed.
  8059. * Kept for back compatibility, you can use the onDisposeObservable instead.
  8060. */
  8061. set onDispose(callback: () => void);
  8062. protected _scene: Nullable<Scene>;
  8063. /** @hidden */
  8064. _texture: Nullable<InternalTexture>;
  8065. private _uid;
  8066. /**
  8067. * Define if the texture is preventinga material to render or not.
  8068. * If not and the texture is not ready, the engine will use a default black texture instead.
  8069. */
  8070. get isBlocking(): boolean;
  8071. /**
  8072. * Instantiates a new BaseTexture.
  8073. * Base class of all the textures in babylon.
  8074. * It groups all the common properties the materials, post process, lights... might need
  8075. * in order to make a correct use of the texture.
  8076. * @param sceneOrEngine Define the scene or engine the texture blongs to
  8077. */
  8078. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8079. /**
  8080. * Get the scene the texture belongs to.
  8081. * @returns the scene or null if undefined
  8082. */
  8083. getScene(): Nullable<Scene>;
  8084. /** @hidden */
  8085. protected _getEngine(): Nullable<ThinEngine>;
  8086. /**
  8087. * Checks if the texture has the same transform matrix than another texture
  8088. * @param texture texture to check against
  8089. * @returns true if the transforms are the same, else false
  8090. */
  8091. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8092. /**
  8093. * Get the texture transform matrix used to offset tile the texture for istance.
  8094. * @returns the transformation matrix
  8095. */
  8096. getTextureMatrix(): Matrix;
  8097. /**
  8098. * Get the texture reflection matrix used to rotate/transform the reflection.
  8099. * @returns the reflection matrix
  8100. */
  8101. getReflectionTextureMatrix(): Matrix;
  8102. /**
  8103. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8104. * @returns true if ready or not blocking
  8105. */
  8106. isReadyOrNotBlocking(): boolean;
  8107. /**
  8108. * Scales the texture if is `canRescale()`
  8109. * @param ratio the resize factor we want to use to rescale
  8110. */
  8111. scale(ratio: number): void;
  8112. /**
  8113. * Get if the texture can rescale.
  8114. */
  8115. get canRescale(): boolean;
  8116. /** @hidden */
  8117. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8118. /** @hidden */
  8119. _rebuild(): void;
  8120. /**
  8121. * Clones the texture.
  8122. * @returns the cloned texture
  8123. */
  8124. clone(): Nullable<BaseTexture>;
  8125. /**
  8126. * Get the texture underlying type (INT, FLOAT...)
  8127. */
  8128. get textureType(): number;
  8129. /**
  8130. * Get the texture underlying format (RGB, RGBA...)
  8131. */
  8132. get textureFormat(): number;
  8133. /**
  8134. * Indicates that textures need to be re-calculated for all materials
  8135. */
  8136. protected _markAllSubMeshesAsTexturesDirty(): void;
  8137. /**
  8138. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8139. * This will returns an RGBA array buffer containing either in values (0-255) or
  8140. * float values (0-1) depending of the underlying buffer type.
  8141. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8142. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8143. * @param buffer defines a user defined buffer to fill with data (can be null)
  8144. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8145. * @returns The Array buffer promise containing the pixels data.
  8146. */
  8147. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8148. /** @hidden */
  8149. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8150. /** @hidden */
  8151. get _lodTextureHigh(): Nullable<BaseTexture>;
  8152. /** @hidden */
  8153. get _lodTextureMid(): Nullable<BaseTexture>;
  8154. /** @hidden */
  8155. get _lodTextureLow(): Nullable<BaseTexture>;
  8156. /**
  8157. * Dispose the texture and release its associated resources.
  8158. */
  8159. dispose(): void;
  8160. /**
  8161. * Serialize the texture into a JSON representation that can be parsed later on.
  8162. * @returns the JSON representation of the texture
  8163. */
  8164. serialize(): any;
  8165. /**
  8166. * Helper function to be called back once a list of texture contains only ready textures.
  8167. * @param textures Define the list of textures to wait for
  8168. * @param callback Define the callback triggered once the entire list will be ready
  8169. */
  8170. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8171. private static _isScene;
  8172. }
  8173. }
  8174. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  8175. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8176. /** @hidden */
  8177. export class WebGLDataBuffer extends DataBuffer {
  8178. private _buffer;
  8179. constructor(resource: WebGLBuffer);
  8180. get underlyingResource(): any;
  8181. }
  8182. }
  8183. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  8184. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8185. import { Nullable } from "babylonjs/types";
  8186. import { Effect } from "babylonjs/Materials/effect";
  8187. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  8188. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  8189. /** @hidden */
  8190. export class WebGLPipelineContext implements IPipelineContext {
  8191. private _valueCache;
  8192. private _uniforms;
  8193. engine: ThinEngine;
  8194. program: Nullable<WebGLProgram>;
  8195. context?: WebGLRenderingContext;
  8196. vertexShader?: WebGLShader;
  8197. fragmentShader?: WebGLShader;
  8198. isParallelCompiled: boolean;
  8199. onCompiled?: () => void;
  8200. transformFeedback?: WebGLTransformFeedback | null;
  8201. vertexCompilationError: Nullable<string>;
  8202. fragmentCompilationError: Nullable<string>;
  8203. programLinkError: Nullable<string>;
  8204. programValidationError: Nullable<string>;
  8205. get isAsync(): boolean;
  8206. get isReady(): boolean;
  8207. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8208. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8209. [key: string]: number;
  8210. }, uniformsNames: string[], uniforms: {
  8211. [key: string]: Nullable<WebGLUniformLocation>;
  8212. }, samplerList: string[], samplers: {
  8213. [key: string]: number;
  8214. }, attributesNames: string[], attributes: number[]): void;
  8215. /**
  8216. * Release all associated resources.
  8217. **/
  8218. dispose(): void;
  8219. /** @hidden */
  8220. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8221. /** @hidden */
  8222. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8223. /** @hidden */
  8224. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8225. /** @hidden */
  8226. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8227. /**
  8228. * Sets an interger value on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param value Value to be set.
  8231. */
  8232. setInt(uniformName: string, value: number): void;
  8233. /**
  8234. * Sets a int2 on a uniform variable.
  8235. * @param uniformName Name of the variable.
  8236. * @param x First int in int2.
  8237. * @param y Second int in int2.
  8238. */
  8239. setInt2(uniformName: string, x: number, y: number): void;
  8240. /**
  8241. * Sets a int3 on a uniform variable.
  8242. * @param uniformName Name of the variable.
  8243. * @param x First int in int3.
  8244. * @param y Second int in int3.
  8245. * @param y Third int in int3.
  8246. */
  8247. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8248. /**
  8249. * Sets a int4 on a uniform variable.
  8250. * @param uniformName Name of the variable.
  8251. * @param x First int in int4.
  8252. * @param y Second int in int4.
  8253. * @param y Third int in int4.
  8254. * @param w Fourth int in int4.
  8255. */
  8256. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8257. /**
  8258. * Sets an int array on a uniform variable.
  8259. * @param uniformName Name of the variable.
  8260. * @param array array to be set.
  8261. */
  8262. setIntArray(uniformName: string, array: Int32Array): void;
  8263. /**
  8264. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8265. * @param uniformName Name of the variable.
  8266. * @param array array to be set.
  8267. */
  8268. setIntArray2(uniformName: string, array: Int32Array): void;
  8269. /**
  8270. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8271. * @param uniformName Name of the variable.
  8272. * @param array array to be set.
  8273. */
  8274. setIntArray3(uniformName: string, array: Int32Array): void;
  8275. /**
  8276. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8277. * @param uniformName Name of the variable.
  8278. * @param array array to be set.
  8279. */
  8280. setIntArray4(uniformName: string, array: Int32Array): void;
  8281. /**
  8282. * Sets an array on a uniform variable.
  8283. * @param uniformName Name of the variable.
  8284. * @param array array to be set.
  8285. */
  8286. setArray(uniformName: string, array: number[]): void;
  8287. /**
  8288. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8289. * @param uniformName Name of the variable.
  8290. * @param array array to be set.
  8291. */
  8292. setArray2(uniformName: string, array: number[]): void;
  8293. /**
  8294. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8295. * @param uniformName Name of the variable.
  8296. * @param array array to be set.
  8297. * @returns this effect.
  8298. */
  8299. setArray3(uniformName: string, array: number[]): void;
  8300. /**
  8301. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8302. * @param uniformName Name of the variable.
  8303. * @param array array to be set.
  8304. */
  8305. setArray4(uniformName: string, array: number[]): void;
  8306. /**
  8307. * Sets matrices on a uniform variable.
  8308. * @param uniformName Name of the variable.
  8309. * @param matrices matrices to be set.
  8310. */
  8311. setMatrices(uniformName: string, matrices: Float32Array): void;
  8312. /**
  8313. * Sets matrix on a uniform variable.
  8314. * @param uniformName Name of the variable.
  8315. * @param matrix matrix to be set.
  8316. */
  8317. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8318. /**
  8319. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8320. * @param uniformName Name of the variable.
  8321. * @param matrix matrix to be set.
  8322. */
  8323. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8324. /**
  8325. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8326. * @param uniformName Name of the variable.
  8327. * @param matrix matrix to be set.
  8328. */
  8329. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8330. /**
  8331. * Sets a float on a uniform variable.
  8332. * @param uniformName Name of the variable.
  8333. * @param value value to be set.
  8334. * @returns this effect.
  8335. */
  8336. setFloat(uniformName: string, value: number): void;
  8337. /**
  8338. * Sets a Vector2 on a uniform variable.
  8339. * @param uniformName Name of the variable.
  8340. * @param vector2 vector2 to be set.
  8341. */
  8342. setVector2(uniformName: string, vector2: IVector2Like): void;
  8343. /**
  8344. * Sets a float2 on a uniform variable.
  8345. * @param uniformName Name of the variable.
  8346. * @param x First float in float2.
  8347. * @param y Second float in float2.
  8348. */
  8349. setFloat2(uniformName: string, x: number, y: number): void;
  8350. /**
  8351. * Sets a Vector3 on a uniform variable.
  8352. * @param uniformName Name of the variable.
  8353. * @param vector3 Value to be set.
  8354. */
  8355. setVector3(uniformName: string, vector3: IVector3Like): void;
  8356. /**
  8357. * Sets a float3 on a uniform variable.
  8358. * @param uniformName Name of the variable.
  8359. * @param x First float in float3.
  8360. * @param y Second float in float3.
  8361. * @param z Third float in float3.
  8362. */
  8363. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8364. /**
  8365. * Sets a Vector4 on a uniform variable.
  8366. * @param uniformName Name of the variable.
  8367. * @param vector4 Value to be set.
  8368. */
  8369. setVector4(uniformName: string, vector4: IVector4Like): void;
  8370. /**
  8371. * Sets a float4 on a uniform variable.
  8372. * @param uniformName Name of the variable.
  8373. * @param x First float in float4.
  8374. * @param y Second float in float4.
  8375. * @param z Third float in float4.
  8376. * @param w Fourth float in float4.
  8377. * @returns this effect.
  8378. */
  8379. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8380. /**
  8381. * Sets a Color3 on a uniform variable.
  8382. * @param uniformName Name of the variable.
  8383. * @param color3 Value to be set.
  8384. */
  8385. setColor3(uniformName: string, color3: IColor3Like): void;
  8386. /**
  8387. * Sets a Color4 on a uniform variable.
  8388. * @param uniformName Name of the variable.
  8389. * @param color3 Value to be set.
  8390. * @param alpha Alpha value to be set.
  8391. */
  8392. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8393. /**
  8394. * Sets a Color4 on a uniform variable
  8395. * @param uniformName defines the name of the variable
  8396. * @param color4 defines the value to be set
  8397. */
  8398. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8399. _getVertexShaderCode(): string | null;
  8400. _getFragmentShaderCode(): string | null;
  8401. }
  8402. }
  8403. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  8404. import { FloatArray, Nullable } from "babylonjs/types";
  8405. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8406. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8407. module "babylonjs/Engines/thinEngine" {
  8408. interface ThinEngine {
  8409. /**
  8410. * Create an uniform buffer
  8411. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8412. * @param elements defines the content of the uniform buffer
  8413. * @returns the webGL uniform buffer
  8414. */
  8415. createUniformBuffer(elements: FloatArray): DataBuffer;
  8416. /**
  8417. * Create a dynamic uniform buffer
  8418. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8419. * @param elements defines the content of the uniform buffer
  8420. * @returns the webGL uniform buffer
  8421. */
  8422. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8423. /**
  8424. * Update an existing uniform buffer
  8425. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8426. * @param uniformBuffer defines the target uniform buffer
  8427. * @param elements defines the content to update
  8428. * @param offset defines the offset in the uniform buffer where update should start
  8429. * @param count defines the size of the data to update
  8430. */
  8431. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8432. /**
  8433. * Bind an uniform buffer to the current webGL context
  8434. * @param buffer defines the buffer to bind
  8435. */
  8436. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8437. /**
  8438. * Bind a buffer to the current webGL context at a given location
  8439. * @param buffer defines the buffer to bind
  8440. * @param location defines the index where to bind the buffer
  8441. * @param name Name of the uniform variable to bind
  8442. */
  8443. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8444. /**
  8445. * Bind a specific block at a given index in a specific shader program
  8446. * @param pipelineContext defines the pipeline context to use
  8447. * @param blockName defines the block name
  8448. * @param index defines the index where to bind the block
  8449. */
  8450. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8451. }
  8452. }
  8453. }
  8454. declare module "babylonjs/Materials/uniformBuffer" {
  8455. import { Nullable, FloatArray } from "babylonjs/types";
  8456. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  8457. import { Engine } from "babylonjs/Engines/engine";
  8458. import { Effect } from "babylonjs/Materials/effect";
  8459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8460. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8461. import { Color3 } from "babylonjs/Maths/math.color";
  8462. import { IMatrixLike } from "babylonjs/Maths/math.like";
  8463. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  8464. /**
  8465. * Uniform buffer objects.
  8466. *
  8467. * Handles blocks of uniform on the GPU.
  8468. *
  8469. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8470. *
  8471. * For more information, please refer to :
  8472. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8473. */
  8474. export class UniformBuffer {
  8475. /** @hidden */
  8476. static _updatedUbosInFrame: {
  8477. [name: string]: number;
  8478. };
  8479. private _engine;
  8480. private _buffer;
  8481. private _buffers;
  8482. private _bufferIndex;
  8483. private _createBufferOnWrite;
  8484. private _data;
  8485. private _bufferData;
  8486. private _dynamic?;
  8487. private _uniformLocations;
  8488. private _uniformSizes;
  8489. private _uniformArraySizes;
  8490. private _uniformLocationPointer;
  8491. private _needSync;
  8492. private _noUBO;
  8493. private _currentEffect;
  8494. private _currentEffectName;
  8495. private _name;
  8496. private _currentFrameId;
  8497. /** @hidden */
  8498. _alreadyBound: boolean;
  8499. private static _MAX_UNIFORM_SIZE;
  8500. private static _tempBuffer;
  8501. private static _tempBufferInt32View;
  8502. /**
  8503. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8504. * This is dynamic to allow compat with webgl 1 and 2.
  8505. * You will need to pass the name of the uniform as well as the value.
  8506. */
  8507. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8508. /**
  8509. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8510. * This is dynamic to allow compat with webgl 1 and 2.
  8511. * You will need to pass the name of the uniform as well as the value.
  8512. */
  8513. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8514. /**
  8515. * Lambda to Update a single float in a uniform buffer.
  8516. * This is dynamic to allow compat with webgl 1 and 2.
  8517. * You will need to pass the name of the uniform as well as the value.
  8518. */
  8519. updateFloat: (name: string, x: number) => void;
  8520. /**
  8521. * Lambda to Update a vec2 of float in a uniform buffer.
  8522. * This is dynamic to allow compat with webgl 1 and 2.
  8523. * You will need to pass the name of the uniform as well as the value.
  8524. */
  8525. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8526. /**
  8527. * Lambda to Update a vec3 of float in a uniform buffer.
  8528. * This is dynamic to allow compat with webgl 1 and 2.
  8529. * You will need to pass the name of the uniform as well as the value.
  8530. */
  8531. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8532. /**
  8533. * Lambda to Update a vec4 of float in a uniform buffer.
  8534. * This is dynamic to allow compat with webgl 1 and 2.
  8535. * You will need to pass the name of the uniform as well as the value.
  8536. */
  8537. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8538. /**
  8539. * Lambda to Update an array of float in a uniform buffer.
  8540. * This is dynamic to allow compat with webgl 1 and 2.
  8541. * You will need to pass the name of the uniform as well as the value.
  8542. */
  8543. updateFloatArray: (name: string, array: Float32Array) => void;
  8544. /**
  8545. * Lambda to Update an array of number in a uniform buffer.
  8546. * This is dynamic to allow compat with webgl 1 and 2.
  8547. * You will need to pass the name of the uniform as well as the value.
  8548. */
  8549. updateArray: (name: string, array: number[]) => void;
  8550. /**
  8551. * Lambda to Update an array of number in a uniform buffer.
  8552. * This is dynamic to allow compat with webgl 1 and 2.
  8553. * You will need to pass the name of the uniform as well as the value.
  8554. */
  8555. updateIntArray: (name: string, array: Int32Array) => void;
  8556. /**
  8557. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8558. * This is dynamic to allow compat with webgl 1 and 2.
  8559. * You will need to pass the name of the uniform as well as the value.
  8560. */
  8561. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8562. /**
  8563. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8564. * This is dynamic to allow compat with webgl 1 and 2.
  8565. * You will need to pass the name of the uniform as well as the value.
  8566. */
  8567. updateMatrices: (name: string, mat: Float32Array) => void;
  8568. /**
  8569. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8570. * This is dynamic to allow compat with webgl 1 and 2.
  8571. * You will need to pass the name of the uniform as well as the value.
  8572. */
  8573. updateVector3: (name: string, vector: Vector3) => void;
  8574. /**
  8575. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8576. * This is dynamic to allow compat with webgl 1 and 2.
  8577. * You will need to pass the name of the uniform as well as the value.
  8578. */
  8579. updateVector4: (name: string, vector: Vector4) => void;
  8580. /**
  8581. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8582. * This is dynamic to allow compat with webgl 1 and 2.
  8583. * You will need to pass the name of the uniform as well as the value.
  8584. */
  8585. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8586. /**
  8587. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8588. * This is dynamic to allow compat with webgl 1 and 2.
  8589. * You will need to pass the name of the uniform as well as the value.
  8590. */
  8591. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8592. /**
  8593. * Lambda to Update a int a uniform buffer.
  8594. * This is dynamic to allow compat with webgl 1 and 2.
  8595. * You will need to pass the name of the uniform as well as the value.
  8596. */
  8597. updateInt: (name: string, x: number, suffix?: string) => void;
  8598. /**
  8599. * Lambda to Update a vec2 of int in a uniform buffer.
  8600. * This is dynamic to allow compat with webgl 1 and 2.
  8601. * You will need to pass the name of the uniform as well as the value.
  8602. */
  8603. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8604. /**
  8605. * Lambda to Update a vec3 of int in a uniform buffer.
  8606. * This is dynamic to allow compat with webgl 1 and 2.
  8607. * You will need to pass the name of the uniform as well as the value.
  8608. */
  8609. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8610. /**
  8611. * Lambda to Update a vec4 of int in a uniform buffer.
  8612. * This is dynamic to allow compat with webgl 1 and 2.
  8613. * You will need to pass the name of the uniform as well as the value.
  8614. */
  8615. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8616. /**
  8617. * Instantiates a new Uniform buffer objects.
  8618. *
  8619. * Handles blocks of uniform on the GPU.
  8620. *
  8621. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8622. *
  8623. * For more information, please refer to :
  8624. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8625. * @param engine Define the engine the buffer is associated with
  8626. * @param data Define the data contained in the buffer
  8627. * @param dynamic Define if the buffer is updatable
  8628. * @param name to assign to the buffer (debugging purpose)
  8629. */
  8630. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8631. /**
  8632. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8633. * or just falling back on setUniformXXX calls.
  8634. */
  8635. get useUbo(): boolean;
  8636. /**
  8637. * Indicates if the WebGL underlying uniform buffer is in sync
  8638. * with the javascript cache data.
  8639. */
  8640. get isSync(): boolean;
  8641. /**
  8642. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8643. * Also, a dynamic UniformBuffer will disable cache verification and always
  8644. * update the underlying WebGL uniform buffer to the GPU.
  8645. * @returns if Dynamic, otherwise false
  8646. */
  8647. isDynamic(): boolean;
  8648. /**
  8649. * The data cache on JS side.
  8650. * @returns the underlying data as a float array
  8651. */
  8652. getData(): Float32Array;
  8653. /**
  8654. * The underlying WebGL Uniform buffer.
  8655. * @returns the webgl buffer
  8656. */
  8657. getBuffer(): Nullable<DataBuffer>;
  8658. /**
  8659. * std140 layout specifies how to align data within an UBO structure.
  8660. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8661. * for specs.
  8662. */
  8663. private _fillAlignment;
  8664. /**
  8665. * Adds an uniform in the buffer.
  8666. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8667. * for the layout to be correct !
  8668. * @param name Name of the uniform, as used in the uniform block in the shader.
  8669. * @param size Data size, or data directly.
  8670. * @param arraySize The number of elements in the array, 0 if not an array.
  8671. */
  8672. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8673. /**
  8674. * Adds a Matrix 4x4 to the uniform buffer.
  8675. * @param name Name of the uniform, as used in the uniform block in the shader.
  8676. * @param mat A 4x4 matrix.
  8677. */
  8678. addMatrix(name: string, mat: Matrix): void;
  8679. /**
  8680. * Adds a vec2 to the uniform buffer.
  8681. * @param name Name of the uniform, as used in the uniform block in the shader.
  8682. * @param x Define the x component value of the vec2
  8683. * @param y Define the y component value of the vec2
  8684. */
  8685. addFloat2(name: string, x: number, y: number): void;
  8686. /**
  8687. * Adds a vec3 to the uniform buffer.
  8688. * @param name Name of the uniform, as used in the uniform block in the shader.
  8689. * @param x Define the x component value of the vec3
  8690. * @param y Define the y component value of the vec3
  8691. * @param z Define the z component value of the vec3
  8692. */
  8693. addFloat3(name: string, x: number, y: number, z: number): void;
  8694. /**
  8695. * Adds a vec3 to the uniform buffer.
  8696. * @param name Name of the uniform, as used in the uniform block in the shader.
  8697. * @param color Define the vec3 from a Color
  8698. */
  8699. addColor3(name: string, color: Color3): void;
  8700. /**
  8701. * Adds a vec4 to the uniform buffer.
  8702. * @param name Name of the uniform, as used in the uniform block in the shader.
  8703. * @param color Define the rgb components from a Color
  8704. * @param alpha Define the a component of the vec4
  8705. */
  8706. addColor4(name: string, color: Color3, alpha: number): void;
  8707. /**
  8708. * Adds a vec3 to the uniform buffer.
  8709. * @param name Name of the uniform, as used in the uniform block in the shader.
  8710. * @param vector Define the vec3 components from a Vector
  8711. */
  8712. addVector3(name: string, vector: Vector3): void;
  8713. /**
  8714. * Adds a Matrix 3x3 to the uniform buffer.
  8715. * @param name Name of the uniform, as used in the uniform block in the shader.
  8716. */
  8717. addMatrix3x3(name: string): void;
  8718. /**
  8719. * Adds a Matrix 2x2 to the uniform buffer.
  8720. * @param name Name of the uniform, as used in the uniform block in the shader.
  8721. */
  8722. addMatrix2x2(name: string): void;
  8723. /**
  8724. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8725. */
  8726. create(): void;
  8727. /** @hidden */
  8728. _rebuild(): void;
  8729. /** @hidden */
  8730. get _numBuffers(): number;
  8731. /** @hidden */
  8732. get _indexBuffer(): number;
  8733. /** Gets the name of this buffer */
  8734. get name(): string;
  8735. /**
  8736. * Updates the WebGL Uniform Buffer on the GPU.
  8737. * If the `dynamic` flag is set to true, no cache comparison is done.
  8738. * Otherwise, the buffer will be updated only if the cache differs.
  8739. */
  8740. update(): void;
  8741. private _createNewBuffer;
  8742. private _checkNewFrame;
  8743. /**
  8744. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8745. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8746. * @param data Define the flattened data
  8747. * @param size Define the size of the data.
  8748. */
  8749. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8750. /**
  8751. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8752. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8753. * @param data Define the flattened data
  8754. * @param size Define the size of the data.
  8755. */
  8756. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8757. private _valueCache;
  8758. private _cacheMatrix;
  8759. private _updateMatrix3x3ForUniform;
  8760. private _updateMatrix3x3ForEffect;
  8761. private _updateMatrix2x2ForEffect;
  8762. private _updateMatrix2x2ForUniform;
  8763. private _updateFloatForEffect;
  8764. private _updateFloatForUniform;
  8765. private _updateFloat2ForEffect;
  8766. private _updateFloat2ForUniform;
  8767. private _updateFloat3ForEffect;
  8768. private _updateFloat3ForUniform;
  8769. private _updateFloat4ForEffect;
  8770. private _updateFloat4ForUniform;
  8771. private _updateFloatArrayForEffect;
  8772. private _updateFloatArrayForUniform;
  8773. private _updateArrayForEffect;
  8774. private _updateArrayForUniform;
  8775. private _updateIntArrayForEffect;
  8776. private _updateIntArrayForUniform;
  8777. private _updateMatrixForEffect;
  8778. private _updateMatrixForUniform;
  8779. private _updateMatricesForEffect;
  8780. private _updateMatricesForUniform;
  8781. private _updateVector3ForEffect;
  8782. private _updateVector3ForUniform;
  8783. private _updateVector4ForEffect;
  8784. private _updateVector4ForUniform;
  8785. private _updateColor3ForEffect;
  8786. private _updateColor3ForUniform;
  8787. private _updateColor4ForEffect;
  8788. private _updateColor4ForUniform;
  8789. private _updateIntForEffect;
  8790. private _updateIntForUniform;
  8791. private _updateInt2ForEffect;
  8792. private _updateInt2ForUniform;
  8793. private _updateInt3ForEffect;
  8794. private _updateInt3ForUniform;
  8795. private _updateInt4ForEffect;
  8796. private _updateInt4ForUniform;
  8797. /**
  8798. * Sets a sampler uniform on the effect.
  8799. * @param name Define the name of the sampler.
  8800. * @param texture Define the texture to set in the sampler
  8801. */
  8802. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8803. /**
  8804. * Directly updates the value of the uniform in the cache AND on the GPU.
  8805. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8806. * @param data Define the flattened data
  8807. */
  8808. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8809. /**
  8810. * Binds this uniform buffer to an effect.
  8811. * @param effect Define the effect to bind the buffer to
  8812. * @param name Name of the uniform block in the shader.
  8813. */
  8814. bindToEffect(effect: Effect, name: string): void;
  8815. /**
  8816. * Disposes the uniform buffer.
  8817. */
  8818. dispose(): void;
  8819. }
  8820. }
  8821. declare module "babylonjs/Materials/materialDefines" {
  8822. /**
  8823. * Manages the defines for the Material
  8824. */
  8825. export class MaterialDefines {
  8826. /** @hidden */
  8827. protected _keys: string[];
  8828. private _isDirty;
  8829. /** @hidden */
  8830. _renderId: number;
  8831. /** @hidden */
  8832. _areLightsDirty: boolean;
  8833. /** @hidden */
  8834. _areLightsDisposed: boolean;
  8835. /** @hidden */
  8836. _areAttributesDirty: boolean;
  8837. /** @hidden */
  8838. _areTexturesDirty: boolean;
  8839. /** @hidden */
  8840. _areFresnelDirty: boolean;
  8841. /** @hidden */
  8842. _areMiscDirty: boolean;
  8843. /** @hidden */
  8844. _arePrePassDirty: boolean;
  8845. /** @hidden */
  8846. _areImageProcessingDirty: boolean;
  8847. /** @hidden */
  8848. _normals: boolean;
  8849. /** @hidden */
  8850. _uvs: boolean;
  8851. /** @hidden */
  8852. _needNormals: boolean;
  8853. /** @hidden */
  8854. _needUVs: boolean;
  8855. [id: string]: any;
  8856. /**
  8857. * Specifies if the material needs to be re-calculated
  8858. */
  8859. get isDirty(): boolean;
  8860. /**
  8861. * Marks the material to indicate that it has been re-calculated
  8862. */
  8863. markAsProcessed(): void;
  8864. /**
  8865. * Marks the material to indicate that it needs to be re-calculated
  8866. */
  8867. markAsUnprocessed(): void;
  8868. /**
  8869. * Marks the material to indicate all of its defines need to be re-calculated
  8870. */
  8871. markAllAsDirty(): void;
  8872. /**
  8873. * Marks the material to indicate that image processing needs to be re-calculated
  8874. */
  8875. markAsImageProcessingDirty(): void;
  8876. /**
  8877. * Marks the material to indicate the lights need to be re-calculated
  8878. * @param disposed Defines whether the light is dirty due to dispose or not
  8879. */
  8880. markAsLightDirty(disposed?: boolean): void;
  8881. /**
  8882. * Marks the attribute state as changed
  8883. */
  8884. markAsAttributesDirty(): void;
  8885. /**
  8886. * Marks the texture state as changed
  8887. */
  8888. markAsTexturesDirty(): void;
  8889. /**
  8890. * Marks the fresnel state as changed
  8891. */
  8892. markAsFresnelDirty(): void;
  8893. /**
  8894. * Marks the misc state as changed
  8895. */
  8896. markAsMiscDirty(): void;
  8897. /**
  8898. * Marks the prepass state as changed
  8899. */
  8900. markAsPrePassDirty(): void;
  8901. /**
  8902. * Rebuilds the material defines
  8903. */
  8904. rebuild(): void;
  8905. /**
  8906. * Specifies if two material defines are equal
  8907. * @param other - A material define instance to compare to
  8908. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8909. */
  8910. isEqual(other: MaterialDefines): boolean;
  8911. /**
  8912. * Clones this instance's defines to another instance
  8913. * @param other - material defines to clone values to
  8914. */
  8915. cloneTo(other: MaterialDefines): void;
  8916. /**
  8917. * Resets the material define values
  8918. */
  8919. reset(): void;
  8920. /**
  8921. * Converts the material define values to a string
  8922. * @returns - String of material define information
  8923. */
  8924. toString(): string;
  8925. }
  8926. }
  8927. declare module "babylonjs/Misc/iInspectable" {
  8928. /**
  8929. * Enum that determines the text-wrapping mode to use.
  8930. */
  8931. export enum InspectableType {
  8932. /**
  8933. * Checkbox for booleans
  8934. */
  8935. Checkbox = 0,
  8936. /**
  8937. * Sliders for numbers
  8938. */
  8939. Slider = 1,
  8940. /**
  8941. * Vector3
  8942. */
  8943. Vector3 = 2,
  8944. /**
  8945. * Quaternions
  8946. */
  8947. Quaternion = 3,
  8948. /**
  8949. * Color3
  8950. */
  8951. Color3 = 4,
  8952. /**
  8953. * String
  8954. */
  8955. String = 5
  8956. }
  8957. /**
  8958. * Interface used to define custom inspectable properties.
  8959. * This interface is used by the inspector to display custom property grids
  8960. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8961. */
  8962. export interface IInspectable {
  8963. /**
  8964. * Gets the label to display
  8965. */
  8966. label: string;
  8967. /**
  8968. * Gets the name of the property to edit
  8969. */
  8970. propertyName: string;
  8971. /**
  8972. * Gets the type of the editor to use
  8973. */
  8974. type: InspectableType;
  8975. /**
  8976. * Gets the minimum value of the property when using in "slider" mode
  8977. */
  8978. min?: number;
  8979. /**
  8980. * Gets the maximum value of the property when using in "slider" mode
  8981. */
  8982. max?: number;
  8983. /**
  8984. * Gets the setp to use when using in "slider" mode
  8985. */
  8986. step?: number;
  8987. }
  8988. }
  8989. declare module "babylonjs/Lights/light" {
  8990. import { Nullable } from "babylonjs/types";
  8991. import { Scene } from "babylonjs/scene";
  8992. import { Vector3 } from "babylonjs/Maths/math.vector";
  8993. import { Color3 } from "babylonjs/Maths/math.color";
  8994. import { Node } from "babylonjs/node";
  8995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8996. import { Effect } from "babylonjs/Materials/effect";
  8997. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8998. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8999. /**
  9000. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9001. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9002. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9003. */
  9004. export abstract class Light extends Node {
  9005. /**
  9006. * Falloff Default: light is falling off following the material specification:
  9007. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9008. */
  9009. static readonly FALLOFF_DEFAULT: number;
  9010. /**
  9011. * Falloff Physical: light is falling off following the inverse squared distance law.
  9012. */
  9013. static readonly FALLOFF_PHYSICAL: number;
  9014. /**
  9015. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9016. * to enhance interoperability with other engines.
  9017. */
  9018. static readonly FALLOFF_GLTF: number;
  9019. /**
  9020. * Falloff Standard: light is falling off like in the standard material
  9021. * to enhance interoperability with other materials.
  9022. */
  9023. static readonly FALLOFF_STANDARD: number;
  9024. /**
  9025. * If every light affecting the material is in this lightmapMode,
  9026. * material.lightmapTexture adds or multiplies
  9027. * (depends on material.useLightmapAsShadowmap)
  9028. * after every other light calculations.
  9029. */
  9030. static readonly LIGHTMAP_DEFAULT: number;
  9031. /**
  9032. * material.lightmapTexture as only diffuse lighting from this light
  9033. * adds only specular lighting from this light
  9034. * adds dynamic shadows
  9035. */
  9036. static readonly LIGHTMAP_SPECULAR: number;
  9037. /**
  9038. * material.lightmapTexture as only lighting
  9039. * no light calculation from this light
  9040. * only adds dynamic shadows from this light
  9041. */
  9042. static readonly LIGHTMAP_SHADOWSONLY: number;
  9043. /**
  9044. * Each light type uses the default quantity according to its type:
  9045. * point/spot lights use luminous intensity
  9046. * directional lights use illuminance
  9047. */
  9048. static readonly INTENSITYMODE_AUTOMATIC: number;
  9049. /**
  9050. * lumen (lm)
  9051. */
  9052. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9053. /**
  9054. * candela (lm/sr)
  9055. */
  9056. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9057. /**
  9058. * lux (lm/m^2)
  9059. */
  9060. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9061. /**
  9062. * nit (cd/m^2)
  9063. */
  9064. static readonly INTENSITYMODE_LUMINANCE: number;
  9065. /**
  9066. * Light type const id of the point light.
  9067. */
  9068. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9069. /**
  9070. * Light type const id of the directional light.
  9071. */
  9072. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9073. /**
  9074. * Light type const id of the spot light.
  9075. */
  9076. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9077. /**
  9078. * Light type const id of the hemispheric light.
  9079. */
  9080. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9081. /**
  9082. * Diffuse gives the basic color to an object.
  9083. */
  9084. diffuse: Color3;
  9085. /**
  9086. * Specular produces a highlight color on an object.
  9087. * Note: This is note affecting PBR materials.
  9088. */
  9089. specular: Color3;
  9090. /**
  9091. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9092. * falling off base on range or angle.
  9093. * This can be set to any values in Light.FALLOFF_x.
  9094. *
  9095. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9096. * other types of materials.
  9097. */
  9098. falloffType: number;
  9099. /**
  9100. * Strength of the light.
  9101. * Note: By default it is define in the framework own unit.
  9102. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9103. */
  9104. intensity: number;
  9105. private _range;
  9106. protected _inverseSquaredRange: number;
  9107. /**
  9108. * Defines how far from the source the light is impacting in scene units.
  9109. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9110. */
  9111. get range(): number;
  9112. /**
  9113. * Defines how far from the source the light is impacting in scene units.
  9114. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9115. */
  9116. set range(value: number);
  9117. /**
  9118. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9119. * of light.
  9120. */
  9121. private _photometricScale;
  9122. private _intensityMode;
  9123. /**
  9124. * Gets the photometric scale used to interpret the intensity.
  9125. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9126. */
  9127. get intensityMode(): number;
  9128. /**
  9129. * Sets the photometric scale used to interpret the intensity.
  9130. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9131. */
  9132. set intensityMode(value: number);
  9133. private _radius;
  9134. /**
  9135. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9136. */
  9137. get radius(): number;
  9138. /**
  9139. * sets the light radius used by PBR Materials to simulate soft area lights.
  9140. */
  9141. set radius(value: number);
  9142. private _renderPriority;
  9143. /**
  9144. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9145. * exceeding the number allowed of the materials.
  9146. */
  9147. renderPriority: number;
  9148. private _shadowEnabled;
  9149. /**
  9150. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9151. * the current shadow generator.
  9152. */
  9153. get shadowEnabled(): boolean;
  9154. /**
  9155. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9156. * the current shadow generator.
  9157. */
  9158. set shadowEnabled(value: boolean);
  9159. private _includedOnlyMeshes;
  9160. /**
  9161. * Gets the only meshes impacted by this light.
  9162. */
  9163. get includedOnlyMeshes(): AbstractMesh[];
  9164. /**
  9165. * Sets the only meshes impacted by this light.
  9166. */
  9167. set includedOnlyMeshes(value: AbstractMesh[]);
  9168. private _excludedMeshes;
  9169. /**
  9170. * Gets the meshes not impacted by this light.
  9171. */
  9172. get excludedMeshes(): AbstractMesh[];
  9173. /**
  9174. * Sets the meshes not impacted by this light.
  9175. */
  9176. set excludedMeshes(value: AbstractMesh[]);
  9177. private _excludeWithLayerMask;
  9178. /**
  9179. * Gets the layer id use to find what meshes are not impacted by the light.
  9180. * Inactive if 0
  9181. */
  9182. get excludeWithLayerMask(): number;
  9183. /**
  9184. * Sets the layer id use to find what meshes are not impacted by the light.
  9185. * Inactive if 0
  9186. */
  9187. set excludeWithLayerMask(value: number);
  9188. private _includeOnlyWithLayerMask;
  9189. /**
  9190. * Gets the layer id use to find what meshes are impacted by the light.
  9191. * Inactive if 0
  9192. */
  9193. get includeOnlyWithLayerMask(): number;
  9194. /**
  9195. * Sets the layer id use to find what meshes are impacted by the light.
  9196. * Inactive if 0
  9197. */
  9198. set includeOnlyWithLayerMask(value: number);
  9199. private _lightmapMode;
  9200. /**
  9201. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9202. */
  9203. get lightmapMode(): number;
  9204. /**
  9205. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9206. */
  9207. set lightmapMode(value: number);
  9208. /**
  9209. * Shadow generator associted to the light.
  9210. * @hidden Internal use only.
  9211. */
  9212. _shadowGenerator: Nullable<IShadowGenerator>;
  9213. /**
  9214. * @hidden Internal use only.
  9215. */
  9216. _excludedMeshesIds: string[];
  9217. /**
  9218. * @hidden Internal use only.
  9219. */
  9220. _includedOnlyMeshesIds: string[];
  9221. /**
  9222. * The current light unifom buffer.
  9223. * @hidden Internal use only.
  9224. */
  9225. _uniformBuffer: UniformBuffer;
  9226. /** @hidden */
  9227. _renderId: number;
  9228. /**
  9229. * Creates a Light object in the scene.
  9230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9231. * @param name The firendly name of the light
  9232. * @param scene The scene the light belongs too
  9233. */
  9234. constructor(name: string, scene: Scene);
  9235. protected abstract _buildUniformLayout(): void;
  9236. /**
  9237. * Sets the passed Effect "effect" with the Light information.
  9238. * @param effect The effect to update
  9239. * @param lightIndex The index of the light in the effect to update
  9240. * @returns The light
  9241. */
  9242. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9243. /**
  9244. * Sets the passed Effect "effect" with the Light textures.
  9245. * @param effect The effect to update
  9246. * @param lightIndex The index of the light in the effect to update
  9247. * @returns The light
  9248. */
  9249. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9250. /**
  9251. * Binds the lights information from the scene to the effect for the given mesh.
  9252. * @param lightIndex Light index
  9253. * @param scene The scene where the light belongs to
  9254. * @param effect The effect we are binding the data to
  9255. * @param useSpecular Defines if specular is supported
  9256. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9257. */
  9258. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9259. /**
  9260. * Sets the passed Effect "effect" with the Light information.
  9261. * @param effect The effect to update
  9262. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9263. * @returns The light
  9264. */
  9265. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9266. /**
  9267. * Returns the string "Light".
  9268. * @returns the class name
  9269. */
  9270. getClassName(): string;
  9271. /** @hidden */
  9272. readonly _isLight: boolean;
  9273. /**
  9274. * Converts the light information to a readable string for debug purpose.
  9275. * @param fullDetails Supports for multiple levels of logging within scene loading
  9276. * @returns the human readable light info
  9277. */
  9278. toString(fullDetails?: boolean): string;
  9279. /** @hidden */
  9280. protected _syncParentEnabledState(): void;
  9281. /**
  9282. * Set the enabled state of this node.
  9283. * @param value - the new enabled state
  9284. */
  9285. setEnabled(value: boolean): void;
  9286. /**
  9287. * Returns the Light associated shadow generator if any.
  9288. * @return the associated shadow generator.
  9289. */
  9290. getShadowGenerator(): Nullable<IShadowGenerator>;
  9291. /**
  9292. * Returns a Vector3, the absolute light position in the World.
  9293. * @returns the world space position of the light
  9294. */
  9295. getAbsolutePosition(): Vector3;
  9296. /**
  9297. * Specifies if the light will affect the passed mesh.
  9298. * @param mesh The mesh to test against the light
  9299. * @return true the mesh is affected otherwise, false.
  9300. */
  9301. canAffectMesh(mesh: AbstractMesh): boolean;
  9302. /**
  9303. * Sort function to order lights for rendering.
  9304. * @param a First Light object to compare to second.
  9305. * @param b Second Light object to compare first.
  9306. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9307. */
  9308. static CompareLightsPriority(a: Light, b: Light): number;
  9309. /**
  9310. * Releases resources associated with this node.
  9311. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9312. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9313. */
  9314. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9315. /**
  9316. * Returns the light type ID (integer).
  9317. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9318. */
  9319. getTypeID(): number;
  9320. /**
  9321. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9322. * @returns the scaled intensity in intensity mode unit
  9323. */
  9324. getScaledIntensity(): number;
  9325. /**
  9326. * Returns a new Light object, named "name", from the current one.
  9327. * @param name The name of the cloned light
  9328. * @param newParent The parent of this light, if it has one
  9329. * @returns the new created light
  9330. */
  9331. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9332. /**
  9333. * Serializes the current light into a Serialization object.
  9334. * @returns the serialized object.
  9335. */
  9336. serialize(): any;
  9337. /**
  9338. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9339. * This new light is named "name" and added to the passed scene.
  9340. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9341. * @param name The friendly name of the light
  9342. * @param scene The scene the new light will belong to
  9343. * @returns the constructor function
  9344. */
  9345. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9346. /**
  9347. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9348. * @param parsedLight The JSON representation of the light
  9349. * @param scene The scene to create the parsed light in
  9350. * @returns the created light after parsing
  9351. */
  9352. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9353. private _hookArrayForExcluded;
  9354. private _hookArrayForIncludedOnly;
  9355. private _resyncMeshes;
  9356. /**
  9357. * Forces the meshes to update their light related information in their rendering used effects
  9358. * @hidden Internal Use Only
  9359. */
  9360. _markMeshesAsLightDirty(): void;
  9361. /**
  9362. * Recomputes the cached photometric scale if needed.
  9363. */
  9364. private _computePhotometricScale;
  9365. /**
  9366. * Returns the Photometric Scale according to the light type and intensity mode.
  9367. */
  9368. private _getPhotometricScale;
  9369. /**
  9370. * Reorder the light in the scene according to their defined priority.
  9371. * @hidden Internal Use Only
  9372. */
  9373. _reorderLightsInScene(): void;
  9374. /**
  9375. * Prepares the list of defines specific to the light type.
  9376. * @param defines the list of defines
  9377. * @param lightIndex defines the index of the light for the effect
  9378. */
  9379. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9380. }
  9381. }
  9382. declare module "babylonjs/Maths/math.axis" {
  9383. import { Vector3 } from "babylonjs/Maths/math.vector";
  9384. /** Defines supported spaces */
  9385. export enum Space {
  9386. /** Local (object) space */
  9387. LOCAL = 0,
  9388. /** World space */
  9389. WORLD = 1,
  9390. /** Bone space */
  9391. BONE = 2
  9392. }
  9393. /** Defines the 3 main axes */
  9394. export class Axis {
  9395. /** X axis */
  9396. static X: Vector3;
  9397. /** Y axis */
  9398. static Y: Vector3;
  9399. /** Z axis */
  9400. static Z: Vector3;
  9401. }
  9402. /**
  9403. * Defines cartesian components.
  9404. */
  9405. export enum Coordinate {
  9406. /** X axis */
  9407. X = 0,
  9408. /** Y axis */
  9409. Y = 1,
  9410. /** Z axis */
  9411. Z = 2
  9412. }
  9413. }
  9414. declare module "babylonjs/Lights/shadowLight" {
  9415. import { Camera } from "babylonjs/Cameras/camera";
  9416. import { Scene } from "babylonjs/scene";
  9417. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9419. import { Light } from "babylonjs/Lights/light";
  9420. /**
  9421. * Interface describing all the common properties and methods a shadow light needs to implement.
  9422. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9423. * as well as binding the different shadow properties to the effects.
  9424. */
  9425. export interface IShadowLight extends Light {
  9426. /**
  9427. * The light id in the scene (used in scene.findLighById for instance)
  9428. */
  9429. id: string;
  9430. /**
  9431. * The position the shdow will be casted from.
  9432. */
  9433. position: Vector3;
  9434. /**
  9435. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9436. */
  9437. direction: Vector3;
  9438. /**
  9439. * The transformed position. Position of the light in world space taking parenting in account.
  9440. */
  9441. transformedPosition: Vector3;
  9442. /**
  9443. * The transformed direction. Direction of the light in world space taking parenting in account.
  9444. */
  9445. transformedDirection: Vector3;
  9446. /**
  9447. * The friendly name of the light in the scene.
  9448. */
  9449. name: string;
  9450. /**
  9451. * Defines the shadow projection clipping minimum z value.
  9452. */
  9453. shadowMinZ: number;
  9454. /**
  9455. * Defines the shadow projection clipping maximum z value.
  9456. */
  9457. shadowMaxZ: number;
  9458. /**
  9459. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9460. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9461. */
  9462. computeTransformedInformation(): boolean;
  9463. /**
  9464. * Gets the scene the light belongs to.
  9465. * @returns The scene
  9466. */
  9467. getScene(): Scene;
  9468. /**
  9469. * Callback defining a custom Projection Matrix Builder.
  9470. * This can be used to override the default projection matrix computation.
  9471. */
  9472. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9473. /**
  9474. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9475. * @param matrix The materix to updated with the projection information
  9476. * @param viewMatrix The transform matrix of the light
  9477. * @param renderList The list of mesh to render in the map
  9478. * @returns The current light
  9479. */
  9480. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9481. /**
  9482. * Gets the current depth scale used in ESM.
  9483. * @returns The scale
  9484. */
  9485. getDepthScale(): number;
  9486. /**
  9487. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9488. * @returns true if a cube texture needs to be use
  9489. */
  9490. needCube(): boolean;
  9491. /**
  9492. * Detects if the projection matrix requires to be recomputed this frame.
  9493. * @returns true if it requires to be recomputed otherwise, false.
  9494. */
  9495. needProjectionMatrixCompute(): boolean;
  9496. /**
  9497. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9498. */
  9499. forceProjectionMatrixCompute(): void;
  9500. /**
  9501. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9502. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9503. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9504. */
  9505. getShadowDirection(faceIndex?: number): Vector3;
  9506. /**
  9507. * Gets the minZ used for shadow according to both the scene and the light.
  9508. * @param activeCamera The camera we are returning the min for
  9509. * @returns the depth min z
  9510. */
  9511. getDepthMinZ(activeCamera: Camera): number;
  9512. /**
  9513. * Gets the maxZ used for shadow according to both the scene and the light.
  9514. * @param activeCamera The camera we are returning the max for
  9515. * @returns the depth max z
  9516. */
  9517. getDepthMaxZ(activeCamera: Camera): number;
  9518. }
  9519. /**
  9520. * Base implementation IShadowLight
  9521. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9522. */
  9523. export abstract class ShadowLight extends Light implements IShadowLight {
  9524. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9525. protected _position: Vector3;
  9526. protected _setPosition(value: Vector3): void;
  9527. /**
  9528. * Sets the position the shadow will be casted from. Also use as the light position for both
  9529. * point and spot lights.
  9530. */
  9531. get position(): Vector3;
  9532. /**
  9533. * Sets the position the shadow will be casted from. Also use as the light position for both
  9534. * point and spot lights.
  9535. */
  9536. set position(value: Vector3);
  9537. protected _direction: Vector3;
  9538. protected _setDirection(value: Vector3): void;
  9539. /**
  9540. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9541. * Also use as the light direction on spot and directional lights.
  9542. */
  9543. get direction(): Vector3;
  9544. /**
  9545. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9546. * Also use as the light direction on spot and directional lights.
  9547. */
  9548. set direction(value: Vector3);
  9549. protected _shadowMinZ: number;
  9550. /**
  9551. * Gets the shadow projection clipping minimum z value.
  9552. */
  9553. get shadowMinZ(): number;
  9554. /**
  9555. * Sets the shadow projection clipping minimum z value.
  9556. */
  9557. set shadowMinZ(value: number);
  9558. protected _shadowMaxZ: number;
  9559. /**
  9560. * Sets the shadow projection clipping maximum z value.
  9561. */
  9562. get shadowMaxZ(): number;
  9563. /**
  9564. * Gets the shadow projection clipping maximum z value.
  9565. */
  9566. set shadowMaxZ(value: number);
  9567. /**
  9568. * Callback defining a custom Projection Matrix Builder.
  9569. * This can be used to override the default projection matrix computation.
  9570. */
  9571. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9572. /**
  9573. * The transformed position. Position of the light in world space taking parenting in account.
  9574. */
  9575. transformedPosition: Vector3;
  9576. /**
  9577. * The transformed direction. Direction of the light in world space taking parenting in account.
  9578. */
  9579. transformedDirection: Vector3;
  9580. private _needProjectionMatrixCompute;
  9581. /**
  9582. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9583. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9584. */
  9585. computeTransformedInformation(): boolean;
  9586. /**
  9587. * Return the depth scale used for the shadow map.
  9588. * @returns the depth scale.
  9589. */
  9590. getDepthScale(): number;
  9591. /**
  9592. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9593. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9594. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9595. */
  9596. getShadowDirection(faceIndex?: number): Vector3;
  9597. /**
  9598. * Returns the ShadowLight absolute position in the World.
  9599. * @returns the position vector in world space
  9600. */
  9601. getAbsolutePosition(): Vector3;
  9602. /**
  9603. * Sets the ShadowLight direction toward the passed target.
  9604. * @param target The point to target in local space
  9605. * @returns the updated ShadowLight direction
  9606. */
  9607. setDirectionToTarget(target: Vector3): Vector3;
  9608. /**
  9609. * Returns the light rotation in euler definition.
  9610. * @returns the x y z rotation in local space.
  9611. */
  9612. getRotation(): Vector3;
  9613. /**
  9614. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9615. * @returns true if a cube texture needs to be use
  9616. */
  9617. needCube(): boolean;
  9618. /**
  9619. * Detects if the projection matrix requires to be recomputed this frame.
  9620. * @returns true if it requires to be recomputed otherwise, false.
  9621. */
  9622. needProjectionMatrixCompute(): boolean;
  9623. /**
  9624. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9625. */
  9626. forceProjectionMatrixCompute(): void;
  9627. /** @hidden */
  9628. _initCache(): void;
  9629. /** @hidden */
  9630. _isSynchronized(): boolean;
  9631. /**
  9632. * Computes the world matrix of the node
  9633. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9634. * @returns the world matrix
  9635. */
  9636. computeWorldMatrix(force?: boolean): Matrix;
  9637. /**
  9638. * Gets the minZ used for shadow according to both the scene and the light.
  9639. * @param activeCamera The camera we are returning the min for
  9640. * @returns the depth min z
  9641. */
  9642. getDepthMinZ(activeCamera: Camera): number;
  9643. /**
  9644. * Gets the maxZ used for shadow according to both the scene and the light.
  9645. * @param activeCamera The camera we are returning the max for
  9646. * @returns the depth max z
  9647. */
  9648. getDepthMaxZ(activeCamera: Camera): number;
  9649. /**
  9650. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9651. * @param matrix The materix to updated with the projection information
  9652. * @param viewMatrix The transform matrix of the light
  9653. * @param renderList The list of mesh to render in the map
  9654. * @returns The current light
  9655. */
  9656. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9657. }
  9658. }
  9659. declare module "babylonjs/Materials/prePassConfiguration" {
  9660. import { Matrix } from "babylonjs/Maths/math.vector";
  9661. import { Mesh } from "babylonjs/Meshes/mesh";
  9662. import { Scene } from "babylonjs/scene";
  9663. import { Effect } from "babylonjs/Materials/effect";
  9664. /**
  9665. * Configuration needed for prepass-capable materials
  9666. */
  9667. export class PrePassConfiguration {
  9668. /**
  9669. * Previous world matrices of meshes carrying this material
  9670. * Used for computing velocity
  9671. */
  9672. previousWorldMatrices: {
  9673. [index: number]: Matrix;
  9674. };
  9675. /**
  9676. * Previous view project matrix
  9677. * Used for computing velocity
  9678. */
  9679. previousViewProjection: Matrix;
  9680. /**
  9681. * Previous bones of meshes carrying this material
  9682. * Used for computing velocity
  9683. */
  9684. previousBones: {
  9685. [index: number]: Float32Array;
  9686. };
  9687. /**
  9688. * Add the required uniforms to the current list.
  9689. * @param uniforms defines the current uniform list.
  9690. */
  9691. static AddUniforms(uniforms: string[]): void;
  9692. /**
  9693. * Add the required samplers to the current list.
  9694. * @param samplers defines the current sampler list.
  9695. */
  9696. static AddSamplers(samplers: string[]): void;
  9697. /**
  9698. * Binds the material data.
  9699. * @param effect defines the effect to update
  9700. * @param scene defines the scene the material belongs to.
  9701. * @param mesh The mesh
  9702. * @param world World matrix of this mesh
  9703. * @param isFrozen Is the material frozen
  9704. */
  9705. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9706. }
  9707. }
  9708. declare module "babylonjs/Cameras/targetCamera" {
  9709. import { Nullable } from "babylonjs/types";
  9710. import { Camera } from "babylonjs/Cameras/camera";
  9711. import { Scene } from "babylonjs/scene";
  9712. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9713. /**
  9714. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9715. * This is the base of the follow, arc rotate cameras and Free camera
  9716. * @see https://doc.babylonjs.com/features/cameras
  9717. */
  9718. export class TargetCamera extends Camera {
  9719. private static _RigCamTransformMatrix;
  9720. private static _TargetTransformMatrix;
  9721. private static _TargetFocalPoint;
  9722. private _tmpUpVector;
  9723. private _tmpTargetVector;
  9724. /**
  9725. * Define the current direction the camera is moving to
  9726. */
  9727. cameraDirection: Vector3;
  9728. /**
  9729. * Define the current rotation the camera is rotating to
  9730. */
  9731. cameraRotation: Vector2;
  9732. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9733. ignoreParentScaling: boolean;
  9734. /**
  9735. * When set, the up vector of the camera will be updated by the rotation of the camera
  9736. */
  9737. updateUpVectorFromRotation: boolean;
  9738. private _tmpQuaternion;
  9739. /**
  9740. * Define the current rotation of the camera
  9741. */
  9742. rotation: Vector3;
  9743. /**
  9744. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9745. */
  9746. rotationQuaternion: Quaternion;
  9747. /**
  9748. * Define the current speed of the camera
  9749. */
  9750. speed: number;
  9751. /**
  9752. * Add constraint to the camera to prevent it to move freely in all directions and
  9753. * around all axis.
  9754. */
  9755. noRotationConstraint: boolean;
  9756. /**
  9757. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9758. * panning
  9759. */
  9760. invertRotation: boolean;
  9761. /**
  9762. * Speed multiplier for inverse camera panning
  9763. */
  9764. inverseRotationSpeed: number;
  9765. /**
  9766. * Define the current target of the camera as an object or a position.
  9767. */
  9768. lockedTarget: any;
  9769. /** @hidden */
  9770. _currentTarget: Vector3;
  9771. /** @hidden */
  9772. _initialFocalDistance: number;
  9773. /** @hidden */
  9774. _viewMatrix: Matrix;
  9775. /** @hidden */
  9776. _camMatrix: Matrix;
  9777. /** @hidden */
  9778. _cameraTransformMatrix: Matrix;
  9779. /** @hidden */
  9780. _cameraRotationMatrix: Matrix;
  9781. /** @hidden */
  9782. _referencePoint: Vector3;
  9783. /** @hidden */
  9784. _transformedReferencePoint: Vector3;
  9785. /** @hidden */
  9786. _reset: () => void;
  9787. private _defaultUp;
  9788. /**
  9789. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9790. * This is the base of the follow, arc rotate cameras and Free camera
  9791. * @see https://doc.babylonjs.com/features/cameras
  9792. * @param name Defines the name of the camera in the scene
  9793. * @param position Defines the start position of the camera in the scene
  9794. * @param scene Defines the scene the camera belongs to
  9795. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9796. */
  9797. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9798. /**
  9799. * Gets the position in front of the camera at a given distance.
  9800. * @param distance The distance from the camera we want the position to be
  9801. * @returns the position
  9802. */
  9803. getFrontPosition(distance: number): Vector3;
  9804. /** @hidden */
  9805. _getLockedTargetPosition(): Nullable<Vector3>;
  9806. private _storedPosition;
  9807. private _storedRotation;
  9808. private _storedRotationQuaternion;
  9809. /**
  9810. * Store current camera state of the camera (fov, position, rotation, etc..)
  9811. * @returns the camera
  9812. */
  9813. storeState(): Camera;
  9814. /**
  9815. * Restored camera state. You must call storeState() first
  9816. * @returns whether it was successful or not
  9817. * @hidden
  9818. */
  9819. _restoreStateValues(): boolean;
  9820. /** @hidden */
  9821. _initCache(): void;
  9822. /** @hidden */
  9823. _updateCache(ignoreParentClass?: boolean): void;
  9824. /** @hidden */
  9825. _isSynchronizedViewMatrix(): boolean;
  9826. /** @hidden */
  9827. _computeLocalCameraSpeed(): number;
  9828. /**
  9829. * Defines the target the camera should look at.
  9830. * @param target Defines the new target as a Vector or a mesh
  9831. */
  9832. setTarget(target: Vector3): void;
  9833. /**
  9834. * Defines the target point of the camera.
  9835. * The camera looks towards it form the radius distance.
  9836. */
  9837. get target(): Vector3;
  9838. set target(value: Vector3);
  9839. /**
  9840. * Return the current target position of the camera. This value is expressed in local space.
  9841. * @returns the target position
  9842. */
  9843. getTarget(): Vector3;
  9844. /** @hidden */
  9845. _decideIfNeedsToMove(): boolean;
  9846. /** @hidden */
  9847. _updatePosition(): void;
  9848. /** @hidden */
  9849. _checkInputs(): void;
  9850. protected _updateCameraRotationMatrix(): void;
  9851. /**
  9852. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  9853. * @returns the current camera
  9854. */
  9855. private _rotateUpVectorWithCameraRotationMatrix;
  9856. private _cachedRotationZ;
  9857. private _cachedQuaternionRotationZ;
  9858. /** @hidden */
  9859. _getViewMatrix(): Matrix;
  9860. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9861. /**
  9862. * @hidden
  9863. */
  9864. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9865. /**
  9866. * @hidden
  9867. */
  9868. _updateRigCameras(): void;
  9869. private _getRigCamPositionAndTarget;
  9870. /**
  9871. * Gets the current object class name.
  9872. * @return the class name
  9873. */
  9874. getClassName(): string;
  9875. }
  9876. }
  9877. declare module "babylonjs/Cameras/cameraInputsManager" {
  9878. import { Nullable } from "babylonjs/types";
  9879. import { Camera } from "babylonjs/Cameras/camera";
  9880. /**
  9881. * @ignore
  9882. * This is a list of all the different input types that are available in the application.
  9883. * Fo instance: ArcRotateCameraGamepadInput...
  9884. */
  9885. export var CameraInputTypes: {};
  9886. /**
  9887. * This is the contract to implement in order to create a new input class.
  9888. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9889. */
  9890. export interface ICameraInput<TCamera extends Camera> {
  9891. /**
  9892. * Defines the camera the input is attached to.
  9893. */
  9894. camera: Nullable<TCamera>;
  9895. /**
  9896. * Gets the class name of the current intput.
  9897. * @returns the class name
  9898. */
  9899. getClassName(): string;
  9900. /**
  9901. * Get the friendly name associated with the input class.
  9902. * @returns the input friendly name
  9903. */
  9904. getSimpleName(): string;
  9905. /**
  9906. * Attach the input controls to a specific dom element to get the input from.
  9907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9908. */
  9909. attachControl(noPreventDefault?: boolean): void;
  9910. /**
  9911. * Detach the current controls from the specified dom element.
  9912. */
  9913. detachControl(): void;
  9914. /**
  9915. * Update the current camera state depending on the inputs that have been used this frame.
  9916. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9917. */
  9918. checkInputs?: () => void;
  9919. }
  9920. /**
  9921. * Represents a map of input types to input instance or input index to input instance.
  9922. */
  9923. export interface CameraInputsMap<TCamera extends Camera> {
  9924. /**
  9925. * Accessor to the input by input type.
  9926. */
  9927. [name: string]: ICameraInput<TCamera>;
  9928. /**
  9929. * Accessor to the input by input index.
  9930. */
  9931. [idx: number]: ICameraInput<TCamera>;
  9932. }
  9933. /**
  9934. * This represents the input manager used within a camera.
  9935. * It helps dealing with all the different kind of input attached to a camera.
  9936. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9937. */
  9938. export class CameraInputsManager<TCamera extends Camera> {
  9939. /**
  9940. * Defines the list of inputs attahed to the camera.
  9941. */
  9942. attached: CameraInputsMap<TCamera>;
  9943. /**
  9944. * Defines the dom element the camera is collecting inputs from.
  9945. * This is null if the controls have not been attached.
  9946. */
  9947. attachedToElement: boolean;
  9948. /**
  9949. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9950. */
  9951. noPreventDefault: boolean;
  9952. /**
  9953. * Defined the camera the input manager belongs to.
  9954. */
  9955. camera: TCamera;
  9956. /**
  9957. * Update the current camera state depending on the inputs that have been used this frame.
  9958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9959. */
  9960. checkInputs: () => void;
  9961. /**
  9962. * Instantiate a new Camera Input Manager.
  9963. * @param camera Defines the camera the input manager blongs to
  9964. */
  9965. constructor(camera: TCamera);
  9966. /**
  9967. * Add an input method to a camera
  9968. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9969. * @param input camera input method
  9970. */
  9971. add(input: ICameraInput<TCamera>): void;
  9972. /**
  9973. * Remove a specific input method from a camera
  9974. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9975. * @param inputToRemove camera input method
  9976. */
  9977. remove(inputToRemove: ICameraInput<TCamera>): void;
  9978. /**
  9979. * Remove a specific input type from a camera
  9980. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9981. * @param inputType the type of the input to remove
  9982. */
  9983. removeByType(inputType: string): void;
  9984. private _addCheckInputs;
  9985. /**
  9986. * Attach the input controls to the currently attached dom element to listen the events from.
  9987. * @param input Defines the input to attach
  9988. */
  9989. attachInput(input: ICameraInput<TCamera>): void;
  9990. /**
  9991. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9992. * @param element Defines the dom element to collect the events from
  9993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9994. */
  9995. attachElement(noPreventDefault?: boolean): void;
  9996. /**
  9997. * Detach the current manager inputs controls from a specific dom element.
  9998. * @param element Defines the dom element to collect the events from
  9999. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  10000. */
  10001. detachElement(disconnect?: boolean): void;
  10002. /**
  10003. * Rebuild the dynamic inputCheck function from the current list of
  10004. * defined inputs in the manager.
  10005. */
  10006. rebuildInputCheck(): void;
  10007. /**
  10008. * Remove all attached input methods from a camera
  10009. */
  10010. clear(): void;
  10011. /**
  10012. * Serialize the current input manager attached to a camera.
  10013. * This ensures than once parsed,
  10014. * the input associated to the camera will be identical to the current ones
  10015. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  10016. */
  10017. serialize(serializedCamera: any): void;
  10018. /**
  10019. * Parses an input manager serialized JSON to restore the previous list of inputs
  10020. * and states associated to a camera.
  10021. * @param parsedCamera Defines the JSON to parse
  10022. */
  10023. parse(parsedCamera: any): void;
  10024. }
  10025. }
  10026. declare module "babylonjs/Events/keyboardEvents" {
  10027. /**
  10028. * Gather the list of keyboard event types as constants.
  10029. */
  10030. export class KeyboardEventTypes {
  10031. /**
  10032. * The keydown event is fired when a key becomes active (pressed).
  10033. */
  10034. static readonly KEYDOWN: number;
  10035. /**
  10036. * The keyup event is fired when a key has been released.
  10037. */
  10038. static readonly KEYUP: number;
  10039. }
  10040. /**
  10041. * This class is used to store keyboard related info for the onKeyboardObservable event.
  10042. */
  10043. export class KeyboardInfo {
  10044. /**
  10045. * Defines the type of event (KeyboardEventTypes)
  10046. */
  10047. type: number;
  10048. /**
  10049. * Defines the related dom event
  10050. */
  10051. event: KeyboardEvent;
  10052. /**
  10053. * Instantiates a new keyboard info.
  10054. * This class is used to store keyboard related info for the onKeyboardObservable event.
  10055. * @param type Defines the type of event (KeyboardEventTypes)
  10056. * @param event Defines the related dom event
  10057. */
  10058. constructor(
  10059. /**
  10060. * Defines the type of event (KeyboardEventTypes)
  10061. */
  10062. type: number,
  10063. /**
  10064. * Defines the related dom event
  10065. */
  10066. event: KeyboardEvent);
  10067. }
  10068. /**
  10069. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10070. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  10071. */
  10072. export class KeyboardInfoPre extends KeyboardInfo {
  10073. /**
  10074. * Defines the type of event (KeyboardEventTypes)
  10075. */
  10076. type: number;
  10077. /**
  10078. * Defines the related dom event
  10079. */
  10080. event: KeyboardEvent;
  10081. /**
  10082. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  10083. */
  10084. skipOnPointerObservable: boolean;
  10085. /**
  10086. * Instantiates a new keyboard pre info.
  10087. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10088. * @param type Defines the type of event (KeyboardEventTypes)
  10089. * @param event Defines the related dom event
  10090. */
  10091. constructor(
  10092. /**
  10093. * Defines the type of event (KeyboardEventTypes)
  10094. */
  10095. type: number,
  10096. /**
  10097. * Defines the related dom event
  10098. */
  10099. event: KeyboardEvent);
  10100. }
  10101. }
  10102. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  10103. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10104. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10105. /**
  10106. * Manage the keyboard inputs to control the movement of a free camera.
  10107. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  10108. */
  10109. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  10110. /**
  10111. * Defines the camera the input is attached to.
  10112. */
  10113. camera: FreeCamera;
  10114. /**
  10115. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  10116. */
  10117. keysUp: number[];
  10118. /**
  10119. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10120. */
  10121. keysUpward: number[];
  10122. /**
  10123. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10124. */
  10125. keysDown: number[];
  10126. /**
  10127. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10128. */
  10129. keysDownward: number[];
  10130. /**
  10131. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10132. */
  10133. keysLeft: number[];
  10134. /**
  10135. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10136. */
  10137. keysRight: number[];
  10138. private _keys;
  10139. private _onCanvasBlurObserver;
  10140. private _onKeyboardObserver;
  10141. private _engine;
  10142. private _scene;
  10143. /**
  10144. * Attach the input controls to a specific dom element to get the input from.
  10145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10146. */
  10147. attachControl(noPreventDefault?: boolean): void;
  10148. /**
  10149. * Detach the current controls from the specified dom element.
  10150. */
  10151. detachControl(): void;
  10152. /**
  10153. * Update the current camera state depending on the inputs that have been used this frame.
  10154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10155. */
  10156. checkInputs(): void;
  10157. /**
  10158. * Gets the class name of the current intput.
  10159. * @returns the class name
  10160. */
  10161. getClassName(): string;
  10162. /** @hidden */
  10163. _onLostFocus(): void;
  10164. /**
  10165. * Get the friendly name associated with the input class.
  10166. * @returns the input friendly name
  10167. */
  10168. getSimpleName(): string;
  10169. }
  10170. }
  10171. declare module "babylonjs/Actions/action" {
  10172. import { Observable } from "babylonjs/Misc/observable";
  10173. import { Condition } from "babylonjs/Actions/condition";
  10174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10175. import { Nullable } from "babylonjs/types";
  10176. import { Scene } from "babylonjs/scene";
  10177. import { ActionManager } from "babylonjs/Actions/actionManager";
  10178. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10179. import { Node } from "babylonjs/node";
  10180. /**
  10181. * Interface used to define Action
  10182. */
  10183. export interface IAction {
  10184. /**
  10185. * Trigger for the action
  10186. */
  10187. trigger: number;
  10188. /** Options of the trigger */
  10189. triggerOptions: any;
  10190. /**
  10191. * Gets the trigger parameters
  10192. * @returns the trigger parameters
  10193. */
  10194. getTriggerParameter(): any;
  10195. /**
  10196. * Internal only - executes current action event
  10197. * @hidden
  10198. */
  10199. _executeCurrent(evt?: ActionEvent): void;
  10200. /**
  10201. * Serialize placeholder for child classes
  10202. * @param parent of child
  10203. * @returns the serialized object
  10204. */
  10205. serialize(parent: any): any;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. _prepare(): void;
  10211. /**
  10212. * Internal only - manager for action
  10213. * @hidden
  10214. */
  10215. _actionManager: Nullable<AbstractActionManager>;
  10216. /**
  10217. * Adds action to chain of actions, may be a DoNothingAction
  10218. * @param action defines the next action to execute
  10219. * @returns The action passed in
  10220. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10221. */
  10222. then(action: IAction): IAction;
  10223. }
  10224. /**
  10225. * The action to be carried out following a trigger
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10227. */
  10228. export class Action implements IAction {
  10229. /** the trigger, with or without parameters, for the action */
  10230. triggerOptions: any;
  10231. /**
  10232. * Trigger for the action
  10233. */
  10234. trigger: number;
  10235. /**
  10236. * Internal only - manager for action
  10237. * @hidden
  10238. */
  10239. _actionManager: ActionManager;
  10240. private _nextActiveAction;
  10241. private _child;
  10242. private _condition?;
  10243. private _triggerParameter;
  10244. /**
  10245. * An event triggered prior to action being executed.
  10246. */
  10247. onBeforeExecuteObservable: Observable<Action>;
  10248. /**
  10249. * Creates a new Action
  10250. * @param triggerOptions the trigger, with or without parameters, for the action
  10251. * @param condition an optional determinant of action
  10252. */
  10253. constructor(
  10254. /** the trigger, with or without parameters, for the action */
  10255. triggerOptions: any, condition?: Condition);
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */
  10260. _prepare(): void;
  10261. /**
  10262. * Gets the trigger parameter
  10263. * @returns the trigger parameter
  10264. */
  10265. getTriggerParameter(): any;
  10266. /**
  10267. * Sets the trigger parameter
  10268. * @param value defines the new trigger parameter
  10269. */
  10270. setTriggerParameter(value: any): void;
  10271. /**
  10272. * Internal only - executes current action event
  10273. * @hidden
  10274. */
  10275. _executeCurrent(evt?: ActionEvent): void;
  10276. /**
  10277. * Execute placeholder for child classes
  10278. * @param evt optional action event
  10279. */
  10280. execute(evt?: ActionEvent): void;
  10281. /**
  10282. * Skips to next active action
  10283. */
  10284. skipToNextActiveAction(): void;
  10285. /**
  10286. * Adds action to chain of actions, may be a DoNothingAction
  10287. * @param action defines the next action to execute
  10288. * @returns The action passed in
  10289. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10290. */
  10291. then(action: Action): Action;
  10292. /**
  10293. * Internal only
  10294. * @hidden
  10295. */
  10296. _getProperty(propertyPath: string): string;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. _getEffectiveTarget(target: any, propertyPath: string): any;
  10302. /**
  10303. * Serialize placeholder for child classes
  10304. * @param parent of child
  10305. * @returns the serialized object
  10306. */
  10307. serialize(parent: any): any;
  10308. /**
  10309. * Internal only called by serialize
  10310. * @hidden
  10311. */
  10312. protected _serialize(serializedAction: any, parent?: any): any;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. static _SerializeValueAsString: (value: any) => string;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. static _GetTargetProperty: (target: Scene | Node) => {
  10323. name: string;
  10324. targetType: string;
  10325. value: string;
  10326. };
  10327. }
  10328. }
  10329. declare module "babylonjs/Actions/condition" {
  10330. import { ActionManager } from "babylonjs/Actions/actionManager";
  10331. /**
  10332. * A Condition applied to an Action
  10333. */
  10334. export class Condition {
  10335. /**
  10336. * Internal only - manager for action
  10337. * @hidden
  10338. */
  10339. _actionManager: ActionManager;
  10340. /**
  10341. * Internal only
  10342. * @hidden
  10343. */
  10344. _evaluationId: number;
  10345. /**
  10346. * Internal only
  10347. * @hidden
  10348. */
  10349. _currentResult: boolean;
  10350. /**
  10351. * Creates a new Condition
  10352. * @param actionManager the manager of the action the condition is applied to
  10353. */
  10354. constructor(actionManager: ActionManager);
  10355. /**
  10356. * Check if the current condition is valid
  10357. * @returns a boolean
  10358. */
  10359. isValid(): boolean;
  10360. /**
  10361. * Internal only
  10362. * @hidden
  10363. */
  10364. _getProperty(propertyPath: string): string;
  10365. /**
  10366. * Internal only
  10367. * @hidden
  10368. */
  10369. _getEffectiveTarget(target: any, propertyPath: string): any;
  10370. /**
  10371. * Serialize placeholder for child classes
  10372. * @returns the serialized object
  10373. */
  10374. serialize(): any;
  10375. /**
  10376. * Internal only
  10377. * @hidden
  10378. */
  10379. protected _serialize(serializedCondition: any): any;
  10380. }
  10381. /**
  10382. * Defines specific conditional operators as extensions of Condition
  10383. */
  10384. export class ValueCondition extends Condition {
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string;
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any;
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator: number;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. private static _IsEqual;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. private static _IsDifferent;
  10401. /**
  10402. * Internal only
  10403. * @hidden
  10404. */
  10405. private static _IsGreater;
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */
  10410. private static _IsLesser;
  10411. /**
  10412. * returns the number for IsEqual
  10413. */
  10414. static get IsEqual(): number;
  10415. /**
  10416. * Returns the number for IsDifferent
  10417. */
  10418. static get IsDifferent(): number;
  10419. /**
  10420. * Returns the number for IsGreater
  10421. */
  10422. static get IsGreater(): number;
  10423. /**
  10424. * Returns the number for IsLesser
  10425. */
  10426. static get IsLesser(): number;
  10427. /**
  10428. * Internal only The action manager for the condition
  10429. * @hidden
  10430. */
  10431. _actionManager: ActionManager;
  10432. /**
  10433. * Internal only
  10434. * @hidden
  10435. */
  10436. private _target;
  10437. /**
  10438. * Internal only
  10439. * @hidden
  10440. */
  10441. private _effectiveTarget;
  10442. /**
  10443. * Internal only
  10444. * @hidden
  10445. */
  10446. private _property;
  10447. /**
  10448. * Creates a new ValueCondition
  10449. * @param actionManager manager for the action the condition applies to
  10450. * @param target for the action
  10451. * @param propertyPath path to specify the property of the target the conditional operator uses
  10452. * @param value the value compared by the conditional operator against the current value of the property
  10453. * @param operator the conditional operator, default ValueCondition.IsEqual
  10454. */
  10455. constructor(actionManager: ActionManager, target: any,
  10456. /** path to specify the property of the target the conditional operator uses */
  10457. propertyPath: string,
  10458. /** the value compared by the conditional operator against the current value of the property */
  10459. value: any,
  10460. /** the conditional operator, default ValueCondition.IsEqual */
  10461. operator?: number);
  10462. /**
  10463. * Compares the given value with the property value for the specified conditional operator
  10464. * @returns the result of the comparison
  10465. */
  10466. isValid(): boolean;
  10467. /**
  10468. * Serialize the ValueCondition into a JSON compatible object
  10469. * @returns serialization object
  10470. */
  10471. serialize(): any;
  10472. /**
  10473. * Gets the name of the conditional operator for the ValueCondition
  10474. * @param operator the conditional operator
  10475. * @returns the name
  10476. */
  10477. static GetOperatorName(operator: number): string;
  10478. }
  10479. /**
  10480. * Defines a predicate condition as an extension of Condition
  10481. */
  10482. export class PredicateCondition extends Condition {
  10483. /** defines the predicate function used to validate the condition */
  10484. predicate: () => boolean;
  10485. /**
  10486. * Internal only - manager for action
  10487. * @hidden
  10488. */
  10489. _actionManager: ActionManager;
  10490. /**
  10491. * Creates a new PredicateCondition
  10492. * @param actionManager manager for the action the condition applies to
  10493. * @param predicate defines the predicate function used to validate the condition
  10494. */
  10495. constructor(actionManager: ActionManager,
  10496. /** defines the predicate function used to validate the condition */
  10497. predicate: () => boolean);
  10498. /**
  10499. * @returns the validity of the predicate condition
  10500. */
  10501. isValid(): boolean;
  10502. }
  10503. /**
  10504. * Defines a state condition as an extension of Condition
  10505. */
  10506. export class StateCondition extends Condition {
  10507. /** Value to compare with target state */
  10508. value: string;
  10509. /**
  10510. * Internal only - manager for action
  10511. * @hidden
  10512. */
  10513. _actionManager: ActionManager;
  10514. /**
  10515. * Internal only
  10516. * @hidden
  10517. */
  10518. private _target;
  10519. /**
  10520. * Creates a new StateCondition
  10521. * @param actionManager manager for the action the condition applies to
  10522. * @param target of the condition
  10523. * @param value to compare with target state
  10524. */
  10525. constructor(actionManager: ActionManager, target: any,
  10526. /** Value to compare with target state */
  10527. value: string);
  10528. /**
  10529. * Gets a boolean indicating if the current condition is met
  10530. * @returns the validity of the state
  10531. */
  10532. isValid(): boolean;
  10533. /**
  10534. * Serialize the StateCondition into a JSON compatible object
  10535. * @returns serialization object
  10536. */
  10537. serialize(): any;
  10538. }
  10539. }
  10540. declare module "babylonjs/Actions/directActions" {
  10541. import { Action } from "babylonjs/Actions/action";
  10542. import { Condition } from "babylonjs/Actions/condition";
  10543. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10544. /**
  10545. * This defines an action responsible to toggle a boolean once triggered.
  10546. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10547. */
  10548. export class SwitchBooleanAction extends Action {
  10549. /**
  10550. * The path to the boolean property in the target object
  10551. */
  10552. propertyPath: string;
  10553. private _target;
  10554. private _effectiveTarget;
  10555. private _property;
  10556. /**
  10557. * Instantiate the action
  10558. * @param triggerOptions defines the trigger options
  10559. * @param target defines the object containing the boolean
  10560. * @param propertyPath defines the path to the boolean property in the target object
  10561. * @param condition defines the trigger related conditions
  10562. */
  10563. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10564. /** @hidden */
  10565. _prepare(): void;
  10566. /**
  10567. * Execute the action toggle the boolean value.
  10568. */
  10569. execute(): void;
  10570. /**
  10571. * Serializes the actions and its related information.
  10572. * @param parent defines the object to serialize in
  10573. * @returns the serialized object
  10574. */
  10575. serialize(parent: any): any;
  10576. }
  10577. /**
  10578. * This defines an action responsible to set a the state field of the target
  10579. * to a desired value once triggered.
  10580. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10581. */
  10582. export class SetStateAction extends Action {
  10583. /**
  10584. * The value to store in the state field.
  10585. */
  10586. value: string;
  10587. private _target;
  10588. /**
  10589. * Instantiate the action
  10590. * @param triggerOptions defines the trigger options
  10591. * @param target defines the object containing the state property
  10592. * @param value defines the value to store in the state field
  10593. * @param condition defines the trigger related conditions
  10594. */
  10595. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10596. /**
  10597. * Execute the action and store the value on the target state property.
  10598. */
  10599. execute(): void;
  10600. /**
  10601. * Serializes the actions and its related information.
  10602. * @param parent defines the object to serialize in
  10603. * @returns the serialized object
  10604. */
  10605. serialize(parent: any): any;
  10606. }
  10607. /**
  10608. * This defines an action responsible to set a property of the target
  10609. * to a desired value once triggered.
  10610. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10611. */
  10612. export class SetValueAction extends Action {
  10613. /**
  10614. * The path of the property to set in the target.
  10615. */
  10616. propertyPath: string;
  10617. /**
  10618. * The value to set in the property
  10619. */
  10620. value: any;
  10621. private _target;
  10622. private _effectiveTarget;
  10623. private _property;
  10624. /**
  10625. * Instantiate the action
  10626. * @param triggerOptions defines the trigger options
  10627. * @param target defines the object containing the property
  10628. * @param propertyPath defines the path of the property to set in the target
  10629. * @param value defines the value to set in the property
  10630. * @param condition defines the trigger related conditions
  10631. */
  10632. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10633. /** @hidden */
  10634. _prepare(): void;
  10635. /**
  10636. * Execute the action and set the targetted property to the desired value.
  10637. */
  10638. execute(): void;
  10639. /**
  10640. * Serializes the actions and its related information.
  10641. * @param parent defines the object to serialize in
  10642. * @returns the serialized object
  10643. */
  10644. serialize(parent: any): any;
  10645. }
  10646. /**
  10647. * This defines an action responsible to increment the target value
  10648. * to a desired value once triggered.
  10649. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10650. */
  10651. export class IncrementValueAction extends Action {
  10652. /**
  10653. * The path of the property to increment in the target.
  10654. */
  10655. propertyPath: string;
  10656. /**
  10657. * The value we should increment the property by.
  10658. */
  10659. value: any;
  10660. private _target;
  10661. private _effectiveTarget;
  10662. private _property;
  10663. /**
  10664. * Instantiate the action
  10665. * @param triggerOptions defines the trigger options
  10666. * @param target defines the object containing the property
  10667. * @param propertyPath defines the path of the property to increment in the target
  10668. * @param value defines the value value we should increment the property by
  10669. * @param condition defines the trigger related conditions
  10670. */
  10671. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10672. /** @hidden */
  10673. _prepare(): void;
  10674. /**
  10675. * Execute the action and increment the target of the value amount.
  10676. */
  10677. execute(): void;
  10678. /**
  10679. * Serializes the actions and its related information.
  10680. * @param parent defines the object to serialize in
  10681. * @returns the serialized object
  10682. */
  10683. serialize(parent: any): any;
  10684. }
  10685. /**
  10686. * This defines an action responsible to start an animation once triggered.
  10687. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10688. */
  10689. export class PlayAnimationAction extends Action {
  10690. /**
  10691. * Where the animation should start (animation frame)
  10692. */
  10693. from: number;
  10694. /**
  10695. * Where the animation should stop (animation frame)
  10696. */
  10697. to: number;
  10698. /**
  10699. * Define if the animation should loop or stop after the first play.
  10700. */
  10701. loop?: boolean;
  10702. private _target;
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param target defines the target animation or animation name
  10707. * @param from defines from where the animation should start (animation frame)
  10708. * @param end defines where the animation should stop (animation frame)
  10709. * @param loop defines if the animation should loop or stop after the first play
  10710. * @param condition defines the trigger related conditions
  10711. */
  10712. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10713. /** @hidden */
  10714. _prepare(): void;
  10715. /**
  10716. * Execute the action and play the animation.
  10717. */
  10718. execute(): void;
  10719. /**
  10720. * Serializes the actions and its related information.
  10721. * @param parent defines the object to serialize in
  10722. * @returns the serialized object
  10723. */
  10724. serialize(parent: any): any;
  10725. }
  10726. /**
  10727. * This defines an action responsible to stop an animation once triggered.
  10728. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10729. */
  10730. export class StopAnimationAction extends Action {
  10731. private _target;
  10732. /**
  10733. * Instantiate the action
  10734. * @param triggerOptions defines the trigger options
  10735. * @param target defines the target animation or animation name
  10736. * @param condition defines the trigger related conditions
  10737. */
  10738. constructor(triggerOptions: any, target: any, condition?: Condition);
  10739. /** @hidden */
  10740. _prepare(): void;
  10741. /**
  10742. * Execute the action and stop the animation.
  10743. */
  10744. execute(): void;
  10745. /**
  10746. * Serializes the actions and its related information.
  10747. * @param parent defines the object to serialize in
  10748. * @returns the serialized object
  10749. */
  10750. serialize(parent: any): any;
  10751. }
  10752. /**
  10753. * This defines an action responsible that does nothing once triggered.
  10754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10755. */
  10756. export class DoNothingAction extends Action {
  10757. /**
  10758. * Instantiate the action
  10759. * @param triggerOptions defines the trigger options
  10760. * @param condition defines the trigger related conditions
  10761. */
  10762. constructor(triggerOptions?: any, condition?: Condition);
  10763. /**
  10764. * Execute the action and do nothing.
  10765. */
  10766. execute(): void;
  10767. /**
  10768. * Serializes the actions and its related information.
  10769. * @param parent defines the object to serialize in
  10770. * @returns the serialized object
  10771. */
  10772. serialize(parent: any): any;
  10773. }
  10774. /**
  10775. * This defines an action responsible to trigger several actions once triggered.
  10776. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10777. */
  10778. export class CombineAction extends Action {
  10779. /**
  10780. * The list of aggregated animations to run.
  10781. */
  10782. children: Action[];
  10783. /**
  10784. * Instantiate the action
  10785. * @param triggerOptions defines the trigger options
  10786. * @param children defines the list of aggregated animations to run
  10787. * @param condition defines the trigger related conditions
  10788. */
  10789. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10790. /** @hidden */
  10791. _prepare(): void;
  10792. /**
  10793. * Execute the action and executes all the aggregated actions.
  10794. */
  10795. execute(evt: ActionEvent): void;
  10796. /**
  10797. * Serializes the actions and its related information.
  10798. * @param parent defines the object to serialize in
  10799. * @returns the serialized object
  10800. */
  10801. serialize(parent: any): any;
  10802. }
  10803. /**
  10804. * This defines an action responsible to run code (external event) once triggered.
  10805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10806. */
  10807. export class ExecuteCodeAction extends Action {
  10808. /**
  10809. * The callback function to run.
  10810. */
  10811. func: (evt: ActionEvent) => void;
  10812. /**
  10813. * Instantiate the action
  10814. * @param triggerOptions defines the trigger options
  10815. * @param func defines the callback function to run
  10816. * @param condition defines the trigger related conditions
  10817. */
  10818. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10819. /**
  10820. * Execute the action and run the attached code.
  10821. */
  10822. execute(evt: ActionEvent): void;
  10823. }
  10824. /**
  10825. * This defines an action responsible to set the parent property of the target once triggered.
  10826. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10827. */
  10828. export class SetParentAction extends Action {
  10829. private _parent;
  10830. private _target;
  10831. /**
  10832. * Instantiate the action
  10833. * @param triggerOptions defines the trigger options
  10834. * @param target defines the target containing the parent property
  10835. * @param parent defines from where the animation should start (animation frame)
  10836. * @param condition defines the trigger related conditions
  10837. */
  10838. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10839. /** @hidden */
  10840. _prepare(): void;
  10841. /**
  10842. * Execute the action and set the parent property.
  10843. */
  10844. execute(): void;
  10845. /**
  10846. * Serializes the actions and its related information.
  10847. * @param parent defines the object to serialize in
  10848. * @returns the serialized object
  10849. */
  10850. serialize(parent: any): any;
  10851. }
  10852. }
  10853. declare module "babylonjs/Actions/actionManager" {
  10854. import { Nullable } from "babylonjs/types";
  10855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10856. import { Scene } from "babylonjs/scene";
  10857. import { IAction } from "babylonjs/Actions/action";
  10858. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10859. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10860. /**
  10861. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10862. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10863. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10864. */
  10865. export class ActionManager extends AbstractActionManager {
  10866. /**
  10867. * Nothing
  10868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly NothingTrigger: number;
  10871. /**
  10872. * On pick
  10873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnPickTrigger: number;
  10876. /**
  10877. * On left pick
  10878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnLeftPickTrigger: number;
  10881. /**
  10882. * On right pick
  10883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10884. */
  10885. static readonly OnRightPickTrigger: number;
  10886. /**
  10887. * On center pick
  10888. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10889. */
  10890. static readonly OnCenterPickTrigger: number;
  10891. /**
  10892. * On pick down
  10893. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnPickDownTrigger: number;
  10896. /**
  10897. * On double pick
  10898. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10899. */
  10900. static readonly OnDoublePickTrigger: number;
  10901. /**
  10902. * On pick up
  10903. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10904. */
  10905. static readonly OnPickUpTrigger: number;
  10906. /**
  10907. * On pick out.
  10908. * This trigger will only be raised if you also declared a OnPickDown
  10909. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10910. */
  10911. static readonly OnPickOutTrigger: number;
  10912. /**
  10913. * On long press
  10914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10915. */
  10916. static readonly OnLongPressTrigger: number;
  10917. /**
  10918. * On pointer over
  10919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10920. */
  10921. static readonly OnPointerOverTrigger: number;
  10922. /**
  10923. * On pointer out
  10924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10925. */
  10926. static readonly OnPointerOutTrigger: number;
  10927. /**
  10928. * On every frame
  10929. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10930. */
  10931. static readonly OnEveryFrameTrigger: number;
  10932. /**
  10933. * On intersection enter
  10934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10935. */
  10936. static readonly OnIntersectionEnterTrigger: number;
  10937. /**
  10938. * On intersection exit
  10939. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10940. */
  10941. static readonly OnIntersectionExitTrigger: number;
  10942. /**
  10943. * On key down
  10944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10945. */
  10946. static readonly OnKeyDownTrigger: number;
  10947. /**
  10948. * On key up
  10949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10950. */
  10951. static readonly OnKeyUpTrigger: number;
  10952. private _scene;
  10953. /**
  10954. * Creates a new action manager
  10955. * @param scene defines the hosting scene
  10956. */
  10957. constructor(scene: Scene);
  10958. /**
  10959. * Releases all associated resources
  10960. */
  10961. dispose(): void;
  10962. /**
  10963. * Gets hosting scene
  10964. * @returns the hosting scene
  10965. */
  10966. getScene(): Scene;
  10967. /**
  10968. * Does this action manager handles actions of any of the given triggers
  10969. * @param triggers defines the triggers to be tested
  10970. * @return a boolean indicating whether one (or more) of the triggers is handled
  10971. */
  10972. hasSpecificTriggers(triggers: number[]): boolean;
  10973. /**
  10974. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10975. * speed.
  10976. * @param triggerA defines the trigger to be tested
  10977. * @param triggerB defines the trigger to be tested
  10978. * @return a boolean indicating whether one (or more) of the triggers is handled
  10979. */
  10980. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10981. /**
  10982. * Does this action manager handles actions of a given trigger
  10983. * @param trigger defines the trigger to be tested
  10984. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10985. * @return whether the trigger is handled
  10986. */
  10987. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10988. /**
  10989. * Does this action manager has pointer triggers
  10990. */
  10991. get hasPointerTriggers(): boolean;
  10992. /**
  10993. * Does this action manager has pick triggers
  10994. */
  10995. get hasPickTriggers(): boolean;
  10996. /**
  10997. * Registers an action to this action manager
  10998. * @param action defines the action to be registered
  10999. * @return the action amended (prepared) after registration
  11000. */
  11001. registerAction(action: IAction): Nullable<IAction>;
  11002. /**
  11003. * Unregisters an action to this action manager
  11004. * @param action defines the action to be unregistered
  11005. * @return a boolean indicating whether the action has been unregistered
  11006. */
  11007. unregisterAction(action: IAction): Boolean;
  11008. /**
  11009. * Process a specific trigger
  11010. * @param trigger defines the trigger to process
  11011. * @param evt defines the event details to be processed
  11012. */
  11013. processTrigger(trigger: number, evt?: IActionEvent): void;
  11014. /** @hidden */
  11015. _getEffectiveTarget(target: any, propertyPath: string): any;
  11016. /** @hidden */
  11017. _getProperty(propertyPath: string): string;
  11018. /**
  11019. * Serialize this manager to a JSON object
  11020. * @param name defines the property name to store this manager
  11021. * @returns a JSON representation of this manager
  11022. */
  11023. serialize(name: string): any;
  11024. /**
  11025. * Creates a new ActionManager from a JSON data
  11026. * @param parsedActions defines the JSON data to read from
  11027. * @param object defines the hosting mesh
  11028. * @param scene defines the hosting scene
  11029. */
  11030. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11031. /**
  11032. * Get a trigger name by index
  11033. * @param trigger defines the trigger index
  11034. * @returns a trigger name
  11035. */
  11036. static GetTriggerName(trigger: number): string;
  11037. }
  11038. }
  11039. declare module "babylonjs/Culling/ray" {
  11040. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11041. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11043. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11044. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11045. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11046. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11047. import { Plane } from "babylonjs/Maths/math.plane";
  11048. /**
  11049. * Class representing a ray with position and direction
  11050. */
  11051. export class Ray {
  11052. /** origin point */
  11053. origin: Vector3;
  11054. /** direction */
  11055. direction: Vector3;
  11056. /** length of the ray */
  11057. length: number;
  11058. private static readonly _TmpVector3;
  11059. private _tmpRay;
  11060. /**
  11061. * Creates a new ray
  11062. * @param origin origin point
  11063. * @param direction direction
  11064. * @param length length of the ray
  11065. */
  11066. constructor(
  11067. /** origin point */
  11068. origin: Vector3,
  11069. /** direction */
  11070. direction: Vector3,
  11071. /** length of the ray */
  11072. length?: number);
  11073. /**
  11074. * Checks if the ray intersects a box
  11075. * This does not account for the ray lenght by design to improve perfs.
  11076. * @param minimum bound of the box
  11077. * @param maximum bound of the box
  11078. * @param intersectionTreshold extra extend to be added to the box in all direction
  11079. * @returns if the box was hit
  11080. */
  11081. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11082. /**
  11083. * Checks if the ray intersects a box
  11084. * This does not account for the ray lenght by design to improve perfs.
  11085. * @param box the bounding box to check
  11086. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11087. * @returns if the box was hit
  11088. */
  11089. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11090. /**
  11091. * If the ray hits a sphere
  11092. * @param sphere the bounding sphere to check
  11093. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11094. * @returns true if it hits the sphere
  11095. */
  11096. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11097. /**
  11098. * If the ray hits a triange
  11099. * @param vertex0 triangle vertex
  11100. * @param vertex1 triangle vertex
  11101. * @param vertex2 triangle vertex
  11102. * @returns intersection information if hit
  11103. */
  11104. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11105. /**
  11106. * Checks if ray intersects a plane
  11107. * @param plane the plane to check
  11108. * @returns the distance away it was hit
  11109. */
  11110. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11111. /**
  11112. * Calculate the intercept of a ray on a given axis
  11113. * @param axis to check 'x' | 'y' | 'z'
  11114. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11115. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11116. */
  11117. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11118. /**
  11119. * Checks if ray intersects a mesh
  11120. * @param mesh the mesh to check
  11121. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11122. * @returns picking info of the intersecton
  11123. */
  11124. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11125. /**
  11126. * Checks if ray intersects a mesh
  11127. * @param meshes the meshes to check
  11128. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11129. * @param results array to store result in
  11130. * @returns Array of picking infos
  11131. */
  11132. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11133. private _comparePickingInfo;
  11134. private static smallnum;
  11135. private static rayl;
  11136. /**
  11137. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11138. * @param sega the first point of the segment to test the intersection against
  11139. * @param segb the second point of the segment to test the intersection against
  11140. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11141. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11142. */
  11143. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11144. /**
  11145. * Update the ray from viewport position
  11146. * @param x position
  11147. * @param y y position
  11148. * @param viewportWidth viewport width
  11149. * @param viewportHeight viewport height
  11150. * @param world world matrix
  11151. * @param view view matrix
  11152. * @param projection projection matrix
  11153. * @returns this ray updated
  11154. */
  11155. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11156. /**
  11157. * Creates a ray with origin and direction of 0,0,0
  11158. * @returns the new ray
  11159. */
  11160. static Zero(): Ray;
  11161. /**
  11162. * Creates a new ray from screen space and viewport
  11163. * @param x position
  11164. * @param y y position
  11165. * @param viewportWidth viewport width
  11166. * @param viewportHeight viewport height
  11167. * @param world world matrix
  11168. * @param view view matrix
  11169. * @param projection projection matrix
  11170. * @returns new ray
  11171. */
  11172. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11173. /**
  11174. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11175. * transformed to the given world matrix.
  11176. * @param origin The origin point
  11177. * @param end The end point
  11178. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11179. * @returns the new ray
  11180. */
  11181. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11182. /**
  11183. * Transforms a ray by a matrix
  11184. * @param ray ray to transform
  11185. * @param matrix matrix to apply
  11186. * @returns the resulting new ray
  11187. */
  11188. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11189. /**
  11190. * Transforms a ray by a matrix
  11191. * @param ray ray to transform
  11192. * @param matrix matrix to apply
  11193. * @param result ray to store result in
  11194. */
  11195. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11196. /**
  11197. * Unproject a ray from screen space to object space
  11198. * @param sourceX defines the screen space x coordinate to use
  11199. * @param sourceY defines the screen space y coordinate to use
  11200. * @param viewportWidth defines the current width of the viewport
  11201. * @param viewportHeight defines the current height of the viewport
  11202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11203. * @param view defines the view matrix to use
  11204. * @param projection defines the projection matrix to use
  11205. */
  11206. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11207. }
  11208. /**
  11209. * Type used to define predicate used to select faces when a mesh intersection is detected
  11210. */
  11211. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11212. module "babylonjs/scene" {
  11213. interface Scene {
  11214. /** @hidden */
  11215. _tempPickingRay: Nullable<Ray>;
  11216. /** @hidden */
  11217. _cachedRayForTransform: Ray;
  11218. /** @hidden */
  11219. _pickWithRayInverseMatrix: Matrix;
  11220. /** @hidden */
  11221. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11222. /** @hidden */
  11223. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11224. /** @hidden */
  11225. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11226. }
  11227. }
  11228. }
  11229. declare module "babylonjs/sceneComponent" {
  11230. import { Scene } from "babylonjs/scene";
  11231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11232. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11233. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11234. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11235. import { Nullable } from "babylonjs/types";
  11236. import { Camera } from "babylonjs/Cameras/camera";
  11237. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11238. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11239. import { AbstractScene } from "babylonjs/abstractScene";
  11240. import { Mesh } from "babylonjs/Meshes/mesh";
  11241. import { Effect } from "babylonjs/Materials/effect";
  11242. /**
  11243. * Groups all the scene component constants in one place to ease maintenance.
  11244. * @hidden
  11245. */
  11246. export class SceneComponentConstants {
  11247. static readonly NAME_EFFECTLAYER: string;
  11248. static readonly NAME_LAYER: string;
  11249. static readonly NAME_LENSFLARESYSTEM: string;
  11250. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11251. static readonly NAME_PARTICLESYSTEM: string;
  11252. static readonly NAME_GAMEPAD: string;
  11253. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11254. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11255. static readonly NAME_PREPASSRENDERER: string;
  11256. static readonly NAME_DEPTHRENDERER: string;
  11257. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11258. static readonly NAME_SPRITE: string;
  11259. static readonly NAME_SUBSURFACE: string;
  11260. static readonly NAME_OUTLINERENDERER: string;
  11261. static readonly NAME_PROCEDURALTEXTURE: string;
  11262. static readonly NAME_SHADOWGENERATOR: string;
  11263. static readonly NAME_OCTREE: string;
  11264. static readonly NAME_PHYSICSENGINE: string;
  11265. static readonly NAME_AUDIO: string;
  11266. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11267. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11268. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11269. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11270. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11271. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11272. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11273. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11274. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11275. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11276. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11277. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11278. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11279. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11280. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11281. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11282. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11283. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11284. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11285. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11286. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11287. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11288. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11289. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11290. static readonly STEP_AFTERRENDER_AUDIO: number;
  11291. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11292. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11293. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11294. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11295. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11296. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11297. static readonly STEP_POINTERMOVE_SPRITE: number;
  11298. static readonly STEP_POINTERDOWN_SPRITE: number;
  11299. static readonly STEP_POINTERUP_SPRITE: number;
  11300. }
  11301. /**
  11302. * This represents a scene component.
  11303. *
  11304. * This is used to decouple the dependency the scene is having on the different workloads like
  11305. * layers, post processes...
  11306. */
  11307. export interface ISceneComponent {
  11308. /**
  11309. * The name of the component. Each component must have a unique name.
  11310. */
  11311. name: string;
  11312. /**
  11313. * The scene the component belongs to.
  11314. */
  11315. scene: Scene;
  11316. /**
  11317. * Register the component to one instance of a scene.
  11318. */
  11319. register(): void;
  11320. /**
  11321. * Rebuilds the elements related to this component in case of
  11322. * context lost for instance.
  11323. */
  11324. rebuild(): void;
  11325. /**
  11326. * Disposes the component and the associated ressources.
  11327. */
  11328. dispose(): void;
  11329. }
  11330. /**
  11331. * This represents a SERIALIZABLE scene component.
  11332. *
  11333. * This extends Scene Component to add Serialization methods on top.
  11334. */
  11335. export interface ISceneSerializableComponent extends ISceneComponent {
  11336. /**
  11337. * Adds all the elements from the container to the scene
  11338. * @param container the container holding the elements
  11339. */
  11340. addFromContainer(container: AbstractScene): void;
  11341. /**
  11342. * Removes all the elements in the container from the scene
  11343. * @param container contains the elements to remove
  11344. * @param dispose if the removed element should be disposed (default: false)
  11345. */
  11346. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11347. /**
  11348. * Serializes the component data to the specified json object
  11349. * @param serializationObject The object to serialize to
  11350. */
  11351. serialize(serializationObject: any): void;
  11352. }
  11353. /**
  11354. * Strong typing of a Mesh related stage step action
  11355. */
  11356. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11357. /**
  11358. * Strong typing of a Evaluate Sub Mesh related stage step action
  11359. */
  11360. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11361. /**
  11362. * Strong typing of a pre active Mesh related stage step action
  11363. */
  11364. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11365. /**
  11366. * Strong typing of a Camera related stage step action
  11367. */
  11368. export type CameraStageAction = (camera: Camera) => void;
  11369. /**
  11370. * Strong typing of a Camera Frame buffer related stage step action
  11371. */
  11372. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11373. /**
  11374. * Strong typing of a Render Target related stage step action
  11375. */
  11376. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11377. /**
  11378. * Strong typing of a RenderingGroup related stage step action
  11379. */
  11380. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11381. /**
  11382. * Strong typing of a Mesh Render related stage step action
  11383. */
  11384. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11385. /**
  11386. * Strong typing of a simple stage step action
  11387. */
  11388. export type SimpleStageAction = () => void;
  11389. /**
  11390. * Strong typing of a render target action.
  11391. */
  11392. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11393. /**
  11394. * Strong typing of a pointer move action.
  11395. */
  11396. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11397. /**
  11398. * Strong typing of a pointer up/down action.
  11399. */
  11400. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11401. /**
  11402. * Representation of a stage in the scene (Basically a list of ordered steps)
  11403. * @hidden
  11404. */
  11405. export class Stage<T extends Function> extends Array<{
  11406. index: number;
  11407. component: ISceneComponent;
  11408. action: T;
  11409. }> {
  11410. /**
  11411. * Hide ctor from the rest of the world.
  11412. * @param items The items to add.
  11413. */
  11414. private constructor();
  11415. /**
  11416. * Creates a new Stage.
  11417. * @returns A new instance of a Stage
  11418. */
  11419. static Create<T extends Function>(): Stage<T>;
  11420. /**
  11421. * Registers a step in an ordered way in the targeted stage.
  11422. * @param index Defines the position to register the step in
  11423. * @param component Defines the component attached to the step
  11424. * @param action Defines the action to launch during the step
  11425. */
  11426. registerStep(index: number, component: ISceneComponent, action: T): void;
  11427. /**
  11428. * Clears all the steps from the stage.
  11429. */
  11430. clear(): void;
  11431. }
  11432. }
  11433. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11434. import { Nullable } from "babylonjs/types";
  11435. import { Observable } from "babylonjs/Misc/observable";
  11436. import { Scene } from "babylonjs/scene";
  11437. import { Sprite } from "babylonjs/Sprites/sprite";
  11438. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11439. import { Ray } from "babylonjs/Culling/ray";
  11440. import { Camera } from "babylonjs/Cameras/camera";
  11441. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11442. import { ISceneComponent } from "babylonjs/sceneComponent";
  11443. module "babylonjs/scene" {
  11444. interface Scene {
  11445. /** @hidden */
  11446. _pointerOverSprite: Nullable<Sprite>;
  11447. /** @hidden */
  11448. _pickedDownSprite: Nullable<Sprite>;
  11449. /** @hidden */
  11450. _tempSpritePickingRay: Nullable<Ray>;
  11451. /**
  11452. * All of the sprite managers added to this scene
  11453. * @see https://doc.babylonjs.com/babylon101/sprites
  11454. */
  11455. spriteManagers: Array<ISpriteManager>;
  11456. /**
  11457. * An event triggered when sprites rendering is about to start
  11458. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11459. */
  11460. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11461. /**
  11462. * An event triggered when sprites rendering is done
  11463. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11464. */
  11465. onAfterSpritesRenderingObservable: Observable<Scene>;
  11466. /** @hidden */
  11467. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11468. /** Launch a ray to try to pick a sprite in the scene
  11469. * @param x position on screen
  11470. * @param y position on screen
  11471. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11472. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11473. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11474. * @returns a PickingInfo
  11475. */
  11476. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11477. /** Use the given ray to pick a sprite in the scene
  11478. * @param ray The ray (in world space) to use to pick meshes
  11479. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11480. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11481. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11482. * @returns a PickingInfo
  11483. */
  11484. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11485. /** @hidden */
  11486. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11487. /** Launch a ray to try to pick sprites in the scene
  11488. * @param x position on screen
  11489. * @param y position on screen
  11490. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11491. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11492. * @returns a PickingInfo array
  11493. */
  11494. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11495. /** Use the given ray to pick sprites in the scene
  11496. * @param ray The ray (in world space) to use to pick meshes
  11497. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11498. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11499. * @returns a PickingInfo array
  11500. */
  11501. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11502. /**
  11503. * Force the sprite under the pointer
  11504. * @param sprite defines the sprite to use
  11505. */
  11506. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11507. /**
  11508. * Gets the sprite under the pointer
  11509. * @returns a Sprite or null if no sprite is under the pointer
  11510. */
  11511. getPointerOverSprite(): Nullable<Sprite>;
  11512. }
  11513. }
  11514. /**
  11515. * Defines the sprite scene component responsible to manage sprites
  11516. * in a given scene.
  11517. */
  11518. export class SpriteSceneComponent implements ISceneComponent {
  11519. /**
  11520. * The component name helpfull to identify the component in the list of scene components.
  11521. */
  11522. readonly name: string;
  11523. /**
  11524. * The scene the component belongs to.
  11525. */
  11526. scene: Scene;
  11527. /** @hidden */
  11528. private _spritePredicate;
  11529. /**
  11530. * Creates a new instance of the component for the given scene
  11531. * @param scene Defines the scene to register the component in
  11532. */
  11533. constructor(scene: Scene);
  11534. /**
  11535. * Registers the component in a given scene
  11536. */
  11537. register(): void;
  11538. /**
  11539. * Rebuilds the elements related to this component in case of
  11540. * context lost for instance.
  11541. */
  11542. rebuild(): void;
  11543. /**
  11544. * Disposes the component and the associated ressources.
  11545. */
  11546. dispose(): void;
  11547. private _pickSpriteButKeepRay;
  11548. private _pointerMove;
  11549. private _pointerDown;
  11550. private _pointerUp;
  11551. }
  11552. }
  11553. declare module "babylonjs/Misc/timingTools" {
  11554. /**
  11555. * Class used to provide helper for timing
  11556. */
  11557. export class TimingTools {
  11558. /**
  11559. * Polyfill for setImmediate
  11560. * @param action defines the action to execute after the current execution block
  11561. */
  11562. static SetImmediate(action: () => void): void;
  11563. }
  11564. }
  11565. declare module "babylonjs/Misc/instantiationTools" {
  11566. /**
  11567. * Class used to enable instatition of objects by class name
  11568. */
  11569. export class InstantiationTools {
  11570. /**
  11571. * Use this object to register external classes like custom textures or material
  11572. * to allow the laoders to instantiate them
  11573. */
  11574. static RegisteredExternalClasses: {
  11575. [key: string]: Object;
  11576. };
  11577. /**
  11578. * Tries to instantiate a new object from a given class name
  11579. * @param className defines the class name to instantiate
  11580. * @returns the new object or null if the system was not able to do the instantiation
  11581. */
  11582. static Instantiate(className: string): any;
  11583. }
  11584. }
  11585. declare module "babylonjs/Misc/copyTools" {
  11586. import { ISize } from "babylonjs/Maths/math.size";
  11587. import { Nullable } from "babylonjs/types";
  11588. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11589. /**
  11590. * Class used to host copy specific utilities
  11591. */
  11592. export class CopyTools {
  11593. /**
  11594. * Transform some pixel data to a base64 string
  11595. * @param pixels defines the pixel data to transform to base64
  11596. * @param size defines the width and height of the (texture) data
  11597. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11598. * @returns The base64 encoded string or null
  11599. */
  11600. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11601. /**
  11602. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11603. * @param texture defines the texture to read pixels from
  11604. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11605. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11606. * @returns The base64 encoded string or null
  11607. */
  11608. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11609. /**
  11610. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11611. * @param texture defines the texture to read pixels from
  11612. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11613. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11614. * @returns The base64 encoded string or null wrapped in a promise
  11615. */
  11616. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11617. }
  11618. }
  11619. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  11620. /**
  11621. * Define options used to create a depth texture
  11622. */
  11623. export class DepthTextureCreationOptions {
  11624. /** Specifies whether or not a stencil should be allocated in the texture */
  11625. generateStencil?: boolean;
  11626. /** Specifies whether or not bilinear filtering is enable on the texture */
  11627. bilinearFiltering?: boolean;
  11628. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11629. comparisonFunction?: number;
  11630. /** Specifies if the created texture is a cube texture */
  11631. isCube?: boolean;
  11632. /** Specifies the sample count of the depth/stencil texture texture */
  11633. samples?: number;
  11634. }
  11635. }
  11636. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  11637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11638. import { Nullable } from "babylonjs/types";
  11639. import { Scene } from "babylonjs/scene";
  11640. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11641. module "babylonjs/Engines/thinEngine" {
  11642. interface ThinEngine {
  11643. /**
  11644. * Creates a depth stencil cube texture.
  11645. * This is only available in WebGL 2.
  11646. * @param size The size of face edge in the cube texture.
  11647. * @param options The options defining the cube texture.
  11648. * @returns The cube texture
  11649. */
  11650. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11651. /**
  11652. * Creates a cube texture
  11653. * @param rootUrl defines the url where the files to load is located
  11654. * @param scene defines the current scene
  11655. * @param files defines the list of files to load (1 per face)
  11656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11657. * @param onLoad defines an optional callback raised when the texture is loaded
  11658. * @param onError defines an optional callback raised if there is an issue to load the texture
  11659. * @param format defines the format of the data
  11660. * @param forcedExtension defines the extension to use to pick the right loader
  11661. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11662. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11663. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11664. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11665. * @param loaderOptions options to be passed to the loader
  11666. * @returns the cube texture as an InternalTexture
  11667. */
  11668. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  11669. /**
  11670. * Creates a cube texture
  11671. * @param rootUrl defines the url where the files to load is located
  11672. * @param scene defines the current scene
  11673. * @param files defines the list of files to load (1 per face)
  11674. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11675. * @param onLoad defines an optional callback raised when the texture is loaded
  11676. * @param onError defines an optional callback raised if there is an issue to load the texture
  11677. * @param format defines the format of the data
  11678. * @param forcedExtension defines the extension to use to pick the right loader
  11679. * @returns the cube texture as an InternalTexture
  11680. */
  11681. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  11682. /**
  11683. * Creates a cube texture
  11684. * @param rootUrl defines the url where the files to load is located
  11685. * @param scene defines the current scene
  11686. * @param files defines the list of files to load (1 per face)
  11687. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11688. * @param onLoad defines an optional callback raised when the texture is loaded
  11689. * @param onError defines an optional callback raised if there is an issue to load the texture
  11690. * @param format defines the format of the data
  11691. * @param forcedExtension defines the extension to use to pick the right loader
  11692. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11693. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11694. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11695. * @returns the cube texture as an InternalTexture
  11696. */
  11697. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  11698. /** @hidden */
  11699. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11700. /** @hidden */
  11701. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11702. /** @hidden */
  11703. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11704. /** @hidden */
  11705. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11706. /** @hidden */
  11707. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11708. /**
  11709. * @hidden
  11710. */
  11711. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11712. }
  11713. }
  11714. }
  11715. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11716. import { Nullable } from "babylonjs/types";
  11717. import { Scene } from "babylonjs/scene";
  11718. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11720. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11721. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11722. import { Observable } from "babylonjs/Misc/observable";
  11723. /**
  11724. * Class for creating a cube texture
  11725. */
  11726. export class CubeTexture extends BaseTexture {
  11727. private _delayedOnLoad;
  11728. /**
  11729. * Observable triggered once the texture has been loaded.
  11730. */
  11731. onLoadObservable: Observable<CubeTexture>;
  11732. /**
  11733. * The url of the texture
  11734. */
  11735. url: string;
  11736. /**
  11737. * Gets or sets the center of the bounding box associated with the cube texture.
  11738. * It must define where the camera used to render the texture was set
  11739. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11740. */
  11741. boundingBoxPosition: Vector3;
  11742. private _boundingBoxSize;
  11743. /**
  11744. * Gets or sets the size of the bounding box associated with the cube texture
  11745. * When defined, the cubemap will switch to local mode
  11746. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11747. * @example https://www.babylonjs-playground.com/#RNASML
  11748. */
  11749. set boundingBoxSize(value: Vector3);
  11750. /**
  11751. * Returns the bounding box size
  11752. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11753. */
  11754. get boundingBoxSize(): Vector3;
  11755. protected _rotationY: number;
  11756. /**
  11757. * Sets texture matrix rotation angle around Y axis in radians.
  11758. */
  11759. set rotationY(value: number);
  11760. /**
  11761. * Gets texture matrix rotation angle around Y axis radians.
  11762. */
  11763. get rotationY(): number;
  11764. /**
  11765. * Are mip maps generated for this texture or not.
  11766. */
  11767. get noMipmap(): boolean;
  11768. private _noMipmap;
  11769. private _files;
  11770. protected _forcedExtension: Nullable<string>;
  11771. private _extensions;
  11772. private _textureMatrix;
  11773. private _format;
  11774. private _createPolynomials;
  11775. private _loaderOptions;
  11776. /**
  11777. * Creates a cube texture from an array of image urls
  11778. * @param files defines an array of image urls
  11779. * @param scene defines the hosting scene
  11780. * @param noMipmap specifies if mip maps are not used
  11781. * @returns a cube texture
  11782. */
  11783. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11784. /**
  11785. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11786. * @param url defines the url of the prefiltered texture
  11787. * @param scene defines the scene the texture is attached to
  11788. * @param forcedExtension defines the extension of the file if different from the url
  11789. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11790. * @return the prefiltered texture
  11791. */
  11792. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11793. /**
  11794. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11795. * as prefiltered data.
  11796. * @param rootUrl defines the url of the texture or the root name of the six images
  11797. * @param null defines the scene or engine the texture is attached to
  11798. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11799. * @param noMipmap defines if mipmaps should be created or not
  11800. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11801. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11802. * @param onError defines a callback triggered in case of error during load
  11803. * @param format defines the internal format to use for the texture once loaded
  11804. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11805. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11806. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11809. * @param loaderOptions options to be passed to the loader
  11810. * @return the cube texture
  11811. */
  11812. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11813. /**
  11814. * Get the current class name of the texture useful for serialization or dynamic coding.
  11815. * @returns "CubeTexture"
  11816. */
  11817. getClassName(): string;
  11818. /**
  11819. * Update the url (and optional buffer) of this texture if url was null during construction.
  11820. * @param url the url of the texture
  11821. * @param forcedExtension defines the extension to use
  11822. * @param onLoad callback called when the texture is loaded (defaults to null)
  11823. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11824. */
  11825. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11826. /**
  11827. * Delays loading of the cube texture
  11828. * @param forcedExtension defines the extension to use
  11829. */
  11830. delayLoad(forcedExtension?: string): void;
  11831. /**
  11832. * Returns the reflection texture matrix
  11833. * @returns the reflection texture matrix
  11834. */
  11835. getReflectionTextureMatrix(): Matrix;
  11836. /**
  11837. * Sets the reflection texture matrix
  11838. * @param value Reflection texture matrix
  11839. */
  11840. setReflectionTextureMatrix(value: Matrix): void;
  11841. /**
  11842. * Parses text to create a cube texture
  11843. * @param parsedTexture define the serialized text to read from
  11844. * @param scene defines the hosting scene
  11845. * @param rootUrl defines the root url of the cube texture
  11846. * @returns a cube texture
  11847. */
  11848. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11849. /**
  11850. * Makes a clone, or deep copy, of the cube texture
  11851. * @returns a new cube texture
  11852. */
  11853. clone(): CubeTexture;
  11854. }
  11855. }
  11856. declare module "babylonjs/Materials/colorCurves" {
  11857. import { Effect } from "babylonjs/Materials/effect";
  11858. /**
  11859. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11860. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11861. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  11862. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11863. */
  11864. export class ColorCurves {
  11865. private _dirty;
  11866. private _tempColor;
  11867. private _globalCurve;
  11868. private _highlightsCurve;
  11869. private _midtonesCurve;
  11870. private _shadowsCurve;
  11871. private _positiveCurve;
  11872. private _negativeCurve;
  11873. private _globalHue;
  11874. private _globalDensity;
  11875. private _globalSaturation;
  11876. private _globalExposure;
  11877. /**
  11878. * Gets the global Hue value.
  11879. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11880. */
  11881. get globalHue(): number;
  11882. /**
  11883. * Sets the global Hue value.
  11884. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11885. */
  11886. set globalHue(value: number);
  11887. /**
  11888. * Gets the global Density value.
  11889. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11890. * Values less than zero provide a filter of opposite hue.
  11891. */
  11892. get globalDensity(): number;
  11893. /**
  11894. * Sets the global Density value.
  11895. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11896. * Values less than zero provide a filter of opposite hue.
  11897. */
  11898. set globalDensity(value: number);
  11899. /**
  11900. * Gets the global Saturation value.
  11901. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11902. */
  11903. get globalSaturation(): number;
  11904. /**
  11905. * Sets the global Saturation value.
  11906. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11907. */
  11908. set globalSaturation(value: number);
  11909. /**
  11910. * Gets the global Exposure value.
  11911. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11912. */
  11913. get globalExposure(): number;
  11914. /**
  11915. * Sets the global Exposure value.
  11916. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11917. */
  11918. set globalExposure(value: number);
  11919. private _highlightsHue;
  11920. private _highlightsDensity;
  11921. private _highlightsSaturation;
  11922. private _highlightsExposure;
  11923. /**
  11924. * Gets the highlights Hue value.
  11925. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11926. */
  11927. get highlightsHue(): number;
  11928. /**
  11929. * Sets the highlights Hue value.
  11930. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11931. */
  11932. set highlightsHue(value: number);
  11933. /**
  11934. * Gets the highlights Density value.
  11935. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11936. * Values less than zero provide a filter of opposite hue.
  11937. */
  11938. get highlightsDensity(): number;
  11939. /**
  11940. * Sets the highlights Density value.
  11941. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11942. * Values less than zero provide a filter of opposite hue.
  11943. */
  11944. set highlightsDensity(value: number);
  11945. /**
  11946. * Gets the highlights Saturation value.
  11947. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11948. */
  11949. get highlightsSaturation(): number;
  11950. /**
  11951. * Sets the highlights Saturation value.
  11952. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11953. */
  11954. set highlightsSaturation(value: number);
  11955. /**
  11956. * Gets the highlights Exposure value.
  11957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11958. */
  11959. get highlightsExposure(): number;
  11960. /**
  11961. * Sets the highlights Exposure value.
  11962. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11963. */
  11964. set highlightsExposure(value: number);
  11965. private _midtonesHue;
  11966. private _midtonesDensity;
  11967. private _midtonesSaturation;
  11968. private _midtonesExposure;
  11969. /**
  11970. * Gets the midtones Hue value.
  11971. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11972. */
  11973. get midtonesHue(): number;
  11974. /**
  11975. * Sets the midtones Hue value.
  11976. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11977. */
  11978. set midtonesHue(value: number);
  11979. /**
  11980. * Gets the midtones Density value.
  11981. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11982. * Values less than zero provide a filter of opposite hue.
  11983. */
  11984. get midtonesDensity(): number;
  11985. /**
  11986. * Sets the midtones Density value.
  11987. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11988. * Values less than zero provide a filter of opposite hue.
  11989. */
  11990. set midtonesDensity(value: number);
  11991. /**
  11992. * Gets the midtones Saturation value.
  11993. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11994. */
  11995. get midtonesSaturation(): number;
  11996. /**
  11997. * Sets the midtones Saturation value.
  11998. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11999. */
  12000. set midtonesSaturation(value: number);
  12001. /**
  12002. * Gets the midtones Exposure value.
  12003. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12004. */
  12005. get midtonesExposure(): number;
  12006. /**
  12007. * Sets the midtones Exposure value.
  12008. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12009. */
  12010. set midtonesExposure(value: number);
  12011. private _shadowsHue;
  12012. private _shadowsDensity;
  12013. private _shadowsSaturation;
  12014. private _shadowsExposure;
  12015. /**
  12016. * Gets the shadows Hue value.
  12017. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  12018. */
  12019. get shadowsHue(): number;
  12020. /**
  12021. * Sets the shadows Hue value.
  12022. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  12023. */
  12024. set shadowsHue(value: number);
  12025. /**
  12026. * Gets the shadows Density value.
  12027. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  12028. * Values less than zero provide a filter of opposite hue.
  12029. */
  12030. get shadowsDensity(): number;
  12031. /**
  12032. * Sets the shadows Density value.
  12033. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  12034. * Values less than zero provide a filter of opposite hue.
  12035. */
  12036. set shadowsDensity(value: number);
  12037. /**
  12038. * Gets the shadows Saturation value.
  12039. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  12040. */
  12041. get shadowsSaturation(): number;
  12042. /**
  12043. * Sets the shadows Saturation value.
  12044. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  12045. */
  12046. set shadowsSaturation(value: number);
  12047. /**
  12048. * Gets the shadows Exposure value.
  12049. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12050. */
  12051. get shadowsExposure(): number;
  12052. /**
  12053. * Sets the shadows Exposure value.
  12054. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  12055. */
  12056. set shadowsExposure(value: number);
  12057. /**
  12058. * Returns the class name
  12059. * @returns The class name
  12060. */
  12061. getClassName(): string;
  12062. /**
  12063. * Binds the color curves to the shader.
  12064. * @param colorCurves The color curve to bind
  12065. * @param effect The effect to bind to
  12066. * @param positiveUniform The positive uniform shader parameter
  12067. * @param neutralUniform The neutral uniform shader parameter
  12068. * @param negativeUniform The negative uniform shader parameter
  12069. */
  12070. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12071. /**
  12072. * Prepare the list of uniforms associated with the ColorCurves effects.
  12073. * @param uniformsList The list of uniforms used in the effect
  12074. */
  12075. static PrepareUniforms(uniformsList: string[]): void;
  12076. /**
  12077. * Returns color grading data based on a hue, density, saturation and exposure value.
  12078. * @param filterHue The hue of the color filter.
  12079. * @param filterDensity The density of the color filter.
  12080. * @param saturation The saturation.
  12081. * @param exposure The exposure.
  12082. * @param result The result data container.
  12083. */
  12084. private getColorGradingDataToRef;
  12085. /**
  12086. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12087. * @param value The input slider value in range [-100,100].
  12088. * @returns Adjusted value.
  12089. */
  12090. private static applyColorGradingSliderNonlinear;
  12091. /**
  12092. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12093. * @param hue The hue (H) input.
  12094. * @param saturation The saturation (S) input.
  12095. * @param brightness The brightness (B) input.
  12096. * @result An RGBA color represented as Vector4.
  12097. */
  12098. private static fromHSBToRef;
  12099. /**
  12100. * Returns a value clamped between min and max
  12101. * @param value The value to clamp
  12102. * @param min The minimum of value
  12103. * @param max The maximum of value
  12104. * @returns The clamped value.
  12105. */
  12106. private static clamp;
  12107. /**
  12108. * Clones the current color curve instance.
  12109. * @return The cloned curves
  12110. */
  12111. clone(): ColorCurves;
  12112. /**
  12113. * Serializes the current color curve instance to a json representation.
  12114. * @return a JSON representation
  12115. */
  12116. serialize(): any;
  12117. /**
  12118. * Parses the color curve from a json representation.
  12119. * @param source the JSON source to parse
  12120. * @return The parsed curves
  12121. */
  12122. static Parse(source: any): ColorCurves;
  12123. }
  12124. }
  12125. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  12126. import { Observable } from "babylonjs/Misc/observable";
  12127. import { Nullable } from "babylonjs/types";
  12128. import { Color4 } from "babylonjs/Maths/math.color";
  12129. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  12130. import { Effect } from "babylonjs/Materials/effect";
  12131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12132. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  12133. /**
  12134. * Interface to follow in your material defines to integrate easily the
  12135. * Image proccessing functions.
  12136. * @hidden
  12137. */
  12138. export interface IImageProcessingConfigurationDefines {
  12139. IMAGEPROCESSING: boolean;
  12140. VIGNETTE: boolean;
  12141. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12142. VIGNETTEBLENDMODEOPAQUE: boolean;
  12143. TONEMAPPING: boolean;
  12144. TONEMAPPING_ACES: boolean;
  12145. CONTRAST: boolean;
  12146. EXPOSURE: boolean;
  12147. COLORCURVES: boolean;
  12148. COLORGRADING: boolean;
  12149. COLORGRADING3D: boolean;
  12150. SAMPLER3DGREENDEPTH: boolean;
  12151. SAMPLER3DBGRMAP: boolean;
  12152. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12153. }
  12154. /**
  12155. * @hidden
  12156. */
  12157. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12158. IMAGEPROCESSING: boolean;
  12159. VIGNETTE: boolean;
  12160. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12161. VIGNETTEBLENDMODEOPAQUE: boolean;
  12162. TONEMAPPING: boolean;
  12163. TONEMAPPING_ACES: boolean;
  12164. CONTRAST: boolean;
  12165. COLORCURVES: boolean;
  12166. COLORGRADING: boolean;
  12167. COLORGRADING3D: boolean;
  12168. SAMPLER3DGREENDEPTH: boolean;
  12169. SAMPLER3DBGRMAP: boolean;
  12170. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12171. EXPOSURE: boolean;
  12172. constructor();
  12173. }
  12174. /**
  12175. * This groups together the common properties used for image processing either in direct forward pass
  12176. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12177. * or not.
  12178. */
  12179. export class ImageProcessingConfiguration {
  12180. /**
  12181. * Default tone mapping applied in BabylonJS.
  12182. */
  12183. static readonly TONEMAPPING_STANDARD: number;
  12184. /**
  12185. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  12186. * to other engines rendering to increase portability.
  12187. */
  12188. static readonly TONEMAPPING_ACES: number;
  12189. /**
  12190. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12191. */
  12192. colorCurves: Nullable<ColorCurves>;
  12193. private _colorCurvesEnabled;
  12194. /**
  12195. * Gets wether the color curves effect is enabled.
  12196. */
  12197. get colorCurvesEnabled(): boolean;
  12198. /**
  12199. * Sets wether the color curves effect is enabled.
  12200. */
  12201. set colorCurvesEnabled(value: boolean);
  12202. private _colorGradingTexture;
  12203. /**
  12204. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12205. */
  12206. get colorGradingTexture(): Nullable<BaseTexture>;
  12207. /**
  12208. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12209. */
  12210. set colorGradingTexture(value: Nullable<BaseTexture>);
  12211. private _colorGradingEnabled;
  12212. /**
  12213. * Gets wether the color grading effect is enabled.
  12214. */
  12215. get colorGradingEnabled(): boolean;
  12216. /**
  12217. * Sets wether the color grading effect is enabled.
  12218. */
  12219. set colorGradingEnabled(value: boolean);
  12220. private _colorGradingWithGreenDepth;
  12221. /**
  12222. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12223. */
  12224. get colorGradingWithGreenDepth(): boolean;
  12225. /**
  12226. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12227. */
  12228. set colorGradingWithGreenDepth(value: boolean);
  12229. private _colorGradingBGR;
  12230. /**
  12231. * Gets wether the color grading texture contains BGR values.
  12232. */
  12233. get colorGradingBGR(): boolean;
  12234. /**
  12235. * Sets wether the color grading texture contains BGR values.
  12236. */
  12237. set colorGradingBGR(value: boolean);
  12238. /** @hidden */
  12239. _exposure: number;
  12240. /**
  12241. * Gets the Exposure used in the effect.
  12242. */
  12243. get exposure(): number;
  12244. /**
  12245. * Sets the Exposure used in the effect.
  12246. */
  12247. set exposure(value: number);
  12248. private _toneMappingEnabled;
  12249. /**
  12250. * Gets wether the tone mapping effect is enabled.
  12251. */
  12252. get toneMappingEnabled(): boolean;
  12253. /**
  12254. * Sets wether the tone mapping effect is enabled.
  12255. */
  12256. set toneMappingEnabled(value: boolean);
  12257. private _toneMappingType;
  12258. /**
  12259. * Gets the type of tone mapping effect.
  12260. */
  12261. get toneMappingType(): number;
  12262. /**
  12263. * Sets the type of tone mapping effect used in BabylonJS.
  12264. */
  12265. set toneMappingType(value: number);
  12266. protected _contrast: number;
  12267. /**
  12268. * Gets the contrast used in the effect.
  12269. */
  12270. get contrast(): number;
  12271. /**
  12272. * Sets the contrast used in the effect.
  12273. */
  12274. set contrast(value: number);
  12275. /**
  12276. * Vignette stretch size.
  12277. */
  12278. vignetteStretch: number;
  12279. /**
  12280. * Vignette centre X Offset.
  12281. */
  12282. vignetteCentreX: number;
  12283. /**
  12284. * Vignette centre Y Offset.
  12285. */
  12286. vignetteCentreY: number;
  12287. /**
  12288. * Vignette weight or intensity of the vignette effect.
  12289. */
  12290. vignetteWeight: number;
  12291. /**
  12292. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12293. * if vignetteEnabled is set to true.
  12294. */
  12295. vignetteColor: Color4;
  12296. /**
  12297. * Camera field of view used by the Vignette effect.
  12298. */
  12299. vignetteCameraFov: number;
  12300. private _vignetteBlendMode;
  12301. /**
  12302. * Gets the vignette blend mode allowing different kind of effect.
  12303. */
  12304. get vignetteBlendMode(): number;
  12305. /**
  12306. * Sets the vignette blend mode allowing different kind of effect.
  12307. */
  12308. set vignetteBlendMode(value: number);
  12309. private _vignetteEnabled;
  12310. /**
  12311. * Gets wether the vignette effect is enabled.
  12312. */
  12313. get vignetteEnabled(): boolean;
  12314. /**
  12315. * Sets wether the vignette effect is enabled.
  12316. */
  12317. set vignetteEnabled(value: boolean);
  12318. private _applyByPostProcess;
  12319. /**
  12320. * Gets wether the image processing is applied through a post process or not.
  12321. */
  12322. get applyByPostProcess(): boolean;
  12323. /**
  12324. * Sets wether the image processing is applied through a post process or not.
  12325. */
  12326. set applyByPostProcess(value: boolean);
  12327. private _isEnabled;
  12328. /**
  12329. * Gets wether the image processing is enabled or not.
  12330. */
  12331. get isEnabled(): boolean;
  12332. /**
  12333. * Sets wether the image processing is enabled or not.
  12334. */
  12335. set isEnabled(value: boolean);
  12336. /**
  12337. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12338. */
  12339. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12340. /**
  12341. * Method called each time the image processing information changes requires to recompile the effect.
  12342. */
  12343. protected _updateParameters(): void;
  12344. /**
  12345. * Gets the current class name.
  12346. * @return "ImageProcessingConfiguration"
  12347. */
  12348. getClassName(): string;
  12349. /**
  12350. * Prepare the list of uniforms associated with the Image Processing effects.
  12351. * @param uniforms The list of uniforms used in the effect
  12352. * @param defines the list of defines currently in use
  12353. */
  12354. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12355. /**
  12356. * Prepare the list of samplers associated with the Image Processing effects.
  12357. * @param samplersList The list of uniforms used in the effect
  12358. * @param defines the list of defines currently in use
  12359. */
  12360. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12361. /**
  12362. * Prepare the list of defines associated to the shader.
  12363. * @param defines the list of defines to complete
  12364. * @param forPostProcess Define if we are currently in post process mode or not
  12365. */
  12366. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12367. /**
  12368. * Returns true if all the image processing information are ready.
  12369. * @returns True if ready, otherwise, false
  12370. */
  12371. isReady(): boolean;
  12372. /**
  12373. * Binds the image processing to the shader.
  12374. * @param effect The effect to bind to
  12375. * @param overrideAspectRatio Override the aspect ratio of the effect
  12376. */
  12377. bind(effect: Effect, overrideAspectRatio?: number): void;
  12378. /**
  12379. * Clones the current image processing instance.
  12380. * @return The cloned image processing
  12381. */
  12382. clone(): ImageProcessingConfiguration;
  12383. /**
  12384. * Serializes the current image processing instance to a json representation.
  12385. * @return a JSON representation
  12386. */
  12387. serialize(): any;
  12388. /**
  12389. * Parses the image processing from a json representation.
  12390. * @param source the JSON source to parse
  12391. * @return The parsed image processing
  12392. */
  12393. static Parse(source: any): ImageProcessingConfiguration;
  12394. private static _VIGNETTEMODE_MULTIPLY;
  12395. private static _VIGNETTEMODE_OPAQUE;
  12396. /**
  12397. * Used to apply the vignette as a mix with the pixel color.
  12398. */
  12399. static get VIGNETTEMODE_MULTIPLY(): number;
  12400. /**
  12401. * Used to apply the vignette as a replacement of the pixel color.
  12402. */
  12403. static get VIGNETTEMODE_OPAQUE(): number;
  12404. }
  12405. }
  12406. declare module "babylonjs/Shaders/postprocess.vertex" {
  12407. /** @hidden */
  12408. export var postprocessVertexShader: {
  12409. name: string;
  12410. shader: string;
  12411. };
  12412. }
  12413. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  12414. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12415. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  12416. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  12417. /**
  12418. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12419. */
  12420. export type RenderTargetTextureSize = number | {
  12421. width: number;
  12422. height: number;
  12423. layers?: number;
  12424. };
  12425. module "babylonjs/Engines/thinEngine" {
  12426. interface ThinEngine {
  12427. /**
  12428. * Creates a new render target texture
  12429. * @param size defines the size of the texture
  12430. * @param options defines the options used to create the texture
  12431. * @returns a new render target texture stored in an InternalTexture
  12432. */
  12433. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12434. /**
  12435. * Creates a depth stencil texture.
  12436. * This is only available in WebGL 2 or with the depth texture extension available.
  12437. * @param size The size of face edge in the texture.
  12438. * @param options The options defining the texture.
  12439. * @returns The texture
  12440. */
  12441. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12442. /** @hidden */
  12443. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12444. }
  12445. }
  12446. }
  12447. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  12448. /**
  12449. * Defines the kind of connection point for node based material
  12450. */
  12451. export enum NodeMaterialBlockConnectionPointTypes {
  12452. /** Float */
  12453. Float = 1,
  12454. /** Int */
  12455. Int = 2,
  12456. /** Vector2 */
  12457. Vector2 = 4,
  12458. /** Vector3 */
  12459. Vector3 = 8,
  12460. /** Vector4 */
  12461. Vector4 = 16,
  12462. /** Color3 */
  12463. Color3 = 32,
  12464. /** Color4 */
  12465. Color4 = 64,
  12466. /** Matrix */
  12467. Matrix = 128,
  12468. /** Custom object */
  12469. Object = 256,
  12470. /** Detect type based on connection */
  12471. AutoDetect = 1024,
  12472. /** Output type that will be defined by input type */
  12473. BasedOnInput = 2048
  12474. }
  12475. }
  12476. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  12477. /**
  12478. * Enum used to define the target of a block
  12479. */
  12480. export enum NodeMaterialBlockTargets {
  12481. /** Vertex shader */
  12482. Vertex = 1,
  12483. /** Fragment shader */
  12484. Fragment = 2,
  12485. /** Neutral */
  12486. Neutral = 4,
  12487. /** Vertex and Fragment */
  12488. VertexAndFragment = 3
  12489. }
  12490. }
  12491. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  12492. /**
  12493. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12494. */
  12495. export enum NodeMaterialBlockConnectionPointMode {
  12496. /** Value is an uniform */
  12497. Uniform = 0,
  12498. /** Value is a mesh attribute */
  12499. Attribute = 1,
  12500. /** Value is a varying between vertex and fragment shaders */
  12501. Varying = 2,
  12502. /** Mode is undefined */
  12503. Undefined = 3
  12504. }
  12505. }
  12506. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  12507. /**
  12508. * Enum used to define system values e.g. values automatically provided by the system
  12509. */
  12510. export enum NodeMaterialSystemValues {
  12511. /** World */
  12512. World = 1,
  12513. /** View */
  12514. View = 2,
  12515. /** Projection */
  12516. Projection = 3,
  12517. /** ViewProjection */
  12518. ViewProjection = 4,
  12519. /** WorldView */
  12520. WorldView = 5,
  12521. /** WorldViewProjection */
  12522. WorldViewProjection = 6,
  12523. /** CameraPosition */
  12524. CameraPosition = 7,
  12525. /** Fog Color */
  12526. FogColor = 8,
  12527. /** Delta time */
  12528. DeltaTime = 9
  12529. }
  12530. }
  12531. declare module "babylonjs/Maths/math.frustum" {
  12532. import { Matrix } from "babylonjs/Maths/math.vector";
  12533. import { DeepImmutable } from "babylonjs/types";
  12534. import { Plane } from "babylonjs/Maths/math.plane";
  12535. /**
  12536. * Represents a camera frustum
  12537. */
  12538. export class Frustum {
  12539. /**
  12540. * Gets the planes representing the frustum
  12541. * @param transform matrix to be applied to the returned planes
  12542. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12543. */
  12544. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12545. /**
  12546. * Gets the near frustum plane transformed by the transform matrix
  12547. * @param transform transformation matrix to be applied to the resulting frustum plane
  12548. * @param frustumPlane the resuling frustum plane
  12549. */
  12550. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12551. /**
  12552. * Gets the far frustum plane transformed by the transform matrix
  12553. * @param transform transformation matrix to be applied to the resulting frustum plane
  12554. * @param frustumPlane the resuling frustum plane
  12555. */
  12556. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12557. /**
  12558. * Gets the left frustum plane transformed by the transform matrix
  12559. * @param transform transformation matrix to be applied to the resulting frustum plane
  12560. * @param frustumPlane the resuling frustum plane
  12561. */
  12562. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12563. /**
  12564. * Gets the right frustum plane transformed by the transform matrix
  12565. * @param transform transformation matrix to be applied to the resulting frustum plane
  12566. * @param frustumPlane the resuling frustum plane
  12567. */
  12568. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12569. /**
  12570. * Gets the top frustum plane transformed by the transform matrix
  12571. * @param transform transformation matrix to be applied to the resulting frustum plane
  12572. * @param frustumPlane the resuling frustum plane
  12573. */
  12574. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12575. /**
  12576. * Gets the bottom frustum plane transformed by the transform matrix
  12577. * @param transform transformation matrix to be applied to the resulting frustum plane
  12578. * @param frustumPlane the resuling frustum plane
  12579. */
  12580. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12581. /**
  12582. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12583. * @param transform transformation matrix to be applied to the resulting frustum planes
  12584. * @param frustumPlanes the resuling frustum planes
  12585. */
  12586. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12587. }
  12588. }
  12589. declare module "babylonjs/Maths/math.vertexFormat" {
  12590. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12591. /**
  12592. * Contains position and normal vectors for a vertex
  12593. */
  12594. export class PositionNormalVertex {
  12595. /** the position of the vertex (defaut: 0,0,0) */
  12596. position: Vector3;
  12597. /** the normal of the vertex (defaut: 0,1,0) */
  12598. normal: Vector3;
  12599. /**
  12600. * Creates a PositionNormalVertex
  12601. * @param position the position of the vertex (defaut: 0,0,0)
  12602. * @param normal the normal of the vertex (defaut: 0,1,0)
  12603. */
  12604. constructor(
  12605. /** the position of the vertex (defaut: 0,0,0) */
  12606. position?: Vector3,
  12607. /** the normal of the vertex (defaut: 0,1,0) */
  12608. normal?: Vector3);
  12609. /**
  12610. * Clones the PositionNormalVertex
  12611. * @returns the cloned PositionNormalVertex
  12612. */
  12613. clone(): PositionNormalVertex;
  12614. }
  12615. /**
  12616. * Contains position, normal and uv vectors for a vertex
  12617. */
  12618. export class PositionNormalTextureVertex {
  12619. /** the position of the vertex (defaut: 0,0,0) */
  12620. position: Vector3;
  12621. /** the normal of the vertex (defaut: 0,1,0) */
  12622. normal: Vector3;
  12623. /** the uv of the vertex (default: 0,0) */
  12624. uv: Vector2;
  12625. /**
  12626. * Creates a PositionNormalTextureVertex
  12627. * @param position the position of the vertex (defaut: 0,0,0)
  12628. * @param normal the normal of the vertex (defaut: 0,1,0)
  12629. * @param uv the uv of the vertex (default: 0,0)
  12630. */
  12631. constructor(
  12632. /** the position of the vertex (defaut: 0,0,0) */
  12633. position?: Vector3,
  12634. /** the normal of the vertex (defaut: 0,1,0) */
  12635. normal?: Vector3,
  12636. /** the uv of the vertex (default: 0,0) */
  12637. uv?: Vector2);
  12638. /**
  12639. * Clones the PositionNormalTextureVertex
  12640. * @returns the cloned PositionNormalTextureVertex
  12641. */
  12642. clone(): PositionNormalTextureVertex;
  12643. }
  12644. }
  12645. declare module "babylonjs/Maths/math" {
  12646. export * from "babylonjs/Maths/math.axis";
  12647. export * from "babylonjs/Maths/math.color";
  12648. export * from "babylonjs/Maths/math.constants";
  12649. export * from "babylonjs/Maths/math.frustum";
  12650. export * from "babylonjs/Maths/math.path";
  12651. export * from "babylonjs/Maths/math.plane";
  12652. export * from "babylonjs/Maths/math.size";
  12653. export * from "babylonjs/Maths/math.vector";
  12654. export * from "babylonjs/Maths/math.vertexFormat";
  12655. export * from "babylonjs/Maths/math.viewport";
  12656. }
  12657. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  12658. /**
  12659. * Enum defining the type of animations supported by InputBlock
  12660. */
  12661. export enum AnimatedInputBlockTypes {
  12662. /** No animation */
  12663. None = 0,
  12664. /** Time based animation. Will only work for floats */
  12665. Time = 1
  12666. }
  12667. }
  12668. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  12669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12670. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12671. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12672. import { Nullable } from "babylonjs/types";
  12673. import { Effect } from "babylonjs/Materials/effect";
  12674. import { Matrix } from "babylonjs/Maths/math.vector";
  12675. import { Scene } from "babylonjs/scene";
  12676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12678. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12679. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12680. import { Observable } from "babylonjs/Misc/observable";
  12681. /**
  12682. * Block used to expose an input value
  12683. */
  12684. export class InputBlock extends NodeMaterialBlock {
  12685. private _mode;
  12686. private _associatedVariableName;
  12687. private _storedValue;
  12688. private _valueCallback;
  12689. private _type;
  12690. private _animationType;
  12691. /** Gets or set a value used to limit the range of float values */
  12692. min: number;
  12693. /** Gets or set a value used to limit the range of float values */
  12694. max: number;
  12695. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12696. isBoolean: boolean;
  12697. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12698. matrixMode: number;
  12699. /** @hidden */
  12700. _systemValue: Nullable<NodeMaterialSystemValues>;
  12701. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12702. isConstant: boolean;
  12703. /** Gets or sets the group to use to display this block in the Inspector */
  12704. groupInInspector: string;
  12705. /** Gets an observable raised when the value is changed */
  12706. onValueChangedObservable: Observable<InputBlock>;
  12707. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12708. convertToGammaSpace: boolean;
  12709. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12710. convertToLinearSpace: boolean;
  12711. /**
  12712. * Gets or sets the connection point type (default is float)
  12713. */
  12714. get type(): NodeMaterialBlockConnectionPointTypes;
  12715. /**
  12716. * Creates a new InputBlock
  12717. * @param name defines the block name
  12718. * @param target defines the target of that block (Vertex by default)
  12719. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12720. */
  12721. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12722. /**
  12723. * Validates if a name is a reserve word.
  12724. * @param newName the new name to be given to the node.
  12725. * @returns false if the name is a reserve word, else true.
  12726. */
  12727. validateBlockName(newName: string): boolean;
  12728. /**
  12729. * Gets the output component
  12730. */
  12731. get output(): NodeMaterialConnectionPoint;
  12732. /**
  12733. * Set the source of this connection point to a vertex attribute
  12734. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12735. * @returns the current connection point
  12736. */
  12737. setAsAttribute(attributeName?: string): InputBlock;
  12738. /**
  12739. * Set the source of this connection point to a system value
  12740. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12741. * @returns the current connection point
  12742. */
  12743. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12744. /**
  12745. * Gets or sets the value of that point.
  12746. * Please note that this value will be ignored if valueCallback is defined
  12747. */
  12748. get value(): any;
  12749. set value(value: any);
  12750. /**
  12751. * Gets or sets a callback used to get the value of that point.
  12752. * Please note that setting this value will force the connection point to ignore the value property
  12753. */
  12754. get valueCallback(): () => any;
  12755. set valueCallback(value: () => any);
  12756. /**
  12757. * Gets or sets the associated variable name in the shader
  12758. */
  12759. get associatedVariableName(): string;
  12760. set associatedVariableName(value: string);
  12761. /** Gets or sets the type of animation applied to the input */
  12762. get animationType(): AnimatedInputBlockTypes;
  12763. set animationType(value: AnimatedInputBlockTypes);
  12764. /**
  12765. * Gets a boolean indicating that this connection point not defined yet
  12766. */
  12767. get isUndefined(): boolean;
  12768. /**
  12769. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12770. * In this case the connection point name must be the name of the uniform to use.
  12771. * Can only be set on inputs
  12772. */
  12773. get isUniform(): boolean;
  12774. set isUniform(value: boolean);
  12775. /**
  12776. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12777. * In this case the connection point name must be the name of the attribute to use
  12778. * Can only be set on inputs
  12779. */
  12780. get isAttribute(): boolean;
  12781. set isAttribute(value: boolean);
  12782. /**
  12783. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12784. * Can only be set on exit points
  12785. */
  12786. get isVarying(): boolean;
  12787. set isVarying(value: boolean);
  12788. /**
  12789. * Gets a boolean indicating that the current connection point is a system value
  12790. */
  12791. get isSystemValue(): boolean;
  12792. /**
  12793. * Gets or sets the current well known value or null if not defined as a system value
  12794. */
  12795. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12796. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12797. /**
  12798. * Gets the current class name
  12799. * @returns the class name
  12800. */
  12801. getClassName(): string;
  12802. /**
  12803. * Animate the input if animationType !== None
  12804. * @param scene defines the rendering scene
  12805. */
  12806. animate(scene: Scene): void;
  12807. private _emitDefine;
  12808. initialize(state: NodeMaterialBuildState): void;
  12809. /**
  12810. * Set the input block to its default value (based on its type)
  12811. */
  12812. setDefaultValue(): void;
  12813. private _emitConstant;
  12814. /** @hidden */
  12815. get _noContextSwitch(): boolean;
  12816. private _emit;
  12817. /** @hidden */
  12818. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12819. /** @hidden */
  12820. _transmit(effect: Effect, scene: Scene): void;
  12821. protected _buildBlock(state: NodeMaterialBuildState): void;
  12822. protected _dumpPropertiesCode(): string;
  12823. dispose(): void;
  12824. serialize(): any;
  12825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12826. }
  12827. }
  12828. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12829. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12830. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12831. import { Nullable } from "babylonjs/types";
  12832. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12833. import { Observable } from "babylonjs/Misc/observable";
  12834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12835. /**
  12836. * Enum used to define the compatibility state between two connection points
  12837. */
  12838. export enum NodeMaterialConnectionPointCompatibilityStates {
  12839. /** Points are compatibles */
  12840. Compatible = 0,
  12841. /** Points are incompatible because of their types */
  12842. TypeIncompatible = 1,
  12843. /** Points are incompatible because of their targets (vertex vs fragment) */
  12844. TargetIncompatible = 2
  12845. }
  12846. /**
  12847. * Defines the direction of a connection point
  12848. */
  12849. export enum NodeMaterialConnectionPointDirection {
  12850. /** Input */
  12851. Input = 0,
  12852. /** Output */
  12853. Output = 1
  12854. }
  12855. /**
  12856. * Defines a connection point for a block
  12857. */
  12858. export class NodeMaterialConnectionPoint {
  12859. /**
  12860. * Checks if two types are equivalent
  12861. * @param type1 type 1 to check
  12862. * @param type2 type 2 to check
  12863. * @returns true if both types are equivalent, else false
  12864. */
  12865. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12866. /** @hidden */
  12867. _ownerBlock: NodeMaterialBlock;
  12868. /** @hidden */
  12869. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12870. private _endpoints;
  12871. private _associatedVariableName;
  12872. private _direction;
  12873. /** @hidden */
  12874. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12875. /** @hidden */
  12876. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12877. /** @hidden */
  12878. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12879. private _type;
  12880. /** @hidden */
  12881. _enforceAssociatedVariableName: boolean;
  12882. /** Gets the direction of the point */
  12883. get direction(): NodeMaterialConnectionPointDirection;
  12884. /** Indicates that this connection point needs dual validation before being connected to another point */
  12885. needDualDirectionValidation: boolean;
  12886. /**
  12887. * Gets or sets the additional types supported by this connection point
  12888. */
  12889. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12890. /**
  12891. * Gets or sets the additional types excluded by this connection point
  12892. */
  12893. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12894. /**
  12895. * Observable triggered when this point is connected
  12896. */
  12897. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12898. /**
  12899. * Gets or sets the associated variable name in the shader
  12900. */
  12901. get associatedVariableName(): string;
  12902. set associatedVariableName(value: string);
  12903. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12904. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12905. /**
  12906. * Gets or sets the connection point type (default is float)
  12907. */
  12908. get type(): NodeMaterialBlockConnectionPointTypes;
  12909. set type(value: NodeMaterialBlockConnectionPointTypes);
  12910. /**
  12911. * Gets or sets the connection point name
  12912. */
  12913. name: string;
  12914. /**
  12915. * Gets or sets the connection point name
  12916. */
  12917. displayName: string;
  12918. /**
  12919. * Gets or sets a boolean indicating that this connection point can be omitted
  12920. */
  12921. isOptional: boolean;
  12922. /**
  12923. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12924. */
  12925. isExposedOnFrame: boolean;
  12926. /**
  12927. * Gets or sets number indicating the position that the port is exposed to on a frame
  12928. */
  12929. exposedPortPosition: number;
  12930. /**
  12931. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12932. */
  12933. define: string;
  12934. /** @hidden */
  12935. _prioritizeVertex: boolean;
  12936. private _target;
  12937. /** Gets or sets the target of that connection point */
  12938. get target(): NodeMaterialBlockTargets;
  12939. set target(value: NodeMaterialBlockTargets);
  12940. /**
  12941. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12942. */
  12943. get isConnected(): boolean;
  12944. /**
  12945. * Gets a boolean indicating that the current point is connected to an input block
  12946. */
  12947. get isConnectedToInputBlock(): boolean;
  12948. /**
  12949. * Gets a the connected input block (if any)
  12950. */
  12951. get connectInputBlock(): Nullable<InputBlock>;
  12952. /** Get the other side of the connection (if any) */
  12953. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12954. /** Get the block that owns this connection point */
  12955. get ownerBlock(): NodeMaterialBlock;
  12956. /** Get the block connected on the other side of this connection (if any) */
  12957. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12958. /** Get the block connected on the endpoints of this connection (if any) */
  12959. get connectedBlocks(): Array<NodeMaterialBlock>;
  12960. /** Gets the list of connected endpoints */
  12961. get endpoints(): NodeMaterialConnectionPoint[];
  12962. /** Gets a boolean indicating if that output point is connected to at least one input */
  12963. get hasEndpoints(): boolean;
  12964. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12965. get isConnectedInVertexShader(): boolean;
  12966. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12967. get isConnectedInFragmentShader(): boolean;
  12968. /**
  12969. * Creates a block suitable to be used as an input for this input point.
  12970. * If null is returned, a block based on the point type will be created.
  12971. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12972. */
  12973. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12974. /**
  12975. * Creates a new connection point
  12976. * @param name defines the connection point name
  12977. * @param ownerBlock defines the block hosting this connection point
  12978. * @param direction defines the direction of the connection point
  12979. */
  12980. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12981. /**
  12982. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12983. * @returns the class name
  12984. */
  12985. getClassName(): string;
  12986. /**
  12987. * Gets a boolean indicating if the current point can be connected to another point
  12988. * @param connectionPoint defines the other connection point
  12989. * @returns a boolean
  12990. */
  12991. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12992. /**
  12993. * Gets a number indicating if the current point can be connected to another point
  12994. * @param connectionPoint defines the other connection point
  12995. * @returns a number defining the compatibility state
  12996. */
  12997. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12998. /**
  12999. * Connect this point to another connection point
  13000. * @param connectionPoint defines the other connection point
  13001. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  13002. * @returns the current connection point
  13003. */
  13004. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  13005. /**
  13006. * Disconnect this point from one of his endpoint
  13007. * @param endpoint defines the other connection point
  13008. * @returns the current connection point
  13009. */
  13010. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  13011. /**
  13012. * Serializes this point in a JSON representation
  13013. * @param isInput defines if the connection point is an input (default is true)
  13014. * @returns the serialized point object
  13015. */
  13016. serialize(isInput?: boolean): any;
  13017. /**
  13018. * Release resources
  13019. */
  13020. dispose(): void;
  13021. }
  13022. }
  13023. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  13024. /**
  13025. * Enum used to define the material modes
  13026. */
  13027. export enum NodeMaterialModes {
  13028. /** Regular material */
  13029. Material = 0,
  13030. /** For post process */
  13031. PostProcess = 1,
  13032. /** For particle system */
  13033. Particle = 2,
  13034. /** For procedural texture */
  13035. ProceduralTexture = 3
  13036. }
  13037. }
  13038. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  13039. /** @hidden */
  13040. export var helperFunctions: {
  13041. name: string;
  13042. shader: string;
  13043. };
  13044. }
  13045. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  13046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13048. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13051. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13052. import { Effect } from "babylonjs/Materials/effect";
  13053. import { Mesh } from "babylonjs/Meshes/mesh";
  13054. import { Nullable } from "babylonjs/types";
  13055. import { Texture } from "babylonjs/Materials/Textures/texture";
  13056. import { Scene } from "babylonjs/scene";
  13057. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  13058. /**
  13059. * Block used to read a texture from a sampler
  13060. */
  13061. export class TextureBlock extends NodeMaterialBlock {
  13062. private _defineName;
  13063. private _linearDefineName;
  13064. private _gammaDefineName;
  13065. private _tempTextureRead;
  13066. private _samplerName;
  13067. private _transformedUVName;
  13068. private _textureTransformName;
  13069. private _textureInfoName;
  13070. private _mainUVName;
  13071. private _mainUVDefineName;
  13072. private _fragmentOnly;
  13073. /**
  13074. * Gets or sets the texture associated with the node
  13075. */
  13076. texture: Nullable<Texture>;
  13077. /**
  13078. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13079. */
  13080. convertToGammaSpace: boolean;
  13081. /**
  13082. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13083. */
  13084. convertToLinearSpace: boolean;
  13085. /**
  13086. * Create a new TextureBlock
  13087. * @param name defines the block name
  13088. */
  13089. constructor(name: string, fragmentOnly?: boolean);
  13090. /**
  13091. * Gets the current class name
  13092. * @returns the class name
  13093. */
  13094. getClassName(): string;
  13095. /**
  13096. * Gets the uv input component
  13097. */
  13098. get uv(): NodeMaterialConnectionPoint;
  13099. /**
  13100. * Gets the rgba output component
  13101. */
  13102. get rgba(): NodeMaterialConnectionPoint;
  13103. /**
  13104. * Gets the rgb output component
  13105. */
  13106. get rgb(): NodeMaterialConnectionPoint;
  13107. /**
  13108. * Gets the r output component
  13109. */
  13110. get r(): NodeMaterialConnectionPoint;
  13111. /**
  13112. * Gets the g output component
  13113. */
  13114. get g(): NodeMaterialConnectionPoint;
  13115. /**
  13116. * Gets the b output component
  13117. */
  13118. get b(): NodeMaterialConnectionPoint;
  13119. /**
  13120. * Gets the a output component
  13121. */
  13122. get a(): NodeMaterialConnectionPoint;
  13123. get target(): NodeMaterialBlockTargets;
  13124. autoConfigure(material: NodeMaterial): void;
  13125. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13127. isReady(): boolean;
  13128. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13129. private get _isMixed();
  13130. private _injectVertexCode;
  13131. private _writeTextureRead;
  13132. private _writeOutput;
  13133. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13134. protected _dumpPropertiesCode(): string;
  13135. serialize(): any;
  13136. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13137. dispose(): void;
  13138. }
  13139. }
  13140. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  13141. /** @hidden */
  13142. export var reflectionFunction: {
  13143. name: string;
  13144. shader: string;
  13145. };
  13146. }
  13147. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  13148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13153. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13154. import { Effect } from "babylonjs/Materials/effect";
  13155. import { Mesh } from "babylonjs/Meshes/mesh";
  13156. import { Nullable } from "babylonjs/types";
  13157. import { Scene } from "babylonjs/scene";
  13158. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  13159. /**
  13160. * Base block used to read a reflection texture from a sampler
  13161. */
  13162. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  13163. /** @hidden */
  13164. _define3DName: string;
  13165. /** @hidden */
  13166. _defineCubicName: string;
  13167. /** @hidden */
  13168. _defineExplicitName: string;
  13169. /** @hidden */
  13170. _defineProjectionName: string;
  13171. /** @hidden */
  13172. _defineLocalCubicName: string;
  13173. /** @hidden */
  13174. _defineSphericalName: string;
  13175. /** @hidden */
  13176. _definePlanarName: string;
  13177. /** @hidden */
  13178. _defineEquirectangularName: string;
  13179. /** @hidden */
  13180. _defineMirroredEquirectangularFixedName: string;
  13181. /** @hidden */
  13182. _defineEquirectangularFixedName: string;
  13183. /** @hidden */
  13184. _defineSkyboxName: string;
  13185. /** @hidden */
  13186. _defineOppositeZ: string;
  13187. /** @hidden */
  13188. _cubeSamplerName: string;
  13189. /** @hidden */
  13190. _2DSamplerName: string;
  13191. protected _positionUVWName: string;
  13192. protected _directionWName: string;
  13193. protected _reflectionVectorName: string;
  13194. /** @hidden */
  13195. _reflectionCoordsName: string;
  13196. /** @hidden */
  13197. _reflectionMatrixName: string;
  13198. protected _reflectionColorName: string;
  13199. /**
  13200. * Gets or sets the texture associated with the node
  13201. */
  13202. texture: Nullable<BaseTexture>;
  13203. /**
  13204. * Create a new ReflectionTextureBaseBlock
  13205. * @param name defines the block name
  13206. */
  13207. constructor(name: string);
  13208. /**
  13209. * Gets the current class name
  13210. * @returns the class name
  13211. */
  13212. getClassName(): string;
  13213. /**
  13214. * Gets the world position input component
  13215. */
  13216. abstract get position(): NodeMaterialConnectionPoint;
  13217. /**
  13218. * Gets the world position input component
  13219. */
  13220. abstract get worldPosition(): NodeMaterialConnectionPoint;
  13221. /**
  13222. * Gets the world normal input component
  13223. */
  13224. abstract get worldNormal(): NodeMaterialConnectionPoint;
  13225. /**
  13226. * Gets the world input component
  13227. */
  13228. abstract get world(): NodeMaterialConnectionPoint;
  13229. /**
  13230. * Gets the camera (or eye) position component
  13231. */
  13232. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  13233. /**
  13234. * Gets the view input component
  13235. */
  13236. abstract get view(): NodeMaterialConnectionPoint;
  13237. protected _getTexture(): Nullable<BaseTexture>;
  13238. autoConfigure(material: NodeMaterial): void;
  13239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13240. isReady(): boolean;
  13241. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13242. /**
  13243. * Gets the code to inject in the vertex shader
  13244. * @param state current state of the node material building
  13245. * @returns the shader code
  13246. */
  13247. handleVertexSide(state: NodeMaterialBuildState): string;
  13248. /**
  13249. * Handles the inits for the fragment code path
  13250. * @param state node material build state
  13251. */
  13252. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  13253. /**
  13254. * Generates the reflection coords code for the fragment code path
  13255. * @param worldNormalVarName name of the world normal variable
  13256. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13257. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13258. * @returns the shader code
  13259. */
  13260. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13261. /**
  13262. * Generates the reflection color code for the fragment code path
  13263. * @param lodVarName name of the lod variable
  13264. * @param swizzleLookupTexture swizzle to use for the final color variable
  13265. * @returns the shader code
  13266. */
  13267. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13268. /**
  13269. * Generates the code corresponding to the connected output points
  13270. * @param state node material build state
  13271. * @param varName name of the variable to output
  13272. * @returns the shader code
  13273. */
  13274. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13275. protected _buildBlock(state: NodeMaterialBuildState): this;
  13276. protected _dumpPropertiesCode(): string;
  13277. serialize(): any;
  13278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13279. dispose(): void;
  13280. }
  13281. }
  13282. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  13283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13284. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13285. import { Nullable } from "babylonjs/types";
  13286. /**
  13287. * Defines a connection point to be used for points with a custom object type
  13288. */
  13289. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13290. private _blockType;
  13291. private _blockName;
  13292. private _nameForCheking?;
  13293. /**
  13294. * Creates a new connection point
  13295. * @param name defines the connection point name
  13296. * @param ownerBlock defines the block hosting this connection point
  13297. * @param direction defines the direction of the connection point
  13298. */
  13299. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13300. /**
  13301. * Gets a number indicating if the current point can be connected to another point
  13302. * @param connectionPoint defines the other connection point
  13303. * @returns a number defining the compatibility state
  13304. */
  13305. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13306. /**
  13307. * Creates a block suitable to be used as an input for this input point.
  13308. * If null is returned, a block based on the point type will be created.
  13309. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  13310. */
  13311. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13312. }
  13313. }
  13314. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  13315. /**
  13316. * Enum defining the type of properties that can be edited in the property pages in the NME
  13317. */
  13318. export enum PropertyTypeForEdition {
  13319. /** property is a boolean */
  13320. Boolean = 0,
  13321. /** property is a float */
  13322. Float = 1,
  13323. /** property is a Vector2 */
  13324. Vector2 = 2,
  13325. /** property is a list of values */
  13326. List = 3
  13327. }
  13328. /**
  13329. * Interface that defines an option in a variable of type list
  13330. */
  13331. export interface IEditablePropertyListOption {
  13332. /** label of the option */
  13333. "label": string;
  13334. /** value of the option */
  13335. "value": number;
  13336. }
  13337. /**
  13338. * Interface that defines the options available for an editable property
  13339. */
  13340. export interface IEditablePropertyOption {
  13341. /** min value */
  13342. "min"?: number;
  13343. /** max value */
  13344. "max"?: number;
  13345. /** notifiers: indicates which actions to take when the property is changed */
  13346. "notifiers"?: {
  13347. /** the material should be rebuilt */
  13348. "rebuild"?: boolean;
  13349. /** the preview should be updated */
  13350. "update"?: boolean;
  13351. };
  13352. /** list of the options for a variable of type list */
  13353. "options"?: IEditablePropertyListOption[];
  13354. }
  13355. /**
  13356. * Interface that describes an editable property
  13357. */
  13358. export interface IPropertyDescriptionForEdition {
  13359. /** name of the property */
  13360. "propertyName": string;
  13361. /** display name of the property */
  13362. "displayName": string;
  13363. /** type of the property */
  13364. "type": PropertyTypeForEdition;
  13365. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13366. "groupName": string;
  13367. /** options for the property */
  13368. "options": IEditablePropertyOption;
  13369. }
  13370. /**
  13371. * Decorator that flags a property in a node material block as being editable
  13372. */
  13373. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13374. }
  13375. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  13376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13378. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13380. import { Nullable } from "babylonjs/types";
  13381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13382. import { Mesh } from "babylonjs/Meshes/mesh";
  13383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13384. import { Effect } from "babylonjs/Materials/effect";
  13385. import { Scene } from "babylonjs/scene";
  13386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13387. /**
  13388. * Block used to implement the refraction part of the sub surface module of the PBR material
  13389. */
  13390. export class RefractionBlock extends NodeMaterialBlock {
  13391. /** @hidden */
  13392. _define3DName: string;
  13393. /** @hidden */
  13394. _refractionMatrixName: string;
  13395. /** @hidden */
  13396. _defineLODRefractionAlpha: string;
  13397. /** @hidden */
  13398. _defineLinearSpecularRefraction: string;
  13399. /** @hidden */
  13400. _defineOppositeZ: string;
  13401. /** @hidden */
  13402. _cubeSamplerName: string;
  13403. /** @hidden */
  13404. _2DSamplerName: string;
  13405. /** @hidden */
  13406. _vRefractionMicrosurfaceInfosName: string;
  13407. /** @hidden */
  13408. _vRefractionInfosName: string;
  13409. /** @hidden */
  13410. _vRefractionFilteringInfoName: string;
  13411. private _scene;
  13412. /**
  13413. * The properties below are set by the main PBR block prior to calling methods of this class.
  13414. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13415. * It's less burden on the user side in the editor part.
  13416. */
  13417. /** @hidden */
  13418. viewConnectionPoint: NodeMaterialConnectionPoint;
  13419. /** @hidden */
  13420. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13421. /**
  13422. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13423. * Materials half opaque for instance using refraction could benefit from this control.
  13424. */
  13425. linkRefractionWithTransparency: boolean;
  13426. /**
  13427. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13428. */
  13429. invertRefractionY: boolean;
  13430. /**
  13431. * Gets or sets the texture associated with the node
  13432. */
  13433. texture: Nullable<BaseTexture>;
  13434. /**
  13435. * Create a new RefractionBlock
  13436. * @param name defines the block name
  13437. */
  13438. constructor(name: string);
  13439. /**
  13440. * Gets the current class name
  13441. * @returns the class name
  13442. */
  13443. getClassName(): string;
  13444. /**
  13445. * Gets the intensity input component
  13446. */
  13447. get intensity(): NodeMaterialConnectionPoint;
  13448. /**
  13449. * Gets the tint at distance input component
  13450. */
  13451. get tintAtDistance(): NodeMaterialConnectionPoint;
  13452. /**
  13453. * Gets the view input component
  13454. */
  13455. get view(): NodeMaterialConnectionPoint;
  13456. /**
  13457. * Gets the refraction object output component
  13458. */
  13459. get refraction(): NodeMaterialConnectionPoint;
  13460. /**
  13461. * Returns true if the block has a texture
  13462. */
  13463. get hasTexture(): boolean;
  13464. protected _getTexture(): Nullable<BaseTexture>;
  13465. autoConfigure(material: NodeMaterial): void;
  13466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13467. isReady(): boolean;
  13468. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13469. /**
  13470. * Gets the main code of the block (fragment side)
  13471. * @param state current state of the node material building
  13472. * @returns the shader code
  13473. */
  13474. getCode(state: NodeMaterialBuildState): string;
  13475. protected _buildBlock(state: NodeMaterialBuildState): this;
  13476. protected _dumpPropertiesCode(): string;
  13477. serialize(): any;
  13478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13479. dispose(): void;
  13480. }
  13481. }
  13482. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  13483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13485. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13488. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13490. import { Nullable } from "babylonjs/types";
  13491. import { Scene } from "babylonjs/scene";
  13492. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  13493. /**
  13494. * Base block used as input for post process
  13495. */
  13496. export class CurrentScreenBlock extends NodeMaterialBlock {
  13497. private _samplerName;
  13498. private _linearDefineName;
  13499. private _gammaDefineName;
  13500. private _mainUVName;
  13501. private _tempTextureRead;
  13502. /**
  13503. * Gets or sets the texture associated with the node
  13504. */
  13505. texture: Nullable<BaseTexture>;
  13506. /**
  13507. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13508. */
  13509. convertToGammaSpace: boolean;
  13510. /**
  13511. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13512. */
  13513. convertToLinearSpace: boolean;
  13514. /**
  13515. * Create a new CurrentScreenBlock
  13516. * @param name defines the block name
  13517. */
  13518. constructor(name: string);
  13519. /**
  13520. * Gets the current class name
  13521. * @returns the class name
  13522. */
  13523. getClassName(): string;
  13524. /**
  13525. * Gets the uv input component
  13526. */
  13527. get uv(): NodeMaterialConnectionPoint;
  13528. /**
  13529. * Gets the rgba output component
  13530. */
  13531. get rgba(): NodeMaterialConnectionPoint;
  13532. /**
  13533. * Gets the rgb output component
  13534. */
  13535. get rgb(): NodeMaterialConnectionPoint;
  13536. /**
  13537. * Gets the r output component
  13538. */
  13539. get r(): NodeMaterialConnectionPoint;
  13540. /**
  13541. * Gets the g output component
  13542. */
  13543. get g(): NodeMaterialConnectionPoint;
  13544. /**
  13545. * Gets the b output component
  13546. */
  13547. get b(): NodeMaterialConnectionPoint;
  13548. /**
  13549. * Gets the a output component
  13550. */
  13551. get a(): NodeMaterialConnectionPoint;
  13552. /**
  13553. * Initialize the block and prepare the context for build
  13554. * @param state defines the state that will be used for the build
  13555. */
  13556. initialize(state: NodeMaterialBuildState): void;
  13557. get target(): NodeMaterialBlockTargets;
  13558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13559. isReady(): boolean;
  13560. private _injectVertexCode;
  13561. private _writeTextureRead;
  13562. private _writeOutput;
  13563. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13564. serialize(): any;
  13565. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13566. dispose(): void;
  13567. }
  13568. }
  13569. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  13570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13574. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13576. import { Nullable } from "babylonjs/types";
  13577. import { Scene } from "babylonjs/scene";
  13578. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  13579. /**
  13580. * Base block used for the particle texture
  13581. */
  13582. export class ParticleTextureBlock extends NodeMaterialBlock {
  13583. private _samplerName;
  13584. private _linearDefineName;
  13585. private _gammaDefineName;
  13586. private _tempTextureRead;
  13587. /**
  13588. * Gets or sets the texture associated with the node
  13589. */
  13590. texture: Nullable<BaseTexture>;
  13591. /**
  13592. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13593. */
  13594. convertToGammaSpace: boolean;
  13595. /**
  13596. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13597. */
  13598. convertToLinearSpace: boolean;
  13599. /**
  13600. * Create a new ParticleTextureBlock
  13601. * @param name defines the block name
  13602. */
  13603. constructor(name: string);
  13604. /**
  13605. * Gets the current class name
  13606. * @returns the class name
  13607. */
  13608. getClassName(): string;
  13609. /**
  13610. * Gets the uv input component
  13611. */
  13612. get uv(): NodeMaterialConnectionPoint;
  13613. /**
  13614. * Gets the rgba output component
  13615. */
  13616. get rgba(): NodeMaterialConnectionPoint;
  13617. /**
  13618. * Gets the rgb output component
  13619. */
  13620. get rgb(): NodeMaterialConnectionPoint;
  13621. /**
  13622. * Gets the r output component
  13623. */
  13624. get r(): NodeMaterialConnectionPoint;
  13625. /**
  13626. * Gets the g output component
  13627. */
  13628. get g(): NodeMaterialConnectionPoint;
  13629. /**
  13630. * Gets the b output component
  13631. */
  13632. get b(): NodeMaterialConnectionPoint;
  13633. /**
  13634. * Gets the a output component
  13635. */
  13636. get a(): NodeMaterialConnectionPoint;
  13637. /**
  13638. * Initialize the block and prepare the context for build
  13639. * @param state defines the state that will be used for the build
  13640. */
  13641. initialize(state: NodeMaterialBuildState): void;
  13642. autoConfigure(material: NodeMaterial): void;
  13643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13644. isReady(): boolean;
  13645. private _writeOutput;
  13646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13647. serialize(): any;
  13648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13649. dispose(): void;
  13650. }
  13651. }
  13652. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  13653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13655. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  13656. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  13657. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  13658. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  13659. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  13660. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  13661. import { Scene } from "babylonjs/scene";
  13662. /**
  13663. * Class used to store shared data between 2 NodeMaterialBuildState
  13664. */
  13665. export class NodeMaterialBuildStateSharedData {
  13666. /**
  13667. * Gets the list of emitted varyings
  13668. */
  13669. temps: string[];
  13670. /**
  13671. * Gets the list of emitted varyings
  13672. */
  13673. varyings: string[];
  13674. /**
  13675. * Gets the varying declaration string
  13676. */
  13677. varyingDeclaration: string;
  13678. /**
  13679. * Input blocks
  13680. */
  13681. inputBlocks: InputBlock[];
  13682. /**
  13683. * Input blocks
  13684. */
  13685. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13686. /**
  13687. * Bindable blocks (Blocks that need to set data to the effect)
  13688. */
  13689. bindableBlocks: NodeMaterialBlock[];
  13690. /**
  13691. * List of blocks that can provide a compilation fallback
  13692. */
  13693. blocksWithFallbacks: NodeMaterialBlock[];
  13694. /**
  13695. * List of blocks that can provide a define update
  13696. */
  13697. blocksWithDefines: NodeMaterialBlock[];
  13698. /**
  13699. * List of blocks that can provide a repeatable content
  13700. */
  13701. repeatableContentBlocks: NodeMaterialBlock[];
  13702. /**
  13703. * List of blocks that can provide a dynamic list of uniforms
  13704. */
  13705. dynamicUniformBlocks: NodeMaterialBlock[];
  13706. /**
  13707. * List of blocks that can block the isReady function for the material
  13708. */
  13709. blockingBlocks: NodeMaterialBlock[];
  13710. /**
  13711. * Gets the list of animated inputs
  13712. */
  13713. animatedInputs: InputBlock[];
  13714. /**
  13715. * Build Id used to avoid multiple recompilations
  13716. */
  13717. buildId: number;
  13718. /** List of emitted variables */
  13719. variableNames: {
  13720. [key: string]: number;
  13721. };
  13722. /** List of emitted defines */
  13723. defineNames: {
  13724. [key: string]: number;
  13725. };
  13726. /** Should emit comments? */
  13727. emitComments: boolean;
  13728. /** Emit build activity */
  13729. verbose: boolean;
  13730. /** Gets or sets the hosting scene */
  13731. scene: Scene;
  13732. /**
  13733. * Gets the compilation hints emitted at compilation time
  13734. */
  13735. hints: {
  13736. needWorldViewMatrix: boolean;
  13737. needWorldViewProjectionMatrix: boolean;
  13738. needAlphaBlending: boolean;
  13739. needAlphaTesting: boolean;
  13740. };
  13741. /**
  13742. * List of compilation checks
  13743. */
  13744. checks: {
  13745. emitVertex: boolean;
  13746. emitFragment: boolean;
  13747. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13748. };
  13749. /**
  13750. * Is vertex program allowed to be empty?
  13751. */
  13752. allowEmptyVertexProgram: boolean;
  13753. /** Creates a new shared data */
  13754. constructor();
  13755. /**
  13756. * Emits console errors and exceptions if there is a failing check
  13757. */
  13758. emitErrors(): void;
  13759. }
  13760. }
  13761. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13762. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13763. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13764. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13765. /**
  13766. * Class used to store node based material build state
  13767. */
  13768. export class NodeMaterialBuildState {
  13769. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13770. supportUniformBuffers: boolean;
  13771. /**
  13772. * Gets the list of emitted attributes
  13773. */
  13774. attributes: string[];
  13775. /**
  13776. * Gets the list of emitted uniforms
  13777. */
  13778. uniforms: string[];
  13779. /**
  13780. * Gets the list of emitted constants
  13781. */
  13782. constants: string[];
  13783. /**
  13784. * Gets the list of emitted samplers
  13785. */
  13786. samplers: string[];
  13787. /**
  13788. * Gets the list of emitted functions
  13789. */
  13790. functions: {
  13791. [key: string]: string;
  13792. };
  13793. /**
  13794. * Gets the list of emitted extensions
  13795. */
  13796. extensions: {
  13797. [key: string]: string;
  13798. };
  13799. /**
  13800. * Gets the target of the compilation state
  13801. */
  13802. target: NodeMaterialBlockTargets;
  13803. /**
  13804. * Gets the list of emitted counters
  13805. */
  13806. counters: {
  13807. [key: string]: number;
  13808. };
  13809. /**
  13810. * Shared data between multiple NodeMaterialBuildState instances
  13811. */
  13812. sharedData: NodeMaterialBuildStateSharedData;
  13813. /** @hidden */
  13814. _vertexState: NodeMaterialBuildState;
  13815. /** @hidden */
  13816. _attributeDeclaration: string;
  13817. /** @hidden */
  13818. _uniformDeclaration: string;
  13819. /** @hidden */
  13820. _constantDeclaration: string;
  13821. /** @hidden */
  13822. _samplerDeclaration: string;
  13823. /** @hidden */
  13824. _varyingTransfer: string;
  13825. /** @hidden */
  13826. _injectAtEnd: string;
  13827. private _repeatableContentAnchorIndex;
  13828. /** @hidden */
  13829. _builtCompilationString: string;
  13830. /**
  13831. * Gets the emitted compilation strings
  13832. */
  13833. compilationString: string;
  13834. /**
  13835. * Finalize the compilation strings
  13836. * @param state defines the current compilation state
  13837. */
  13838. finalize(state: NodeMaterialBuildState): void;
  13839. /** @hidden */
  13840. get _repeatableContentAnchor(): string;
  13841. /** @hidden */
  13842. _getFreeVariableName(prefix: string): string;
  13843. /** @hidden */
  13844. _getFreeDefineName(prefix: string): string;
  13845. /** @hidden */
  13846. _excludeVariableName(name: string): void;
  13847. /** @hidden */
  13848. _emit2DSampler(name: string): void;
  13849. /** @hidden */
  13850. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13851. /** @hidden */
  13852. _emitExtension(name: string, extension: string, define?: string): void;
  13853. /** @hidden */
  13854. _emitFunction(name: string, code: string, comments: string): void;
  13855. /** @hidden */
  13856. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13857. replaceStrings?: {
  13858. search: RegExp;
  13859. replace: string;
  13860. }[];
  13861. repeatKey?: string;
  13862. }): string;
  13863. /** @hidden */
  13864. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13865. repeatKey?: string;
  13866. removeAttributes?: boolean;
  13867. removeUniforms?: boolean;
  13868. removeVaryings?: boolean;
  13869. removeIfDef?: boolean;
  13870. replaceStrings?: {
  13871. search: RegExp;
  13872. replace: string;
  13873. }[];
  13874. }, storeKey?: string): void;
  13875. /** @hidden */
  13876. _registerTempVariable(name: string): boolean;
  13877. /** @hidden */
  13878. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13879. /** @hidden */
  13880. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13881. /** @hidden */
  13882. _emitFloat(value: number): string;
  13883. }
  13884. }
  13885. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13886. /**
  13887. * Helper class used to generate session unique ID
  13888. */
  13889. export class UniqueIdGenerator {
  13890. private static _UniqueIdCounter;
  13891. /**
  13892. * Gets an unique (relatively to the current scene) Id
  13893. */
  13894. static get UniqueId(): number;
  13895. }
  13896. }
  13897. declare module "babylonjs/Materials/effectFallbacks" {
  13898. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13899. import { Effect } from "babylonjs/Materials/effect";
  13900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13901. /**
  13902. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13903. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13904. */
  13905. export class EffectFallbacks implements IEffectFallbacks {
  13906. private _defines;
  13907. private _currentRank;
  13908. private _maxRank;
  13909. private _mesh;
  13910. /**
  13911. * Removes the fallback from the bound mesh.
  13912. */
  13913. unBindMesh(): void;
  13914. /**
  13915. * Adds a fallback on the specified property.
  13916. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13917. * @param define The name of the define in the shader
  13918. */
  13919. addFallback(rank: number, define: string): void;
  13920. /**
  13921. * Sets the mesh to use CPU skinning when needing to fallback.
  13922. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13923. * @param mesh The mesh to use the fallbacks.
  13924. */
  13925. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13926. /**
  13927. * Checks to see if more fallbacks are still availible.
  13928. */
  13929. get hasMoreFallbacks(): boolean;
  13930. /**
  13931. * Removes the defines that should be removed when falling back.
  13932. * @param currentDefines defines the current define statements for the shader.
  13933. * @param effect defines the current effect we try to compile
  13934. * @returns The resulting defines with defines of the current rank removed.
  13935. */
  13936. reduce(currentDefines: string, effect: Effect): string;
  13937. }
  13938. }
  13939. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13940. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13942. import { Nullable } from "babylonjs/types";
  13943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13944. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13945. import { Effect } from "babylonjs/Materials/effect";
  13946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13947. import { Mesh } from "babylonjs/Meshes/mesh";
  13948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13949. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13950. import { Scene } from "babylonjs/scene";
  13951. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13952. /**
  13953. * Defines a block that can be used inside a node based material
  13954. */
  13955. export class NodeMaterialBlock {
  13956. private _buildId;
  13957. private _buildTarget;
  13958. private _target;
  13959. private _isFinalMerger;
  13960. private _isInput;
  13961. private _name;
  13962. protected _isUnique: boolean;
  13963. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13964. inputsAreExclusive: boolean;
  13965. /** @hidden */
  13966. _codeVariableName: string;
  13967. /** @hidden */
  13968. _inputs: NodeMaterialConnectionPoint[];
  13969. /** @hidden */
  13970. _outputs: NodeMaterialConnectionPoint[];
  13971. /** @hidden */
  13972. _preparationId: number;
  13973. /** @hidden */
  13974. readonly _originalTargetIsNeutral: boolean;
  13975. /**
  13976. * Gets the name of the block
  13977. */
  13978. get name(): string;
  13979. /**
  13980. * Sets the name of the block. Will check if the name is valid.
  13981. */
  13982. set name(newName: string);
  13983. /**
  13984. * Gets or sets the unique id of the node
  13985. */
  13986. uniqueId: number;
  13987. /**
  13988. * Gets or sets the comments associated with this block
  13989. */
  13990. comments: string;
  13991. /**
  13992. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13993. */
  13994. get isUnique(): boolean;
  13995. /**
  13996. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13997. */
  13998. get isFinalMerger(): boolean;
  13999. /**
  14000. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  14001. */
  14002. get isInput(): boolean;
  14003. /**
  14004. * Gets or sets the build Id
  14005. */
  14006. get buildId(): number;
  14007. set buildId(value: number);
  14008. /**
  14009. * Gets or sets the target of the block
  14010. */
  14011. get target(): NodeMaterialBlockTargets;
  14012. set target(value: NodeMaterialBlockTargets);
  14013. /**
  14014. * Gets the list of input points
  14015. */
  14016. get inputs(): NodeMaterialConnectionPoint[];
  14017. /** Gets the list of output points */
  14018. get outputs(): NodeMaterialConnectionPoint[];
  14019. /**
  14020. * Find an input by its name
  14021. * @param name defines the name of the input to look for
  14022. * @returns the input or null if not found
  14023. */
  14024. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  14025. /**
  14026. * Find an output by its name
  14027. * @param name defines the name of the outputto look for
  14028. * @returns the output or null if not found
  14029. */
  14030. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  14031. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  14032. visibleInInspector: boolean;
  14033. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  14034. visibleOnFrame: boolean;
  14035. /**
  14036. * Creates a new NodeMaterialBlock
  14037. * @param name defines the block name
  14038. * @param target defines the target of that block (Vertex by default)
  14039. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  14040. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  14041. */
  14042. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  14043. /**
  14044. * Initialize the block and prepare the context for build
  14045. * @param state defines the state that will be used for the build
  14046. */
  14047. initialize(state: NodeMaterialBuildState): void;
  14048. /**
  14049. * Bind data to effect. Will only be called for blocks with isBindable === true
  14050. * @param effect defines the effect to bind data to
  14051. * @param nodeMaterial defines the hosting NodeMaterial
  14052. * @param mesh defines the mesh that will be rendered
  14053. * @param subMesh defines the submesh that will be rendered
  14054. */
  14055. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  14056. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  14057. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  14058. protected _writeFloat(value: number): string;
  14059. /**
  14060. * Gets the current class name e.g. "NodeMaterialBlock"
  14061. * @returns the class name
  14062. */
  14063. getClassName(): string;
  14064. /**
  14065. * Register a new input. Must be called inside a block constructor
  14066. * @param name defines the connection point name
  14067. * @param type defines the connection point type
  14068. * @param isOptional defines a boolean indicating that this input can be omitted
  14069. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14070. * @param point an already created connection point. If not provided, create a new one
  14071. * @returns the current block
  14072. */
  14073. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14074. /**
  14075. * Register a new output. Must be called inside a block constructor
  14076. * @param name defines the connection point name
  14077. * @param type defines the connection point type
  14078. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14079. * @param point an already created connection point. If not provided, create a new one
  14080. * @returns the current block
  14081. */
  14082. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14083. /**
  14084. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  14085. * @param forOutput defines an optional connection point to check compatibility with
  14086. * @returns the first available input or null
  14087. */
  14088. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  14089. /**
  14090. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  14091. * @param forBlock defines an optional block to check compatibility with
  14092. * @returns the first available input or null
  14093. */
  14094. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  14095. /**
  14096. * Gets the sibling of the given output
  14097. * @param current defines the current output
  14098. * @returns the next output in the list or null
  14099. */
  14100. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  14101. /**
  14102. * Connect current block with another block
  14103. * @param other defines the block to connect with
  14104. * @param options define the various options to help pick the right connections
  14105. * @returns the current block
  14106. */
  14107. connectTo(other: NodeMaterialBlock, options?: {
  14108. input?: string;
  14109. output?: string;
  14110. outputSwizzle?: string;
  14111. }): this | undefined;
  14112. protected _buildBlock(state: NodeMaterialBuildState): void;
  14113. /**
  14114. * Add uniforms, samplers and uniform buffers at compilation time
  14115. * @param state defines the state to update
  14116. * @param nodeMaterial defines the node material requesting the update
  14117. * @param defines defines the material defines to update
  14118. * @param uniformBuffers defines the list of uniform buffer names
  14119. */
  14120. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  14121. /**
  14122. * Add potential fallbacks if shader compilation fails
  14123. * @param mesh defines the mesh to be rendered
  14124. * @param fallbacks defines the current prioritized list of fallbacks
  14125. */
  14126. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  14127. /**
  14128. * Initialize defines for shader compilation
  14129. * @param mesh defines the mesh to be rendered
  14130. * @param nodeMaterial defines the node material requesting the update
  14131. * @param defines defines the material defines to update
  14132. * @param useInstances specifies that instances should be used
  14133. */
  14134. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  14135. /**
  14136. * Update defines for shader compilation
  14137. * @param mesh defines the mesh to be rendered
  14138. * @param nodeMaterial defines the node material requesting the update
  14139. * @param defines defines the material defines to update
  14140. * @param useInstances specifies that instances should be used
  14141. * @param subMesh defines which submesh to render
  14142. */
  14143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14144. /**
  14145. * Lets the block try to connect some inputs automatically
  14146. * @param material defines the hosting NodeMaterial
  14147. */
  14148. autoConfigure(material: NodeMaterial): void;
  14149. /**
  14150. * Function called when a block is declared as repeatable content generator
  14151. * @param vertexShaderState defines the current compilation state for the vertex shader
  14152. * @param fragmentShaderState defines the current compilation state for the fragment shader
  14153. * @param mesh defines the mesh to be rendered
  14154. * @param defines defines the material defines to update
  14155. */
  14156. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  14157. /**
  14158. * Checks if the block is ready
  14159. * @param mesh defines the mesh to be rendered
  14160. * @param nodeMaterial defines the node material requesting the update
  14161. * @param defines defines the material defines to update
  14162. * @param useInstances specifies that instances should be used
  14163. * @returns true if the block is ready
  14164. */
  14165. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  14166. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  14167. private _processBuild;
  14168. /**
  14169. * Validates the new name for the block node.
  14170. * @param newName the new name to be given to the node.
  14171. * @returns false if the name is a reserve word, else true.
  14172. */
  14173. validateBlockName(newName: string): boolean;
  14174. /**
  14175. * Compile the current node and generate the shader code
  14176. * @param state defines the current compilation state (uniforms, samplers, current string)
  14177. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  14178. * @returns true if already built
  14179. */
  14180. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  14181. protected _inputRename(name: string): string;
  14182. protected _outputRename(name: string): string;
  14183. protected _dumpPropertiesCode(): string;
  14184. /** @hidden */
  14185. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  14186. /** @hidden */
  14187. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  14188. /**
  14189. * Clone the current block to a new identical block
  14190. * @param scene defines the hosting scene
  14191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  14192. * @returns a copy of the current block
  14193. */
  14194. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  14195. /**
  14196. * Serializes this block in a JSON representation
  14197. * @returns the serialized block object
  14198. */
  14199. serialize(): any;
  14200. /** @hidden */
  14201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14202. private _deserializePortDisplayNamesAndExposedOnFrame;
  14203. /**
  14204. * Release resources
  14205. */
  14206. dispose(): void;
  14207. }
  14208. }
  14209. declare module "babylonjs/Materials/pushMaterial" {
  14210. import { Nullable } from "babylonjs/types";
  14211. import { Scene } from "babylonjs/scene";
  14212. import { Matrix } from "babylonjs/Maths/math.vector";
  14213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14214. import { Mesh } from "babylonjs/Meshes/mesh";
  14215. import { Material } from "babylonjs/Materials/material";
  14216. import { Effect } from "babylonjs/Materials/effect";
  14217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14218. /**
  14219. * Base class of materials working in push mode in babylon JS
  14220. * @hidden
  14221. */
  14222. export class PushMaterial extends Material {
  14223. protected _activeEffect: Effect;
  14224. protected _normalMatrix: Matrix;
  14225. constructor(name: string, scene: Scene);
  14226. getEffect(): Effect;
  14227. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14228. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  14229. /**
  14230. * Binds the given world matrix to the active effect
  14231. *
  14232. * @param world the matrix to bind
  14233. */
  14234. bindOnlyWorldMatrix(world: Matrix): void;
  14235. /**
  14236. * Binds the given normal matrix to the active effect
  14237. *
  14238. * @param normalMatrix the matrix to bind
  14239. */
  14240. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14241. bind(world: Matrix, mesh?: Mesh): void;
  14242. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14243. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14244. }
  14245. }
  14246. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  14247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14248. /**
  14249. * Root class for all node material optimizers
  14250. */
  14251. export class NodeMaterialOptimizer {
  14252. /**
  14253. * Function used to optimize a NodeMaterial graph
  14254. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  14255. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  14256. */
  14257. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  14258. }
  14259. }
  14260. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  14261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14264. import { Scene } from "babylonjs/scene";
  14265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14266. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  14267. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14268. /**
  14269. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  14270. */
  14271. export class TransformBlock extends NodeMaterialBlock {
  14272. /**
  14273. * Defines the value to use to complement W value to transform it to a Vector4
  14274. */
  14275. complementW: number;
  14276. /**
  14277. * Defines the value to use to complement z value to transform it to a Vector4
  14278. */
  14279. complementZ: number;
  14280. /**
  14281. * Creates a new TransformBlock
  14282. * @param name defines the block name
  14283. */
  14284. constructor(name: string);
  14285. /**
  14286. * Gets the current class name
  14287. * @returns the class name
  14288. */
  14289. getClassName(): string;
  14290. /**
  14291. * Gets the vector input
  14292. */
  14293. get vector(): NodeMaterialConnectionPoint;
  14294. /**
  14295. * Gets the output component
  14296. */
  14297. get output(): NodeMaterialConnectionPoint;
  14298. /**
  14299. * Gets the xyz output component
  14300. */
  14301. get xyz(): NodeMaterialConnectionPoint;
  14302. /**
  14303. * Gets the matrix transform input
  14304. */
  14305. get transform(): NodeMaterialConnectionPoint;
  14306. protected _buildBlock(state: NodeMaterialBuildState): this;
  14307. /**
  14308. * Update defines for shader compilation
  14309. * @param mesh defines the mesh to be rendered
  14310. * @param nodeMaterial defines the node material requesting the update
  14311. * @param defines defines the material defines to update
  14312. * @param useInstances specifies that instances should be used
  14313. * @param subMesh defines which submesh to render
  14314. */
  14315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14316. serialize(): any;
  14317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14318. protected _dumpPropertiesCode(): string;
  14319. }
  14320. }
  14321. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  14322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14325. /**
  14326. * Block used to output the vertex position
  14327. */
  14328. export class VertexOutputBlock extends NodeMaterialBlock {
  14329. /**
  14330. * Creates a new VertexOutputBlock
  14331. * @param name defines the block name
  14332. */
  14333. constructor(name: string);
  14334. /**
  14335. * Gets the current class name
  14336. * @returns the class name
  14337. */
  14338. getClassName(): string;
  14339. /**
  14340. * Gets the vector input component
  14341. */
  14342. get vector(): NodeMaterialConnectionPoint;
  14343. protected _buildBlock(state: NodeMaterialBuildState): this;
  14344. }
  14345. }
  14346. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  14347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14350. /**
  14351. * Block used to output the final color
  14352. */
  14353. export class FragmentOutputBlock extends NodeMaterialBlock {
  14354. /**
  14355. * Create a new FragmentOutputBlock
  14356. * @param name defines the block name
  14357. */
  14358. constructor(name: string);
  14359. /**
  14360. * Gets the current class name
  14361. * @returns the class name
  14362. */
  14363. getClassName(): string;
  14364. /**
  14365. * Gets the rgba input component
  14366. */
  14367. get rgba(): NodeMaterialConnectionPoint;
  14368. /**
  14369. * Gets the rgb input component
  14370. */
  14371. get rgb(): NodeMaterialConnectionPoint;
  14372. /**
  14373. * Gets the a input component
  14374. */
  14375. get a(): NodeMaterialConnectionPoint;
  14376. protected _buildBlock(state: NodeMaterialBuildState): this;
  14377. }
  14378. }
  14379. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  14380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14383. /**
  14384. * Block used for the particle ramp gradient section
  14385. */
  14386. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14387. /**
  14388. * Create a new ParticleRampGradientBlock
  14389. * @param name defines the block name
  14390. */
  14391. constructor(name: string);
  14392. /**
  14393. * Gets the current class name
  14394. * @returns the class name
  14395. */
  14396. getClassName(): string;
  14397. /**
  14398. * Gets the color input component
  14399. */
  14400. get color(): NodeMaterialConnectionPoint;
  14401. /**
  14402. * Gets the rampColor output component
  14403. */
  14404. get rampColor(): NodeMaterialConnectionPoint;
  14405. /**
  14406. * Initialize the block and prepare the context for build
  14407. * @param state defines the state that will be used for the build
  14408. */
  14409. initialize(state: NodeMaterialBuildState): void;
  14410. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14411. }
  14412. }
  14413. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  14414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14417. /**
  14418. * Block used for the particle blend multiply section
  14419. */
  14420. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14421. /**
  14422. * Create a new ParticleBlendMultiplyBlock
  14423. * @param name defines the block name
  14424. */
  14425. constructor(name: string);
  14426. /**
  14427. * Gets the current class name
  14428. * @returns the class name
  14429. */
  14430. getClassName(): string;
  14431. /**
  14432. * Gets the color input component
  14433. */
  14434. get color(): NodeMaterialConnectionPoint;
  14435. /**
  14436. * Gets the alphaTexture input component
  14437. */
  14438. get alphaTexture(): NodeMaterialConnectionPoint;
  14439. /**
  14440. * Gets the alphaColor input component
  14441. */
  14442. get alphaColor(): NodeMaterialConnectionPoint;
  14443. /**
  14444. * Gets the blendColor output component
  14445. */
  14446. get blendColor(): NodeMaterialConnectionPoint;
  14447. /**
  14448. * Initialize the block and prepare the context for build
  14449. * @param state defines the state that will be used for the build
  14450. */
  14451. initialize(state: NodeMaterialBuildState): void;
  14452. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14453. }
  14454. }
  14455. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  14456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14459. /**
  14460. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14461. */
  14462. export class VectorMergerBlock extends NodeMaterialBlock {
  14463. /**
  14464. * Create a new VectorMergerBlock
  14465. * @param name defines the block name
  14466. */
  14467. constructor(name: string);
  14468. /**
  14469. * Gets the current class name
  14470. * @returns the class name
  14471. */
  14472. getClassName(): string;
  14473. /**
  14474. * Gets the xyz component (input)
  14475. */
  14476. get xyzIn(): NodeMaterialConnectionPoint;
  14477. /**
  14478. * Gets the xy component (input)
  14479. */
  14480. get xyIn(): NodeMaterialConnectionPoint;
  14481. /**
  14482. * Gets the x component (input)
  14483. */
  14484. get x(): NodeMaterialConnectionPoint;
  14485. /**
  14486. * Gets the y component (input)
  14487. */
  14488. get y(): NodeMaterialConnectionPoint;
  14489. /**
  14490. * Gets the z component (input)
  14491. */
  14492. get z(): NodeMaterialConnectionPoint;
  14493. /**
  14494. * Gets the w component (input)
  14495. */
  14496. get w(): NodeMaterialConnectionPoint;
  14497. /**
  14498. * Gets the xyzw component (output)
  14499. */
  14500. get xyzw(): NodeMaterialConnectionPoint;
  14501. /**
  14502. * Gets the xyz component (output)
  14503. */
  14504. get xyzOut(): NodeMaterialConnectionPoint;
  14505. /**
  14506. * Gets the xy component (output)
  14507. */
  14508. get xyOut(): NodeMaterialConnectionPoint;
  14509. /**
  14510. * Gets the xy component (output)
  14511. * @deprecated Please use xyOut instead.
  14512. */
  14513. get xy(): NodeMaterialConnectionPoint;
  14514. /**
  14515. * Gets the xyz component (output)
  14516. * @deprecated Please use xyzOut instead.
  14517. */
  14518. get xyz(): NodeMaterialConnectionPoint;
  14519. protected _buildBlock(state: NodeMaterialBuildState): this;
  14520. }
  14521. }
  14522. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  14523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14526. import { Vector2 } from "babylonjs/Maths/math.vector";
  14527. import { Scene } from "babylonjs/scene";
  14528. /**
  14529. * Block used to remap a float from a range to a new one
  14530. */
  14531. export class RemapBlock extends NodeMaterialBlock {
  14532. /**
  14533. * Gets or sets the source range
  14534. */
  14535. sourceRange: Vector2;
  14536. /**
  14537. * Gets or sets the target range
  14538. */
  14539. targetRange: Vector2;
  14540. /**
  14541. * Creates a new RemapBlock
  14542. * @param name defines the block name
  14543. */
  14544. constructor(name: string);
  14545. /**
  14546. * Gets the current class name
  14547. * @returns the class name
  14548. */
  14549. getClassName(): string;
  14550. /**
  14551. * Gets the input component
  14552. */
  14553. get input(): NodeMaterialConnectionPoint;
  14554. /**
  14555. * Gets the source min input component
  14556. */
  14557. get sourceMin(): NodeMaterialConnectionPoint;
  14558. /**
  14559. * Gets the source max input component
  14560. */
  14561. get sourceMax(): NodeMaterialConnectionPoint;
  14562. /**
  14563. * Gets the target min input component
  14564. */
  14565. get targetMin(): NodeMaterialConnectionPoint;
  14566. /**
  14567. * Gets the target max input component
  14568. */
  14569. get targetMax(): NodeMaterialConnectionPoint;
  14570. /**
  14571. * Gets the output component
  14572. */
  14573. get output(): NodeMaterialConnectionPoint;
  14574. protected _buildBlock(state: NodeMaterialBuildState): this;
  14575. protected _dumpPropertiesCode(): string;
  14576. serialize(): any;
  14577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14578. }
  14579. }
  14580. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  14581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14584. /**
  14585. * Block used to multiply 2 values
  14586. */
  14587. export class MultiplyBlock extends NodeMaterialBlock {
  14588. /**
  14589. * Creates a new MultiplyBlock
  14590. * @param name defines the block name
  14591. */
  14592. constructor(name: string);
  14593. /**
  14594. * Gets the current class name
  14595. * @returns the class name
  14596. */
  14597. getClassName(): string;
  14598. /**
  14599. * Gets the left operand input component
  14600. */
  14601. get left(): NodeMaterialConnectionPoint;
  14602. /**
  14603. * Gets the right operand input component
  14604. */
  14605. get right(): NodeMaterialConnectionPoint;
  14606. /**
  14607. * Gets the output component
  14608. */
  14609. get output(): NodeMaterialConnectionPoint;
  14610. protected _buildBlock(state: NodeMaterialBuildState): this;
  14611. }
  14612. }
  14613. declare module "babylonjs/Misc/gradients" {
  14614. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14615. /** Interface used by value gradients (color, factor, ...) */
  14616. export interface IValueGradient {
  14617. /**
  14618. * Gets or sets the gradient value (between 0 and 1)
  14619. */
  14620. gradient: number;
  14621. }
  14622. /** Class used to store color4 gradient */
  14623. export class ColorGradient implements IValueGradient {
  14624. /**
  14625. * Gets or sets the gradient value (between 0 and 1)
  14626. */
  14627. gradient: number;
  14628. /**
  14629. * Gets or sets first associated color
  14630. */
  14631. color1: Color4;
  14632. /**
  14633. * Gets or sets second associated color
  14634. */
  14635. color2?: Color4 | undefined;
  14636. /**
  14637. * Creates a new color4 gradient
  14638. * @param gradient gets or sets the gradient value (between 0 and 1)
  14639. * @param color1 gets or sets first associated color
  14640. * @param color2 gets or sets first second color
  14641. */
  14642. constructor(
  14643. /**
  14644. * Gets or sets the gradient value (between 0 and 1)
  14645. */
  14646. gradient: number,
  14647. /**
  14648. * Gets or sets first associated color
  14649. */
  14650. color1: Color4,
  14651. /**
  14652. * Gets or sets second associated color
  14653. */
  14654. color2?: Color4 | undefined);
  14655. /**
  14656. * Will get a color picked randomly between color1 and color2.
  14657. * If color2 is undefined then color1 will be used
  14658. * @param result defines the target Color4 to store the result in
  14659. */
  14660. getColorToRef(result: Color4): void;
  14661. }
  14662. /** Class used to store color 3 gradient */
  14663. export class Color3Gradient implements IValueGradient {
  14664. /**
  14665. * Gets or sets the gradient value (between 0 and 1)
  14666. */
  14667. gradient: number;
  14668. /**
  14669. * Gets or sets the associated color
  14670. */
  14671. color: Color3;
  14672. /**
  14673. * Creates a new color3 gradient
  14674. * @param gradient gets or sets the gradient value (between 0 and 1)
  14675. * @param color gets or sets associated color
  14676. */
  14677. constructor(
  14678. /**
  14679. * Gets or sets the gradient value (between 0 and 1)
  14680. */
  14681. gradient: number,
  14682. /**
  14683. * Gets or sets the associated color
  14684. */
  14685. color: Color3);
  14686. }
  14687. /** Class used to store factor gradient */
  14688. export class FactorGradient implements IValueGradient {
  14689. /**
  14690. * Gets or sets the gradient value (between 0 and 1)
  14691. */
  14692. gradient: number;
  14693. /**
  14694. * Gets or sets first associated factor
  14695. */
  14696. factor1: number;
  14697. /**
  14698. * Gets or sets second associated factor
  14699. */
  14700. factor2?: number | undefined;
  14701. /**
  14702. * Creates a new factor gradient
  14703. * @param gradient gets or sets the gradient value (between 0 and 1)
  14704. * @param factor1 gets or sets first associated factor
  14705. * @param factor2 gets or sets second associated factor
  14706. */
  14707. constructor(
  14708. /**
  14709. * Gets or sets the gradient value (between 0 and 1)
  14710. */
  14711. gradient: number,
  14712. /**
  14713. * Gets or sets first associated factor
  14714. */
  14715. factor1: number,
  14716. /**
  14717. * Gets or sets second associated factor
  14718. */
  14719. factor2?: number | undefined);
  14720. /**
  14721. * Will get a number picked randomly between factor1 and factor2.
  14722. * If factor2 is undefined then factor1 will be used
  14723. * @returns the picked number
  14724. */
  14725. getFactor(): number;
  14726. }
  14727. /**
  14728. * Helper used to simplify some generic gradient tasks
  14729. */
  14730. export class GradientHelper {
  14731. /**
  14732. * Gets the current gradient from an array of IValueGradient
  14733. * @param ratio defines the current ratio to get
  14734. * @param gradients defines the array of IValueGradient
  14735. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14736. */
  14737. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14738. }
  14739. }
  14740. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14741. import { Nullable } from "babylonjs/types";
  14742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14743. import { Scene } from "babylonjs/scene";
  14744. module "babylonjs/Engines/thinEngine" {
  14745. interface ThinEngine {
  14746. /**
  14747. * Creates a raw texture
  14748. * @param data defines the data to store in the texture
  14749. * @param width defines the width of the texture
  14750. * @param height defines the height of the texture
  14751. * @param format defines the format of the data
  14752. * @param generateMipMaps defines if the engine should generate the mip levels
  14753. * @param invertY defines if data must be stored with Y axis inverted
  14754. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14755. * @param compression defines the compression used (null by default)
  14756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14757. * @returns the raw texture inside an InternalTexture
  14758. */
  14759. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14760. /**
  14761. * Update a raw texture
  14762. * @param texture defines the texture to update
  14763. * @param data defines the data to store in the texture
  14764. * @param format defines the format of the data
  14765. * @param invertY defines if data must be stored with Y axis inverted
  14766. */
  14767. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14768. /**
  14769. * Update a raw texture
  14770. * @param texture defines the texture to update
  14771. * @param data defines the data to store in the texture
  14772. * @param format defines the format of the data
  14773. * @param invertY defines if data must be stored with Y axis inverted
  14774. * @param compression defines the compression used (null by default)
  14775. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14776. */
  14777. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14778. /**
  14779. * Creates a new raw cube texture
  14780. * @param data defines the array of data to use to create each face
  14781. * @param size defines the size of the textures
  14782. * @param format defines the format of the data
  14783. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14784. * @param generateMipMaps defines if the engine should generate the mip levels
  14785. * @param invertY defines if data must be stored with Y axis inverted
  14786. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14787. * @param compression defines the compression used (null by default)
  14788. * @returns the cube texture as an InternalTexture
  14789. */
  14790. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14791. /**
  14792. * Update a raw cube texture
  14793. * @param texture defines the texture to udpdate
  14794. * @param data defines the data to store
  14795. * @param format defines the data format
  14796. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14797. * @param invertY defines if data must be stored with Y axis inverted
  14798. */
  14799. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14800. /**
  14801. * Update a raw cube texture
  14802. * @param texture defines the texture to udpdate
  14803. * @param data defines the data to store
  14804. * @param format defines the data format
  14805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14806. * @param invertY defines if data must be stored with Y axis inverted
  14807. * @param compression defines the compression used (null by default)
  14808. */
  14809. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14810. /**
  14811. * Update a raw cube texture
  14812. * @param texture defines the texture to udpdate
  14813. * @param data defines the data to store
  14814. * @param format defines the data format
  14815. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14816. * @param invertY defines if data must be stored with Y axis inverted
  14817. * @param compression defines the compression used (null by default)
  14818. * @param level defines which level of the texture to update
  14819. */
  14820. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14821. /**
  14822. * Creates a new raw cube texture from a specified url
  14823. * @param url defines the url where the data is located
  14824. * @param scene defines the current scene
  14825. * @param size defines the size of the textures
  14826. * @param format defines the format of the data
  14827. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14828. * @param noMipmap defines if the engine should avoid generating the mip levels
  14829. * @param callback defines a callback used to extract texture data from loaded data
  14830. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14831. * @param onLoad defines a callback called when texture is loaded
  14832. * @param onError defines a callback called if there is an error
  14833. * @returns the cube texture as an InternalTexture
  14834. */
  14835. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  14836. /**
  14837. * Creates a new raw cube texture from a specified url
  14838. * @param url defines the url where the data is located
  14839. * @param scene defines the current scene
  14840. * @param size defines the size of the textures
  14841. * @param format defines the format of the data
  14842. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14843. * @param noMipmap defines if the engine should avoid generating the mip levels
  14844. * @param callback defines a callback used to extract texture data from loaded data
  14845. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14846. * @param onLoad defines a callback called when texture is loaded
  14847. * @param onError defines a callback called if there is an error
  14848. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14849. * @param invertY defines if data must be stored with Y axis inverted
  14850. * @returns the cube texture as an InternalTexture
  14851. */
  14852. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  14853. /**
  14854. * Creates a new raw 3D texture
  14855. * @param data defines the data used to create the texture
  14856. * @param width defines the width of the texture
  14857. * @param height defines the height of the texture
  14858. * @param depth defines the depth of the texture
  14859. * @param format defines the format of the texture
  14860. * @param generateMipMaps defines if the engine must generate mip levels
  14861. * @param invertY defines if data must be stored with Y axis inverted
  14862. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14863. * @param compression defines the compressed used (can be null)
  14864. * @param textureType defines the compressed used (can be null)
  14865. * @returns a new raw 3D texture (stored in an InternalTexture)
  14866. */
  14867. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14868. /**
  14869. * Update a raw 3D texture
  14870. * @param texture defines the texture to update
  14871. * @param data defines the data to store
  14872. * @param format defines the data format
  14873. * @param invertY defines if data must be stored with Y axis inverted
  14874. */
  14875. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14876. /**
  14877. * Update a raw 3D texture
  14878. * @param texture defines the texture to update
  14879. * @param data defines the data to store
  14880. * @param format defines the data format
  14881. * @param invertY defines if data must be stored with Y axis inverted
  14882. * @param compression defines the used compression (can be null)
  14883. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14884. */
  14885. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14886. /**
  14887. * Creates a new raw 2D array texture
  14888. * @param data defines the data used to create the texture
  14889. * @param width defines the width of the texture
  14890. * @param height defines the height of the texture
  14891. * @param depth defines the number of layers of the texture
  14892. * @param format defines the format of the texture
  14893. * @param generateMipMaps defines if the engine must generate mip levels
  14894. * @param invertY defines if data must be stored with Y axis inverted
  14895. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14896. * @param compression defines the compressed used (can be null)
  14897. * @param textureType defines the compressed used (can be null)
  14898. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14899. */
  14900. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14901. /**
  14902. * Update a raw 2D array texture
  14903. * @param texture defines the texture to update
  14904. * @param data defines the data to store
  14905. * @param format defines the data format
  14906. * @param invertY defines if data must be stored with Y axis inverted
  14907. */
  14908. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14909. /**
  14910. * Update a raw 2D array texture
  14911. * @param texture defines the texture to update
  14912. * @param data defines the data to store
  14913. * @param format defines the data format
  14914. * @param invertY defines if data must be stored with Y axis inverted
  14915. * @param compression defines the used compression (can be null)
  14916. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14917. */
  14918. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14919. }
  14920. }
  14921. }
  14922. declare module "babylonjs/Materials/Textures/rawTexture" {
  14923. import { Texture } from "babylonjs/Materials/Textures/texture";
  14924. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14925. import { Nullable } from "babylonjs/types";
  14926. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14927. import { Scene } from "babylonjs/scene";
  14928. /**
  14929. * Raw texture can help creating a texture directly from an array of data.
  14930. * This can be super useful if you either get the data from an uncompressed source or
  14931. * if you wish to create your texture pixel by pixel.
  14932. */
  14933. export class RawTexture extends Texture {
  14934. /**
  14935. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14936. */
  14937. format: number;
  14938. /**
  14939. * Instantiates a new RawTexture.
  14940. * Raw texture can help creating a texture directly from an array of data.
  14941. * This can be super useful if you either get the data from an uncompressed source or
  14942. * if you wish to create your texture pixel by pixel.
  14943. * @param data define the array of data to use to create the texture
  14944. * @param width define the width of the texture
  14945. * @param height define the height of the texture
  14946. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14947. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14948. * @param generateMipMaps define whether mip maps should be generated or not
  14949. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14950. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14951. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14952. */
  14953. constructor(data: ArrayBufferView, width: number, height: number,
  14954. /**
  14955. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14956. */
  14957. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14958. /**
  14959. * Updates the texture underlying data.
  14960. * @param data Define the new data of the texture
  14961. */
  14962. update(data: ArrayBufferView): void;
  14963. /**
  14964. * Creates a luminance texture from some data.
  14965. * @param data Define the texture data
  14966. * @param width Define the width of the texture
  14967. * @param height Define the height of the texture
  14968. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14972. * @returns the luminance texture
  14973. */
  14974. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14975. /**
  14976. * Creates a luminance alpha texture from some data.
  14977. * @param data Define the texture data
  14978. * @param width Define the width of the texture
  14979. * @param height Define the height of the texture
  14980. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14981. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14984. * @returns the luminance alpha texture
  14985. */
  14986. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14987. /**
  14988. * Creates an alpha texture from some data.
  14989. * @param data Define the texture data
  14990. * @param width Define the width of the texture
  14991. * @param height Define the height of the texture
  14992. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14996. * @returns the alpha texture
  14997. */
  14998. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14999. /**
  15000. * Creates a RGB texture from some data.
  15001. * @param data Define the texture data
  15002. * @param width Define the width of the texture
  15003. * @param height Define the height of the texture
  15004. * @param sceneOrEngine defines the scene or engine the texture will belong to
  15005. * @param generateMipMaps Define whether or not to create mip maps for the texture
  15006. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  15007. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  15008. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  15009. * @returns the RGB alpha texture
  15010. */
  15011. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  15012. /**
  15013. * Creates a RGBA texture from some data.
  15014. * @param data Define the texture data
  15015. * @param width Define the width of the texture
  15016. * @param height Define the height of the texture
  15017. * @param sceneOrEngine defines the scene or engine the texture will belong to
  15018. * @param generateMipMaps Define whether or not to create mip maps for the texture
  15019. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  15020. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  15021. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  15022. * @returns the RGBA texture
  15023. */
  15024. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  15025. /**
  15026. * Creates a R texture from some data.
  15027. * @param data Define the texture data
  15028. * @param width Define the width of the texture
  15029. * @param height Define the height of the texture
  15030. * @param sceneOrEngine defines the scene or engine the texture will belong to
  15031. * @param generateMipMaps Define whether or not to create mip maps for the texture
  15032. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  15033. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  15034. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  15035. * @returns the R texture
  15036. */
  15037. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  15038. }
  15039. }
  15040. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  15041. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  15042. import { IndicesArray, DataArray } from "babylonjs/types";
  15043. module "babylonjs/Engines/thinEngine" {
  15044. interface ThinEngine {
  15045. /**
  15046. * Update a dynamic index buffer
  15047. * @param indexBuffer defines the target index buffer
  15048. * @param indices defines the data to update
  15049. * @param offset defines the offset in the target index buffer where update should start
  15050. */
  15051. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  15052. /**
  15053. * Updates a dynamic vertex buffer.
  15054. * @param vertexBuffer the vertex buffer to update
  15055. * @param data the data used to update the vertex buffer
  15056. * @param byteOffset the byte offset of the data
  15057. * @param byteLength the byte length of the data
  15058. */
  15059. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  15060. }
  15061. }
  15062. }
  15063. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  15064. import { Scene } from "babylonjs/scene";
  15065. import { ISceneComponent } from "babylonjs/sceneComponent";
  15066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  15067. module "babylonjs/abstractScene" {
  15068. interface AbstractScene {
  15069. /**
  15070. * The list of procedural textures added to the scene
  15071. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15072. */
  15073. proceduralTextures: Array<ProceduralTexture>;
  15074. }
  15075. }
  15076. /**
  15077. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15078. * in a given scene.
  15079. */
  15080. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15081. /**
  15082. * The component name helpfull to identify the component in the list of scene components.
  15083. */
  15084. readonly name: string;
  15085. /**
  15086. * The scene the component belongs to.
  15087. */
  15088. scene: Scene;
  15089. /**
  15090. * Creates a new instance of the component for the given scene
  15091. * @param scene Defines the scene to register the component in
  15092. */
  15093. constructor(scene: Scene);
  15094. /**
  15095. * Registers the component in a given scene
  15096. */
  15097. register(): void;
  15098. /**
  15099. * Rebuilds the elements related to this component in case of
  15100. * context lost for instance.
  15101. */
  15102. rebuild(): void;
  15103. /**
  15104. * Disposes the component and the associated ressources.
  15105. */
  15106. dispose(): void;
  15107. private _beforeClear;
  15108. }
  15109. }
  15110. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  15111. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15112. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  15113. module "babylonjs/Engines/thinEngine" {
  15114. interface ThinEngine {
  15115. /**
  15116. * Creates a new render target cube texture
  15117. * @param size defines the size of the texture
  15118. * @param options defines the options used to create the texture
  15119. * @returns a new render target cube texture stored in an InternalTexture
  15120. */
  15121. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15122. }
  15123. }
  15124. }
  15125. declare module "babylonjs/Shaders/procedural.vertex" {
  15126. /** @hidden */
  15127. export var proceduralVertexShader: {
  15128. name: string;
  15129. shader: string;
  15130. };
  15131. }
  15132. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  15133. import { Observable } from "babylonjs/Misc/observable";
  15134. import { Nullable } from "babylonjs/types";
  15135. import { Scene } from "babylonjs/scene";
  15136. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  15137. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15138. import { Effect } from "babylonjs/Materials/effect";
  15139. import { Texture } from "babylonjs/Materials/Textures/texture";
  15140. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15141. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  15142. import "babylonjs/Shaders/procedural.vertex";
  15143. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  15144. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  15145. /**
  15146. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  15147. * This is the base class of any Procedural texture and contains most of the shareable code.
  15148. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15149. */
  15150. export class ProceduralTexture extends Texture {
  15151. /**
  15152. * Define if the texture is enabled or not (disabled texture will not render)
  15153. */
  15154. isEnabled: boolean;
  15155. /**
  15156. * Define if the texture must be cleared before rendering (default is true)
  15157. */
  15158. autoClear: boolean;
  15159. /**
  15160. * Callback called when the texture is generated
  15161. */
  15162. onGenerated: () => void;
  15163. /**
  15164. * Event raised when the texture is generated
  15165. */
  15166. onGeneratedObservable: Observable<ProceduralTexture>;
  15167. /**
  15168. * Event raised before the texture is generated
  15169. */
  15170. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  15171. /**
  15172. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  15173. */
  15174. nodeMaterialSource: Nullable<NodeMaterial>;
  15175. /** @hidden */
  15176. _generateMipMaps: boolean;
  15177. /** @hidden **/
  15178. _effect: Effect;
  15179. /** @hidden */
  15180. _textures: {
  15181. [key: string]: Texture;
  15182. };
  15183. /** @hidden */
  15184. protected _fallbackTexture: Nullable<Texture>;
  15185. private _size;
  15186. private _textureType;
  15187. private _currentRefreshId;
  15188. private _frameId;
  15189. private _refreshRate;
  15190. private _vertexBuffers;
  15191. private _indexBuffer;
  15192. private _uniforms;
  15193. private _samplers;
  15194. private _fragment;
  15195. private _floats;
  15196. private _ints;
  15197. private _floatsArrays;
  15198. private _colors3;
  15199. private _colors4;
  15200. private _vectors2;
  15201. private _vectors3;
  15202. private _matrices;
  15203. private _fallbackTextureUsed;
  15204. private _fullEngine;
  15205. private _cachedDefines;
  15206. private _contentUpdateId;
  15207. private _contentData;
  15208. /**
  15209. * Instantiates a new procedural texture.
  15210. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  15211. * This is the base class of any Procedural texture and contains most of the shareable code.
  15212. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15213. * @param name Define the name of the texture
  15214. * @param size Define the size of the texture to create
  15215. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15216. * @param scene Define the scene the texture belongs to
  15217. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15218. * @param generateMipMaps Define if the texture should creates mip maps or not
  15219. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15220. * @param textureType The FBO internal texture type
  15221. */
  15222. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  15223. /**
  15224. * The effect that is created when initializing the post process.
  15225. * @returns The created effect corresponding the the postprocess.
  15226. */
  15227. getEffect(): Effect;
  15228. /**
  15229. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15230. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  15231. */
  15232. getContent(): Nullable<Promise<ArrayBufferView>>;
  15233. private _createIndexBuffer;
  15234. /** @hidden */
  15235. _rebuild(): void;
  15236. /**
  15237. * Resets the texture in order to recreate its associated resources.
  15238. * This can be called in case of context loss
  15239. */
  15240. reset(): void;
  15241. protected _getDefines(): string;
  15242. /**
  15243. * Is the texture ready to be used ? (rendered at least once)
  15244. * @returns true if ready, otherwise, false.
  15245. */
  15246. isReady(): boolean;
  15247. /**
  15248. * Resets the refresh counter of the texture and start bak from scratch.
  15249. * Could be useful to regenerate the texture if it is setup to render only once.
  15250. */
  15251. resetRefreshCounter(): void;
  15252. /**
  15253. * Set the fragment shader to use in order to render the texture.
  15254. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15255. */
  15256. setFragment(fragment: any): void;
  15257. /**
  15258. * Define the refresh rate of the texture or the rendering frequency.
  15259. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15260. */
  15261. get refreshRate(): number;
  15262. set refreshRate(value: number);
  15263. /** @hidden */
  15264. _shouldRender(): boolean;
  15265. /**
  15266. * Get the size the texture is rendering at.
  15267. * @returns the size (on cube texture it is always squared)
  15268. */
  15269. getRenderSize(): RenderTargetTextureSize;
  15270. /**
  15271. * Resize the texture to new value.
  15272. * @param size Define the new size the texture should have
  15273. * @param generateMipMaps Define whether the new texture should create mip maps
  15274. */
  15275. resize(size: number, generateMipMaps: boolean): void;
  15276. private _checkUniform;
  15277. /**
  15278. * Set a texture in the shader program used to render.
  15279. * @param name Define the name of the uniform samplers as defined in the shader
  15280. * @param texture Define the texture to bind to this sampler
  15281. * @return the texture itself allowing "fluent" like uniform updates
  15282. */
  15283. setTexture(name: string, texture: Texture): ProceduralTexture;
  15284. /**
  15285. * Set a float in the shader.
  15286. * @param name Define the name of the uniform as defined in the shader
  15287. * @param value Define the value to give to the uniform
  15288. * @return the texture itself allowing "fluent" like uniform updates
  15289. */
  15290. setFloat(name: string, value: number): ProceduralTexture;
  15291. /**
  15292. * Set a int in the shader.
  15293. * @param name Define the name of the uniform as defined in the shader
  15294. * @param value Define the value to give to the uniform
  15295. * @return the texture itself allowing "fluent" like uniform updates
  15296. */
  15297. setInt(name: string, value: number): ProceduralTexture;
  15298. /**
  15299. * Set an array of floats in the shader.
  15300. * @param name Define the name of the uniform as defined in the shader
  15301. * @param value Define the value to give to the uniform
  15302. * @return the texture itself allowing "fluent" like uniform updates
  15303. */
  15304. setFloats(name: string, value: number[]): ProceduralTexture;
  15305. /**
  15306. * Set a vec3 in the shader from a Color3.
  15307. * @param name Define the name of the uniform as defined in the shader
  15308. * @param value Define the value to give to the uniform
  15309. * @return the texture itself allowing "fluent" like uniform updates
  15310. */
  15311. setColor3(name: string, value: Color3): ProceduralTexture;
  15312. /**
  15313. * Set a vec4 in the shader from a Color4.
  15314. * @param name Define the name of the uniform as defined in the shader
  15315. * @param value Define the value to give to the uniform
  15316. * @return the texture itself allowing "fluent" like uniform updates
  15317. */
  15318. setColor4(name: string, value: Color4): ProceduralTexture;
  15319. /**
  15320. * Set a vec2 in the shader from a Vector2.
  15321. * @param name Define the name of the uniform as defined in the shader
  15322. * @param value Define the value to give to the uniform
  15323. * @return the texture itself allowing "fluent" like uniform updates
  15324. */
  15325. setVector2(name: string, value: Vector2): ProceduralTexture;
  15326. /**
  15327. * Set a vec3 in the shader from a Vector3.
  15328. * @param name Define the name of the uniform as defined in the shader
  15329. * @param value Define the value to give to the uniform
  15330. * @return the texture itself allowing "fluent" like uniform updates
  15331. */
  15332. setVector3(name: string, value: Vector3): ProceduralTexture;
  15333. /**
  15334. * Set a mat4 in the shader from a MAtrix.
  15335. * @param name Define the name of the uniform as defined in the shader
  15336. * @param value Define the value to give to the uniform
  15337. * @return the texture itself allowing "fluent" like uniform updates
  15338. */
  15339. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15340. /**
  15341. * Render the texture to its associated render target.
  15342. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15343. */
  15344. render(useCameraPostProcess?: boolean): void;
  15345. /**
  15346. * Clone the texture.
  15347. * @returns the cloned texture
  15348. */
  15349. clone(): ProceduralTexture;
  15350. /**
  15351. * Dispose the texture and release its asoociated resources.
  15352. */
  15353. dispose(): void;
  15354. }
  15355. }
  15356. declare module "babylonjs/Particles/baseParticleSystem" {
  15357. import { Nullable } from "babylonjs/types";
  15358. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  15359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15360. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  15361. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  15362. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15363. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15364. import { Color4 } from "babylonjs/Maths/math.color";
  15365. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15366. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  15367. import { Animation } from "babylonjs/Animations/animation";
  15368. import { Scene } from "babylonjs/scene";
  15369. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  15370. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15371. /**
  15372. * This represents the base class for particle system in Babylon.
  15373. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15374. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15375. * @example https://doc.babylonjs.com/babylon101/particles
  15376. */
  15377. export class BaseParticleSystem {
  15378. /**
  15379. * Source color is added to the destination color without alpha affecting the result
  15380. */
  15381. static BLENDMODE_ONEONE: number;
  15382. /**
  15383. * Blend current color and particle color using particle’s alpha
  15384. */
  15385. static BLENDMODE_STANDARD: number;
  15386. /**
  15387. * Add current color and particle color multiplied by particle’s alpha
  15388. */
  15389. static BLENDMODE_ADD: number;
  15390. /**
  15391. * Multiply current color with particle color
  15392. */
  15393. static BLENDMODE_MULTIPLY: number;
  15394. /**
  15395. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15396. */
  15397. static BLENDMODE_MULTIPLYADD: number;
  15398. /**
  15399. * List of animations used by the particle system.
  15400. */
  15401. animations: Animation[];
  15402. /**
  15403. * Gets or sets the unique id of the particle system
  15404. */
  15405. uniqueId: number;
  15406. /**
  15407. * The id of the Particle system.
  15408. */
  15409. id: string;
  15410. /**
  15411. * The friendly name of the Particle system.
  15412. */
  15413. name: string;
  15414. /**
  15415. * Snippet ID if the particle system was created from the snippet server
  15416. */
  15417. snippetId: string;
  15418. /**
  15419. * The rendering group used by the Particle system to chose when to render.
  15420. */
  15421. renderingGroupId: number;
  15422. /**
  15423. * The emitter represents the Mesh or position we are attaching the particle system to.
  15424. */
  15425. emitter: Nullable<AbstractMesh | Vector3>;
  15426. /**
  15427. * The maximum number of particles to emit per frame
  15428. */
  15429. emitRate: number;
  15430. /**
  15431. * If you want to launch only a few particles at once, that can be done, as well.
  15432. */
  15433. manualEmitCount: number;
  15434. /**
  15435. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15436. */
  15437. updateSpeed: number;
  15438. /**
  15439. * The amount of time the particle system is running (depends of the overall update speed).
  15440. */
  15441. targetStopDuration: number;
  15442. /**
  15443. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15444. */
  15445. disposeOnStop: boolean;
  15446. /**
  15447. * Minimum power of emitting particles.
  15448. */
  15449. minEmitPower: number;
  15450. /**
  15451. * Maximum power of emitting particles.
  15452. */
  15453. maxEmitPower: number;
  15454. /**
  15455. * Minimum life time of emitting particles.
  15456. */
  15457. minLifeTime: number;
  15458. /**
  15459. * Maximum life time of emitting particles.
  15460. */
  15461. maxLifeTime: number;
  15462. /**
  15463. * Minimum Size of emitting particles.
  15464. */
  15465. minSize: number;
  15466. /**
  15467. * Maximum Size of emitting particles.
  15468. */
  15469. maxSize: number;
  15470. /**
  15471. * Minimum scale of emitting particles on X axis.
  15472. */
  15473. minScaleX: number;
  15474. /**
  15475. * Maximum scale of emitting particles on X axis.
  15476. */
  15477. maxScaleX: number;
  15478. /**
  15479. * Minimum scale of emitting particles on Y axis.
  15480. */
  15481. minScaleY: number;
  15482. /**
  15483. * Maximum scale of emitting particles on Y axis.
  15484. */
  15485. maxScaleY: number;
  15486. /**
  15487. * Gets or sets the minimal initial rotation in radians.
  15488. */
  15489. minInitialRotation: number;
  15490. /**
  15491. * Gets or sets the maximal initial rotation in radians.
  15492. */
  15493. maxInitialRotation: number;
  15494. /**
  15495. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15496. */
  15497. minAngularSpeed: number;
  15498. /**
  15499. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15500. */
  15501. maxAngularSpeed: number;
  15502. /**
  15503. * The texture used to render each particle. (this can be a spritesheet)
  15504. */
  15505. particleTexture: Nullable<BaseTexture>;
  15506. /**
  15507. * The layer mask we are rendering the particles through.
  15508. */
  15509. layerMask: number;
  15510. /**
  15511. * This can help using your own shader to render the particle system.
  15512. * The according effect will be created
  15513. */
  15514. customShader: any;
  15515. /**
  15516. * By default particle system starts as soon as they are created. This prevents the
  15517. * automatic start to happen and let you decide when to start emitting particles.
  15518. */
  15519. preventAutoStart: boolean;
  15520. protected _rootUrl: string;
  15521. private _noiseTexture;
  15522. /**
  15523. * Gets or sets a texture used to add random noise to particle positions
  15524. */
  15525. get noiseTexture(): Nullable<ProceduralTexture>;
  15526. set noiseTexture(value: Nullable<ProceduralTexture>);
  15527. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15528. noiseStrength: Vector3;
  15529. /**
  15530. * Callback triggered when the particle animation is ending.
  15531. */
  15532. onAnimationEnd: Nullable<() => void>;
  15533. /**
  15534. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15535. */
  15536. blendMode: number;
  15537. /**
  15538. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15539. * to override the particles.
  15540. */
  15541. forceDepthWrite: boolean;
  15542. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  15543. preWarmCycles: number;
  15544. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15545. preWarmStepOffset: number;
  15546. /**
  15547. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  15548. */
  15549. spriteCellChangeSpeed: number;
  15550. /**
  15551. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15552. */
  15553. startSpriteCellID: number;
  15554. /**
  15555. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15556. */
  15557. endSpriteCellID: number;
  15558. /**
  15559. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15560. */
  15561. spriteCellWidth: number;
  15562. /**
  15563. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15564. */
  15565. spriteCellHeight: number;
  15566. /**
  15567. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15568. */
  15569. spriteRandomStartCell: boolean;
  15570. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15571. translationPivot: Vector2;
  15572. /** @hidden */
  15573. protected _isAnimationSheetEnabled: boolean;
  15574. /**
  15575. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15576. */
  15577. beginAnimationOnStart: boolean;
  15578. /**
  15579. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15580. */
  15581. beginAnimationFrom: number;
  15582. /**
  15583. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15584. */
  15585. beginAnimationTo: number;
  15586. /**
  15587. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15588. */
  15589. beginAnimationLoop: boolean;
  15590. /**
  15591. * Gets or sets a world offset applied to all particles
  15592. */
  15593. worldOffset: Vector3;
  15594. /**
  15595. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15596. */
  15597. get isAnimationSheetEnabled(): boolean;
  15598. set isAnimationSheetEnabled(value: boolean);
  15599. /**
  15600. * Get hosting scene
  15601. * @returns the scene
  15602. */
  15603. getScene(): Nullable<Scene>;
  15604. /**
  15605. * You can use gravity if you want to give an orientation to your particles.
  15606. */
  15607. gravity: Vector3;
  15608. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15609. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15610. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15611. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15612. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15613. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15614. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15615. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15616. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15617. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15618. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15619. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15620. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15621. /**
  15622. * Defines the delay in milliseconds before starting the system (0 by default)
  15623. */
  15624. startDelay: number;
  15625. /**
  15626. * Gets the current list of drag gradients.
  15627. * You must use addDragGradient and removeDragGradient to udpate this list
  15628. * @returns the list of drag gradients
  15629. */
  15630. getDragGradients(): Nullable<Array<FactorGradient>>;
  15631. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15632. limitVelocityDamping: number;
  15633. /**
  15634. * Gets the current list of limit velocity gradients.
  15635. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15636. * @returns the list of limit velocity gradients
  15637. */
  15638. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15639. /**
  15640. * Gets the current list of color gradients.
  15641. * You must use addColorGradient and removeColorGradient to udpate this list
  15642. * @returns the list of color gradients
  15643. */
  15644. getColorGradients(): Nullable<Array<ColorGradient>>;
  15645. /**
  15646. * Gets the current list of size gradients.
  15647. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15648. * @returns the list of size gradients
  15649. */
  15650. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15651. /**
  15652. * Gets the current list of color remap gradients.
  15653. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15654. * @returns the list of color remap gradients
  15655. */
  15656. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15657. /**
  15658. * Gets the current list of alpha remap gradients.
  15659. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15660. * @returns the list of alpha remap gradients
  15661. */
  15662. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15663. /**
  15664. * Gets the current list of life time gradients.
  15665. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15666. * @returns the list of life time gradients
  15667. */
  15668. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15669. /**
  15670. * Gets the current list of angular speed gradients.
  15671. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15672. * @returns the list of angular speed gradients
  15673. */
  15674. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15675. /**
  15676. * Gets the current list of velocity gradients.
  15677. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15678. * @returns the list of velocity gradients
  15679. */
  15680. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15681. /**
  15682. * Gets the current list of start size gradients.
  15683. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15684. * @returns the list of start size gradients
  15685. */
  15686. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15687. /**
  15688. * Gets the current list of emit rate gradients.
  15689. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15690. * @returns the list of emit rate gradients
  15691. */
  15692. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15693. /**
  15694. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15695. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15696. */
  15697. get direction1(): Vector3;
  15698. set direction1(value: Vector3);
  15699. /**
  15700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15701. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15702. */
  15703. get direction2(): Vector3;
  15704. set direction2(value: Vector3);
  15705. /**
  15706. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15707. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15708. */
  15709. get minEmitBox(): Vector3;
  15710. set minEmitBox(value: Vector3);
  15711. /**
  15712. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15713. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15714. */
  15715. get maxEmitBox(): Vector3;
  15716. set maxEmitBox(value: Vector3);
  15717. /**
  15718. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15719. */
  15720. color1: Color4;
  15721. /**
  15722. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15723. */
  15724. color2: Color4;
  15725. /**
  15726. * Color the particle will have at the end of its lifetime
  15727. */
  15728. colorDead: Color4;
  15729. /**
  15730. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15731. */
  15732. textureMask: Color4;
  15733. /**
  15734. * The particle emitter type defines the emitter used by the particle system.
  15735. * It can be for example box, sphere, or cone...
  15736. */
  15737. particleEmitterType: IParticleEmitterType;
  15738. /** @hidden */
  15739. _isSubEmitter: boolean;
  15740. /**
  15741. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15742. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15743. */
  15744. billboardMode: number;
  15745. protected _isBillboardBased: boolean;
  15746. /**
  15747. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15748. */
  15749. get isBillboardBased(): boolean;
  15750. set isBillboardBased(value: boolean);
  15751. /**
  15752. * The scene the particle system belongs to.
  15753. */
  15754. protected _scene: Nullable<Scene>;
  15755. /**
  15756. * The engine the particle system belongs to.
  15757. */
  15758. protected _engine: ThinEngine;
  15759. /**
  15760. * Local cache of defines for image processing.
  15761. */
  15762. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15763. /**
  15764. * Default configuration related to image processing available in the standard Material.
  15765. */
  15766. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15767. /**
  15768. * Gets the image processing configuration used either in this material.
  15769. */
  15770. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15771. /**
  15772. * Sets the Default image processing configuration used either in the this material.
  15773. *
  15774. * If sets to null, the scene one is in use.
  15775. */
  15776. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15777. /**
  15778. * Attaches a new image processing configuration to the Standard Material.
  15779. * @param configuration
  15780. */
  15781. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15782. /** @hidden */
  15783. protected _reset(): void;
  15784. /** @hidden */
  15785. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15786. /**
  15787. * Instantiates a particle system.
  15788. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15789. * @param name The name of the particle system
  15790. */
  15791. constructor(name: string);
  15792. /**
  15793. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15794. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15795. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15796. * @returns the emitter
  15797. */
  15798. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15799. /**
  15800. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15801. * @param radius The radius of the hemisphere to emit from
  15802. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15803. * @returns the emitter
  15804. */
  15805. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15806. /**
  15807. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15808. * @param radius The radius of the sphere to emit from
  15809. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15810. * @returns the emitter
  15811. */
  15812. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15813. /**
  15814. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15815. * @param radius The radius of the sphere to emit from
  15816. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15817. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15818. * @returns the emitter
  15819. */
  15820. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15821. /**
  15822. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15823. * @param radius The radius of the emission cylinder
  15824. * @param height The height of the emission cylinder
  15825. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15826. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15827. * @returns the emitter
  15828. */
  15829. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15830. /**
  15831. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15832. * @param radius The radius of the cylinder to emit from
  15833. * @param height The height of the emission cylinder
  15834. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15837. * @returns the emitter
  15838. */
  15839. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15840. /**
  15841. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15842. * @param radius The radius of the cone to emit from
  15843. * @param angle The base angle of the cone
  15844. * @returns the emitter
  15845. */
  15846. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15847. /**
  15848. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15851. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15852. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15853. * @returns the emitter
  15854. */
  15855. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15856. }
  15857. }
  15858. declare module "babylonjs/Particles/subEmitter" {
  15859. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15860. import { Scene } from "babylonjs/scene";
  15861. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15862. /**
  15863. * Type of sub emitter
  15864. */
  15865. export enum SubEmitterType {
  15866. /**
  15867. * Attached to the particle over it's lifetime
  15868. */
  15869. ATTACHED = 0,
  15870. /**
  15871. * Created when the particle dies
  15872. */
  15873. END = 1
  15874. }
  15875. /**
  15876. * Sub emitter class used to emit particles from an existing particle
  15877. */
  15878. export class SubEmitter {
  15879. /**
  15880. * the particle system to be used by the sub emitter
  15881. */
  15882. particleSystem: ParticleSystem;
  15883. /**
  15884. * Type of the submitter (Default: END)
  15885. */
  15886. type: SubEmitterType;
  15887. /**
  15888. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  15889. * Note: This only is supported when using an emitter of type Mesh
  15890. */
  15891. inheritDirection: boolean;
  15892. /**
  15893. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15894. */
  15895. inheritedVelocityAmount: number;
  15896. /**
  15897. * Creates a sub emitter
  15898. * @param particleSystem the particle system to be used by the sub emitter
  15899. */
  15900. constructor(
  15901. /**
  15902. * the particle system to be used by the sub emitter
  15903. */
  15904. particleSystem: ParticleSystem);
  15905. /**
  15906. * Clones the sub emitter
  15907. * @returns the cloned sub emitter
  15908. */
  15909. clone(): SubEmitter;
  15910. /**
  15911. * Serialize current object to a JSON object
  15912. * @returns the serialized object
  15913. */
  15914. serialize(): any;
  15915. /** @hidden */
  15916. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15917. /**
  15918. * Creates a new SubEmitter from a serialized JSON version
  15919. * @param serializationObject defines the JSON object to read from
  15920. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15921. * @param rootUrl defines the rootUrl for data loading
  15922. * @returns a new SubEmitter
  15923. */
  15924. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15925. /** Release associated resources */
  15926. dispose(): void;
  15927. }
  15928. }
  15929. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15930. /** @hidden */
  15931. export var clipPlaneFragmentDeclaration: {
  15932. name: string;
  15933. shader: string;
  15934. };
  15935. }
  15936. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15937. /** @hidden */
  15938. export var imageProcessingDeclaration: {
  15939. name: string;
  15940. shader: string;
  15941. };
  15942. }
  15943. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15944. /** @hidden */
  15945. export var imageProcessingFunctions: {
  15946. name: string;
  15947. shader: string;
  15948. };
  15949. }
  15950. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15951. /** @hidden */
  15952. export var clipPlaneFragment: {
  15953. name: string;
  15954. shader: string;
  15955. };
  15956. }
  15957. declare module "babylonjs/Shaders/particles.fragment" {
  15958. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15959. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15960. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15961. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15962. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15963. /** @hidden */
  15964. export var particlesPixelShader: {
  15965. name: string;
  15966. shader: string;
  15967. };
  15968. }
  15969. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15970. /** @hidden */
  15971. export var clipPlaneVertexDeclaration: {
  15972. name: string;
  15973. shader: string;
  15974. };
  15975. }
  15976. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15977. /** @hidden */
  15978. export var clipPlaneVertex: {
  15979. name: string;
  15980. shader: string;
  15981. };
  15982. }
  15983. declare module "babylonjs/Shaders/particles.vertex" {
  15984. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15985. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15986. /** @hidden */
  15987. export var particlesVertexShader: {
  15988. name: string;
  15989. shader: string;
  15990. };
  15991. }
  15992. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15993. import { Nullable } from "babylonjs/types";
  15994. import { Plane } from "babylonjs/Maths/math";
  15995. /**
  15996. * Interface used to define entities containing multiple clip planes
  15997. */
  15998. export interface IClipPlanesHolder {
  15999. /**
  16000. * Gets or sets the active clipplane 1
  16001. */
  16002. clipPlane: Nullable<Plane>;
  16003. /**
  16004. * Gets or sets the active clipplane 2
  16005. */
  16006. clipPlane2: Nullable<Plane>;
  16007. /**
  16008. * Gets or sets the active clipplane 3
  16009. */
  16010. clipPlane3: Nullable<Plane>;
  16011. /**
  16012. * Gets or sets the active clipplane 4
  16013. */
  16014. clipPlane4: Nullable<Plane>;
  16015. /**
  16016. * Gets or sets the active clipplane 5
  16017. */
  16018. clipPlane5: Nullable<Plane>;
  16019. /**
  16020. * Gets or sets the active clipplane 6
  16021. */
  16022. clipPlane6: Nullable<Plane>;
  16023. }
  16024. }
  16025. declare module "babylonjs/Materials/thinMaterialHelper" {
  16026. import { Effect } from "babylonjs/Materials/effect";
  16027. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  16028. /**
  16029. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  16030. *
  16031. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  16032. *
  16033. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  16034. */
  16035. export class ThinMaterialHelper {
  16036. /**
  16037. * Binds the clip plane information from the holder to the effect.
  16038. * @param effect The effect we are binding the data to
  16039. * @param holder The entity containing the clip plane information
  16040. */
  16041. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  16042. }
  16043. }
  16044. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  16045. module "babylonjs/Engines/thinEngine" {
  16046. interface ThinEngine {
  16047. /**
  16048. * Sets alpha constants used by some alpha blending modes
  16049. * @param r defines the red component
  16050. * @param g defines the green component
  16051. * @param b defines the blue component
  16052. * @param a defines the alpha component
  16053. */
  16054. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  16055. /**
  16056. * Sets the current alpha mode
  16057. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  16058. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  16059. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  16060. */
  16061. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  16062. /**
  16063. * Gets the current alpha mode
  16064. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  16065. * @returns the current alpha mode
  16066. */
  16067. getAlphaMode(): number;
  16068. /**
  16069. * Sets the current alpha equation
  16070. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  16071. */
  16072. setAlphaEquation(equation: number): void;
  16073. /**
  16074. * Gets the current alpha equation.
  16075. * @returns the current alpha equation
  16076. */
  16077. getAlphaEquation(): number;
  16078. }
  16079. }
  16080. }
  16081. declare module "babylonjs/Particles/particleSystem" {
  16082. import { Nullable } from "babylonjs/types";
  16083. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16084. import { Observable } from "babylonjs/Misc/observable";
  16085. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16086. import { Effect } from "babylonjs/Materials/effect";
  16087. import { IDisposable } from "babylonjs/scene";
  16088. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16089. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  16090. import { Particle } from "babylonjs/Particles/particle";
  16091. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16092. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16093. import "babylonjs/Shaders/particles.fragment";
  16094. import "babylonjs/Shaders/particles.vertex";
  16095. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16096. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16097. import "babylonjs/Engines/Extensions/engine.alpha";
  16098. import { Scene } from "babylonjs/scene";
  16099. /**
  16100. * This represents a particle system in Babylon.
  16101. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16102. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16103. * @example https://doc.babylonjs.com/babylon101/particles
  16104. */
  16105. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16106. /**
  16107. * Billboard mode will only apply to Y axis
  16108. */
  16109. static readonly BILLBOARDMODE_Y: number;
  16110. /**
  16111. * Billboard mode will apply to all axes
  16112. */
  16113. static readonly BILLBOARDMODE_ALL: number;
  16114. /**
  16115. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16116. */
  16117. static readonly BILLBOARDMODE_STRETCHED: number;
  16118. /**
  16119. * This function can be defined to provide custom update for active particles.
  16120. * This function will be called instead of regular update (age, position, color, etc.).
  16121. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16122. */
  16123. updateFunction: (particles: Particle[]) => void;
  16124. private _emitterWorldMatrix;
  16125. /**
  16126. * This function can be defined to specify initial direction for every new particle.
  16127. * It by default use the emitterType defined function
  16128. */
  16129. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16130. /**
  16131. * This function can be defined to specify initial position for every new particle.
  16132. * It by default use the emitterType defined function
  16133. */
  16134. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16135. /**
  16136. * @hidden
  16137. */
  16138. _inheritedVelocityOffset: Vector3;
  16139. /**
  16140. * An event triggered when the system is disposed
  16141. */
  16142. onDisposeObservable: Observable<IParticleSystem>;
  16143. /**
  16144. * An event triggered when the system is stopped
  16145. */
  16146. onStoppedObservable: Observable<IParticleSystem>;
  16147. private _onDisposeObserver;
  16148. /**
  16149. * Sets a callback that will be triggered when the system is disposed
  16150. */
  16151. set onDispose(callback: () => void);
  16152. private _particles;
  16153. private _epsilon;
  16154. private _capacity;
  16155. private _stockParticles;
  16156. private _newPartsExcess;
  16157. private _vertexData;
  16158. private _vertexBuffer;
  16159. private _vertexBuffers;
  16160. private _spriteBuffer;
  16161. private _indexBuffer;
  16162. private _effect;
  16163. private _customEffect;
  16164. private _cachedDefines;
  16165. private _scaledColorStep;
  16166. private _colorDiff;
  16167. private _scaledDirection;
  16168. private _scaledGravity;
  16169. private _currentRenderId;
  16170. private _alive;
  16171. private _useInstancing;
  16172. private _vertexArrayObject;
  16173. private _started;
  16174. private _stopped;
  16175. private _actualFrame;
  16176. private _scaledUpdateSpeed;
  16177. private _vertexBufferSize;
  16178. /** @hidden */
  16179. _currentEmitRateGradient: Nullable<FactorGradient>;
  16180. /** @hidden */
  16181. _currentEmitRate1: number;
  16182. /** @hidden */
  16183. _currentEmitRate2: number;
  16184. /** @hidden */
  16185. _currentStartSizeGradient: Nullable<FactorGradient>;
  16186. /** @hidden */
  16187. _currentStartSize1: number;
  16188. /** @hidden */
  16189. _currentStartSize2: number;
  16190. private readonly _rawTextureWidth;
  16191. private _rampGradientsTexture;
  16192. private _useRampGradients;
  16193. /** Gets or sets a matrix to use to compute projection */
  16194. defaultProjectionMatrix: Matrix;
  16195. /** Gets or sets a matrix to use to compute view */
  16196. defaultViewMatrix: Matrix;
  16197. /** Gets or sets a boolean indicating that ramp gradients must be used
  16198. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16199. */
  16200. get useRampGradients(): boolean;
  16201. set useRampGradients(value: boolean);
  16202. /**
  16203. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  16204. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  16205. */
  16206. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16207. private _subEmitters;
  16208. /**
  16209. * @hidden
  16210. * If the particle systems emitter should be disposed when the particle system is disposed
  16211. */
  16212. _disposeEmitterOnDispose: boolean;
  16213. /**
  16214. * The current active Sub-systems, this property is used by the root particle system only.
  16215. */
  16216. activeSubSystems: Array<ParticleSystem>;
  16217. /**
  16218. * Specifies if the particles are updated in emitter local space or world space
  16219. */
  16220. isLocal: boolean;
  16221. private _rootParticleSystem;
  16222. /**
  16223. * Gets the current list of active particles
  16224. */
  16225. get particles(): Particle[];
  16226. /**
  16227. * Gets the number of particles active at the same time.
  16228. * @returns The number of active particles.
  16229. */
  16230. getActiveCount(): number;
  16231. /**
  16232. * Returns the string "ParticleSystem"
  16233. * @returns a string containing the class name
  16234. */
  16235. getClassName(): string;
  16236. /**
  16237. * Gets a boolean indicating that the system is stopping
  16238. * @returns true if the system is currently stopping
  16239. */
  16240. isStopping(): boolean;
  16241. /**
  16242. * Gets the custom effect used to render the particles
  16243. * @param blendMode Blend mode for which the effect should be retrieved
  16244. * @returns The effect
  16245. */
  16246. getCustomEffect(blendMode?: number): Nullable<Effect>;
  16247. /**
  16248. * Sets the custom effect used to render the particles
  16249. * @param effect The effect to set
  16250. * @param blendMode Blend mode for which the effect should be set
  16251. */
  16252. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  16253. /** @hidden */
  16254. private _onBeforeDrawParticlesObservable;
  16255. /**
  16256. * Observable that will be called just before the particles are drawn
  16257. */
  16258. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  16259. /**
  16260. * Gets the name of the particle vertex shader
  16261. */
  16262. get vertexShaderName(): string;
  16263. /**
  16264. * Instantiates a particle system.
  16265. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16266. * @param name The name of the particle system
  16267. * @param capacity The max number of particles alive at the same time
  16268. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  16269. * @param customEffect a custom effect used to change the way particles are rendered by default
  16270. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16271. * @param epsilon Offset used to render the particles
  16272. */
  16273. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16274. private _addFactorGradient;
  16275. private _removeFactorGradient;
  16276. /**
  16277. * Adds a new life time gradient
  16278. * @param gradient defines the gradient to use (between 0 and 1)
  16279. * @param factor defines the life time factor to affect to the specified gradient
  16280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16281. * @returns the current particle system
  16282. */
  16283. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16284. /**
  16285. * Remove a specific life time gradient
  16286. * @param gradient defines the gradient to remove
  16287. * @returns the current particle system
  16288. */
  16289. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16290. /**
  16291. * Adds a new size gradient
  16292. * @param gradient defines the gradient to use (between 0 and 1)
  16293. * @param factor defines the size factor to affect to the specified gradient
  16294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16295. * @returns the current particle system
  16296. */
  16297. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16298. /**
  16299. * Remove a specific size gradient
  16300. * @param gradient defines the gradient to remove
  16301. * @returns the current particle system
  16302. */
  16303. removeSizeGradient(gradient: number): IParticleSystem;
  16304. /**
  16305. * Adds a new color remap gradient
  16306. * @param gradient defines the gradient to use (between 0 and 1)
  16307. * @param min defines the color remap minimal range
  16308. * @param max defines the color remap maximal range
  16309. * @returns the current particle system
  16310. */
  16311. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16312. /**
  16313. * Remove a specific color remap gradient
  16314. * @param gradient defines the gradient to remove
  16315. * @returns the current particle system
  16316. */
  16317. removeColorRemapGradient(gradient: number): IParticleSystem;
  16318. /**
  16319. * Adds a new alpha remap gradient
  16320. * @param gradient defines the gradient to use (between 0 and 1)
  16321. * @param min defines the alpha remap minimal range
  16322. * @param max defines the alpha remap maximal range
  16323. * @returns the current particle system
  16324. */
  16325. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16326. /**
  16327. * Remove a specific alpha remap gradient
  16328. * @param gradient defines the gradient to remove
  16329. * @returns the current particle system
  16330. */
  16331. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16332. /**
  16333. * Adds a new angular speed gradient
  16334. * @param gradient defines the gradient to use (between 0 and 1)
  16335. * @param factor defines the angular speed to affect to the specified gradient
  16336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16337. * @returns the current particle system
  16338. */
  16339. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16340. /**
  16341. * Remove a specific angular speed gradient
  16342. * @param gradient defines the gradient to remove
  16343. * @returns the current particle system
  16344. */
  16345. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16346. /**
  16347. * Adds a new velocity gradient
  16348. * @param gradient defines the gradient to use (between 0 and 1)
  16349. * @param factor defines the velocity to affect to the specified gradient
  16350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16351. * @returns the current particle system
  16352. */
  16353. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16354. /**
  16355. * Remove a specific velocity gradient
  16356. * @param gradient defines the gradient to remove
  16357. * @returns the current particle system
  16358. */
  16359. removeVelocityGradient(gradient: number): IParticleSystem;
  16360. /**
  16361. * Adds a new limit velocity gradient
  16362. * @param gradient defines the gradient to use (between 0 and 1)
  16363. * @param factor defines the limit velocity value to affect to the specified gradient
  16364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16365. * @returns the current particle system
  16366. */
  16367. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16368. /**
  16369. * Remove a specific limit velocity gradient
  16370. * @param gradient defines the gradient to remove
  16371. * @returns the current particle system
  16372. */
  16373. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16374. /**
  16375. * Adds a new drag gradient
  16376. * @param gradient defines the gradient to use (between 0 and 1)
  16377. * @param factor defines the drag value to affect to the specified gradient
  16378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16379. * @returns the current particle system
  16380. */
  16381. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16382. /**
  16383. * Remove a specific drag gradient
  16384. * @param gradient defines the gradient to remove
  16385. * @returns the current particle system
  16386. */
  16387. removeDragGradient(gradient: number): IParticleSystem;
  16388. /**
  16389. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16390. * @param gradient defines the gradient to use (between 0 and 1)
  16391. * @param factor defines the emit rate value to affect to the specified gradient
  16392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16393. * @returns the current particle system
  16394. */
  16395. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16396. /**
  16397. * Remove a specific emit rate gradient
  16398. * @param gradient defines the gradient to remove
  16399. * @returns the current particle system
  16400. */
  16401. removeEmitRateGradient(gradient: number): IParticleSystem;
  16402. /**
  16403. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16404. * @param gradient defines the gradient to use (between 0 and 1)
  16405. * @param factor defines the start size value to affect to the specified gradient
  16406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16407. * @returns the current particle system
  16408. */
  16409. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16410. /**
  16411. * Remove a specific start size gradient
  16412. * @param gradient defines the gradient to remove
  16413. * @returns the current particle system
  16414. */
  16415. removeStartSizeGradient(gradient: number): IParticleSystem;
  16416. private _createRampGradientTexture;
  16417. /**
  16418. * Gets the current list of ramp gradients.
  16419. * You must use addRampGradient and removeRampGradient to udpate this list
  16420. * @returns the list of ramp gradients
  16421. */
  16422. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16423. /** Force the system to rebuild all gradients that need to be resync */
  16424. forceRefreshGradients(): void;
  16425. private _syncRampGradientTexture;
  16426. /**
  16427. * Adds a new ramp gradient used to remap particle colors
  16428. * @param gradient defines the gradient to use (between 0 and 1)
  16429. * @param color defines the color to affect to the specified gradient
  16430. * @returns the current particle system
  16431. */
  16432. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16433. /**
  16434. * Remove a specific ramp gradient
  16435. * @param gradient defines the gradient to remove
  16436. * @returns the current particle system
  16437. */
  16438. removeRampGradient(gradient: number): ParticleSystem;
  16439. /**
  16440. * Adds a new color gradient
  16441. * @param gradient defines the gradient to use (between 0 and 1)
  16442. * @param color1 defines the color to affect to the specified gradient
  16443. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16444. * @returns this particle system
  16445. */
  16446. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16447. /**
  16448. * Remove a specific color gradient
  16449. * @param gradient defines the gradient to remove
  16450. * @returns this particle system
  16451. */
  16452. removeColorGradient(gradient: number): IParticleSystem;
  16453. private _fetchR;
  16454. protected _reset(): void;
  16455. private _resetEffect;
  16456. private _createVertexBuffers;
  16457. private _createIndexBuffer;
  16458. /**
  16459. * Gets the maximum number of particles active at the same time.
  16460. * @returns The max number of active particles.
  16461. */
  16462. getCapacity(): number;
  16463. /**
  16464. * Gets whether there are still active particles in the system.
  16465. * @returns True if it is alive, otherwise false.
  16466. */
  16467. isAlive(): boolean;
  16468. /**
  16469. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16470. * @returns True if it has been started, otherwise false.
  16471. */
  16472. isStarted(): boolean;
  16473. private _prepareSubEmitterInternalArray;
  16474. /**
  16475. * Starts the particle system and begins to emit
  16476. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16477. */
  16478. start(delay?: number): void;
  16479. /**
  16480. * Stops the particle system.
  16481. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  16482. */
  16483. stop(stopSubEmitters?: boolean): void;
  16484. /**
  16485. * Remove all active particles
  16486. */
  16487. reset(): void;
  16488. /**
  16489. * @hidden (for internal use only)
  16490. */
  16491. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16492. /**
  16493. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16494. * Its lifetime will start back at 0.
  16495. */
  16496. recycleParticle: (particle: Particle) => void;
  16497. private _stopSubEmitters;
  16498. private _createParticle;
  16499. private _removeFromRoot;
  16500. private _emitFromParticle;
  16501. private _update;
  16502. /** @hidden */
  16503. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16504. /** @hidden */
  16505. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16506. /**
  16507. * Fill the defines array according to the current settings of the particle system
  16508. * @param defines Array to be updated
  16509. * @param blendMode blend mode to take into account when updating the array
  16510. */
  16511. fillDefines(defines: Array<string>, blendMode: number): void;
  16512. /**
  16513. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16514. * @param uniforms Uniforms array to fill
  16515. * @param attributes Attributes array to fill
  16516. * @param samplers Samplers array to fill
  16517. */
  16518. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16519. /** @hidden */
  16520. private _getEffect;
  16521. /**
  16522. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16523. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16524. */
  16525. animate(preWarmOnly?: boolean): void;
  16526. private _appendParticleVertices;
  16527. /**
  16528. * Rebuilds the particle system.
  16529. */
  16530. rebuild(): void;
  16531. /**
  16532. * Is this system ready to be used/rendered
  16533. * @return true if the system is ready
  16534. */
  16535. isReady(): boolean;
  16536. private _render;
  16537. /**
  16538. * Renders the particle system in its current state.
  16539. * @returns the current number of particles
  16540. */
  16541. render(): number;
  16542. /**
  16543. * Disposes the particle system and free the associated resources
  16544. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16545. */
  16546. dispose(disposeTexture?: boolean): void;
  16547. /**
  16548. * Clones the particle system.
  16549. * @param name The name of the cloned object
  16550. * @param newEmitter The new emitter to use
  16551. * @returns the cloned particle system
  16552. */
  16553. clone(name: string, newEmitter: any): ParticleSystem;
  16554. /**
  16555. * Serializes the particle system to a JSON object
  16556. * @param serializeTexture defines if the texture must be serialized as well
  16557. * @returns the JSON object
  16558. */
  16559. serialize(serializeTexture?: boolean): any;
  16560. /** @hidden */
  16561. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16562. /** @hidden */
  16563. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16564. /**
  16565. * Parses a JSON object to create a particle system.
  16566. * @param parsedParticleSystem The JSON object to parse
  16567. * @param sceneOrEngine The scene or the engine to create the particle system in
  16568. * @param rootUrl The root url to use to load external dependencies like texture
  16569. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16570. * @returns the Parsed particle system
  16571. */
  16572. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16573. }
  16574. }
  16575. declare module "babylonjs/Particles/particle" {
  16576. import { Nullable } from "babylonjs/types";
  16577. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  16578. import { Color4 } from "babylonjs/Maths/math.color";
  16579. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  16580. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16581. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  16582. /**
  16583. * A particle represents one of the element emitted by a particle system.
  16584. * This is mainly define by its coordinates, direction, velocity and age.
  16585. */
  16586. export class Particle {
  16587. /**
  16588. * The particle system the particle belongs to.
  16589. */
  16590. particleSystem: ParticleSystem;
  16591. private static _Count;
  16592. /**
  16593. * Unique ID of the particle
  16594. */
  16595. id: number;
  16596. /**
  16597. * The world position of the particle in the scene.
  16598. */
  16599. position: Vector3;
  16600. /**
  16601. * The world direction of the particle in the scene.
  16602. */
  16603. direction: Vector3;
  16604. /**
  16605. * The color of the particle.
  16606. */
  16607. color: Color4;
  16608. /**
  16609. * The color change of the particle per step.
  16610. */
  16611. colorStep: Color4;
  16612. /**
  16613. * Defines how long will the life of the particle be.
  16614. */
  16615. lifeTime: number;
  16616. /**
  16617. * The current age of the particle.
  16618. */
  16619. age: number;
  16620. /**
  16621. * The current size of the particle.
  16622. */
  16623. size: number;
  16624. /**
  16625. * The current scale of the particle.
  16626. */
  16627. scale: Vector2;
  16628. /**
  16629. * The current angle of the particle.
  16630. */
  16631. angle: number;
  16632. /**
  16633. * Defines how fast is the angle changing.
  16634. */
  16635. angularSpeed: number;
  16636. /**
  16637. * Defines the cell index used by the particle to be rendered from a sprite.
  16638. */
  16639. cellIndex: number;
  16640. /**
  16641. * The information required to support color remapping
  16642. */
  16643. remapData: Vector4;
  16644. /** @hidden */
  16645. _randomCellOffset?: number;
  16646. /** @hidden */
  16647. _initialDirection: Nullable<Vector3>;
  16648. /** @hidden */
  16649. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16650. /** @hidden */
  16651. _initialStartSpriteCellID: number;
  16652. /** @hidden */
  16653. _initialEndSpriteCellID: number;
  16654. /** @hidden */
  16655. _currentColorGradient: Nullable<ColorGradient>;
  16656. /** @hidden */
  16657. _currentColor1: Color4;
  16658. /** @hidden */
  16659. _currentColor2: Color4;
  16660. /** @hidden */
  16661. _currentSizeGradient: Nullable<FactorGradient>;
  16662. /** @hidden */
  16663. _currentSize1: number;
  16664. /** @hidden */
  16665. _currentSize2: number;
  16666. /** @hidden */
  16667. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16668. /** @hidden */
  16669. _currentAngularSpeed1: number;
  16670. /** @hidden */
  16671. _currentAngularSpeed2: number;
  16672. /** @hidden */
  16673. _currentVelocityGradient: Nullable<FactorGradient>;
  16674. /** @hidden */
  16675. _currentVelocity1: number;
  16676. /** @hidden */
  16677. _currentVelocity2: number;
  16678. /** @hidden */
  16679. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16680. /** @hidden */
  16681. _currentLimitVelocity1: number;
  16682. /** @hidden */
  16683. _currentLimitVelocity2: number;
  16684. /** @hidden */
  16685. _currentDragGradient: Nullable<FactorGradient>;
  16686. /** @hidden */
  16687. _currentDrag1: number;
  16688. /** @hidden */
  16689. _currentDrag2: number;
  16690. /** @hidden */
  16691. _randomNoiseCoordinates1: Vector3;
  16692. /** @hidden */
  16693. _randomNoiseCoordinates2: Vector3;
  16694. /** @hidden */
  16695. _localPosition?: Vector3;
  16696. /**
  16697. * Creates a new instance Particle
  16698. * @param particleSystem the particle system the particle belongs to
  16699. */
  16700. constructor(
  16701. /**
  16702. * The particle system the particle belongs to.
  16703. */
  16704. particleSystem: ParticleSystem);
  16705. private updateCellInfoFromSystem;
  16706. /**
  16707. * Defines how the sprite cell index is updated for the particle
  16708. */
  16709. updateCellIndex(): void;
  16710. /** @hidden */
  16711. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16712. /** @hidden */
  16713. _inheritParticleInfoToSubEmitters(): void;
  16714. /** @hidden */
  16715. _reset(): void;
  16716. /**
  16717. * Copy the properties of particle to another one.
  16718. * @param other the particle to copy the information to.
  16719. */
  16720. copyTo(other: Particle): void;
  16721. }
  16722. }
  16723. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16724. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16725. import { Effect } from "babylonjs/Materials/effect";
  16726. import { Particle } from "babylonjs/Particles/particle";
  16727. import { Nullable } from "babylonjs/types";
  16728. import { Scene } from "babylonjs/scene";
  16729. /**
  16730. * Particle emitter represents a volume emitting particles.
  16731. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16732. */
  16733. export interface IParticleEmitterType {
  16734. /**
  16735. * Called by the particle System when the direction is computed for the created particle.
  16736. * @param worldMatrix is the world matrix of the particle system
  16737. * @param directionToUpdate is the direction vector to update with the result
  16738. * @param particle is the particle we are computed the direction for
  16739. * @param isLocal defines if the direction should be set in local space
  16740. */
  16741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16742. /**
  16743. * Called by the particle System when the position is computed for the created particle.
  16744. * @param worldMatrix is the world matrix of the particle system
  16745. * @param positionToUpdate is the position vector to update with the result
  16746. * @param particle is the particle we are computed the position for
  16747. * @param isLocal defines if the position should be set in local space
  16748. */
  16749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16750. /**
  16751. * Clones the current emitter and returns a copy of it
  16752. * @returns the new emitter
  16753. */
  16754. clone(): IParticleEmitterType;
  16755. /**
  16756. * Called by the GPUParticleSystem to setup the update shader
  16757. * @param effect defines the update shader
  16758. */
  16759. applyToShader(effect: Effect): void;
  16760. /**
  16761. * Returns a string to use to update the GPU particles update shader
  16762. * @returns the effect defines string
  16763. */
  16764. getEffectDefines(): string;
  16765. /**
  16766. * Returns a string representing the class name
  16767. * @returns a string containing the class name
  16768. */
  16769. getClassName(): string;
  16770. /**
  16771. * Serializes the particle system to a JSON object.
  16772. * @returns the JSON object
  16773. */
  16774. serialize(): any;
  16775. /**
  16776. * Parse properties from a JSON object
  16777. * @param serializationObject defines the JSON object
  16778. * @param scene defines the hosting scene
  16779. */
  16780. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16781. }
  16782. }
  16783. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16784. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16785. import { Effect } from "babylonjs/Materials/effect";
  16786. import { Particle } from "babylonjs/Particles/particle";
  16787. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16788. /**
  16789. * Particle emitter emitting particles from the inside of a box.
  16790. * It emits the particles randomly between 2 given directions.
  16791. */
  16792. export class BoxParticleEmitter implements IParticleEmitterType {
  16793. /**
  16794. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16795. */
  16796. direction1: Vector3;
  16797. /**
  16798. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16799. */
  16800. direction2: Vector3;
  16801. /**
  16802. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16803. */
  16804. minEmitBox: Vector3;
  16805. /**
  16806. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16807. */
  16808. maxEmitBox: Vector3;
  16809. /**
  16810. * Creates a new instance BoxParticleEmitter
  16811. */
  16812. constructor();
  16813. /**
  16814. * Called by the particle System when the direction is computed for the created particle.
  16815. * @param worldMatrix is the world matrix of the particle system
  16816. * @param directionToUpdate is the direction vector to update with the result
  16817. * @param particle is the particle we are computed the direction for
  16818. * @param isLocal defines if the direction should be set in local space
  16819. */
  16820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16821. /**
  16822. * Called by the particle System when the position is computed for the created particle.
  16823. * @param worldMatrix is the world matrix of the particle system
  16824. * @param positionToUpdate is the position vector to update with the result
  16825. * @param particle is the particle we are computed the position for
  16826. * @param isLocal defines if the position should be set in local space
  16827. */
  16828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16829. /**
  16830. * Clones the current emitter and returns a copy of it
  16831. * @returns the new emitter
  16832. */
  16833. clone(): BoxParticleEmitter;
  16834. /**
  16835. * Called by the GPUParticleSystem to setup the update shader
  16836. * @param effect defines the update shader
  16837. */
  16838. applyToShader(effect: Effect): void;
  16839. /**
  16840. * Returns a string to use to update the GPU particles update shader
  16841. * @returns a string containng the defines string
  16842. */
  16843. getEffectDefines(): string;
  16844. /**
  16845. * Returns the string "BoxParticleEmitter"
  16846. * @returns a string containing the class name
  16847. */
  16848. getClassName(): string;
  16849. /**
  16850. * Serializes the particle system to a JSON object.
  16851. * @returns the JSON object
  16852. */
  16853. serialize(): any;
  16854. /**
  16855. * Parse properties from a JSON object
  16856. * @param serializationObject defines the JSON object
  16857. */
  16858. parse(serializationObject: any): void;
  16859. }
  16860. }
  16861. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16862. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16863. import { Effect } from "babylonjs/Materials/effect";
  16864. import { Particle } from "babylonjs/Particles/particle";
  16865. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16866. /**
  16867. * Particle emitter emitting particles from the inside of a cone.
  16868. * It emits the particles alongside the cone volume from the base to the particle.
  16869. * The emission direction might be randomized.
  16870. */
  16871. export class ConeParticleEmitter implements IParticleEmitterType {
  16872. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16873. directionRandomizer: number;
  16874. private _radius;
  16875. private _angle;
  16876. private _height;
  16877. /**
  16878. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16879. */
  16880. radiusRange: number;
  16881. /**
  16882. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16883. */
  16884. heightRange: number;
  16885. /**
  16886. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16887. */
  16888. emitFromSpawnPointOnly: boolean;
  16889. /**
  16890. * Gets or sets the radius of the emission cone
  16891. */
  16892. get radius(): number;
  16893. set radius(value: number);
  16894. /**
  16895. * Gets or sets the angle of the emission cone
  16896. */
  16897. get angle(): number;
  16898. set angle(value: number);
  16899. private _buildHeight;
  16900. /**
  16901. * Creates a new instance ConeParticleEmitter
  16902. * @param radius the radius of the emission cone (1 by default)
  16903. * @param angle the cone base angle (PI by default)
  16904. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16905. */
  16906. constructor(radius?: number, angle?: number,
  16907. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16908. directionRandomizer?: number);
  16909. /**
  16910. * Called by the particle System when the direction is computed for the created particle.
  16911. * @param worldMatrix is the world matrix of the particle system
  16912. * @param directionToUpdate is the direction vector to update with the result
  16913. * @param particle is the particle we are computed the direction for
  16914. * @param isLocal defines if the direction should be set in local space
  16915. */
  16916. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16917. /**
  16918. * Called by the particle System when the position is computed for the created particle.
  16919. * @param worldMatrix is the world matrix of the particle system
  16920. * @param positionToUpdate is the position vector to update with the result
  16921. * @param particle is the particle we are computed the position for
  16922. * @param isLocal defines if the position should be set in local space
  16923. */
  16924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16925. /**
  16926. * Clones the current emitter and returns a copy of it
  16927. * @returns the new emitter
  16928. */
  16929. clone(): ConeParticleEmitter;
  16930. /**
  16931. * Called by the GPUParticleSystem to setup the update shader
  16932. * @param effect defines the update shader
  16933. */
  16934. applyToShader(effect: Effect): void;
  16935. /**
  16936. * Returns a string to use to update the GPU particles update shader
  16937. * @returns a string containng the defines string
  16938. */
  16939. getEffectDefines(): string;
  16940. /**
  16941. * Returns the string "ConeParticleEmitter"
  16942. * @returns a string containing the class name
  16943. */
  16944. getClassName(): string;
  16945. /**
  16946. * Serializes the particle system to a JSON object.
  16947. * @returns the JSON object
  16948. */
  16949. serialize(): any;
  16950. /**
  16951. * Parse properties from a JSON object
  16952. * @param serializationObject defines the JSON object
  16953. */
  16954. parse(serializationObject: any): void;
  16955. }
  16956. }
  16957. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16958. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16959. import { Effect } from "babylonjs/Materials/effect";
  16960. import { Particle } from "babylonjs/Particles/particle";
  16961. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16962. /**
  16963. * Particle emitter emitting particles from the inside of a cylinder.
  16964. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16965. */
  16966. export class CylinderParticleEmitter implements IParticleEmitterType {
  16967. /**
  16968. * The radius of the emission cylinder.
  16969. */
  16970. radius: number;
  16971. /**
  16972. * The height of the emission cylinder.
  16973. */
  16974. height: number;
  16975. /**
  16976. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16977. */
  16978. radiusRange: number;
  16979. /**
  16980. * How much to randomize the particle direction [0-1].
  16981. */
  16982. directionRandomizer: number;
  16983. /**
  16984. * Creates a new instance CylinderParticleEmitter
  16985. * @param radius the radius of the emission cylinder (1 by default)
  16986. * @param height the height of the emission cylinder (1 by default)
  16987. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16988. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16989. */
  16990. constructor(
  16991. /**
  16992. * The radius of the emission cylinder.
  16993. */
  16994. radius?: number,
  16995. /**
  16996. * The height of the emission cylinder.
  16997. */
  16998. height?: number,
  16999. /**
  17000. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17001. */
  17002. radiusRange?: number,
  17003. /**
  17004. * How much to randomize the particle direction [0-1].
  17005. */
  17006. directionRandomizer?: number);
  17007. /**
  17008. * Called by the particle System when the direction is computed for the created particle.
  17009. * @param worldMatrix is the world matrix of the particle system
  17010. * @param directionToUpdate is the direction vector to update with the result
  17011. * @param particle is the particle we are computed the direction for
  17012. * @param isLocal defines if the direction should be set in local space
  17013. */
  17014. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17015. /**
  17016. * Called by the particle System when the position is computed for the created particle.
  17017. * @param worldMatrix is the world matrix of the particle system
  17018. * @param positionToUpdate is the position vector to update with the result
  17019. * @param particle is the particle we are computed the position for
  17020. * @param isLocal defines if the position should be set in local space
  17021. */
  17022. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17023. /**
  17024. * Clones the current emitter and returns a copy of it
  17025. * @returns the new emitter
  17026. */
  17027. clone(): CylinderParticleEmitter;
  17028. /**
  17029. * Called by the GPUParticleSystem to setup the update shader
  17030. * @param effect defines the update shader
  17031. */
  17032. applyToShader(effect: Effect): void;
  17033. /**
  17034. * Returns a string to use to update the GPU particles update shader
  17035. * @returns a string containng the defines string
  17036. */
  17037. getEffectDefines(): string;
  17038. /**
  17039. * Returns the string "CylinderParticleEmitter"
  17040. * @returns a string containing the class name
  17041. */
  17042. getClassName(): string;
  17043. /**
  17044. * Serializes the particle system to a JSON object.
  17045. * @returns the JSON object
  17046. */
  17047. serialize(): any;
  17048. /**
  17049. * Parse properties from a JSON object
  17050. * @param serializationObject defines the JSON object
  17051. */
  17052. parse(serializationObject: any): void;
  17053. }
  17054. /**
  17055. * Particle emitter emitting particles from the inside of a cylinder.
  17056. * It emits the particles randomly between two vectors.
  17057. */
  17058. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17059. /**
  17060. * The min limit of the emission direction.
  17061. */
  17062. direction1: Vector3;
  17063. /**
  17064. * The max limit of the emission direction.
  17065. */
  17066. direction2: Vector3;
  17067. /**
  17068. * Creates a new instance CylinderDirectedParticleEmitter
  17069. * @param radius the radius of the emission cylinder (1 by default)
  17070. * @param height the height of the emission cylinder (1 by default)
  17071. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17072. * @param direction1 the min limit of the emission direction (up vector by default)
  17073. * @param direction2 the max limit of the emission direction (up vector by default)
  17074. */
  17075. constructor(radius?: number, height?: number, radiusRange?: number,
  17076. /**
  17077. * The min limit of the emission direction.
  17078. */
  17079. direction1?: Vector3,
  17080. /**
  17081. * The max limit of the emission direction.
  17082. */
  17083. direction2?: Vector3);
  17084. /**
  17085. * Called by the particle System when the direction is computed for the created particle.
  17086. * @param worldMatrix is the world matrix of the particle system
  17087. * @param directionToUpdate is the direction vector to update with the result
  17088. * @param particle is the particle we are computed the direction for
  17089. */
  17090. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17091. /**
  17092. * Clones the current emitter and returns a copy of it
  17093. * @returns the new emitter
  17094. */
  17095. clone(): CylinderDirectedParticleEmitter;
  17096. /**
  17097. * Called by the GPUParticleSystem to setup the update shader
  17098. * @param effect defines the update shader
  17099. */
  17100. applyToShader(effect: Effect): void;
  17101. /**
  17102. * Returns a string to use to update the GPU particles update shader
  17103. * @returns a string containng the defines string
  17104. */
  17105. getEffectDefines(): string;
  17106. /**
  17107. * Returns the string "CylinderDirectedParticleEmitter"
  17108. * @returns a string containing the class name
  17109. */
  17110. getClassName(): string;
  17111. /**
  17112. * Serializes the particle system to a JSON object.
  17113. * @returns the JSON object
  17114. */
  17115. serialize(): any;
  17116. /**
  17117. * Parse properties from a JSON object
  17118. * @param serializationObject defines the JSON object
  17119. */
  17120. parse(serializationObject: any): void;
  17121. }
  17122. }
  17123. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  17124. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17125. import { Effect } from "babylonjs/Materials/effect";
  17126. import { Particle } from "babylonjs/Particles/particle";
  17127. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17128. /**
  17129. * Particle emitter emitting particles from the inside of a hemisphere.
  17130. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17131. */
  17132. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17133. /**
  17134. * The radius of the emission hemisphere.
  17135. */
  17136. radius: number;
  17137. /**
  17138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17139. */
  17140. radiusRange: number;
  17141. /**
  17142. * How much to randomize the particle direction [0-1].
  17143. */
  17144. directionRandomizer: number;
  17145. /**
  17146. * Creates a new instance HemisphericParticleEmitter
  17147. * @param radius the radius of the emission hemisphere (1 by default)
  17148. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17149. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17150. */
  17151. constructor(
  17152. /**
  17153. * The radius of the emission hemisphere.
  17154. */
  17155. radius?: number,
  17156. /**
  17157. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17158. */
  17159. radiusRange?: number,
  17160. /**
  17161. * How much to randomize the particle direction [0-1].
  17162. */
  17163. directionRandomizer?: number);
  17164. /**
  17165. * Called by the particle System when the direction is computed for the created particle.
  17166. * @param worldMatrix is the world matrix of the particle system
  17167. * @param directionToUpdate is the direction vector to update with the result
  17168. * @param particle is the particle we are computed the direction for
  17169. * @param isLocal defines if the direction should be set in local space
  17170. */
  17171. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17172. /**
  17173. * Called by the particle System when the position is computed for the created particle.
  17174. * @param worldMatrix is the world matrix of the particle system
  17175. * @param positionToUpdate is the position vector to update with the result
  17176. * @param particle is the particle we are computed the position for
  17177. * @param isLocal defines if the position should be set in local space
  17178. */
  17179. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17180. /**
  17181. * Clones the current emitter and returns a copy of it
  17182. * @returns the new emitter
  17183. */
  17184. clone(): HemisphericParticleEmitter;
  17185. /**
  17186. * Called by the GPUParticleSystem to setup the update shader
  17187. * @param effect defines the update shader
  17188. */
  17189. applyToShader(effect: Effect): void;
  17190. /**
  17191. * Returns a string to use to update the GPU particles update shader
  17192. * @returns a string containng the defines string
  17193. */
  17194. getEffectDefines(): string;
  17195. /**
  17196. * Returns the string "HemisphericParticleEmitter"
  17197. * @returns a string containing the class name
  17198. */
  17199. getClassName(): string;
  17200. /**
  17201. * Serializes the particle system to a JSON object.
  17202. * @returns the JSON object
  17203. */
  17204. serialize(): any;
  17205. /**
  17206. * Parse properties from a JSON object
  17207. * @param serializationObject defines the JSON object
  17208. */
  17209. parse(serializationObject: any): void;
  17210. }
  17211. }
  17212. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  17213. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17214. import { Effect } from "babylonjs/Materials/effect";
  17215. import { Particle } from "babylonjs/Particles/particle";
  17216. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17217. /**
  17218. * Particle emitter emitting particles from a point.
  17219. * It emits the particles randomly between 2 given directions.
  17220. */
  17221. export class PointParticleEmitter implements IParticleEmitterType {
  17222. /**
  17223. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17224. */
  17225. direction1: Vector3;
  17226. /**
  17227. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17228. */
  17229. direction2: Vector3;
  17230. /**
  17231. * Creates a new instance PointParticleEmitter
  17232. */
  17233. constructor();
  17234. /**
  17235. * Called by the particle System when the direction is computed for the created particle.
  17236. * @param worldMatrix is the world matrix of the particle system
  17237. * @param directionToUpdate is the direction vector to update with the result
  17238. * @param particle is the particle we are computed the direction for
  17239. * @param isLocal defines if the direction should be set in local space
  17240. */
  17241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17242. /**
  17243. * Called by the particle System when the position is computed for the created particle.
  17244. * @param worldMatrix is the world matrix of the particle system
  17245. * @param positionToUpdate is the position vector to update with the result
  17246. * @param particle is the particle we are computed the position for
  17247. * @param isLocal defines if the position should be set in local space
  17248. */
  17249. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17250. /**
  17251. * Clones the current emitter and returns a copy of it
  17252. * @returns the new emitter
  17253. */
  17254. clone(): PointParticleEmitter;
  17255. /**
  17256. * Called by the GPUParticleSystem to setup the update shader
  17257. * @param effect defines the update shader
  17258. */
  17259. applyToShader(effect: Effect): void;
  17260. /**
  17261. * Returns a string to use to update the GPU particles update shader
  17262. * @returns a string containng the defines string
  17263. */
  17264. getEffectDefines(): string;
  17265. /**
  17266. * Returns the string "PointParticleEmitter"
  17267. * @returns a string containing the class name
  17268. */
  17269. getClassName(): string;
  17270. /**
  17271. * Serializes the particle system to a JSON object.
  17272. * @returns the JSON object
  17273. */
  17274. serialize(): any;
  17275. /**
  17276. * Parse properties from a JSON object
  17277. * @param serializationObject defines the JSON object
  17278. */
  17279. parse(serializationObject: any): void;
  17280. }
  17281. }
  17282. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  17283. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17284. import { Effect } from "babylonjs/Materials/effect";
  17285. import { Particle } from "babylonjs/Particles/particle";
  17286. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17287. /**
  17288. * Particle emitter emitting particles from the inside of a sphere.
  17289. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17290. */
  17291. export class SphereParticleEmitter implements IParticleEmitterType {
  17292. /**
  17293. * The radius of the emission sphere.
  17294. */
  17295. radius: number;
  17296. /**
  17297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17298. */
  17299. radiusRange: number;
  17300. /**
  17301. * How much to randomize the particle direction [0-1].
  17302. */
  17303. directionRandomizer: number;
  17304. /**
  17305. * Creates a new instance SphereParticleEmitter
  17306. * @param radius the radius of the emission sphere (1 by default)
  17307. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17308. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17309. */
  17310. constructor(
  17311. /**
  17312. * The radius of the emission sphere.
  17313. */
  17314. radius?: number,
  17315. /**
  17316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17317. */
  17318. radiusRange?: number,
  17319. /**
  17320. * How much to randomize the particle direction [0-1].
  17321. */
  17322. directionRandomizer?: number);
  17323. /**
  17324. * Called by the particle System when the direction is computed for the created particle.
  17325. * @param worldMatrix is the world matrix of the particle system
  17326. * @param directionToUpdate is the direction vector to update with the result
  17327. * @param particle is the particle we are computed the direction for
  17328. * @param isLocal defines if the direction should be set in local space
  17329. */
  17330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17331. /**
  17332. * Called by the particle System when the position is computed for the created particle.
  17333. * @param worldMatrix is the world matrix of the particle system
  17334. * @param positionToUpdate is the position vector to update with the result
  17335. * @param particle is the particle we are computed the position for
  17336. * @param isLocal defines if the position should be set in local space
  17337. */
  17338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17339. /**
  17340. * Clones the current emitter and returns a copy of it
  17341. * @returns the new emitter
  17342. */
  17343. clone(): SphereParticleEmitter;
  17344. /**
  17345. * Called by the GPUParticleSystem to setup the update shader
  17346. * @param effect defines the update shader
  17347. */
  17348. applyToShader(effect: Effect): void;
  17349. /**
  17350. * Returns a string to use to update the GPU particles update shader
  17351. * @returns a string containng the defines string
  17352. */
  17353. getEffectDefines(): string;
  17354. /**
  17355. * Returns the string "SphereParticleEmitter"
  17356. * @returns a string containing the class name
  17357. */
  17358. getClassName(): string;
  17359. /**
  17360. * Serializes the particle system to a JSON object.
  17361. * @returns the JSON object
  17362. */
  17363. serialize(): any;
  17364. /**
  17365. * Parse properties from a JSON object
  17366. * @param serializationObject defines the JSON object
  17367. */
  17368. parse(serializationObject: any): void;
  17369. }
  17370. /**
  17371. * Particle emitter emitting particles from the inside of a sphere.
  17372. * It emits the particles randomly between two vectors.
  17373. */
  17374. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17375. /**
  17376. * The min limit of the emission direction.
  17377. */
  17378. direction1: Vector3;
  17379. /**
  17380. * The max limit of the emission direction.
  17381. */
  17382. direction2: Vector3;
  17383. /**
  17384. * Creates a new instance SphereDirectedParticleEmitter
  17385. * @param radius the radius of the emission sphere (1 by default)
  17386. * @param direction1 the min limit of the emission direction (up vector by default)
  17387. * @param direction2 the max limit of the emission direction (up vector by default)
  17388. */
  17389. constructor(radius?: number,
  17390. /**
  17391. * The min limit of the emission direction.
  17392. */
  17393. direction1?: Vector3,
  17394. /**
  17395. * The max limit of the emission direction.
  17396. */
  17397. direction2?: Vector3);
  17398. /**
  17399. * Called by the particle System when the direction is computed for the created particle.
  17400. * @param worldMatrix is the world matrix of the particle system
  17401. * @param directionToUpdate is the direction vector to update with the result
  17402. * @param particle is the particle we are computed the direction for
  17403. */
  17404. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17405. /**
  17406. * Clones the current emitter and returns a copy of it
  17407. * @returns the new emitter
  17408. */
  17409. clone(): SphereDirectedParticleEmitter;
  17410. /**
  17411. * Called by the GPUParticleSystem to setup the update shader
  17412. * @param effect defines the update shader
  17413. */
  17414. applyToShader(effect: Effect): void;
  17415. /**
  17416. * Returns a string to use to update the GPU particles update shader
  17417. * @returns a string containng the defines string
  17418. */
  17419. getEffectDefines(): string;
  17420. /**
  17421. * Returns the string "SphereDirectedParticleEmitter"
  17422. * @returns a string containing the class name
  17423. */
  17424. getClassName(): string;
  17425. /**
  17426. * Serializes the particle system to a JSON object.
  17427. * @returns the JSON object
  17428. */
  17429. serialize(): any;
  17430. /**
  17431. * Parse properties from a JSON object
  17432. * @param serializationObject defines the JSON object
  17433. */
  17434. parse(serializationObject: any): void;
  17435. }
  17436. }
  17437. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  17438. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17439. import { Effect } from "babylonjs/Materials/effect";
  17440. import { Particle } from "babylonjs/Particles/particle";
  17441. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17442. import { Nullable } from "babylonjs/types";
  17443. /**
  17444. * Particle emitter emitting particles from a custom list of positions.
  17445. */
  17446. export class CustomParticleEmitter implements IParticleEmitterType {
  17447. /**
  17448. * Gets or sets the position generator that will create the inital position of each particle.
  17449. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17450. */
  17451. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  17452. /**
  17453. * Gets or sets the destination generator that will create the final destination of each particle.
  17454. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17455. */
  17456. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  17457. /**
  17458. * Creates a new instance CustomParticleEmitter
  17459. */
  17460. constructor();
  17461. /**
  17462. * Called by the particle System when the direction is computed for the created particle.
  17463. * @param worldMatrix is the world matrix of the particle system
  17464. * @param directionToUpdate is the direction vector to update with the result
  17465. * @param particle is the particle we are computed the direction for
  17466. * @param isLocal defines if the direction should be set in local space
  17467. */
  17468. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17469. /**
  17470. * Called by the particle System when the position is computed for the created particle.
  17471. * @param worldMatrix is the world matrix of the particle system
  17472. * @param positionToUpdate is the position vector to update with the result
  17473. * @param particle is the particle we are computed the position for
  17474. * @param isLocal defines if the position should be set in local space
  17475. */
  17476. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17477. /**
  17478. * Clones the current emitter and returns a copy of it
  17479. * @returns the new emitter
  17480. */
  17481. clone(): CustomParticleEmitter;
  17482. /**
  17483. * Called by the GPUParticleSystem to setup the update shader
  17484. * @param effect defines the update shader
  17485. */
  17486. applyToShader(effect: Effect): void;
  17487. /**
  17488. * Returns a string to use to update the GPU particles update shader
  17489. * @returns a string containng the defines string
  17490. */
  17491. getEffectDefines(): string;
  17492. /**
  17493. * Returns the string "PointParticleEmitter"
  17494. * @returns a string containing the class name
  17495. */
  17496. getClassName(): string;
  17497. /**
  17498. * Serializes the particle system to a JSON object.
  17499. * @returns the JSON object
  17500. */
  17501. serialize(): any;
  17502. /**
  17503. * Parse properties from a JSON object
  17504. * @param serializationObject defines the JSON object
  17505. */
  17506. parse(serializationObject: any): void;
  17507. }
  17508. }
  17509. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  17510. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17511. import { Effect } from "babylonjs/Materials/effect";
  17512. import { Particle } from "babylonjs/Particles/particle";
  17513. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17514. import { Nullable } from "babylonjs/types";
  17515. import { Scene } from "babylonjs/scene";
  17516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17517. /**
  17518. * Particle emitter emitting particles from the inside of a box.
  17519. * It emits the particles randomly between 2 given directions.
  17520. */
  17521. export class MeshParticleEmitter implements IParticleEmitterType {
  17522. private _indices;
  17523. private _positions;
  17524. private _normals;
  17525. private _storedNormal;
  17526. private _mesh;
  17527. /**
  17528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17529. */
  17530. direction1: Vector3;
  17531. /**
  17532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17533. */
  17534. direction2: Vector3;
  17535. /**
  17536. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17537. */
  17538. useMeshNormalsForDirection: boolean;
  17539. /** Defines the mesh to use as source */
  17540. get mesh(): Nullable<AbstractMesh>;
  17541. set mesh(value: Nullable<AbstractMesh>);
  17542. /**
  17543. * Creates a new instance MeshParticleEmitter
  17544. * @param mesh defines the mesh to use as source
  17545. */
  17546. constructor(mesh?: Nullable<AbstractMesh>);
  17547. /**
  17548. * Called by the particle System when the direction is computed for the created particle.
  17549. * @param worldMatrix is the world matrix of the particle system
  17550. * @param directionToUpdate is the direction vector to update with the result
  17551. * @param particle is the particle we are computed the direction for
  17552. * @param isLocal defines if the direction should be set in local space
  17553. */
  17554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17555. /**
  17556. * Called by the particle System when the position is computed for the created particle.
  17557. * @param worldMatrix is the world matrix of the particle system
  17558. * @param positionToUpdate is the position vector to update with the result
  17559. * @param particle is the particle we are computed the position for
  17560. * @param isLocal defines if the position should be set in local space
  17561. */
  17562. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17563. /**
  17564. * Clones the current emitter and returns a copy of it
  17565. * @returns the new emitter
  17566. */
  17567. clone(): MeshParticleEmitter;
  17568. /**
  17569. * Called by the GPUParticleSystem to setup the update shader
  17570. * @param effect defines the update shader
  17571. */
  17572. applyToShader(effect: Effect): void;
  17573. /**
  17574. * Returns a string to use to update the GPU particles update shader
  17575. * @returns a string containng the defines string
  17576. */
  17577. getEffectDefines(): string;
  17578. /**
  17579. * Returns the string "BoxParticleEmitter"
  17580. * @returns a string containing the class name
  17581. */
  17582. getClassName(): string;
  17583. /**
  17584. * Serializes the particle system to a JSON object.
  17585. * @returns the JSON object
  17586. */
  17587. serialize(): any;
  17588. /**
  17589. * Parse properties from a JSON object
  17590. * @param serializationObject defines the JSON object
  17591. * @param scene defines the hosting scene
  17592. */
  17593. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17594. }
  17595. }
  17596. declare module "babylonjs/Particles/EmitterTypes/index" {
  17597. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  17598. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  17599. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  17600. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  17601. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17602. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  17603. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  17604. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  17605. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  17606. }
  17607. declare module "babylonjs/Particles/IParticleSystem" {
  17608. import { Nullable } from "babylonjs/types";
  17609. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17610. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17612. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17613. import { Scene } from "babylonjs/scene";
  17614. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17615. import { Effect } from "babylonjs/Materials/effect";
  17616. import { Observable } from "babylonjs/Misc/observable";
  17617. import { Animation } from "babylonjs/Animations/animation";
  17618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17619. /**
  17620. * Interface representing a particle system in Babylon.js.
  17621. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17622. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17623. */
  17624. export interface IParticleSystem {
  17625. /**
  17626. * List of animations used by the particle system.
  17627. */
  17628. animations: Animation[];
  17629. /**
  17630. * The id of the Particle system.
  17631. */
  17632. id: string;
  17633. /**
  17634. * The name of the Particle system.
  17635. */
  17636. name: string;
  17637. /**
  17638. * The emitter represents the Mesh or position we are attaching the particle system to.
  17639. */
  17640. emitter: Nullable<AbstractMesh | Vector3>;
  17641. /**
  17642. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17643. */
  17644. isBillboardBased: boolean;
  17645. /**
  17646. * The rendering group used by the Particle system to chose when to render.
  17647. */
  17648. renderingGroupId: number;
  17649. /**
  17650. * The layer mask we are rendering the particles through.
  17651. */
  17652. layerMask: number;
  17653. /**
  17654. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17655. */
  17656. updateSpeed: number;
  17657. /**
  17658. * The amount of time the particle system is running (depends of the overall update speed).
  17659. */
  17660. targetStopDuration: number;
  17661. /**
  17662. * The texture used to render each particle. (this can be a spritesheet)
  17663. */
  17664. particleTexture: Nullable<BaseTexture>;
  17665. /**
  17666. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17667. */
  17668. blendMode: number;
  17669. /**
  17670. * Minimum life time of emitting particles.
  17671. */
  17672. minLifeTime: number;
  17673. /**
  17674. * Maximum life time of emitting particles.
  17675. */
  17676. maxLifeTime: number;
  17677. /**
  17678. * Minimum Size of emitting particles.
  17679. */
  17680. minSize: number;
  17681. /**
  17682. * Maximum Size of emitting particles.
  17683. */
  17684. maxSize: number;
  17685. /**
  17686. * Minimum scale of emitting particles on X axis.
  17687. */
  17688. minScaleX: number;
  17689. /**
  17690. * Maximum scale of emitting particles on X axis.
  17691. */
  17692. maxScaleX: number;
  17693. /**
  17694. * Minimum scale of emitting particles on Y axis.
  17695. */
  17696. minScaleY: number;
  17697. /**
  17698. * Maximum scale of emitting particles on Y axis.
  17699. */
  17700. maxScaleY: number;
  17701. /**
  17702. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17703. */
  17704. color1: Color4;
  17705. /**
  17706. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17707. */
  17708. color2: Color4;
  17709. /**
  17710. * Color the particle will have at the end of its lifetime.
  17711. */
  17712. colorDead: Color4;
  17713. /**
  17714. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17715. */
  17716. emitRate: number;
  17717. /**
  17718. * You can use gravity if you want to give an orientation to your particles.
  17719. */
  17720. gravity: Vector3;
  17721. /**
  17722. * Minimum power of emitting particles.
  17723. */
  17724. minEmitPower: number;
  17725. /**
  17726. * Maximum power of emitting particles.
  17727. */
  17728. maxEmitPower: number;
  17729. /**
  17730. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17731. */
  17732. minAngularSpeed: number;
  17733. /**
  17734. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17735. */
  17736. maxAngularSpeed: number;
  17737. /**
  17738. * Gets or sets the minimal initial rotation in radians.
  17739. */
  17740. minInitialRotation: number;
  17741. /**
  17742. * Gets or sets the maximal initial rotation in radians.
  17743. */
  17744. maxInitialRotation: number;
  17745. /**
  17746. * The particle emitter type defines the emitter used by the particle system.
  17747. * It can be for example box, sphere, or cone...
  17748. */
  17749. particleEmitterType: Nullable<IParticleEmitterType>;
  17750. /**
  17751. * Defines the delay in milliseconds before starting the system (0 by default)
  17752. */
  17753. startDelay: number;
  17754. /**
  17755. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  17756. */
  17757. preWarmCycles: number;
  17758. /**
  17759. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17760. */
  17761. preWarmStepOffset: number;
  17762. /**
  17763. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  17764. */
  17765. spriteCellChangeSpeed: number;
  17766. /**
  17767. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17768. */
  17769. startSpriteCellID: number;
  17770. /**
  17771. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17772. */
  17773. endSpriteCellID: number;
  17774. /**
  17775. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17776. */
  17777. spriteCellWidth: number;
  17778. /**
  17779. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17780. */
  17781. spriteCellHeight: number;
  17782. /**
  17783. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17784. */
  17785. spriteRandomStartCell: boolean;
  17786. /**
  17787. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17788. */
  17789. isAnimationSheetEnabled: boolean;
  17790. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17791. translationPivot: Vector2;
  17792. /**
  17793. * Gets or sets a texture used to add random noise to particle positions
  17794. */
  17795. noiseTexture: Nullable<BaseTexture>;
  17796. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17797. noiseStrength: Vector3;
  17798. /**
  17799. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17800. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17801. */
  17802. billboardMode: number;
  17803. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17804. limitVelocityDamping: number;
  17805. /**
  17806. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17807. */
  17808. beginAnimationOnStart: boolean;
  17809. /**
  17810. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17811. */
  17812. beginAnimationFrom: number;
  17813. /**
  17814. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17815. */
  17816. beginAnimationTo: number;
  17817. /**
  17818. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17819. */
  17820. beginAnimationLoop: boolean;
  17821. /**
  17822. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17823. */
  17824. disposeOnStop: boolean;
  17825. /**
  17826. * If you want to launch only a few particles at once, that can be done, as well.
  17827. */
  17828. manualEmitCount: number;
  17829. /**
  17830. * Specifies if the particles are updated in emitter local space or world space
  17831. */
  17832. isLocal: boolean;
  17833. /** Snippet ID if the particle system was created from the snippet server */
  17834. snippetId: string;
  17835. /** Gets or sets a matrix to use to compute projection */
  17836. defaultProjectionMatrix: Matrix;
  17837. /**
  17838. * Gets the maximum number of particles active at the same time.
  17839. * @returns The max number of active particles.
  17840. */
  17841. getCapacity(): number;
  17842. /**
  17843. * Gets the number of particles active at the same time.
  17844. * @returns The number of active particles.
  17845. */
  17846. getActiveCount(): number;
  17847. /**
  17848. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17849. * @returns True if it has been started, otherwise false.
  17850. */
  17851. isStarted(): boolean;
  17852. /**
  17853. * Animates the particle system for this frame.
  17854. */
  17855. animate(): void;
  17856. /**
  17857. * Renders the particle system in its current state.
  17858. * @returns the current number of particles
  17859. */
  17860. render(): number;
  17861. /**
  17862. * Dispose the particle system and frees its associated resources.
  17863. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17864. */
  17865. dispose(disposeTexture?: boolean): void;
  17866. /**
  17867. * An event triggered when the system is disposed
  17868. */
  17869. onDisposeObservable: Observable<IParticleSystem>;
  17870. /**
  17871. * An event triggered when the system is stopped
  17872. */
  17873. onStoppedObservable: Observable<IParticleSystem>;
  17874. /**
  17875. * Clones the particle system.
  17876. * @param name The name of the cloned object
  17877. * @param newEmitter The new emitter to use
  17878. * @returns the cloned particle system
  17879. */
  17880. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17881. /**
  17882. * Serializes the particle system to a JSON object
  17883. * @param serializeTexture defines if the texture must be serialized as well
  17884. * @returns the JSON object
  17885. */
  17886. serialize(serializeTexture: boolean): any;
  17887. /**
  17888. * Rebuild the particle system
  17889. */
  17890. rebuild(): void;
  17891. /** Force the system to rebuild all gradients that need to be resync */
  17892. forceRefreshGradients(): void;
  17893. /**
  17894. * Starts the particle system and begins to emit
  17895. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17896. */
  17897. start(delay?: number): void;
  17898. /**
  17899. * Stops the particle system.
  17900. */
  17901. stop(): void;
  17902. /**
  17903. * Remove all active particles
  17904. */
  17905. reset(): void;
  17906. /**
  17907. * Gets a boolean indicating that the system is stopping
  17908. * @returns true if the system is currently stopping
  17909. */
  17910. isStopping(): boolean;
  17911. /**
  17912. * Is this system ready to be used/rendered
  17913. * @return true if the system is ready
  17914. */
  17915. isReady(): boolean;
  17916. /**
  17917. * Returns the string "ParticleSystem"
  17918. * @returns a string containing the class name
  17919. */
  17920. getClassName(): string;
  17921. /**
  17922. * Gets the custom effect used to render the particles
  17923. * @param blendMode Blend mode for which the effect should be retrieved
  17924. * @returns The effect
  17925. */
  17926. getCustomEffect(blendMode: number): Nullable<Effect>;
  17927. /**
  17928. * Sets the custom effect used to render the particles
  17929. * @param effect The effect to set
  17930. * @param blendMode Blend mode for which the effect should be set
  17931. */
  17932. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17933. /**
  17934. * Fill the defines array according to the current settings of the particle system
  17935. * @param defines Array to be updated
  17936. * @param blendMode blend mode to take into account when updating the array
  17937. */
  17938. fillDefines(defines: Array<string>, blendMode: number): void;
  17939. /**
  17940. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17941. * @param uniforms Uniforms array to fill
  17942. * @param attributes Attributes array to fill
  17943. * @param samplers Samplers array to fill
  17944. */
  17945. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17946. /**
  17947. * Observable that will be called just before the particles are drawn
  17948. */
  17949. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17950. /**
  17951. * Gets the name of the particle vertex shader
  17952. */
  17953. vertexShaderName: string;
  17954. /**
  17955. * Adds a new color gradient
  17956. * @param gradient defines the gradient to use (between 0 and 1)
  17957. * @param color1 defines the color to affect to the specified gradient
  17958. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17959. * @returns the current particle system
  17960. */
  17961. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17962. /**
  17963. * Remove a specific color gradient
  17964. * @param gradient defines the gradient to remove
  17965. * @returns the current particle system
  17966. */
  17967. removeColorGradient(gradient: number): IParticleSystem;
  17968. /**
  17969. * Adds a new size gradient
  17970. * @param gradient defines the gradient to use (between 0 and 1)
  17971. * @param factor defines the size factor to affect to the specified gradient
  17972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17973. * @returns the current particle system
  17974. */
  17975. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17976. /**
  17977. * Remove a specific size gradient
  17978. * @param gradient defines the gradient to remove
  17979. * @returns the current particle system
  17980. */
  17981. removeSizeGradient(gradient: number): IParticleSystem;
  17982. /**
  17983. * Gets the current list of color gradients.
  17984. * You must use addColorGradient and removeColorGradient to udpate this list
  17985. * @returns the list of color gradients
  17986. */
  17987. getColorGradients(): Nullable<Array<ColorGradient>>;
  17988. /**
  17989. * Gets the current list of size gradients.
  17990. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17991. * @returns the list of size gradients
  17992. */
  17993. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17994. /**
  17995. * Gets the current list of angular speed gradients.
  17996. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17997. * @returns the list of angular speed gradients
  17998. */
  17999. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18000. /**
  18001. * Adds a new angular speed gradient
  18002. * @param gradient defines the gradient to use (between 0 and 1)
  18003. * @param factor defines the angular speed to affect to the specified gradient
  18004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18005. * @returns the current particle system
  18006. */
  18007. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18008. /**
  18009. * Remove a specific angular speed gradient
  18010. * @param gradient defines the gradient to remove
  18011. * @returns the current particle system
  18012. */
  18013. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18014. /**
  18015. * Gets the current list of velocity gradients.
  18016. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18017. * @returns the list of velocity gradients
  18018. */
  18019. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18020. /**
  18021. * Adds a new velocity gradient
  18022. * @param gradient defines the gradient to use (between 0 and 1)
  18023. * @param factor defines the velocity to affect to the specified gradient
  18024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18025. * @returns the current particle system
  18026. */
  18027. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18028. /**
  18029. * Remove a specific velocity gradient
  18030. * @param gradient defines the gradient to remove
  18031. * @returns the current particle system
  18032. */
  18033. removeVelocityGradient(gradient: number): IParticleSystem;
  18034. /**
  18035. * Gets the current list of limit velocity gradients.
  18036. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18037. * @returns the list of limit velocity gradients
  18038. */
  18039. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18040. /**
  18041. * Adds a new limit velocity gradient
  18042. * @param gradient defines the gradient to use (between 0 and 1)
  18043. * @param factor defines the limit velocity to affect to the specified gradient
  18044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18045. * @returns the current particle system
  18046. */
  18047. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18048. /**
  18049. * Remove a specific limit velocity gradient
  18050. * @param gradient defines the gradient to remove
  18051. * @returns the current particle system
  18052. */
  18053. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18054. /**
  18055. * Adds a new drag gradient
  18056. * @param gradient defines the gradient to use (between 0 and 1)
  18057. * @param factor defines the drag to affect to the specified gradient
  18058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18059. * @returns the current particle system
  18060. */
  18061. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18062. /**
  18063. * Remove a specific drag gradient
  18064. * @param gradient defines the gradient to remove
  18065. * @returns the current particle system
  18066. */
  18067. removeDragGradient(gradient: number): IParticleSystem;
  18068. /**
  18069. * Gets the current list of drag gradients.
  18070. * You must use addDragGradient and removeDragGradient to udpate this list
  18071. * @returns the list of drag gradients
  18072. */
  18073. getDragGradients(): Nullable<Array<FactorGradient>>;
  18074. /**
  18075. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18076. * @param gradient defines the gradient to use (between 0 and 1)
  18077. * @param factor defines the emit rate to affect to the specified gradient
  18078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18079. * @returns the current particle system
  18080. */
  18081. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18082. /**
  18083. * Remove a specific emit rate gradient
  18084. * @param gradient defines the gradient to remove
  18085. * @returns the current particle system
  18086. */
  18087. removeEmitRateGradient(gradient: number): IParticleSystem;
  18088. /**
  18089. * Gets the current list of emit rate gradients.
  18090. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18091. * @returns the list of emit rate gradients
  18092. */
  18093. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18094. /**
  18095. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18096. * @param gradient defines the gradient to use (between 0 and 1)
  18097. * @param factor defines the start size to affect to the specified gradient
  18098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18099. * @returns the current particle system
  18100. */
  18101. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18102. /**
  18103. * Remove a specific start size gradient
  18104. * @param gradient defines the gradient to remove
  18105. * @returns the current particle system
  18106. */
  18107. removeStartSizeGradient(gradient: number): IParticleSystem;
  18108. /**
  18109. * Gets the current list of start size gradients.
  18110. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18111. * @returns the list of start size gradients
  18112. */
  18113. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18114. /**
  18115. * Adds a new life time gradient
  18116. * @param gradient defines the gradient to use (between 0 and 1)
  18117. * @param factor defines the life time factor to affect to the specified gradient
  18118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18119. * @returns the current particle system
  18120. */
  18121. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18122. /**
  18123. * Remove a specific life time gradient
  18124. * @param gradient defines the gradient to remove
  18125. * @returns the current particle system
  18126. */
  18127. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18128. /**
  18129. * Gets the current list of life time gradients.
  18130. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18131. * @returns the list of life time gradients
  18132. */
  18133. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18134. /**
  18135. * Gets the current list of color gradients.
  18136. * You must use addColorGradient and removeColorGradient to udpate this list
  18137. * @returns the list of color gradients
  18138. */
  18139. getColorGradients(): Nullable<Array<ColorGradient>>;
  18140. /**
  18141. * Adds a new ramp gradient used to remap particle colors
  18142. * @param gradient defines the gradient to use (between 0 and 1)
  18143. * @param color defines the color to affect to the specified gradient
  18144. * @returns the current particle system
  18145. */
  18146. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18147. /**
  18148. * Gets the current list of ramp gradients.
  18149. * You must use addRampGradient and removeRampGradient to udpate this list
  18150. * @returns the list of ramp gradients
  18151. */
  18152. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18153. /** Gets or sets a boolean indicating that ramp gradients must be used
  18154. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18155. */
  18156. useRampGradients: boolean;
  18157. /**
  18158. * Adds a new color remap gradient
  18159. * @param gradient defines the gradient to use (between 0 and 1)
  18160. * @param min defines the color remap minimal range
  18161. * @param max defines the color remap maximal range
  18162. * @returns the current particle system
  18163. */
  18164. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18165. /**
  18166. * Gets the current list of color remap gradients.
  18167. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18168. * @returns the list of color remap gradients
  18169. */
  18170. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18171. /**
  18172. * Adds a new alpha remap gradient
  18173. * @param gradient defines the gradient to use (between 0 and 1)
  18174. * @param min defines the alpha remap minimal range
  18175. * @param max defines the alpha remap maximal range
  18176. * @returns the current particle system
  18177. */
  18178. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18179. /**
  18180. * Gets the current list of alpha remap gradients.
  18181. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18182. * @returns the list of alpha remap gradients
  18183. */
  18184. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18185. /**
  18186. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18187. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18188. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18189. * @returns the emitter
  18190. */
  18191. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18192. /**
  18193. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18194. * @param radius The radius of the hemisphere to emit from
  18195. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18196. * @returns the emitter
  18197. */
  18198. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18199. /**
  18200. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18201. * @param radius The radius of the sphere to emit from
  18202. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18203. * @returns the emitter
  18204. */
  18205. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18206. /**
  18207. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18208. * @param radius The radius of the sphere to emit from
  18209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18211. * @returns the emitter
  18212. */
  18213. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18214. /**
  18215. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18216. * @param radius The radius of the emission cylinder
  18217. * @param height The height of the emission cylinder
  18218. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18219. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18220. * @returns the emitter
  18221. */
  18222. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18223. /**
  18224. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18225. * @param radius The radius of the cylinder to emit from
  18226. * @param height The height of the emission cylinder
  18227. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18228. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18229. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18230. * @returns the emitter
  18231. */
  18232. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18233. /**
  18234. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18235. * @param radius The radius of the cone to emit from
  18236. * @param angle The base angle of the cone
  18237. * @returns the emitter
  18238. */
  18239. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18240. /**
  18241. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18242. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18243. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18244. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18245. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18246. * @returns the emitter
  18247. */
  18248. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18249. /**
  18250. * Get hosting scene
  18251. * @returns the scene
  18252. */
  18253. getScene(): Nullable<Scene>;
  18254. }
  18255. }
  18256. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  18257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18260. /**
  18261. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  18262. */
  18263. export class ColorSplitterBlock extends NodeMaterialBlock {
  18264. /**
  18265. * Create a new ColorSplitterBlock
  18266. * @param name defines the block name
  18267. */
  18268. constructor(name: string);
  18269. /**
  18270. * Gets the current class name
  18271. * @returns the class name
  18272. */
  18273. getClassName(): string;
  18274. /**
  18275. * Gets the rgba component (input)
  18276. */
  18277. get rgba(): NodeMaterialConnectionPoint;
  18278. /**
  18279. * Gets the rgb component (input)
  18280. */
  18281. get rgbIn(): NodeMaterialConnectionPoint;
  18282. /**
  18283. * Gets the rgb component (output)
  18284. */
  18285. get rgbOut(): NodeMaterialConnectionPoint;
  18286. /**
  18287. * Gets the r component (output)
  18288. */
  18289. get r(): NodeMaterialConnectionPoint;
  18290. /**
  18291. * Gets the g component (output)
  18292. */
  18293. get g(): NodeMaterialConnectionPoint;
  18294. /**
  18295. * Gets the b component (output)
  18296. */
  18297. get b(): NodeMaterialConnectionPoint;
  18298. /**
  18299. * Gets the a component (output)
  18300. */
  18301. get a(): NodeMaterialConnectionPoint;
  18302. protected _inputRename(name: string): string;
  18303. protected _outputRename(name: string): string;
  18304. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  18305. }
  18306. }
  18307. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  18308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18311. import { Scene } from "babylonjs/scene";
  18312. /**
  18313. * Operations supported by the Trigonometry block
  18314. */
  18315. export enum TrigonometryBlockOperations {
  18316. /** Cos */
  18317. Cos = 0,
  18318. /** Sin */
  18319. Sin = 1,
  18320. /** Abs */
  18321. Abs = 2,
  18322. /** Exp */
  18323. Exp = 3,
  18324. /** Exp2 */
  18325. Exp2 = 4,
  18326. /** Round */
  18327. Round = 5,
  18328. /** Floor */
  18329. Floor = 6,
  18330. /** Ceiling */
  18331. Ceiling = 7,
  18332. /** Square root */
  18333. Sqrt = 8,
  18334. /** Log */
  18335. Log = 9,
  18336. /** Tangent */
  18337. Tan = 10,
  18338. /** Arc tangent */
  18339. ArcTan = 11,
  18340. /** Arc cosinus */
  18341. ArcCos = 12,
  18342. /** Arc sinus */
  18343. ArcSin = 13,
  18344. /** Fraction */
  18345. Fract = 14,
  18346. /** Sign */
  18347. Sign = 15,
  18348. /** To radians (from degrees) */
  18349. Radians = 16,
  18350. /** To degrees (from radians) */
  18351. Degrees = 17
  18352. }
  18353. /**
  18354. * Block used to apply trigonometry operation to floats
  18355. */
  18356. export class TrigonometryBlock extends NodeMaterialBlock {
  18357. /**
  18358. * Gets or sets the operation applied by the block
  18359. */
  18360. operation: TrigonometryBlockOperations;
  18361. /**
  18362. * Creates a new TrigonometryBlock
  18363. * @param name defines the block name
  18364. */
  18365. constructor(name: string);
  18366. /**
  18367. * Gets the current class name
  18368. * @returns the class name
  18369. */
  18370. getClassName(): string;
  18371. /**
  18372. * Gets the input component
  18373. */
  18374. get input(): NodeMaterialConnectionPoint;
  18375. /**
  18376. * Gets the output component
  18377. */
  18378. get output(): NodeMaterialConnectionPoint;
  18379. protected _buildBlock(state: NodeMaterialBuildState): this;
  18380. serialize(): any;
  18381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  18382. protected _dumpPropertiesCode(): string;
  18383. }
  18384. }
  18385. declare module "babylonjs/Materials/Node/nodeMaterial" {
  18386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18387. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  18388. import { Scene } from "babylonjs/scene";
  18389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18390. import { Matrix } from "babylonjs/Maths/math.vector";
  18391. import { Mesh } from "babylonjs/Meshes/mesh";
  18392. import { Engine } from "babylonjs/Engines/engine";
  18393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18394. import { Observable } from "babylonjs/Misc/observable";
  18395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18396. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18397. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  18398. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  18399. import { Nullable } from "babylonjs/types";
  18400. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  18401. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  18402. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  18403. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  18404. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  18405. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  18406. import { Effect } from "babylonjs/Materials/effect";
  18407. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18408. import { Camera } from "babylonjs/Cameras/camera";
  18409. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  18410. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18411. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  18412. /**
  18413. * Interface used to configure the node material editor
  18414. */
  18415. export interface INodeMaterialEditorOptions {
  18416. /** Define the URl to load node editor script */
  18417. editorURL?: string;
  18418. }
  18419. /** @hidden */
  18420. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18421. NORMAL: boolean;
  18422. TANGENT: boolean;
  18423. UV1: boolean;
  18424. /** BONES */
  18425. NUM_BONE_INFLUENCERS: number;
  18426. BonesPerMesh: number;
  18427. BONETEXTURE: boolean;
  18428. /** MORPH TARGETS */
  18429. MORPHTARGETS: boolean;
  18430. MORPHTARGETS_NORMAL: boolean;
  18431. MORPHTARGETS_TANGENT: boolean;
  18432. MORPHTARGETS_UV: boolean;
  18433. NUM_MORPH_INFLUENCERS: number;
  18434. /** IMAGE PROCESSING */
  18435. IMAGEPROCESSING: boolean;
  18436. VIGNETTE: boolean;
  18437. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18438. VIGNETTEBLENDMODEOPAQUE: boolean;
  18439. TONEMAPPING: boolean;
  18440. TONEMAPPING_ACES: boolean;
  18441. CONTRAST: boolean;
  18442. EXPOSURE: boolean;
  18443. COLORCURVES: boolean;
  18444. COLORGRADING: boolean;
  18445. COLORGRADING3D: boolean;
  18446. SAMPLER3DGREENDEPTH: boolean;
  18447. SAMPLER3DBGRMAP: boolean;
  18448. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18449. /** MISC. */
  18450. BUMPDIRECTUV: number;
  18451. constructor();
  18452. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  18453. }
  18454. /**
  18455. * Class used to configure NodeMaterial
  18456. */
  18457. export interface INodeMaterialOptions {
  18458. /**
  18459. * Defines if blocks should emit comments
  18460. */
  18461. emitComments: boolean;
  18462. }
  18463. /**
  18464. * Class used to create a node based material built by assembling shader blocks
  18465. */
  18466. export class NodeMaterial extends PushMaterial {
  18467. private static _BuildIdGenerator;
  18468. private _options;
  18469. private _vertexCompilationState;
  18470. private _fragmentCompilationState;
  18471. private _sharedData;
  18472. private _buildId;
  18473. private _buildWasSuccessful;
  18474. private _cachedWorldViewMatrix;
  18475. private _cachedWorldViewProjectionMatrix;
  18476. private _optimizers;
  18477. private _animationFrame;
  18478. /** Define the Url to load node editor script */
  18479. static EditorURL: string;
  18480. /** Define the Url to load snippets */
  18481. static SnippetUrl: string;
  18482. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  18483. static IgnoreTexturesAtLoadTime: boolean;
  18484. private BJSNODEMATERIALEDITOR;
  18485. /** Get the inspector from bundle or global */
  18486. private _getGlobalNodeMaterialEditor;
  18487. /**
  18488. * Snippet ID if the material was created from the snippet server
  18489. */
  18490. snippetId: string;
  18491. /**
  18492. * Gets or sets data used by visual editor
  18493. * @see https://nme.babylonjs.com
  18494. */
  18495. editorData: any;
  18496. /**
  18497. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  18498. */
  18499. ignoreAlpha: boolean;
  18500. /**
  18501. * Defines the maximum number of lights that can be used in the material
  18502. */
  18503. maxSimultaneousLights: number;
  18504. /**
  18505. * Observable raised when the material is built
  18506. */
  18507. onBuildObservable: Observable<NodeMaterial>;
  18508. /**
  18509. * Gets or sets the root nodes of the material vertex shader
  18510. */
  18511. _vertexOutputNodes: NodeMaterialBlock[];
  18512. /**
  18513. * Gets or sets the root nodes of the material fragment (pixel) shader
  18514. */
  18515. _fragmentOutputNodes: NodeMaterialBlock[];
  18516. /** Gets or sets options to control the node material overall behavior */
  18517. get options(): INodeMaterialOptions;
  18518. set options(options: INodeMaterialOptions);
  18519. /**
  18520. * Default configuration related to image processing available in the standard Material.
  18521. */
  18522. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18523. /**
  18524. * Gets the image processing configuration used either in this material.
  18525. */
  18526. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18527. /**
  18528. * Sets the Default image processing configuration used either in the this material.
  18529. *
  18530. * If sets to null, the scene one is in use.
  18531. */
  18532. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18533. /**
  18534. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  18535. */
  18536. attachedBlocks: NodeMaterialBlock[];
  18537. /**
  18538. * Specifies the mode of the node material
  18539. * @hidden
  18540. */
  18541. _mode: NodeMaterialModes;
  18542. /**
  18543. * Gets the mode property
  18544. */
  18545. get mode(): NodeMaterialModes;
  18546. /**
  18547. * A free comment about the material
  18548. */
  18549. comment: string;
  18550. /**
  18551. * Create a new node based material
  18552. * @param name defines the material name
  18553. * @param scene defines the hosting scene
  18554. * @param options defines creation option
  18555. */
  18556. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18557. /**
  18558. * Gets the current class name of the material e.g. "NodeMaterial"
  18559. * @returns the class name
  18560. */
  18561. getClassName(): string;
  18562. /**
  18563. * Keep track of the image processing observer to allow dispose and replace.
  18564. */
  18565. private _imageProcessingObserver;
  18566. /**
  18567. * Attaches a new image processing configuration to the Standard Material.
  18568. * @param configuration
  18569. */
  18570. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18571. /**
  18572. * Get a block by its name
  18573. * @param name defines the name of the block to retrieve
  18574. * @returns the required block or null if not found
  18575. */
  18576. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18577. /**
  18578. * Get a block by its name
  18579. * @param predicate defines the predicate used to find the good candidate
  18580. * @returns the required block or null if not found
  18581. */
  18582. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18583. /**
  18584. * Get an input block by its name
  18585. * @param predicate defines the predicate used to find the good candidate
  18586. * @returns the required input block or null if not found
  18587. */
  18588. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18589. /**
  18590. * Gets the list of input blocks attached to this material
  18591. * @returns an array of InputBlocks
  18592. */
  18593. getInputBlocks(): InputBlock[];
  18594. /**
  18595. * Adds a new optimizer to the list of optimizers
  18596. * @param optimizer defines the optimizers to add
  18597. * @returns the current material
  18598. */
  18599. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18600. /**
  18601. * Remove an optimizer from the list of optimizers
  18602. * @param optimizer defines the optimizers to remove
  18603. * @returns the current material
  18604. */
  18605. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18606. /**
  18607. * Add a new block to the list of output nodes
  18608. * @param node defines the node to add
  18609. * @returns the current material
  18610. */
  18611. addOutputNode(node: NodeMaterialBlock): this;
  18612. /**
  18613. * Remove a block from the list of root nodes
  18614. * @param node defines the node to remove
  18615. * @returns the current material
  18616. */
  18617. removeOutputNode(node: NodeMaterialBlock): this;
  18618. private _addVertexOutputNode;
  18619. private _removeVertexOutputNode;
  18620. private _addFragmentOutputNode;
  18621. private _removeFragmentOutputNode;
  18622. /**
  18623. * Specifies if the material will require alpha blending
  18624. * @returns a boolean specifying if alpha blending is needed
  18625. */
  18626. needAlphaBlending(): boolean;
  18627. /**
  18628. * Specifies if this material should be rendered in alpha test mode
  18629. * @returns a boolean specifying if an alpha test is needed.
  18630. */
  18631. needAlphaTesting(): boolean;
  18632. private _initializeBlock;
  18633. private _resetDualBlocks;
  18634. /**
  18635. * Remove a block from the current node material
  18636. * @param block defines the block to remove
  18637. */
  18638. removeBlock(block: NodeMaterialBlock): void;
  18639. /**
  18640. * Build the material and generates the inner effect
  18641. * @param verbose defines if the build should log activity
  18642. */
  18643. build(verbose?: boolean): void;
  18644. /**
  18645. * Runs an otpimization phase to try to improve the shader code
  18646. */
  18647. optimize(): void;
  18648. private _prepareDefinesForAttributes;
  18649. /**
  18650. * Create a post process from the material
  18651. * @param camera The camera to apply the render pass to.
  18652. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18654. * @param engine The engine which the post process will be applied. (default: current engine)
  18655. * @param reusable If the post process can be reused on the same frame. (default: false)
  18656. * @param textureType Type of textures used when performing the post process. (default: 0)
  18657. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18658. * @returns the post process created
  18659. */
  18660. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18661. /**
  18662. * Create the post process effect from the material
  18663. * @param postProcess The post process to create the effect for
  18664. */
  18665. createEffectForPostProcess(postProcess: PostProcess): void;
  18666. private _createEffectForPostProcess;
  18667. /**
  18668. * Create a new procedural texture based on this node material
  18669. * @param size defines the size of the texture
  18670. * @param scene defines the hosting scene
  18671. * @returns the new procedural texture attached to this node material
  18672. */
  18673. createProceduralTexture(size: number | {
  18674. width: number;
  18675. height: number;
  18676. layers?: number;
  18677. }, scene: Scene): Nullable<ProceduralTexture>;
  18678. private _createEffectForParticles;
  18679. private _checkInternals;
  18680. /**
  18681. * Create the effect to be used as the custom effect for a particle system
  18682. * @param particleSystem Particle system to create the effect for
  18683. * @param onCompiled defines a function to call when the effect creation is successful
  18684. * @param onError defines a function to call when the effect creation has failed
  18685. */
  18686. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18687. private _processDefines;
  18688. /**
  18689. * Get if the submesh is ready to be used and all its information available.
  18690. * Child classes can use it to update shaders
  18691. * @param mesh defines the mesh to check
  18692. * @param subMesh defines which submesh to check
  18693. * @param useInstances specifies that instances should be used
  18694. * @returns a boolean indicating that the submesh is ready or not
  18695. */
  18696. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18697. /**
  18698. * Get a string representing the shaders built by the current node graph
  18699. */
  18700. get compiledShaders(): string;
  18701. /**
  18702. * Binds the world matrix to the material
  18703. * @param world defines the world transformation matrix
  18704. */
  18705. bindOnlyWorldMatrix(world: Matrix): void;
  18706. /**
  18707. * Binds the submesh to this material by preparing the effect and shader to draw
  18708. * @param world defines the world transformation matrix
  18709. * @param mesh defines the mesh containing the submesh
  18710. * @param subMesh defines the submesh to bind the material to
  18711. */
  18712. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18713. /**
  18714. * Gets the active textures from the material
  18715. * @returns an array of textures
  18716. */
  18717. getActiveTextures(): BaseTexture[];
  18718. /**
  18719. * Gets the list of texture blocks
  18720. * @returns an array of texture blocks
  18721. */
  18722. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18723. /**
  18724. * Specifies if the material uses a texture
  18725. * @param texture defines the texture to check against the material
  18726. * @returns a boolean specifying if the material uses the texture
  18727. */
  18728. hasTexture(texture: BaseTexture): boolean;
  18729. /**
  18730. * Disposes the material
  18731. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18732. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18733. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18734. */
  18735. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18736. /** Creates the node editor window. */
  18737. private _createNodeEditor;
  18738. /**
  18739. * Launch the node material editor
  18740. * @param config Define the configuration of the editor
  18741. * @return a promise fulfilled when the node editor is visible
  18742. */
  18743. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18744. /**
  18745. * Clear the current material
  18746. */
  18747. clear(): void;
  18748. /**
  18749. * Clear the current material and set it to a default state
  18750. */
  18751. setToDefault(): void;
  18752. /**
  18753. * Clear the current material and set it to a default state for post process
  18754. */
  18755. setToDefaultPostProcess(): void;
  18756. /**
  18757. * Clear the current material and set it to a default state for procedural texture
  18758. */
  18759. setToDefaultProceduralTexture(): void;
  18760. /**
  18761. * Clear the current material and set it to a default state for particle
  18762. */
  18763. setToDefaultParticle(): void;
  18764. /**
  18765. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18766. * @param url defines the url to load from
  18767. * @returns a promise that will fullfil when the material is fully loaded
  18768. */
  18769. loadAsync(url: string): Promise<void>;
  18770. private _gatherBlocks;
  18771. /**
  18772. * Generate a string containing the code declaration required to create an equivalent of this material
  18773. * @returns a string
  18774. */
  18775. generateCode(): string;
  18776. /**
  18777. * Serializes this material in a JSON representation
  18778. * @returns the serialized material object
  18779. */
  18780. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18781. private _restoreConnections;
  18782. /**
  18783. * Clear the current graph and load a new one from a serialization object
  18784. * @param source defines the JSON representation of the material
  18785. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18786. * @param merge defines whether or not the source must be merged or replace the current content
  18787. */
  18788. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18789. /**
  18790. * Makes a duplicate of the current material.
  18791. * @param name - name to use for the new material.
  18792. */
  18793. clone(name: string): NodeMaterial;
  18794. /**
  18795. * Creates a node material from parsed material data
  18796. * @param source defines the JSON representation of the material
  18797. * @param scene defines the hosting scene
  18798. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18799. * @returns a new node material
  18800. */
  18801. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18802. /**
  18803. * Creates a node material from a snippet saved in a remote file
  18804. * @param name defines the name of the material to create
  18805. * @param url defines the url to load from
  18806. * @param scene defines the hosting scene
  18807. * @returns a promise that will resolve to the new node material
  18808. */
  18809. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18810. /**
  18811. * Creates a node material from a snippet saved by the node material editor
  18812. * @param snippetId defines the snippet to load
  18813. * @param scene defines the hosting scene
  18814. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18815. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18816. * @returns a promise that will resolve to the new node material
  18817. */
  18818. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18819. /**
  18820. * Creates a new node material set to default basic configuration
  18821. * @param name defines the name of the material
  18822. * @param scene defines the hosting scene
  18823. * @returns a new NodeMaterial
  18824. */
  18825. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18826. }
  18827. }
  18828. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18829. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18830. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18831. import { IColor4Like } from "babylonjs/Maths/math.like";
  18832. import { Nullable } from "babylonjs/types";
  18833. module "babylonjs/Engines/thinEngine" {
  18834. interface ThinEngine {
  18835. /**
  18836. * Unbind a list of render target textures from the webGL context
  18837. * This is used only when drawBuffer extension or webGL2 are active
  18838. * @param textures defines the render target textures to unbind
  18839. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18840. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18841. */
  18842. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18843. /**
  18844. * Create a multi render target texture
  18845. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18846. * @param size defines the size of the texture
  18847. * @param options defines the creation options
  18848. * @returns the cube texture as an InternalTexture
  18849. */
  18850. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18851. /**
  18852. * Update the sample count for a given multiple render target texture
  18853. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18854. * @param textures defines the textures to update
  18855. * @param samples defines the sample count to set
  18856. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18857. */
  18858. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18859. /**
  18860. * Select a subsets of attachments to draw to.
  18861. * @param attachments gl attachments
  18862. */
  18863. bindAttachments(attachments: number[]): void;
  18864. /**
  18865. * Creates a layout object to draw/clear on specific textures in a MRT
  18866. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18867. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18868. */
  18869. buildTextureLayout(textureStatus: boolean[]): number[];
  18870. /**
  18871. * Restores the webgl state to only draw on the main color attachment
  18872. */
  18873. restoreSingleAttachment(): void;
  18874. /**
  18875. * Clears a list of attachments
  18876. * @param attachments list of the attachments
  18877. * @param colorMain clear color for the main attachment (the first one)
  18878. * @param colorOthers clear color for the other attachments
  18879. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18880. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18881. */
  18882. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18883. }
  18884. }
  18885. }
  18886. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18887. import { Scene } from "babylonjs/scene";
  18888. import { Engine } from "babylonjs/Engines/engine";
  18889. import { Texture } from "babylonjs/Materials/Textures/texture";
  18890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18891. import "babylonjs/Engines/Extensions/engine.multiRender";
  18892. /**
  18893. * Creation options of the multi render target texture.
  18894. */
  18895. export interface IMultiRenderTargetOptions {
  18896. /**
  18897. * Define if the texture needs to create mip maps after render.
  18898. */
  18899. generateMipMaps?: boolean;
  18900. /**
  18901. * Define the types of all the draw buffers we want to create
  18902. */
  18903. types?: number[];
  18904. /**
  18905. * Define the sampling modes of all the draw buffers we want to create
  18906. */
  18907. samplingModes?: number[];
  18908. /**
  18909. * Define if a depth buffer is required
  18910. */
  18911. generateDepthBuffer?: boolean;
  18912. /**
  18913. * Define if a stencil buffer is required
  18914. */
  18915. generateStencilBuffer?: boolean;
  18916. /**
  18917. * Define if a depth texture is required instead of a depth buffer
  18918. */
  18919. generateDepthTexture?: boolean;
  18920. /**
  18921. * Define the number of desired draw buffers
  18922. */
  18923. textureCount?: number;
  18924. /**
  18925. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18926. */
  18927. doNotChangeAspectRatio?: boolean;
  18928. /**
  18929. * Define the default type of the buffers we are creating
  18930. */
  18931. defaultType?: number;
  18932. }
  18933. /**
  18934. * A multi render target, like a render target provides the ability to render to a texture.
  18935. * Unlike the render target, it can render to several draw buffers in one draw.
  18936. * This is specially interesting in deferred rendering or for any effects requiring more than
  18937. * just one color from a single pass.
  18938. */
  18939. export class MultiRenderTarget extends RenderTargetTexture {
  18940. private _internalTextures;
  18941. private _textures;
  18942. private _multiRenderTargetOptions;
  18943. private _count;
  18944. /**
  18945. * Get if draw buffers are currently supported by the used hardware and browser.
  18946. */
  18947. get isSupported(): boolean;
  18948. /**
  18949. * Get the list of textures generated by the multi render target.
  18950. */
  18951. get textures(): Texture[];
  18952. /**
  18953. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18954. */
  18955. get count(): number;
  18956. /**
  18957. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18958. */
  18959. get depthTexture(): Texture;
  18960. /**
  18961. * Set the wrapping mode on U of all the textures we are rendering to.
  18962. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18963. */
  18964. set wrapU(wrap: number);
  18965. /**
  18966. * Set the wrapping mode on V of all the textures we are rendering to.
  18967. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18968. */
  18969. set wrapV(wrap: number);
  18970. /**
  18971. * Instantiate a new multi render target texture.
  18972. * A multi render target, like a render target provides the ability to render to a texture.
  18973. * Unlike the render target, it can render to several draw buffers in one draw.
  18974. * This is specially interesting in deferred rendering or for any effects requiring more than
  18975. * just one color from a single pass.
  18976. * @param name Define the name of the texture
  18977. * @param size Define the size of the buffers to render to
  18978. * @param count Define the number of target we are rendering into
  18979. * @param scene Define the scene the texture belongs to
  18980. * @param options Define the options used to create the multi render target
  18981. */
  18982. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18983. private _initTypes;
  18984. /** @hidden */
  18985. _rebuild(forceFullRebuild?: boolean): void;
  18986. private _createInternalTextures;
  18987. private _createTextures;
  18988. /**
  18989. * Replaces a texture within the MRT.
  18990. * @param texture The new texture to insert in the MRT
  18991. * @param index The index of the texture to replace
  18992. */
  18993. replaceTexture(texture: Texture, index: number): void;
  18994. /**
  18995. * Define the number of samples used if MSAA is enabled.
  18996. */
  18997. get samples(): number;
  18998. set samples(value: number);
  18999. /**
  19000. * Resize all the textures in the multi render target.
  19001. * Be careful as it will recreate all the data in the new texture.
  19002. * @param size Define the new size
  19003. */
  19004. resize(size: any): void;
  19005. /**
  19006. * Changes the number of render targets in this MRT
  19007. * Be careful as it will recreate all the data in the new texture.
  19008. * @param count new texture count
  19009. * @param options Specifies texture types and sampling modes for new textures
  19010. */
  19011. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  19012. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19013. /**
  19014. * Dispose the render targets and their associated resources
  19015. */
  19016. dispose(): void;
  19017. /**
  19018. * Release all the underlying texture used as draw buffers.
  19019. */
  19020. releaseInternalTextures(): void;
  19021. }
  19022. }
  19023. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  19024. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19025. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19026. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19027. /** @hidden */
  19028. export var imageProcessingPixelShader: {
  19029. name: string;
  19030. shader: string;
  19031. };
  19032. }
  19033. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  19034. import { Nullable } from "babylonjs/types";
  19035. import { Color4 } from "babylonjs/Maths/math.color";
  19036. import { Camera } from "babylonjs/Cameras/camera";
  19037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19038. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19039. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  19040. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  19041. import { Engine } from "babylonjs/Engines/engine";
  19042. import "babylonjs/Shaders/imageProcessing.fragment";
  19043. import "babylonjs/Shaders/postprocess.vertex";
  19044. /**
  19045. * ImageProcessingPostProcess
  19046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  19047. */
  19048. export class ImageProcessingPostProcess extends PostProcess {
  19049. /**
  19050. * Default configuration related to image processing available in the PBR Material.
  19051. */
  19052. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19053. /**
  19054. * Gets the image processing configuration used either in this material.
  19055. */
  19056. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19057. /**
  19058. * Sets the Default image processing configuration used either in the this material.
  19059. *
  19060. * If sets to null, the scene one is in use.
  19061. */
  19062. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19063. /**
  19064. * Keep track of the image processing observer to allow dispose and replace.
  19065. */
  19066. private _imageProcessingObserver;
  19067. /**
  19068. * Attaches a new image processing configuration to the PBR Material.
  19069. * @param configuration
  19070. */
  19071. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  19072. /**
  19073. * If the post process is supported.
  19074. */
  19075. get isSupported(): boolean;
  19076. /**
  19077. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19078. */
  19079. get colorCurves(): Nullable<ColorCurves>;
  19080. /**
  19081. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19082. */
  19083. set colorCurves(value: Nullable<ColorCurves>);
  19084. /**
  19085. * Gets wether the color curves effect is enabled.
  19086. */
  19087. get colorCurvesEnabled(): boolean;
  19088. /**
  19089. * Sets wether the color curves effect is enabled.
  19090. */
  19091. set colorCurvesEnabled(value: boolean);
  19092. /**
  19093. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19094. */
  19095. get colorGradingTexture(): Nullable<BaseTexture>;
  19096. /**
  19097. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19098. */
  19099. set colorGradingTexture(value: Nullable<BaseTexture>);
  19100. /**
  19101. * Gets wether the color grading effect is enabled.
  19102. */
  19103. get colorGradingEnabled(): boolean;
  19104. /**
  19105. * Gets wether the color grading effect is enabled.
  19106. */
  19107. set colorGradingEnabled(value: boolean);
  19108. /**
  19109. * Gets exposure used in the effect.
  19110. */
  19111. get exposure(): number;
  19112. /**
  19113. * Sets exposure used in the effect.
  19114. */
  19115. set exposure(value: number);
  19116. /**
  19117. * Gets wether tonemapping is enabled or not.
  19118. */
  19119. get toneMappingEnabled(): boolean;
  19120. /**
  19121. * Sets wether tonemapping is enabled or not
  19122. */
  19123. set toneMappingEnabled(value: boolean);
  19124. /**
  19125. * Gets the type of tone mapping effect.
  19126. */
  19127. get toneMappingType(): number;
  19128. /**
  19129. * Sets the type of tone mapping effect.
  19130. */
  19131. set toneMappingType(value: number);
  19132. /**
  19133. * Gets contrast used in the effect.
  19134. */
  19135. get contrast(): number;
  19136. /**
  19137. * Sets contrast used in the effect.
  19138. */
  19139. set contrast(value: number);
  19140. /**
  19141. * Gets Vignette stretch size.
  19142. */
  19143. get vignetteStretch(): number;
  19144. /**
  19145. * Sets Vignette stretch size.
  19146. */
  19147. set vignetteStretch(value: number);
  19148. /**
  19149. * Gets Vignette centre X Offset.
  19150. */
  19151. get vignetteCentreX(): number;
  19152. /**
  19153. * Sets Vignette centre X Offset.
  19154. */
  19155. set vignetteCentreX(value: number);
  19156. /**
  19157. * Gets Vignette centre Y Offset.
  19158. */
  19159. get vignetteCentreY(): number;
  19160. /**
  19161. * Sets Vignette centre Y Offset.
  19162. */
  19163. set vignetteCentreY(value: number);
  19164. /**
  19165. * Gets Vignette weight or intensity of the vignette effect.
  19166. */
  19167. get vignetteWeight(): number;
  19168. /**
  19169. * Sets Vignette weight or intensity of the vignette effect.
  19170. */
  19171. set vignetteWeight(value: number);
  19172. /**
  19173. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19174. * if vignetteEnabled is set to true.
  19175. */
  19176. get vignetteColor(): Color4;
  19177. /**
  19178. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19179. * if vignetteEnabled is set to true.
  19180. */
  19181. set vignetteColor(value: Color4);
  19182. /**
  19183. * Gets Camera field of view used by the Vignette effect.
  19184. */
  19185. get vignetteCameraFov(): number;
  19186. /**
  19187. * Sets Camera field of view used by the Vignette effect.
  19188. */
  19189. set vignetteCameraFov(value: number);
  19190. /**
  19191. * Gets the vignette blend mode allowing different kind of effect.
  19192. */
  19193. get vignetteBlendMode(): number;
  19194. /**
  19195. * Sets the vignette blend mode allowing different kind of effect.
  19196. */
  19197. set vignetteBlendMode(value: number);
  19198. /**
  19199. * Gets wether the vignette effect is enabled.
  19200. */
  19201. get vignetteEnabled(): boolean;
  19202. /**
  19203. * Sets wether the vignette effect is enabled.
  19204. */
  19205. set vignetteEnabled(value: boolean);
  19206. private _fromLinearSpace;
  19207. /**
  19208. * Gets wether the input of the processing is in Gamma or Linear Space.
  19209. */
  19210. get fromLinearSpace(): boolean;
  19211. /**
  19212. * Sets wether the input of the processing is in Gamma or Linear Space.
  19213. */
  19214. set fromLinearSpace(value: boolean);
  19215. /**
  19216. * Defines cache preventing GC.
  19217. */
  19218. private _defines;
  19219. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  19220. /**
  19221. * "ImageProcessingPostProcess"
  19222. * @returns "ImageProcessingPostProcess"
  19223. */
  19224. getClassName(): string;
  19225. /**
  19226. * @hidden
  19227. */
  19228. _updateParameters(): void;
  19229. dispose(camera?: Camera): void;
  19230. }
  19231. }
  19232. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  19233. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19234. /**
  19235. * Interface for defining prepass effects in the prepass post-process pipeline
  19236. */
  19237. export interface PrePassEffectConfiguration {
  19238. /**
  19239. * Name of the effect
  19240. */
  19241. name: string;
  19242. /**
  19243. * Post process to attach for this effect
  19244. */
  19245. postProcess?: PostProcess;
  19246. /**
  19247. * Textures required in the MRT
  19248. */
  19249. texturesRequired: number[];
  19250. /**
  19251. * Is the effect enabled
  19252. */
  19253. enabled: boolean;
  19254. /**
  19255. * Disposes the effect configuration
  19256. */
  19257. dispose?: () => void;
  19258. /**
  19259. * Creates the associated post process
  19260. */
  19261. createPostProcess?: () => PostProcess;
  19262. }
  19263. }
  19264. declare module "babylonjs/Materials/fresnelParameters" {
  19265. import { DeepImmutable } from "babylonjs/types";
  19266. import { Color3 } from "babylonjs/Maths/math.color";
  19267. /**
  19268. * Options to be used when creating a FresnelParameters.
  19269. */
  19270. export type IFresnelParametersCreationOptions = {
  19271. /**
  19272. * Define the color used on edges (grazing angle)
  19273. */
  19274. leftColor?: Color3;
  19275. /**
  19276. * Define the color used on center
  19277. */
  19278. rightColor?: Color3;
  19279. /**
  19280. * Define bias applied to computed fresnel term
  19281. */
  19282. bias?: number;
  19283. /**
  19284. * Defined the power exponent applied to fresnel term
  19285. */
  19286. power?: number;
  19287. /**
  19288. * Define if the fresnel effect is enable or not.
  19289. */
  19290. isEnabled?: boolean;
  19291. };
  19292. /**
  19293. * Serialized format for FresnelParameters.
  19294. */
  19295. export type IFresnelParametersSerialized = {
  19296. /**
  19297. * Define the color used on edges (grazing angle) [as an array]
  19298. */
  19299. leftColor: number[];
  19300. /**
  19301. * Define the color used on center [as an array]
  19302. */
  19303. rightColor: number[];
  19304. /**
  19305. * Define bias applied to computed fresnel term
  19306. */
  19307. bias: number;
  19308. /**
  19309. * Defined the power exponent applied to fresnel term
  19310. */
  19311. power?: number;
  19312. /**
  19313. * Define if the fresnel effect is enable or not.
  19314. */
  19315. isEnabled: boolean;
  19316. };
  19317. /**
  19318. * This represents all the required information to add a fresnel effect on a material:
  19319. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19320. */
  19321. export class FresnelParameters {
  19322. private _isEnabled;
  19323. /**
  19324. * Define if the fresnel effect is enable or not.
  19325. */
  19326. get isEnabled(): boolean;
  19327. set isEnabled(value: boolean);
  19328. /**
  19329. * Define the color used on edges (grazing angle)
  19330. */
  19331. leftColor: Color3;
  19332. /**
  19333. * Define the color used on center
  19334. */
  19335. rightColor: Color3;
  19336. /**
  19337. * Define bias applied to computed fresnel term
  19338. */
  19339. bias: number;
  19340. /**
  19341. * Defined the power exponent applied to fresnel term
  19342. */
  19343. power: number;
  19344. /**
  19345. * Creates a new FresnelParameters object.
  19346. *
  19347. * @param options provide your own settings to optionally to override defaults
  19348. */
  19349. constructor(options?: IFresnelParametersCreationOptions);
  19350. /**
  19351. * Clones the current fresnel and its valuues
  19352. * @returns a clone fresnel configuration
  19353. */
  19354. clone(): FresnelParameters;
  19355. /**
  19356. * Determines equality between FresnelParameters objects
  19357. * @param otherFresnelParameters defines the second operand
  19358. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  19359. */
  19360. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  19361. /**
  19362. * Serializes the current fresnel parameters to a JSON representation.
  19363. * @return the JSON serialization
  19364. */
  19365. serialize(): IFresnelParametersSerialized;
  19366. /**
  19367. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  19368. * @param parsedFresnelParameters Define the JSON representation
  19369. * @returns the parsed parameters
  19370. */
  19371. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  19372. }
  19373. }
  19374. declare module "babylonjs/Materials/materialFlags" {
  19375. /**
  19376. * This groups all the flags used to control the materials channel.
  19377. */
  19378. export class MaterialFlags {
  19379. private static _DiffuseTextureEnabled;
  19380. /**
  19381. * Are diffuse textures enabled in the application.
  19382. */
  19383. static get DiffuseTextureEnabled(): boolean;
  19384. static set DiffuseTextureEnabled(value: boolean);
  19385. private static _DetailTextureEnabled;
  19386. /**
  19387. * Are detail textures enabled in the application.
  19388. */
  19389. static get DetailTextureEnabled(): boolean;
  19390. static set DetailTextureEnabled(value: boolean);
  19391. private static _AmbientTextureEnabled;
  19392. /**
  19393. * Are ambient textures enabled in the application.
  19394. */
  19395. static get AmbientTextureEnabled(): boolean;
  19396. static set AmbientTextureEnabled(value: boolean);
  19397. private static _OpacityTextureEnabled;
  19398. /**
  19399. * Are opacity textures enabled in the application.
  19400. */
  19401. static get OpacityTextureEnabled(): boolean;
  19402. static set OpacityTextureEnabled(value: boolean);
  19403. private static _ReflectionTextureEnabled;
  19404. /**
  19405. * Are reflection textures enabled in the application.
  19406. */
  19407. static get ReflectionTextureEnabled(): boolean;
  19408. static set ReflectionTextureEnabled(value: boolean);
  19409. private static _EmissiveTextureEnabled;
  19410. /**
  19411. * Are emissive textures enabled in the application.
  19412. */
  19413. static get EmissiveTextureEnabled(): boolean;
  19414. static set EmissiveTextureEnabled(value: boolean);
  19415. private static _SpecularTextureEnabled;
  19416. /**
  19417. * Are specular textures enabled in the application.
  19418. */
  19419. static get SpecularTextureEnabled(): boolean;
  19420. static set SpecularTextureEnabled(value: boolean);
  19421. private static _BumpTextureEnabled;
  19422. /**
  19423. * Are bump textures enabled in the application.
  19424. */
  19425. static get BumpTextureEnabled(): boolean;
  19426. static set BumpTextureEnabled(value: boolean);
  19427. private static _LightmapTextureEnabled;
  19428. /**
  19429. * Are lightmap textures enabled in the application.
  19430. */
  19431. static get LightmapTextureEnabled(): boolean;
  19432. static set LightmapTextureEnabled(value: boolean);
  19433. private static _RefractionTextureEnabled;
  19434. /**
  19435. * Are refraction textures enabled in the application.
  19436. */
  19437. static get RefractionTextureEnabled(): boolean;
  19438. static set RefractionTextureEnabled(value: boolean);
  19439. private static _ColorGradingTextureEnabled;
  19440. /**
  19441. * Are color grading textures enabled in the application.
  19442. */
  19443. static get ColorGradingTextureEnabled(): boolean;
  19444. static set ColorGradingTextureEnabled(value: boolean);
  19445. private static _FresnelEnabled;
  19446. /**
  19447. * Are fresnels enabled in the application.
  19448. */
  19449. static get FresnelEnabled(): boolean;
  19450. static set FresnelEnabled(value: boolean);
  19451. private static _ClearCoatTextureEnabled;
  19452. /**
  19453. * Are clear coat textures enabled in the application.
  19454. */
  19455. static get ClearCoatTextureEnabled(): boolean;
  19456. static set ClearCoatTextureEnabled(value: boolean);
  19457. private static _ClearCoatBumpTextureEnabled;
  19458. /**
  19459. * Are clear coat bump textures enabled in the application.
  19460. */
  19461. static get ClearCoatBumpTextureEnabled(): boolean;
  19462. static set ClearCoatBumpTextureEnabled(value: boolean);
  19463. private static _ClearCoatTintTextureEnabled;
  19464. /**
  19465. * Are clear coat tint textures enabled in the application.
  19466. */
  19467. static get ClearCoatTintTextureEnabled(): boolean;
  19468. static set ClearCoatTintTextureEnabled(value: boolean);
  19469. private static _SheenTextureEnabled;
  19470. /**
  19471. * Are sheen textures enabled in the application.
  19472. */
  19473. static get SheenTextureEnabled(): boolean;
  19474. static set SheenTextureEnabled(value: boolean);
  19475. private static _AnisotropicTextureEnabled;
  19476. /**
  19477. * Are anisotropic textures enabled in the application.
  19478. */
  19479. static get AnisotropicTextureEnabled(): boolean;
  19480. static set AnisotropicTextureEnabled(value: boolean);
  19481. private static _ThicknessTextureEnabled;
  19482. /**
  19483. * Are thickness textures enabled in the application.
  19484. */
  19485. static get ThicknessTextureEnabled(): boolean;
  19486. static set ThicknessTextureEnabled(value: boolean);
  19487. }
  19488. }
  19489. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  19490. /** @hidden */
  19491. export var defaultFragmentDeclaration: {
  19492. name: string;
  19493. shader: string;
  19494. };
  19495. }
  19496. declare module "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration" {
  19497. /** @hidden */
  19498. export var sceneUboDeclaration: {
  19499. name: string;
  19500. shader: string;
  19501. };
  19502. }
  19503. declare module "babylonjs/Shaders/ShadersInclude/meshUboDeclaration" {
  19504. /** @hidden */
  19505. export var meshUboDeclaration: {
  19506. name: string;
  19507. shader: string;
  19508. };
  19509. }
  19510. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  19511. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  19512. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  19513. /** @hidden */
  19514. export var defaultUboDeclaration: {
  19515. name: string;
  19516. shader: string;
  19517. };
  19518. }
  19519. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  19520. /** @hidden */
  19521. export var prePassDeclaration: {
  19522. name: string;
  19523. shader: string;
  19524. };
  19525. }
  19526. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  19527. /** @hidden */
  19528. export var lightFragmentDeclaration: {
  19529. name: string;
  19530. shader: string;
  19531. };
  19532. }
  19533. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  19534. /** @hidden */
  19535. export var lightUboDeclaration: {
  19536. name: string;
  19537. shader: string;
  19538. };
  19539. }
  19540. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  19541. /** @hidden */
  19542. export var lightsFragmentFunctions: {
  19543. name: string;
  19544. shader: string;
  19545. };
  19546. }
  19547. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  19548. /** @hidden */
  19549. export var shadowsFragmentFunctions: {
  19550. name: string;
  19551. shader: string;
  19552. };
  19553. }
  19554. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  19555. /** @hidden */
  19556. export var fresnelFunction: {
  19557. name: string;
  19558. shader: string;
  19559. };
  19560. }
  19561. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  19562. /** @hidden */
  19563. export var bumpFragmentMainFunctions: {
  19564. name: string;
  19565. shader: string;
  19566. };
  19567. }
  19568. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  19569. /** @hidden */
  19570. export var bumpFragmentFunctions: {
  19571. name: string;
  19572. shader: string;
  19573. };
  19574. }
  19575. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  19576. /** @hidden */
  19577. export var logDepthDeclaration: {
  19578. name: string;
  19579. shader: string;
  19580. };
  19581. }
  19582. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  19583. /** @hidden */
  19584. export var fogFragmentDeclaration: {
  19585. name: string;
  19586. shader: string;
  19587. };
  19588. }
  19589. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  19590. /** @hidden */
  19591. export var bumpFragment: {
  19592. name: string;
  19593. shader: string;
  19594. };
  19595. }
  19596. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  19597. /** @hidden */
  19598. export var depthPrePass: {
  19599. name: string;
  19600. shader: string;
  19601. };
  19602. }
  19603. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  19604. /** @hidden */
  19605. export var lightFragment: {
  19606. name: string;
  19607. shader: string;
  19608. };
  19609. }
  19610. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  19611. /** @hidden */
  19612. export var logDepthFragment: {
  19613. name: string;
  19614. shader: string;
  19615. };
  19616. }
  19617. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  19618. /** @hidden */
  19619. export var fogFragment: {
  19620. name: string;
  19621. shader: string;
  19622. };
  19623. }
  19624. declare module "babylonjs/Shaders/default.fragment" {
  19625. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  19626. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19627. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  19628. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19629. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19630. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19631. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  19632. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  19633. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  19634. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  19635. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19636. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19637. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  19638. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  19639. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19640. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19641. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  19642. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19643. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  19644. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  19645. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  19646. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  19647. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  19648. /** @hidden */
  19649. export var defaultPixelShader: {
  19650. name: string;
  19651. shader: string;
  19652. };
  19653. }
  19654. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  19655. /** @hidden */
  19656. export var defaultVertexDeclaration: {
  19657. name: string;
  19658. shader: string;
  19659. };
  19660. }
  19661. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  19662. /** @hidden */
  19663. export var bonesDeclaration: {
  19664. name: string;
  19665. shader: string;
  19666. };
  19667. }
  19668. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  19669. /** @hidden */
  19670. export var prePassVertexDeclaration: {
  19671. name: string;
  19672. shader: string;
  19673. };
  19674. }
  19675. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  19676. /** @hidden */
  19677. export var bumpVertexDeclaration: {
  19678. name: string;
  19679. shader: string;
  19680. };
  19681. }
  19682. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  19683. /** @hidden */
  19684. export var fogVertexDeclaration: {
  19685. name: string;
  19686. shader: string;
  19687. };
  19688. }
  19689. declare module "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration" {
  19690. /** @hidden */
  19691. export var lightVxFragmentDeclaration: {
  19692. name: string;
  19693. shader: string;
  19694. };
  19695. }
  19696. declare module "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration" {
  19697. /** @hidden */
  19698. export var lightVxUboDeclaration: {
  19699. name: string;
  19700. shader: string;
  19701. };
  19702. }
  19703. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  19704. /** @hidden */
  19705. export var morphTargetsVertexGlobalDeclaration: {
  19706. name: string;
  19707. shader: string;
  19708. };
  19709. }
  19710. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  19711. /** @hidden */
  19712. export var morphTargetsVertexDeclaration: {
  19713. name: string;
  19714. shader: string;
  19715. };
  19716. }
  19717. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19718. /** @hidden */
  19719. export var morphTargetsVertex: {
  19720. name: string;
  19721. shader: string;
  19722. };
  19723. }
  19724. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19725. /** @hidden */
  19726. export var instancesVertex: {
  19727. name: string;
  19728. shader: string;
  19729. };
  19730. }
  19731. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19732. /** @hidden */
  19733. export var bonesVertex: {
  19734. name: string;
  19735. shader: string;
  19736. };
  19737. }
  19738. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19739. /** @hidden */
  19740. export var prePassVertex: {
  19741. name: string;
  19742. shader: string;
  19743. };
  19744. }
  19745. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19746. /** @hidden */
  19747. export var bumpVertex: {
  19748. name: string;
  19749. shader: string;
  19750. };
  19751. }
  19752. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19753. /** @hidden */
  19754. export var fogVertex: {
  19755. name: string;
  19756. shader: string;
  19757. };
  19758. }
  19759. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19760. /** @hidden */
  19761. export var shadowsVertex: {
  19762. name: string;
  19763. shader: string;
  19764. };
  19765. }
  19766. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19767. /** @hidden */
  19768. export var pointCloudVertex: {
  19769. name: string;
  19770. shader: string;
  19771. };
  19772. }
  19773. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19774. /** @hidden */
  19775. export var logDepthVertex: {
  19776. name: string;
  19777. shader: string;
  19778. };
  19779. }
  19780. declare module "babylonjs/Shaders/default.vertex" {
  19781. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19782. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19783. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19784. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19785. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19786. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19787. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19788. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19789. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  19790. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  19791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19792. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19793. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19794. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19795. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19796. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19797. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19798. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19800. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19801. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19802. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19803. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19804. /** @hidden */
  19805. export var defaultVertexShader: {
  19806. name: string;
  19807. shader: string;
  19808. };
  19809. }
  19810. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19811. import { Nullable } from "babylonjs/types";
  19812. import { Scene } from "babylonjs/scene";
  19813. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19814. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19815. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19816. /**
  19817. * @hidden
  19818. */
  19819. export interface IMaterialDetailMapDefines {
  19820. DETAIL: boolean;
  19821. DETAILDIRECTUV: number;
  19822. DETAIL_NORMALBLENDMETHOD: number;
  19823. /** @hidden */
  19824. _areTexturesDirty: boolean;
  19825. }
  19826. /**
  19827. * Define the code related to the detail map parameters of a material
  19828. *
  19829. * Inspired from:
  19830. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  19831. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19832. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19833. */
  19834. export class DetailMapConfiguration {
  19835. private _texture;
  19836. /**
  19837. * The detail texture of the material.
  19838. */
  19839. texture: Nullable<BaseTexture>;
  19840. /**
  19841. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19842. * Bigger values mean stronger blending
  19843. */
  19844. diffuseBlendLevel: number;
  19845. /**
  19846. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19847. * Bigger values mean stronger blending. Only used with PBR materials
  19848. */
  19849. roughnessBlendLevel: number;
  19850. /**
  19851. * Defines how strong the bump effect from the detail map is
  19852. * Bigger values mean stronger effect
  19853. */
  19854. bumpLevel: number;
  19855. private _normalBlendMethod;
  19856. /**
  19857. * The method used to blend the bump and detail normals together
  19858. */
  19859. normalBlendMethod: number;
  19860. private _isEnabled;
  19861. /**
  19862. * Enable or disable the detail map on this material
  19863. */
  19864. isEnabled: boolean;
  19865. /** @hidden */
  19866. private _internalMarkAllSubMeshesAsTexturesDirty;
  19867. /** @hidden */
  19868. _markAllSubMeshesAsTexturesDirty(): void;
  19869. /**
  19870. * Instantiate a new detail map
  19871. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19872. */
  19873. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19874. /**
  19875. * Gets whether the submesh is ready to be used or not.
  19876. * @param defines the list of "defines" to update.
  19877. * @param scene defines the scene the material belongs to.
  19878. * @returns - boolean indicating that the submesh is ready or not.
  19879. */
  19880. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19881. /**
  19882. * Update the defines for detail map usage
  19883. * @param defines the list of "defines" to update.
  19884. * @param scene defines the scene the material belongs to.
  19885. */
  19886. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19887. /**
  19888. * Binds the material data.
  19889. * @param uniformBuffer defines the Uniform buffer to fill in.
  19890. * @param scene defines the scene the material belongs to.
  19891. * @param isFrozen defines whether the material is frozen or not.
  19892. */
  19893. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19894. /**
  19895. * Checks to see if a texture is used in the material.
  19896. * @param texture - Base texture to use.
  19897. * @returns - Boolean specifying if a texture is used in the material.
  19898. */
  19899. hasTexture(texture: BaseTexture): boolean;
  19900. /**
  19901. * Returns an array of the actively used textures.
  19902. * @param activeTextures Array of BaseTextures
  19903. */
  19904. getActiveTextures(activeTextures: BaseTexture[]): void;
  19905. /**
  19906. * Returns the animatable textures.
  19907. * @param animatables Array of animatable textures.
  19908. */
  19909. getAnimatables(animatables: IAnimatable[]): void;
  19910. /**
  19911. * Disposes the resources of the material.
  19912. * @param forceDisposeTextures - Forces the disposal of all textures.
  19913. */
  19914. dispose(forceDisposeTextures?: boolean): void;
  19915. /**
  19916. * Get the current class name useful for serialization or dynamic coding.
  19917. * @returns "DetailMap"
  19918. */
  19919. getClassName(): string;
  19920. /**
  19921. * Add the required uniforms to the current list.
  19922. * @param uniforms defines the current uniform list.
  19923. */
  19924. static AddUniforms(uniforms: string[]): void;
  19925. /**
  19926. * Add the required samplers to the current list.
  19927. * @param samplers defines the current sampler list.
  19928. */
  19929. static AddSamplers(samplers: string[]): void;
  19930. /**
  19931. * Add the required uniforms to the current buffer.
  19932. * @param uniformBuffer defines the current uniform buffer.
  19933. */
  19934. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19935. /**
  19936. * Makes a duplicate of the current instance into another one.
  19937. * @param detailMap define the instance where to copy the info
  19938. */
  19939. copyTo(detailMap: DetailMapConfiguration): void;
  19940. /**
  19941. * Serializes this detail map instance
  19942. * @returns - An object with the serialized instance.
  19943. */
  19944. serialize(): any;
  19945. /**
  19946. * Parses a detail map setting from a serialized object.
  19947. * @param source - Serialized object.
  19948. * @param scene Defines the scene we are parsing for
  19949. * @param rootUrl Defines the rootUrl to load from
  19950. */
  19951. parse(source: any, scene: Scene, rootUrl: string): void;
  19952. }
  19953. }
  19954. declare module "babylonjs/Materials/standardMaterial" {
  19955. import { SmartArray } from "babylonjs/Misc/smartArray";
  19956. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19957. import { Nullable } from "babylonjs/types";
  19958. import { Scene } from "babylonjs/scene";
  19959. import { Matrix } from "babylonjs/Maths/math.vector";
  19960. import { Color3 } from "babylonjs/Maths/math.color";
  19961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19963. import { Mesh } from "babylonjs/Meshes/mesh";
  19964. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19965. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19966. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19967. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19968. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19969. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19972. import "babylonjs/Shaders/default.fragment";
  19973. import "babylonjs/Shaders/default.vertex";
  19974. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19975. /** @hidden */
  19976. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19977. MAINUV1: boolean;
  19978. MAINUV2: boolean;
  19979. DIFFUSE: boolean;
  19980. DIFFUSEDIRECTUV: number;
  19981. DETAIL: boolean;
  19982. DETAILDIRECTUV: number;
  19983. DETAIL_NORMALBLENDMETHOD: number;
  19984. AMBIENT: boolean;
  19985. AMBIENTDIRECTUV: number;
  19986. OPACITY: boolean;
  19987. OPACITYDIRECTUV: number;
  19988. OPACITYRGB: boolean;
  19989. REFLECTION: boolean;
  19990. EMISSIVE: boolean;
  19991. EMISSIVEDIRECTUV: number;
  19992. SPECULAR: boolean;
  19993. SPECULARDIRECTUV: number;
  19994. BUMP: boolean;
  19995. BUMPDIRECTUV: number;
  19996. PARALLAX: boolean;
  19997. PARALLAXOCCLUSION: boolean;
  19998. SPECULAROVERALPHA: boolean;
  19999. CLIPPLANE: boolean;
  20000. CLIPPLANE2: boolean;
  20001. CLIPPLANE3: boolean;
  20002. CLIPPLANE4: boolean;
  20003. CLIPPLANE5: boolean;
  20004. CLIPPLANE6: boolean;
  20005. ALPHATEST: boolean;
  20006. DEPTHPREPASS: boolean;
  20007. ALPHAFROMDIFFUSE: boolean;
  20008. POINTSIZE: boolean;
  20009. FOG: boolean;
  20010. SPECULARTERM: boolean;
  20011. DIFFUSEFRESNEL: boolean;
  20012. OPACITYFRESNEL: boolean;
  20013. REFLECTIONFRESNEL: boolean;
  20014. REFRACTIONFRESNEL: boolean;
  20015. EMISSIVEFRESNEL: boolean;
  20016. FRESNEL: boolean;
  20017. NORMAL: boolean;
  20018. UV1: boolean;
  20019. UV2: boolean;
  20020. VERTEXCOLOR: boolean;
  20021. VERTEXALPHA: boolean;
  20022. NUM_BONE_INFLUENCERS: number;
  20023. BonesPerMesh: number;
  20024. BONETEXTURE: boolean;
  20025. BONES_VELOCITY_ENABLED: boolean;
  20026. INSTANCES: boolean;
  20027. THIN_INSTANCES: boolean;
  20028. GLOSSINESS: boolean;
  20029. ROUGHNESS: boolean;
  20030. EMISSIVEASILLUMINATION: boolean;
  20031. LINKEMISSIVEWITHDIFFUSE: boolean;
  20032. REFLECTIONFRESNELFROMSPECULAR: boolean;
  20033. LIGHTMAP: boolean;
  20034. LIGHTMAPDIRECTUV: number;
  20035. OBJECTSPACE_NORMALMAP: boolean;
  20036. USELIGHTMAPASSHADOWMAP: boolean;
  20037. REFLECTIONMAP_3D: boolean;
  20038. REFLECTIONMAP_SPHERICAL: boolean;
  20039. REFLECTIONMAP_PLANAR: boolean;
  20040. REFLECTIONMAP_CUBIC: boolean;
  20041. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20042. REFLECTIONMAP_PROJECTION: boolean;
  20043. REFLECTIONMAP_SKYBOX: boolean;
  20044. REFLECTIONMAP_EXPLICIT: boolean;
  20045. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20046. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20047. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20048. REFLECTIONMAP_OPPOSITEZ: boolean;
  20049. INVERTCUBICMAP: boolean;
  20050. LOGARITHMICDEPTH: boolean;
  20051. REFRACTION: boolean;
  20052. REFRACTIONMAP_3D: boolean;
  20053. REFLECTIONOVERALPHA: boolean;
  20054. TWOSIDEDLIGHTING: boolean;
  20055. SHADOWFLOAT: boolean;
  20056. MORPHTARGETS: boolean;
  20057. MORPHTARGETS_NORMAL: boolean;
  20058. MORPHTARGETS_TANGENT: boolean;
  20059. MORPHTARGETS_UV: boolean;
  20060. NUM_MORPH_INFLUENCERS: number;
  20061. NONUNIFORMSCALING: boolean;
  20062. PREMULTIPLYALPHA: boolean;
  20063. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  20064. ALPHABLEND: boolean;
  20065. PREPASS: boolean;
  20066. PREPASS_IRRADIANCE: boolean;
  20067. PREPASS_IRRADIANCE_INDEX: number;
  20068. PREPASS_ALBEDO: boolean;
  20069. PREPASS_ALBEDO_INDEX: number;
  20070. PREPASS_DEPTHNORMAL: boolean;
  20071. PREPASS_DEPTHNORMAL_INDEX: number;
  20072. PREPASS_POSITION: boolean;
  20073. PREPASS_POSITION_INDEX: number;
  20074. PREPASS_VELOCITY: boolean;
  20075. PREPASS_VELOCITY_INDEX: number;
  20076. PREPASS_REFLECTIVITY: boolean;
  20077. PREPASS_REFLECTIVITY_INDEX: number;
  20078. SCENE_MRT_COUNT: number;
  20079. RGBDLIGHTMAP: boolean;
  20080. RGBDREFLECTION: boolean;
  20081. RGBDREFRACTION: boolean;
  20082. IMAGEPROCESSING: boolean;
  20083. VIGNETTE: boolean;
  20084. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20085. VIGNETTEBLENDMODEOPAQUE: boolean;
  20086. TONEMAPPING: boolean;
  20087. TONEMAPPING_ACES: boolean;
  20088. CONTRAST: boolean;
  20089. COLORCURVES: boolean;
  20090. COLORGRADING: boolean;
  20091. COLORGRADING3D: boolean;
  20092. SAMPLER3DGREENDEPTH: boolean;
  20093. SAMPLER3DBGRMAP: boolean;
  20094. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20095. MULTIVIEW: boolean;
  20096. /**
  20097. * If the reflection texture on this material is in linear color space
  20098. * @hidden
  20099. */
  20100. IS_REFLECTION_LINEAR: boolean;
  20101. /**
  20102. * If the refraction texture on this material is in linear color space
  20103. * @hidden
  20104. */
  20105. IS_REFRACTION_LINEAR: boolean;
  20106. EXPOSURE: boolean;
  20107. constructor();
  20108. setReflectionMode(modeToEnable: string): void;
  20109. }
  20110. /**
  20111. * This is the default material used in Babylon. It is the best trade off between quality
  20112. * and performances.
  20113. * @see https://doc.babylonjs.com/babylon101/materials
  20114. */
  20115. export class StandardMaterial extends PushMaterial {
  20116. private _diffuseTexture;
  20117. /**
  20118. * The basic texture of the material as viewed under a light.
  20119. */
  20120. diffuseTexture: Nullable<BaseTexture>;
  20121. private _ambientTexture;
  20122. /**
  20123. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  20124. */
  20125. ambientTexture: Nullable<BaseTexture>;
  20126. private _opacityTexture;
  20127. /**
  20128. * Define the transparency of the material from a texture.
  20129. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  20130. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  20131. */
  20132. opacityTexture: Nullable<BaseTexture>;
  20133. private _reflectionTexture;
  20134. /**
  20135. * Define the texture used to display the reflection.
  20136. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20137. */
  20138. reflectionTexture: Nullable<BaseTexture>;
  20139. private _emissiveTexture;
  20140. /**
  20141. * Define texture of the material as if self lit.
  20142. * This will be mixed in the final result even in the absence of light.
  20143. */
  20144. emissiveTexture: Nullable<BaseTexture>;
  20145. private _specularTexture;
  20146. /**
  20147. * Define how the color and intensity of the highlight given by the light in the material.
  20148. */
  20149. specularTexture: Nullable<BaseTexture>;
  20150. private _bumpTexture;
  20151. /**
  20152. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  20153. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  20154. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  20155. */
  20156. bumpTexture: Nullable<BaseTexture>;
  20157. private _lightmapTexture;
  20158. /**
  20159. * Complex lighting can be computationally expensive to compute at runtime.
  20160. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  20161. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  20162. */
  20163. lightmapTexture: Nullable<BaseTexture>;
  20164. private _refractionTexture;
  20165. /**
  20166. * Define the texture used to display the refraction.
  20167. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20168. */
  20169. refractionTexture: Nullable<BaseTexture>;
  20170. /**
  20171. * The color of the material lit by the environmental background lighting.
  20172. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  20173. */
  20174. ambientColor: Color3;
  20175. /**
  20176. * The basic color of the material as viewed under a light.
  20177. */
  20178. diffuseColor: Color3;
  20179. /**
  20180. * Define how the color and intensity of the highlight given by the light in the material.
  20181. */
  20182. specularColor: Color3;
  20183. /**
  20184. * Define the color of the material as if self lit.
  20185. * This will be mixed in the final result even in the absence of light.
  20186. */
  20187. emissiveColor: Color3;
  20188. /**
  20189. * Defines how sharp are the highlights in the material.
  20190. * The bigger the value the sharper giving a more glossy feeling to the result.
  20191. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  20192. */
  20193. specularPower: number;
  20194. private _useAlphaFromDiffuseTexture;
  20195. /**
  20196. * Does the transparency come from the diffuse texture alpha channel.
  20197. */
  20198. useAlphaFromDiffuseTexture: boolean;
  20199. private _useEmissiveAsIllumination;
  20200. /**
  20201. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  20202. */
  20203. useEmissiveAsIllumination: boolean;
  20204. private _linkEmissiveWithDiffuse;
  20205. /**
  20206. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  20207. * the emissive level when the final color is close to one.
  20208. */
  20209. linkEmissiveWithDiffuse: boolean;
  20210. private _useSpecularOverAlpha;
  20211. /**
  20212. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  20213. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  20214. */
  20215. useSpecularOverAlpha: boolean;
  20216. private _useReflectionOverAlpha;
  20217. /**
  20218. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  20219. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  20220. */
  20221. useReflectionOverAlpha: boolean;
  20222. private _disableLighting;
  20223. /**
  20224. * Does lights from the scene impacts this material.
  20225. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  20226. */
  20227. disableLighting: boolean;
  20228. private _useObjectSpaceNormalMap;
  20229. /**
  20230. * Allows using an object space normal map (instead of tangent space).
  20231. */
  20232. useObjectSpaceNormalMap: boolean;
  20233. private _useParallax;
  20234. /**
  20235. * Is parallax enabled or not.
  20236. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20237. */
  20238. useParallax: boolean;
  20239. private _useParallaxOcclusion;
  20240. /**
  20241. * Is parallax occlusion enabled or not.
  20242. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  20243. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20244. */
  20245. useParallaxOcclusion: boolean;
  20246. /**
  20247. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  20248. */
  20249. parallaxScaleBias: number;
  20250. private _roughness;
  20251. /**
  20252. * Helps to define how blurry the reflections should appears in the material.
  20253. */
  20254. roughness: number;
  20255. /**
  20256. * In case of refraction, define the value of the index of refraction.
  20257. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20258. */
  20259. indexOfRefraction: number;
  20260. /**
  20261. * Invert the refraction texture alongside the y axis.
  20262. * It can be useful with procedural textures or probe for instance.
  20263. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20264. */
  20265. invertRefractionY: boolean;
  20266. /**
  20267. * Defines the alpha limits in alpha test mode.
  20268. */
  20269. alphaCutOff: number;
  20270. private _useLightmapAsShadowmap;
  20271. /**
  20272. * In case of light mapping, define whether the map contains light or shadow informations.
  20273. */
  20274. useLightmapAsShadowmap: boolean;
  20275. private _diffuseFresnelParameters;
  20276. /**
  20277. * Define the diffuse fresnel parameters of the material.
  20278. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20279. */
  20280. diffuseFresnelParameters: FresnelParameters;
  20281. private _opacityFresnelParameters;
  20282. /**
  20283. * Define the opacity fresnel parameters of the material.
  20284. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20285. */
  20286. opacityFresnelParameters: FresnelParameters;
  20287. private _reflectionFresnelParameters;
  20288. /**
  20289. * Define the reflection fresnel parameters of the material.
  20290. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20291. */
  20292. reflectionFresnelParameters: FresnelParameters;
  20293. private _refractionFresnelParameters;
  20294. /**
  20295. * Define the refraction fresnel parameters of the material.
  20296. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20297. */
  20298. refractionFresnelParameters: FresnelParameters;
  20299. private _emissiveFresnelParameters;
  20300. /**
  20301. * Define the emissive fresnel parameters of the material.
  20302. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20303. */
  20304. emissiveFresnelParameters: FresnelParameters;
  20305. private _useReflectionFresnelFromSpecular;
  20306. /**
  20307. * If true automatically deducts the fresnels values from the material specularity.
  20308. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20309. */
  20310. useReflectionFresnelFromSpecular: boolean;
  20311. private _useGlossinessFromSpecularMapAlpha;
  20312. /**
  20313. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  20314. */
  20315. useGlossinessFromSpecularMapAlpha: boolean;
  20316. private _maxSimultaneousLights;
  20317. /**
  20318. * Defines the maximum number of lights that can be used in the material
  20319. */
  20320. maxSimultaneousLights: number;
  20321. private _invertNormalMapX;
  20322. /**
  20323. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20324. */
  20325. invertNormalMapX: boolean;
  20326. private _invertNormalMapY;
  20327. /**
  20328. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20329. */
  20330. invertNormalMapY: boolean;
  20331. private _twoSidedLighting;
  20332. /**
  20333. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20334. */
  20335. twoSidedLighting: boolean;
  20336. /**
  20337. * Default configuration related to image processing available in the standard Material.
  20338. */
  20339. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20340. /**
  20341. * Gets the image processing configuration used either in this material.
  20342. */
  20343. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  20344. /**
  20345. * Sets the Default image processing configuration used either in the this material.
  20346. *
  20347. * If sets to null, the scene one is in use.
  20348. */
  20349. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  20350. /**
  20351. * Keep track of the image processing observer to allow dispose and replace.
  20352. */
  20353. private _imageProcessingObserver;
  20354. /**
  20355. * Attaches a new image processing configuration to the Standard Material.
  20356. * @param configuration
  20357. */
  20358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20359. /**
  20360. * Defines additionnal PrePass parameters for the material.
  20361. */
  20362. readonly prePassConfiguration: PrePassConfiguration;
  20363. /**
  20364. * Gets wether the color curves effect is enabled.
  20365. */
  20366. get cameraColorCurvesEnabled(): boolean;
  20367. /**
  20368. * Sets wether the color curves effect is enabled.
  20369. */
  20370. set cameraColorCurvesEnabled(value: boolean);
  20371. /**
  20372. * Gets wether the color grading effect is enabled.
  20373. */
  20374. get cameraColorGradingEnabled(): boolean;
  20375. /**
  20376. * Gets wether the color grading effect is enabled.
  20377. */
  20378. set cameraColorGradingEnabled(value: boolean);
  20379. /**
  20380. * Gets wether tonemapping is enabled or not.
  20381. */
  20382. get cameraToneMappingEnabled(): boolean;
  20383. /**
  20384. * Sets wether tonemapping is enabled or not
  20385. */
  20386. set cameraToneMappingEnabled(value: boolean);
  20387. /**
  20388. * The camera exposure used on this material.
  20389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20390. * This corresponds to a photographic exposure.
  20391. */
  20392. get cameraExposure(): number;
  20393. /**
  20394. * The camera exposure used on this material.
  20395. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20396. * This corresponds to a photographic exposure.
  20397. */
  20398. set cameraExposure(value: number);
  20399. /**
  20400. * Gets The camera contrast used on this material.
  20401. */
  20402. get cameraContrast(): number;
  20403. /**
  20404. * Sets The camera contrast used on this material.
  20405. */
  20406. set cameraContrast(value: number);
  20407. /**
  20408. * Gets the Color Grading 2D Lookup Texture.
  20409. */
  20410. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  20411. /**
  20412. * Sets the Color Grading 2D Lookup Texture.
  20413. */
  20414. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  20415. /**
  20416. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20417. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20418. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  20419. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20420. */
  20421. get cameraColorCurves(): Nullable<ColorCurves>;
  20422. /**
  20423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20425. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  20426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20427. */
  20428. set cameraColorCurves(value: Nullable<ColorCurves>);
  20429. /**
  20430. * Can this material render to several textures at once
  20431. */
  20432. get canRenderToMRT(): boolean;
  20433. /**
  20434. * Defines the detail map parameters for the material.
  20435. */
  20436. readonly detailMap: DetailMapConfiguration;
  20437. protected _renderTargets: SmartArray<RenderTargetTexture>;
  20438. protected _worldViewProjectionMatrix: Matrix;
  20439. protected _globalAmbientColor: Color3;
  20440. protected _useLogarithmicDepth: boolean;
  20441. protected _rebuildInParallel: boolean;
  20442. /**
  20443. * Instantiates a new standard material.
  20444. * This is the default material used in Babylon. It is the best trade off between quality
  20445. * and performances.
  20446. * @see https://doc.babylonjs.com/babylon101/materials
  20447. * @param name Define the name of the material in the scene
  20448. * @param scene Define the scene the material belong to
  20449. */
  20450. constructor(name: string, scene: Scene);
  20451. /**
  20452. * Gets a boolean indicating that current material needs to register RTT
  20453. */
  20454. get hasRenderTargetTextures(): boolean;
  20455. /**
  20456. * Gets the current class name of the material e.g. "StandardMaterial"
  20457. * Mainly use in serialization.
  20458. * @returns the class name
  20459. */
  20460. getClassName(): string;
  20461. /**
  20462. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  20463. * You can try switching to logarithmic depth.
  20464. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  20465. */
  20466. get useLogarithmicDepth(): boolean;
  20467. set useLogarithmicDepth(value: boolean);
  20468. /**
  20469. * Specifies if the material will require alpha blending
  20470. * @returns a boolean specifying if alpha blending is needed
  20471. */
  20472. needAlphaBlending(): boolean;
  20473. /**
  20474. * Specifies if this material should be rendered in alpha test mode
  20475. * @returns a boolean specifying if an alpha test is needed.
  20476. */
  20477. needAlphaTesting(): boolean;
  20478. /**
  20479. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  20480. */
  20481. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  20482. /**
  20483. * Specifies whether or not there is a usable alpha channel for transparency.
  20484. */
  20485. protected _hasAlphaChannel(): boolean;
  20486. /**
  20487. * Get the texture used for alpha test purpose.
  20488. * @returns the diffuse texture in case of the standard material.
  20489. */
  20490. getAlphaTestTexture(): Nullable<BaseTexture>;
  20491. /**
  20492. * Get if the submesh is ready to be used and all its information available.
  20493. * Child classes can use it to update shaders
  20494. * @param mesh defines the mesh to check
  20495. * @param subMesh defines which submesh to check
  20496. * @param useInstances specifies that instances should be used
  20497. * @returns a boolean indicating that the submesh is ready or not
  20498. */
  20499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20500. /**
  20501. * Builds the material UBO layouts.
  20502. * Used internally during the effect preparation.
  20503. */
  20504. buildUniformLayout(): void;
  20505. /**
  20506. * Unbinds the material from the mesh
  20507. */
  20508. unbind(): void;
  20509. /**
  20510. * Binds the submesh to this material by preparing the effect and shader to draw
  20511. * @param world defines the world transformation matrix
  20512. * @param mesh defines the mesh containing the submesh
  20513. * @param subMesh defines the submesh to bind the material to
  20514. */
  20515. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20516. /**
  20517. * Get the list of animatables in the material.
  20518. * @returns the list of animatables object used in the material
  20519. */
  20520. getAnimatables(): IAnimatable[];
  20521. /**
  20522. * Gets the active textures from the material
  20523. * @returns an array of textures
  20524. */
  20525. getActiveTextures(): BaseTexture[];
  20526. /**
  20527. * Specifies if the material uses a texture
  20528. * @param texture defines the texture to check against the material
  20529. * @returns a boolean specifying if the material uses the texture
  20530. */
  20531. hasTexture(texture: BaseTexture): boolean;
  20532. /**
  20533. * Disposes the material
  20534. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20535. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20536. */
  20537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20538. /**
  20539. * Makes a duplicate of the material, and gives it a new name
  20540. * @param name defines the new name for the duplicated material
  20541. * @returns the cloned material
  20542. */
  20543. clone(name: string): StandardMaterial;
  20544. /**
  20545. * Serializes this material in a JSON representation
  20546. * @returns the serialized material object
  20547. */
  20548. serialize(): any;
  20549. /**
  20550. * Creates a standard material from parsed material data
  20551. * @param source defines the JSON representation of the material
  20552. * @param scene defines the hosting scene
  20553. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20554. * @returns a new standard material
  20555. */
  20556. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20557. /**
  20558. * Are diffuse textures enabled in the application.
  20559. */
  20560. static get DiffuseTextureEnabled(): boolean;
  20561. static set DiffuseTextureEnabled(value: boolean);
  20562. /**
  20563. * Are detail textures enabled in the application.
  20564. */
  20565. static get DetailTextureEnabled(): boolean;
  20566. static set DetailTextureEnabled(value: boolean);
  20567. /**
  20568. * Are ambient textures enabled in the application.
  20569. */
  20570. static get AmbientTextureEnabled(): boolean;
  20571. static set AmbientTextureEnabled(value: boolean);
  20572. /**
  20573. * Are opacity textures enabled in the application.
  20574. */
  20575. static get OpacityTextureEnabled(): boolean;
  20576. static set OpacityTextureEnabled(value: boolean);
  20577. /**
  20578. * Are reflection textures enabled in the application.
  20579. */
  20580. static get ReflectionTextureEnabled(): boolean;
  20581. static set ReflectionTextureEnabled(value: boolean);
  20582. /**
  20583. * Are emissive textures enabled in the application.
  20584. */
  20585. static get EmissiveTextureEnabled(): boolean;
  20586. static set EmissiveTextureEnabled(value: boolean);
  20587. /**
  20588. * Are specular textures enabled in the application.
  20589. */
  20590. static get SpecularTextureEnabled(): boolean;
  20591. static set SpecularTextureEnabled(value: boolean);
  20592. /**
  20593. * Are bump textures enabled in the application.
  20594. */
  20595. static get BumpTextureEnabled(): boolean;
  20596. static set BumpTextureEnabled(value: boolean);
  20597. /**
  20598. * Are lightmap textures enabled in the application.
  20599. */
  20600. static get LightmapTextureEnabled(): boolean;
  20601. static set LightmapTextureEnabled(value: boolean);
  20602. /**
  20603. * Are refraction textures enabled in the application.
  20604. */
  20605. static get RefractionTextureEnabled(): boolean;
  20606. static set RefractionTextureEnabled(value: boolean);
  20607. /**
  20608. * Are color grading textures enabled in the application.
  20609. */
  20610. static get ColorGradingTextureEnabled(): boolean;
  20611. static set ColorGradingTextureEnabled(value: boolean);
  20612. /**
  20613. * Are fresnels enabled in the application.
  20614. */
  20615. static get FresnelEnabled(): boolean;
  20616. static set FresnelEnabled(value: boolean);
  20617. }
  20618. }
  20619. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  20620. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20621. /** @hidden */
  20622. export var rgbdDecodePixelShader: {
  20623. name: string;
  20624. shader: string;
  20625. };
  20626. }
  20627. declare module "babylonjs/Shaders/pass.fragment" {
  20628. /** @hidden */
  20629. export var passPixelShader: {
  20630. name: string;
  20631. shader: string;
  20632. };
  20633. }
  20634. declare module "babylonjs/Shaders/passCube.fragment" {
  20635. /** @hidden */
  20636. export var passCubePixelShader: {
  20637. name: string;
  20638. shader: string;
  20639. };
  20640. }
  20641. declare module "babylonjs/PostProcesses/passPostProcess" {
  20642. import { Nullable } from "babylonjs/types";
  20643. import { Camera } from "babylonjs/Cameras/camera";
  20644. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20645. import { Engine } from "babylonjs/Engines/engine";
  20646. import "babylonjs/Shaders/pass.fragment";
  20647. import "babylonjs/Shaders/passCube.fragment";
  20648. import { Scene } from "babylonjs/scene";
  20649. /**
  20650. * PassPostProcess which produces an output the same as it's input
  20651. */
  20652. export class PassPostProcess extends PostProcess {
  20653. /**
  20654. * Gets a string identifying the name of the class
  20655. * @returns "PassPostProcess" string
  20656. */
  20657. getClassName(): string;
  20658. /**
  20659. * Creates the PassPostProcess
  20660. * @param name The name of the effect.
  20661. * @param options The required width/height ratio to downsize to before computing the render pass.
  20662. * @param camera The camera to apply the render pass to.
  20663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20664. * @param engine The engine which the post process will be applied. (default: current engine)
  20665. * @param reusable If the post process can be reused on the same frame. (default: false)
  20666. * @param textureType The type of texture to be used when performing the post processing.
  20667. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20668. */
  20669. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20670. /** @hidden */
  20671. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20672. }
  20673. /**
  20674. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20675. */
  20676. export class PassCubePostProcess extends PostProcess {
  20677. private _face;
  20678. /**
  20679. * Gets or sets the cube face to display.
  20680. * * 0 is +X
  20681. * * 1 is -X
  20682. * * 2 is +Y
  20683. * * 3 is -Y
  20684. * * 4 is +Z
  20685. * * 5 is -Z
  20686. */
  20687. get face(): number;
  20688. set face(value: number);
  20689. /**
  20690. * Gets a string identifying the name of the class
  20691. * @returns "PassCubePostProcess" string
  20692. */
  20693. getClassName(): string;
  20694. /**
  20695. * Creates the PassCubePostProcess
  20696. * @param name The name of the effect.
  20697. * @param options The required width/height ratio to downsize to before computing the render pass.
  20698. * @param camera The camera to apply the render pass to.
  20699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20700. * @param engine The engine which the post process will be applied. (default: current engine)
  20701. * @param reusable If the post process can be reused on the same frame. (default: false)
  20702. * @param textureType The type of texture to be used when performing the post processing.
  20703. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20704. */
  20705. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20706. /** @hidden */
  20707. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20708. }
  20709. }
  20710. declare module "babylonjs/Misc/textureTools" {
  20711. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20712. import { Texture } from "babylonjs/Materials/Textures/texture";
  20713. import { Scene } from "babylonjs/scene";
  20714. /**
  20715. * Class used to host texture specific utilities
  20716. */
  20717. export class TextureTools {
  20718. /**
  20719. * Uses the GPU to create a copy texture rescaled at a given size
  20720. * @param texture Texture to copy from
  20721. * @param width defines the desired width
  20722. * @param height defines the desired height
  20723. * @param useBilinearMode defines if bilinear mode has to be used
  20724. * @return the generated texture
  20725. */
  20726. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20727. /**
  20728. * Apply a post process to a texture
  20729. * @param postProcessName name of the fragment post process
  20730. * @param internalTexture the texture to encode
  20731. * @param scene the scene hosting the texture
  20732. * @param type type of the output texture. If not provided, use the one from internalTexture
  20733. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  20734. * @param format format of the output texture. If not provided, use the one from internalTexture
  20735. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20736. */
  20737. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20738. }
  20739. }
  20740. declare module "babylonjs/Misc/rgbdTextureTools" {
  20741. import "babylonjs/Shaders/rgbdDecode.fragment";
  20742. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20743. import { Texture } from "babylonjs/Materials/Textures/texture";
  20744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20745. import { Scene } from "babylonjs/scene";
  20746. /**
  20747. * Class used to host RGBD texture specific utilities
  20748. */
  20749. export class RGBDTextureTools {
  20750. /**
  20751. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20752. * @param texture the texture to expand.
  20753. */
  20754. static ExpandRGBDTexture(texture: Texture): void;
  20755. /**
  20756. * Encode the texture to RGBD if possible.
  20757. * @param internalTexture the texture to encode
  20758. * @param scene the scene hosting the texture
  20759. * @param outputTextureType type of the texture in which the encoding is performed
  20760. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20761. */
  20762. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20763. }
  20764. }
  20765. declare module "babylonjs/Misc/brdfTextureTools" {
  20766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20767. import { Scene } from "babylonjs/scene";
  20768. /**
  20769. * Class used to host texture specific utilities
  20770. */
  20771. export class BRDFTextureTools {
  20772. /**
  20773. * Prevents texture cache collision
  20774. */
  20775. private static _instanceNumber;
  20776. /**
  20777. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20778. * @param scene defines the hosting scene
  20779. * @returns the environment BRDF texture
  20780. */
  20781. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20782. private static _environmentBRDFBase64Texture;
  20783. }
  20784. }
  20785. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  20786. import { Nullable } from "babylonjs/types";
  20787. import { Color3 } from "babylonjs/Maths/math.color";
  20788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20789. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20790. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20791. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20793. import { Engine } from "babylonjs/Engines/engine";
  20794. import { Scene } from "babylonjs/scene";
  20795. /**
  20796. * @hidden
  20797. */
  20798. export interface IMaterialClearCoatDefines {
  20799. CLEARCOAT: boolean;
  20800. CLEARCOAT_DEFAULTIOR: boolean;
  20801. CLEARCOAT_TEXTURE: boolean;
  20802. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20803. CLEARCOAT_TEXTUREDIRECTUV: number;
  20804. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20805. CLEARCOAT_BUMP: boolean;
  20806. CLEARCOAT_BUMPDIRECTUV: number;
  20807. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20808. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20809. CLEARCOAT_REMAP_F0: boolean;
  20810. CLEARCOAT_TINT: boolean;
  20811. CLEARCOAT_TINT_TEXTURE: boolean;
  20812. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20813. /** @hidden */
  20814. _areTexturesDirty: boolean;
  20815. }
  20816. /**
  20817. * Define the code related to the clear coat parameters of the pbr material.
  20818. */
  20819. export class PBRClearCoatConfiguration {
  20820. /**
  20821. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20822. * The default fits with a polyurethane material.
  20823. * @hidden
  20824. */
  20825. static readonly _DefaultIndexOfRefraction: number;
  20826. private _isEnabled;
  20827. /**
  20828. * Defines if the clear coat is enabled in the material.
  20829. */
  20830. isEnabled: boolean;
  20831. /**
  20832. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20833. */
  20834. intensity: number;
  20835. /**
  20836. * Defines the clear coat layer roughness.
  20837. */
  20838. roughness: number;
  20839. private _indexOfRefraction;
  20840. /**
  20841. * Defines the index of refraction of the clear coat.
  20842. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20843. * The default fits with a polyurethane material.
  20844. * Changing the default value is more performance intensive.
  20845. */
  20846. indexOfRefraction: number;
  20847. private _texture;
  20848. /**
  20849. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20850. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20851. * if textureRoughness is not empty, else no texture roughness is used
  20852. */
  20853. texture: Nullable<BaseTexture>;
  20854. private _useRoughnessFromMainTexture;
  20855. /**
  20856. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20857. * If false, the green channel from textureRoughness is used for roughness
  20858. */
  20859. useRoughnessFromMainTexture: boolean;
  20860. private _textureRoughness;
  20861. /**
  20862. * Stores the clear coat roughness in a texture (green channel)
  20863. * Not used if useRoughnessFromMainTexture is true
  20864. */
  20865. textureRoughness: Nullable<BaseTexture>;
  20866. private _remapF0OnInterfaceChange;
  20867. /**
  20868. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20869. */
  20870. remapF0OnInterfaceChange: boolean;
  20871. private _bumpTexture;
  20872. /**
  20873. * Define the clear coat specific bump texture.
  20874. */
  20875. bumpTexture: Nullable<BaseTexture>;
  20876. private _isTintEnabled;
  20877. /**
  20878. * Defines if the clear coat tint is enabled in the material.
  20879. */
  20880. isTintEnabled: boolean;
  20881. /**
  20882. * Defines the clear coat tint of the material.
  20883. * This is only use if tint is enabled
  20884. */
  20885. tintColor: Color3;
  20886. /**
  20887. * Defines the distance at which the tint color should be found in the
  20888. * clear coat media.
  20889. * This is only use if tint is enabled
  20890. */
  20891. tintColorAtDistance: number;
  20892. /**
  20893. * Defines the clear coat layer thickness.
  20894. * This is only use if tint is enabled
  20895. */
  20896. tintThickness: number;
  20897. private _tintTexture;
  20898. /**
  20899. * Stores the clear tint values in a texture.
  20900. * rgb is tint
  20901. * a is a thickness factor
  20902. */
  20903. tintTexture: Nullable<BaseTexture>;
  20904. /** @hidden */
  20905. private _internalMarkAllSubMeshesAsTexturesDirty;
  20906. /** @hidden */
  20907. _markAllSubMeshesAsTexturesDirty(): void;
  20908. /**
  20909. * Instantiate a new istance of clear coat configuration.
  20910. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20911. */
  20912. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20913. /**
  20914. * Gets wehter the submesh is ready to be used or not.
  20915. * @param defines the list of "defines" to update.
  20916. * @param scene defines the scene the material belongs to.
  20917. * @param engine defines the engine the material belongs to.
  20918. * @param disableBumpMap defines wether the material disables bump or not.
  20919. * @returns - boolean indicating that the submesh is ready or not.
  20920. */
  20921. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20922. /**
  20923. * Checks to see if a texture is used in the material.
  20924. * @param defines the list of "defines" to update.
  20925. * @param scene defines the scene to the material belongs to.
  20926. */
  20927. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20928. /**
  20929. * Binds the material data.
  20930. * @param uniformBuffer defines the Uniform buffer to fill in.
  20931. * @param scene defines the scene the material belongs to.
  20932. * @param engine defines the engine the material belongs to.
  20933. * @param disableBumpMap defines wether the material disables bump or not.
  20934. * @param isFrozen defines wether the material is frozen or not.
  20935. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20936. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20937. * @param subMesh the submesh to bind data for
  20938. */
  20939. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20940. /**
  20941. * Checks to see if a texture is used in the material.
  20942. * @param texture - Base texture to use.
  20943. * @returns - Boolean specifying if a texture is used in the material.
  20944. */
  20945. hasTexture(texture: BaseTexture): boolean;
  20946. /**
  20947. * Returns an array of the actively used textures.
  20948. * @param activeTextures Array of BaseTextures
  20949. */
  20950. getActiveTextures(activeTextures: BaseTexture[]): void;
  20951. /**
  20952. * Returns the animatable textures.
  20953. * @param animatables Array of animatable textures.
  20954. */
  20955. getAnimatables(animatables: IAnimatable[]): void;
  20956. /**
  20957. * Disposes the resources of the material.
  20958. * @param forceDisposeTextures - Forces the disposal of all textures.
  20959. */
  20960. dispose(forceDisposeTextures?: boolean): void;
  20961. /**
  20962. * Get the current class name of the texture useful for serialization or dynamic coding.
  20963. * @returns "PBRClearCoatConfiguration"
  20964. */
  20965. getClassName(): string;
  20966. /**
  20967. * Add fallbacks to the effect fallbacks list.
  20968. * @param defines defines the Base texture to use.
  20969. * @param fallbacks defines the current fallback list.
  20970. * @param currentRank defines the current fallback rank.
  20971. * @returns the new fallback rank.
  20972. */
  20973. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20974. /**
  20975. * Add the required uniforms to the current list.
  20976. * @param uniforms defines the current uniform list.
  20977. */
  20978. static AddUniforms(uniforms: string[]): void;
  20979. /**
  20980. * Add the required samplers to the current list.
  20981. * @param samplers defines the current sampler list.
  20982. */
  20983. static AddSamplers(samplers: string[]): void;
  20984. /**
  20985. * Add the required uniforms to the current buffer.
  20986. * @param uniformBuffer defines the current uniform buffer.
  20987. */
  20988. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20989. /**
  20990. * Makes a duplicate of the current configuration into another one.
  20991. * @param clearCoatConfiguration define the config where to copy the info
  20992. */
  20993. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20994. /**
  20995. * Serializes this clear coat configuration.
  20996. * @returns - An object with the serialized config.
  20997. */
  20998. serialize(): any;
  20999. /**
  21000. * Parses a anisotropy Configuration from a serialized object.
  21001. * @param source - Serialized object.
  21002. * @param scene Defines the scene we are parsing for
  21003. * @param rootUrl Defines the rootUrl to load from
  21004. */
  21005. parse(source: any, scene: Scene, rootUrl: string): void;
  21006. }
  21007. }
  21008. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  21009. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21011. import { Vector2 } from "babylonjs/Maths/math.vector";
  21012. import { Scene } from "babylonjs/scene";
  21013. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21014. import { Nullable } from "babylonjs/types";
  21015. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21016. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21017. /**
  21018. * @hidden
  21019. */
  21020. export interface IMaterialAnisotropicDefines {
  21021. ANISOTROPIC: boolean;
  21022. ANISOTROPIC_TEXTURE: boolean;
  21023. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21024. MAINUV1: boolean;
  21025. _areTexturesDirty: boolean;
  21026. _needUVs: boolean;
  21027. }
  21028. /**
  21029. * Define the code related to the anisotropic parameters of the pbr material.
  21030. */
  21031. export class PBRAnisotropicConfiguration {
  21032. private _isEnabled;
  21033. /**
  21034. * Defines if the anisotropy is enabled in the material.
  21035. */
  21036. isEnabled: boolean;
  21037. /**
  21038. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  21039. */
  21040. intensity: number;
  21041. /**
  21042. * Defines if the effect is along the tangents, bitangents or in between.
  21043. * By default, the effect is "strectching" the highlights along the tangents.
  21044. */
  21045. direction: Vector2;
  21046. private _texture;
  21047. /**
  21048. * Stores the anisotropy values in a texture.
  21049. * rg is direction (like normal from -1 to 1)
  21050. * b is a intensity
  21051. */
  21052. texture: Nullable<BaseTexture>;
  21053. /** @hidden */
  21054. private _internalMarkAllSubMeshesAsTexturesDirty;
  21055. /** @hidden */
  21056. _markAllSubMeshesAsTexturesDirty(): void;
  21057. /**
  21058. * Instantiate a new istance of anisotropy configuration.
  21059. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21060. */
  21061. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21062. /**
  21063. * Specifies that the submesh is ready to be used.
  21064. * @param defines the list of "defines" to update.
  21065. * @param scene defines the scene the material belongs to.
  21066. * @returns - boolean indicating that the submesh is ready or not.
  21067. */
  21068. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  21069. /**
  21070. * Checks to see if a texture is used in the material.
  21071. * @param defines the list of "defines" to update.
  21072. * @param mesh the mesh we are preparing the defines for.
  21073. * @param scene defines the scene the material belongs to.
  21074. */
  21075. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  21076. /**
  21077. * Binds the material data.
  21078. * @param uniformBuffer defines the Uniform buffer to fill in.
  21079. * @param scene defines the scene the material belongs to.
  21080. * @param isFrozen defines wether the material is frozen or not.
  21081. */
  21082. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  21083. /**
  21084. * Checks to see if a texture is used in the material.
  21085. * @param texture - Base texture to use.
  21086. * @returns - Boolean specifying if a texture is used in the material.
  21087. */
  21088. hasTexture(texture: BaseTexture): boolean;
  21089. /**
  21090. * Returns an array of the actively used textures.
  21091. * @param activeTextures Array of BaseTextures
  21092. */
  21093. getActiveTextures(activeTextures: BaseTexture[]): void;
  21094. /**
  21095. * Returns the animatable textures.
  21096. * @param animatables Array of animatable textures.
  21097. */
  21098. getAnimatables(animatables: IAnimatable[]): void;
  21099. /**
  21100. * Disposes the resources of the material.
  21101. * @param forceDisposeTextures - Forces the disposal of all textures.
  21102. */
  21103. dispose(forceDisposeTextures?: boolean): void;
  21104. /**
  21105. * Get the current class name of the texture useful for serialization or dynamic coding.
  21106. * @returns "PBRAnisotropicConfiguration"
  21107. */
  21108. getClassName(): string;
  21109. /**
  21110. * Add fallbacks to the effect fallbacks list.
  21111. * @param defines defines the Base texture to use.
  21112. * @param fallbacks defines the current fallback list.
  21113. * @param currentRank defines the current fallback rank.
  21114. * @returns the new fallback rank.
  21115. */
  21116. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21117. /**
  21118. * Add the required uniforms to the current list.
  21119. * @param uniforms defines the current uniform list.
  21120. */
  21121. static AddUniforms(uniforms: string[]): void;
  21122. /**
  21123. * Add the required uniforms to the current buffer.
  21124. * @param uniformBuffer defines the current uniform buffer.
  21125. */
  21126. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21127. /**
  21128. * Add the required samplers to the current list.
  21129. * @param samplers defines the current sampler list.
  21130. */
  21131. static AddSamplers(samplers: string[]): void;
  21132. /**
  21133. * Makes a duplicate of the current configuration into another one.
  21134. * @param anisotropicConfiguration define the config where to copy the info
  21135. */
  21136. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  21137. /**
  21138. * Serializes this anisotropy configuration.
  21139. * @returns - An object with the serialized config.
  21140. */
  21141. serialize(): any;
  21142. /**
  21143. * Parses a anisotropy Configuration from a serialized object.
  21144. * @param source - Serialized object.
  21145. * @param scene Defines the scene we are parsing for
  21146. * @param rootUrl Defines the rootUrl to load from
  21147. */
  21148. parse(source: any, scene: Scene, rootUrl: string): void;
  21149. }
  21150. }
  21151. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  21152. import { Scene } from "babylonjs/scene";
  21153. /**
  21154. * @hidden
  21155. */
  21156. export interface IMaterialBRDFDefines {
  21157. BRDF_V_HEIGHT_CORRELATED: boolean;
  21158. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21159. SPHERICAL_HARMONICS: boolean;
  21160. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21161. /** @hidden */
  21162. _areMiscDirty: boolean;
  21163. }
  21164. /**
  21165. * Define the code related to the BRDF parameters of the pbr material.
  21166. */
  21167. export class PBRBRDFConfiguration {
  21168. /**
  21169. * Default value used for the energy conservation.
  21170. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21171. */
  21172. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  21173. /**
  21174. * Default value used for the Smith Visibility Height Correlated mode.
  21175. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21176. */
  21177. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  21178. /**
  21179. * Default value used for the IBL diffuse part.
  21180. * This can help switching back to the polynomials mode globally which is a tiny bit
  21181. * less GPU intensive at the drawback of a lower quality.
  21182. */
  21183. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  21184. /**
  21185. * Default value used for activating energy conservation for the specular workflow.
  21186. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21187. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21188. */
  21189. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  21190. private _useEnergyConservation;
  21191. /**
  21192. * Defines if the material uses energy conservation.
  21193. */
  21194. useEnergyConservation: boolean;
  21195. private _useSmithVisibilityHeightCorrelated;
  21196. /**
  21197. * LEGACY Mode set to false
  21198. * Defines if the material uses height smith correlated visibility term.
  21199. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  21200. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  21201. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  21202. * Not relying on height correlated will also disable energy conservation.
  21203. */
  21204. useSmithVisibilityHeightCorrelated: boolean;
  21205. private _useSphericalHarmonics;
  21206. /**
  21207. * LEGACY Mode set to false
  21208. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  21209. * diffuse part of the IBL.
  21210. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  21211. * to the ground truth.
  21212. */
  21213. useSphericalHarmonics: boolean;
  21214. private _useSpecularGlossinessInputEnergyConservation;
  21215. /**
  21216. * Defines if the material uses energy conservation, when the specular workflow is active.
  21217. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21218. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21219. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  21220. */
  21221. useSpecularGlossinessInputEnergyConservation: boolean;
  21222. /** @hidden */
  21223. private _internalMarkAllSubMeshesAsMiscDirty;
  21224. /** @hidden */
  21225. _markAllSubMeshesAsMiscDirty(): void;
  21226. /**
  21227. * Instantiate a new istance of clear coat configuration.
  21228. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  21229. */
  21230. constructor(markAllSubMeshesAsMiscDirty: () => void);
  21231. /**
  21232. * Checks to see if a texture is used in the material.
  21233. * @param defines the list of "defines" to update.
  21234. */
  21235. prepareDefines(defines: IMaterialBRDFDefines): void;
  21236. /**
  21237. * Get the current class name of the texture useful for serialization or dynamic coding.
  21238. * @returns "PBRClearCoatConfiguration"
  21239. */
  21240. getClassName(): string;
  21241. /**
  21242. * Makes a duplicate of the current configuration into another one.
  21243. * @param brdfConfiguration define the config where to copy the info
  21244. */
  21245. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  21246. /**
  21247. * Serializes this BRDF configuration.
  21248. * @returns - An object with the serialized config.
  21249. */
  21250. serialize(): any;
  21251. /**
  21252. * Parses a anisotropy Configuration from a serialized object.
  21253. * @param source - Serialized object.
  21254. * @param scene Defines the scene we are parsing for
  21255. * @param rootUrl Defines the rootUrl to load from
  21256. */
  21257. parse(source: any, scene: Scene, rootUrl: string): void;
  21258. }
  21259. }
  21260. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  21261. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21262. import { Color3 } from "babylonjs/Maths/math.color";
  21263. import { Scene } from "babylonjs/scene";
  21264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21265. import { Nullable } from "babylonjs/types";
  21266. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21267. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21268. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21269. /**
  21270. * @hidden
  21271. */
  21272. export interface IMaterialSheenDefines {
  21273. SHEEN: boolean;
  21274. SHEEN_TEXTURE: boolean;
  21275. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21276. SHEEN_TEXTUREDIRECTUV: number;
  21277. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21278. SHEEN_LINKWITHALBEDO: boolean;
  21279. SHEEN_ROUGHNESS: boolean;
  21280. SHEEN_ALBEDOSCALING: boolean;
  21281. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21282. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21283. /** @hidden */
  21284. _areTexturesDirty: boolean;
  21285. }
  21286. /**
  21287. * Define the code related to the Sheen parameters of the pbr material.
  21288. */
  21289. export class PBRSheenConfiguration {
  21290. private _isEnabled;
  21291. /**
  21292. * Defines if the material uses sheen.
  21293. */
  21294. isEnabled: boolean;
  21295. private _linkSheenWithAlbedo;
  21296. /**
  21297. * Defines if the sheen is linked to the sheen color.
  21298. */
  21299. linkSheenWithAlbedo: boolean;
  21300. /**
  21301. * Defines the sheen intensity.
  21302. */
  21303. intensity: number;
  21304. /**
  21305. * Defines the sheen color.
  21306. */
  21307. color: Color3;
  21308. private _texture;
  21309. /**
  21310. * Stores the sheen tint values in a texture.
  21311. * rgb is tint
  21312. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  21313. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  21314. */
  21315. texture: Nullable<BaseTexture>;
  21316. private _useRoughnessFromMainTexture;
  21317. /**
  21318. * Indicates that the alpha channel of the texture property will be used for roughness.
  21319. * Has no effect if the roughness (and texture!) property is not defined
  21320. */
  21321. useRoughnessFromMainTexture: boolean;
  21322. private _roughness;
  21323. /**
  21324. * Defines the sheen roughness.
  21325. * It is not taken into account if linkSheenWithAlbedo is true.
  21326. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  21327. */
  21328. roughness: Nullable<number>;
  21329. private _textureRoughness;
  21330. /**
  21331. * Stores the sheen roughness in a texture.
  21332. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  21333. */
  21334. textureRoughness: Nullable<BaseTexture>;
  21335. private _albedoScaling;
  21336. /**
  21337. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  21338. * It allows the strength of the sheen effect to not depend on the base color of the material,
  21339. * making it easier to setup and tweak the effect
  21340. */
  21341. albedoScaling: boolean;
  21342. /** @hidden */
  21343. private _internalMarkAllSubMeshesAsTexturesDirty;
  21344. /** @hidden */
  21345. _markAllSubMeshesAsTexturesDirty(): void;
  21346. /**
  21347. * Instantiate a new istance of clear coat configuration.
  21348. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21349. */
  21350. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21351. /**
  21352. * Specifies that the submesh is ready to be used.
  21353. * @param defines the list of "defines" to update.
  21354. * @param scene defines the scene the material belongs to.
  21355. * @returns - boolean indicating that the submesh is ready or not.
  21356. */
  21357. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  21358. /**
  21359. * Checks to see if a texture is used in the material.
  21360. * @param defines the list of "defines" to update.
  21361. * @param scene defines the scene the material belongs to.
  21362. */
  21363. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  21364. /**
  21365. * Binds the material data.
  21366. * @param uniformBuffer defines the Uniform buffer to fill in.
  21367. * @param scene defines the scene the material belongs to.
  21368. * @param isFrozen defines wether the material is frozen or not.
  21369. * @param subMesh the submesh to bind data for
  21370. */
  21371. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  21372. /**
  21373. * Checks to see if a texture is used in the material.
  21374. * @param texture - Base texture to use.
  21375. * @returns - Boolean specifying if a texture is used in the material.
  21376. */
  21377. hasTexture(texture: BaseTexture): boolean;
  21378. /**
  21379. * Returns an array of the actively used textures.
  21380. * @param activeTextures Array of BaseTextures
  21381. */
  21382. getActiveTextures(activeTextures: BaseTexture[]): void;
  21383. /**
  21384. * Returns the animatable textures.
  21385. * @param animatables Array of animatable textures.
  21386. */
  21387. getAnimatables(animatables: IAnimatable[]): void;
  21388. /**
  21389. * Disposes the resources of the material.
  21390. * @param forceDisposeTextures - Forces the disposal of all textures.
  21391. */
  21392. dispose(forceDisposeTextures?: boolean): void;
  21393. /**
  21394. * Get the current class name of the texture useful for serialization or dynamic coding.
  21395. * @returns "PBRSheenConfiguration"
  21396. */
  21397. getClassName(): string;
  21398. /**
  21399. * Add fallbacks to the effect fallbacks list.
  21400. * @param defines defines the Base texture to use.
  21401. * @param fallbacks defines the current fallback list.
  21402. * @param currentRank defines the current fallback rank.
  21403. * @returns the new fallback rank.
  21404. */
  21405. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21406. /**
  21407. * Add the required uniforms to the current list.
  21408. * @param uniforms defines the current uniform list.
  21409. */
  21410. static AddUniforms(uniforms: string[]): void;
  21411. /**
  21412. * Add the required uniforms to the current buffer.
  21413. * @param uniformBuffer defines the current uniform buffer.
  21414. */
  21415. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21416. /**
  21417. * Add the required samplers to the current list.
  21418. * @param samplers defines the current sampler list.
  21419. */
  21420. static AddSamplers(samplers: string[]): void;
  21421. /**
  21422. * Makes a duplicate of the current configuration into another one.
  21423. * @param sheenConfiguration define the config where to copy the info
  21424. */
  21425. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  21426. /**
  21427. * Serializes this BRDF configuration.
  21428. * @returns - An object with the serialized config.
  21429. */
  21430. serialize(): any;
  21431. /**
  21432. * Parses a anisotropy Configuration from a serialized object.
  21433. * @param source - Serialized object.
  21434. * @param scene Defines the scene we are parsing for
  21435. * @param rootUrl Defines the rootUrl to load from
  21436. */
  21437. parse(source: any, scene: Scene, rootUrl: string): void;
  21438. }
  21439. }
  21440. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  21441. import { Nullable } from "babylonjs/types";
  21442. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21443. import { Color3 } from "babylonjs/Maths/math.color";
  21444. import { SmartArray } from "babylonjs/Misc/smartArray";
  21445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21447. import { Effect } from "babylonjs/Materials/effect";
  21448. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21449. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21450. import { Engine } from "babylonjs/Engines/engine";
  21451. import { Scene } from "babylonjs/scene";
  21452. /**
  21453. * @hidden
  21454. */
  21455. export interface IMaterialSubSurfaceDefines {
  21456. SUBSURFACE: boolean;
  21457. SS_REFRACTION: boolean;
  21458. SS_TRANSLUCENCY: boolean;
  21459. SS_SCATTERING: boolean;
  21460. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21461. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21462. SS_REFRACTIONMAP_3D: boolean;
  21463. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21464. SS_LODINREFRACTIONALPHA: boolean;
  21465. SS_GAMMAREFRACTION: boolean;
  21466. SS_RGBDREFRACTION: boolean;
  21467. SS_LINEARSPECULARREFRACTION: boolean;
  21468. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21469. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21470. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21471. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21472. /** @hidden */
  21473. _areTexturesDirty: boolean;
  21474. }
  21475. /**
  21476. * Define the code related to the sub surface parameters of the pbr material.
  21477. */
  21478. export class PBRSubSurfaceConfiguration {
  21479. private _isRefractionEnabled;
  21480. /**
  21481. * Defines if the refraction is enabled in the material.
  21482. */
  21483. isRefractionEnabled: boolean;
  21484. private _isTranslucencyEnabled;
  21485. /**
  21486. * Defines if the translucency is enabled in the material.
  21487. */
  21488. isTranslucencyEnabled: boolean;
  21489. private _isScatteringEnabled;
  21490. /**
  21491. * Defines if the sub surface scattering is enabled in the material.
  21492. */
  21493. isScatteringEnabled: boolean;
  21494. private _scatteringDiffusionProfileIndex;
  21495. /**
  21496. * Diffusion profile for subsurface scattering.
  21497. * Useful for better scattering in the skins or foliages.
  21498. */
  21499. get scatteringDiffusionProfile(): Nullable<Color3>;
  21500. set scatteringDiffusionProfile(c: Nullable<Color3>);
  21501. /**
  21502. * Defines the refraction intensity of the material.
  21503. * The refraction when enabled replaces the Diffuse part of the material.
  21504. * The intensity helps transitionning between diffuse and refraction.
  21505. */
  21506. refractionIntensity: number;
  21507. /**
  21508. * Defines the translucency intensity of the material.
  21509. * When translucency has been enabled, this defines how much of the "translucency"
  21510. * is addded to the diffuse part of the material.
  21511. */
  21512. translucencyIntensity: number;
  21513. /**
  21514. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  21515. */
  21516. useAlbedoToTintRefraction: boolean;
  21517. private _thicknessTexture;
  21518. /**
  21519. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  21520. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  21521. * 0 would mean minimumThickness
  21522. * 1 would mean maximumThickness
  21523. * The other channels might be use as a mask to vary the different effects intensity.
  21524. */
  21525. thicknessTexture: Nullable<BaseTexture>;
  21526. private _refractionTexture;
  21527. /**
  21528. * Defines the texture to use for refraction.
  21529. */
  21530. refractionTexture: Nullable<BaseTexture>;
  21531. private _indexOfRefraction;
  21532. /**
  21533. * Index of refraction of the material base layer.
  21534. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21535. *
  21536. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21537. *
  21538. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21539. */
  21540. indexOfRefraction: number;
  21541. private _volumeIndexOfRefraction;
  21542. /**
  21543. * Index of refraction of the material's volume.
  21544. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21545. *
  21546. * This ONLY impacts refraction. If not provided or given a non-valid value,
  21547. * the volume will use the same IOR as the surface.
  21548. */
  21549. get volumeIndexOfRefraction(): number;
  21550. set volumeIndexOfRefraction(value: number);
  21551. private _invertRefractionY;
  21552. /**
  21553. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21554. */
  21555. invertRefractionY: boolean;
  21556. private _linkRefractionWithTransparency;
  21557. /**
  21558. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21559. * Materials half opaque for instance using refraction could benefit from this control.
  21560. */
  21561. linkRefractionWithTransparency: boolean;
  21562. /**
  21563. * Defines the minimum thickness stored in the thickness map.
  21564. * If no thickness map is defined, this value will be used to simulate thickness.
  21565. */
  21566. minimumThickness: number;
  21567. /**
  21568. * Defines the maximum thickness stored in the thickness map.
  21569. */
  21570. maximumThickness: number;
  21571. /**
  21572. * Defines the volume tint of the material.
  21573. * This is used for both translucency and scattering.
  21574. */
  21575. tintColor: Color3;
  21576. /**
  21577. * Defines the distance at which the tint color should be found in the media.
  21578. * This is used for refraction only.
  21579. */
  21580. tintColorAtDistance: number;
  21581. /**
  21582. * Defines how far each channel transmit through the media.
  21583. * It is defined as a color to simplify it selection.
  21584. */
  21585. diffusionDistance: Color3;
  21586. private _useMaskFromThicknessTexture;
  21587. /**
  21588. * Stores the intensity of the different subsurface effects in the thickness texture.
  21589. * * the green channel is the translucency intensity.
  21590. * * the blue channel is the scattering intensity.
  21591. * * the alpha channel is the refraction intensity.
  21592. */
  21593. useMaskFromThicknessTexture: boolean;
  21594. private _scene;
  21595. private _useMaskFromThicknessTextureGltf;
  21596. /**
  21597. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21598. * matches the channel-packing that is used by glTF.
  21599. * * the red channel is the transmission/translucency intensity.
  21600. * * the green channel is the thickness.
  21601. */
  21602. useMaskFromThicknessTextureGltf: boolean;
  21603. /** @hidden */
  21604. private _internalMarkAllSubMeshesAsTexturesDirty;
  21605. private _internalMarkScenePrePassDirty;
  21606. /** @hidden */
  21607. _markAllSubMeshesAsTexturesDirty(): void;
  21608. /** @hidden */
  21609. _markScenePrePassDirty(): void;
  21610. /**
  21611. * Instantiate a new istance of sub surface configuration.
  21612. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21613. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21614. * @param scene The scene
  21615. */
  21616. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21617. /**
  21618. * Gets wehter the submesh is ready to be used or not.
  21619. * @param defines the list of "defines" to update.
  21620. * @param scene defines the scene the material belongs to.
  21621. * @returns - boolean indicating that the submesh is ready or not.
  21622. */
  21623. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21624. /**
  21625. * Checks to see if a texture is used in the material.
  21626. * @param defines the list of "defines" to update.
  21627. * @param scene defines the scene to the material belongs to.
  21628. */
  21629. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21630. /**
  21631. * Binds the material data.
  21632. * @param uniformBuffer defines the Uniform buffer to fill in.
  21633. * @param scene defines the scene the material belongs to.
  21634. * @param engine defines the engine the material belongs to.
  21635. * @param isFrozen defines whether the material is frozen or not.
  21636. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21637. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21638. */
  21639. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21640. /**
  21641. * Unbinds the material from the mesh.
  21642. * @param activeEffect defines the effect that should be unbound from.
  21643. * @returns true if unbound, otherwise false
  21644. */
  21645. unbind(activeEffect: Effect): boolean;
  21646. /**
  21647. * Returns the texture used for refraction or null if none is used.
  21648. * @param scene defines the scene the material belongs to.
  21649. * @returns - Refraction texture if present. If no refraction texture and refraction
  21650. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21651. */
  21652. private _getRefractionTexture;
  21653. /**
  21654. * Returns true if alpha blending should be disabled.
  21655. */
  21656. get disableAlphaBlending(): boolean;
  21657. /**
  21658. * Fills the list of render target textures.
  21659. * @param renderTargets the list of render targets to update
  21660. */
  21661. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21662. /**
  21663. * Checks to see if a texture is used in the material.
  21664. * @param texture - Base texture to use.
  21665. * @returns - Boolean specifying if a texture is used in the material.
  21666. */
  21667. hasTexture(texture: BaseTexture): boolean;
  21668. /**
  21669. * Gets a boolean indicating that current material needs to register RTT
  21670. * @returns true if this uses a render target otherwise false.
  21671. */
  21672. hasRenderTargetTextures(): boolean;
  21673. /**
  21674. * Returns an array of the actively used textures.
  21675. * @param activeTextures Array of BaseTextures
  21676. */
  21677. getActiveTextures(activeTextures: BaseTexture[]): void;
  21678. /**
  21679. * Returns the animatable textures.
  21680. * @param animatables Array of animatable textures.
  21681. */
  21682. getAnimatables(animatables: IAnimatable[]): void;
  21683. /**
  21684. * Disposes the resources of the material.
  21685. * @param forceDisposeTextures - Forces the disposal of all textures.
  21686. */
  21687. dispose(forceDisposeTextures?: boolean): void;
  21688. /**
  21689. * Get the current class name of the texture useful for serialization or dynamic coding.
  21690. * @returns "PBRSubSurfaceConfiguration"
  21691. */
  21692. getClassName(): string;
  21693. /**
  21694. * Add fallbacks to the effect fallbacks list.
  21695. * @param defines defines the Base texture to use.
  21696. * @param fallbacks defines the current fallback list.
  21697. * @param currentRank defines the current fallback rank.
  21698. * @returns the new fallback rank.
  21699. */
  21700. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21701. /**
  21702. * Add the required uniforms to the current list.
  21703. * @param uniforms defines the current uniform list.
  21704. */
  21705. static AddUniforms(uniforms: string[]): void;
  21706. /**
  21707. * Add the required samplers to the current list.
  21708. * @param samplers defines the current sampler list.
  21709. */
  21710. static AddSamplers(samplers: string[]): void;
  21711. /**
  21712. * Add the required uniforms to the current buffer.
  21713. * @param uniformBuffer defines the current uniform buffer.
  21714. */
  21715. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21716. /**
  21717. * Makes a duplicate of the current configuration into another one.
  21718. * @param configuration define the config where to copy the info
  21719. */
  21720. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21721. /**
  21722. * Serializes this Sub Surface configuration.
  21723. * @returns - An object with the serialized config.
  21724. */
  21725. serialize(): any;
  21726. /**
  21727. * Parses a anisotropy Configuration from a serialized object.
  21728. * @param source - Serialized object.
  21729. * @param scene Defines the scene we are parsing for
  21730. * @param rootUrl Defines the rootUrl to load from
  21731. */
  21732. parse(source: any, scene: Scene, rootUrl: string): void;
  21733. }
  21734. }
  21735. declare module "babylonjs/Maths/sphericalPolynomial" {
  21736. import { Vector3 } from "babylonjs/Maths/math.vector";
  21737. import { Color3 } from "babylonjs/Maths/math.color";
  21738. /**
  21739. * Class representing spherical harmonics coefficients to the 3rd degree
  21740. */
  21741. export class SphericalHarmonics {
  21742. /**
  21743. * Defines whether or not the harmonics have been prescaled for rendering.
  21744. */
  21745. preScaled: boolean;
  21746. /**
  21747. * The l0,0 coefficients of the spherical harmonics
  21748. */
  21749. l00: Vector3;
  21750. /**
  21751. * The l1,-1 coefficients of the spherical harmonics
  21752. */
  21753. l1_1: Vector3;
  21754. /**
  21755. * The l1,0 coefficients of the spherical harmonics
  21756. */
  21757. l10: Vector3;
  21758. /**
  21759. * The l1,1 coefficients of the spherical harmonics
  21760. */
  21761. l11: Vector3;
  21762. /**
  21763. * The l2,-2 coefficients of the spherical harmonics
  21764. */
  21765. l2_2: Vector3;
  21766. /**
  21767. * The l2,-1 coefficients of the spherical harmonics
  21768. */
  21769. l2_1: Vector3;
  21770. /**
  21771. * The l2,0 coefficients of the spherical harmonics
  21772. */
  21773. l20: Vector3;
  21774. /**
  21775. * The l2,1 coefficients of the spherical harmonics
  21776. */
  21777. l21: Vector3;
  21778. /**
  21779. * The l2,2 coefficients of the spherical harmonics
  21780. */
  21781. l22: Vector3;
  21782. /**
  21783. * Adds a light to the spherical harmonics
  21784. * @param direction the direction of the light
  21785. * @param color the color of the light
  21786. * @param deltaSolidAngle the delta solid angle of the light
  21787. */
  21788. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21789. /**
  21790. * Scales the spherical harmonics by the given amount
  21791. * @param scale the amount to scale
  21792. */
  21793. scaleInPlace(scale: number): void;
  21794. /**
  21795. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21796. *
  21797. * ```
  21798. * E_lm = A_l * L_lm
  21799. * ```
  21800. *
  21801. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21802. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21803. * the scaling factors are given in equation 9.
  21804. */
  21805. convertIncidentRadianceToIrradiance(): void;
  21806. /**
  21807. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21808. *
  21809. * ```
  21810. * L = (1/pi) * E * rho
  21811. * ```
  21812. *
  21813. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21814. */
  21815. convertIrradianceToLambertianRadiance(): void;
  21816. /**
  21817. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21818. * required operations at run time.
  21819. *
  21820. * This is simply done by scaling back the SH with Ylm constants parameter.
  21821. * The trigonometric part being applied by the shader at run time.
  21822. */
  21823. preScaleForRendering(): void;
  21824. /**
  21825. * Constructs a spherical harmonics from an array.
  21826. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21827. * @returns the spherical harmonics
  21828. */
  21829. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21830. /**
  21831. * Gets the spherical harmonics from polynomial
  21832. * @param polynomial the spherical polynomial
  21833. * @returns the spherical harmonics
  21834. */
  21835. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21836. }
  21837. /**
  21838. * Class representing spherical polynomial coefficients to the 3rd degree
  21839. */
  21840. export class SphericalPolynomial {
  21841. private _harmonics;
  21842. /**
  21843. * The spherical harmonics used to create the polynomials.
  21844. */
  21845. get preScaledHarmonics(): SphericalHarmonics;
  21846. /**
  21847. * The x coefficients of the spherical polynomial
  21848. */
  21849. x: Vector3;
  21850. /**
  21851. * The y coefficients of the spherical polynomial
  21852. */
  21853. y: Vector3;
  21854. /**
  21855. * The z coefficients of the spherical polynomial
  21856. */
  21857. z: Vector3;
  21858. /**
  21859. * The xx coefficients of the spherical polynomial
  21860. */
  21861. xx: Vector3;
  21862. /**
  21863. * The yy coefficients of the spherical polynomial
  21864. */
  21865. yy: Vector3;
  21866. /**
  21867. * The zz coefficients of the spherical polynomial
  21868. */
  21869. zz: Vector3;
  21870. /**
  21871. * The xy coefficients of the spherical polynomial
  21872. */
  21873. xy: Vector3;
  21874. /**
  21875. * The yz coefficients of the spherical polynomial
  21876. */
  21877. yz: Vector3;
  21878. /**
  21879. * The zx coefficients of the spherical polynomial
  21880. */
  21881. zx: Vector3;
  21882. /**
  21883. * Adds an ambient color to the spherical polynomial
  21884. * @param color the color to add
  21885. */
  21886. addAmbient(color: Color3): void;
  21887. /**
  21888. * Scales the spherical polynomial by the given amount
  21889. * @param scale the amount to scale
  21890. */
  21891. scaleInPlace(scale: number): void;
  21892. /**
  21893. * Gets the spherical polynomial from harmonics
  21894. * @param harmonics the spherical harmonics
  21895. * @returns the spherical polynomial
  21896. */
  21897. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21898. /**
  21899. * Constructs a spherical polynomial from an array.
  21900. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21901. * @returns the spherical polynomial
  21902. */
  21903. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21904. }
  21905. }
  21906. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21907. import { Nullable } from "babylonjs/types";
  21908. /**
  21909. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21910. */
  21911. export interface CubeMapInfo {
  21912. /**
  21913. * The pixel array for the front face.
  21914. * This is stored in format, left to right, up to down format.
  21915. */
  21916. front: Nullable<ArrayBufferView>;
  21917. /**
  21918. * The pixel array for the back face.
  21919. * This is stored in format, left to right, up to down format.
  21920. */
  21921. back: Nullable<ArrayBufferView>;
  21922. /**
  21923. * The pixel array for the left face.
  21924. * This is stored in format, left to right, up to down format.
  21925. */
  21926. left: Nullable<ArrayBufferView>;
  21927. /**
  21928. * The pixel array for the right face.
  21929. * This is stored in format, left to right, up to down format.
  21930. */
  21931. right: Nullable<ArrayBufferView>;
  21932. /**
  21933. * The pixel array for the up face.
  21934. * This is stored in format, left to right, up to down format.
  21935. */
  21936. up: Nullable<ArrayBufferView>;
  21937. /**
  21938. * The pixel array for the down face.
  21939. * This is stored in format, left to right, up to down format.
  21940. */
  21941. down: Nullable<ArrayBufferView>;
  21942. /**
  21943. * The size of the cubemap stored.
  21944. *
  21945. * Each faces will be size * size pixels.
  21946. */
  21947. size: number;
  21948. /**
  21949. * The format of the texture.
  21950. *
  21951. * RGBA, RGB.
  21952. */
  21953. format: number;
  21954. /**
  21955. * The type of the texture data.
  21956. *
  21957. * UNSIGNED_INT, FLOAT.
  21958. */
  21959. type: number;
  21960. /**
  21961. * Specifies whether the texture is in gamma space.
  21962. */
  21963. gammaSpace: boolean;
  21964. }
  21965. /**
  21966. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21967. */
  21968. export class PanoramaToCubeMapTools {
  21969. private static FACE_LEFT;
  21970. private static FACE_RIGHT;
  21971. private static FACE_FRONT;
  21972. private static FACE_BACK;
  21973. private static FACE_DOWN;
  21974. private static FACE_UP;
  21975. /**
  21976. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21977. *
  21978. * @param float32Array The source data.
  21979. * @param inputWidth The width of the input panorama.
  21980. * @param inputHeight The height of the input panorama.
  21981. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21982. * @return The cubemap data
  21983. */
  21984. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21985. private static CreateCubemapTexture;
  21986. private static CalcProjectionSpherical;
  21987. }
  21988. }
  21989. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21990. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21992. import { Nullable } from "babylonjs/types";
  21993. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21994. /**
  21995. * Helper class dealing with the extraction of spherical polynomial dataArray
  21996. * from a cube map.
  21997. */
  21998. export class CubeMapToSphericalPolynomialTools {
  21999. private static FileFaces;
  22000. /**
  22001. * Converts a texture to the according Spherical Polynomial data.
  22002. * This extracts the first 3 orders only as they are the only one used in the lighting.
  22003. *
  22004. * @param texture The texture to extract the information from.
  22005. * @return The Spherical Polynomial data.
  22006. */
  22007. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  22008. /**
  22009. * Converts a cubemap to the according Spherical Polynomial data.
  22010. * This extracts the first 3 orders only as they are the only one used in the lighting.
  22011. *
  22012. * @param cubeInfo The Cube map to extract the information from.
  22013. * @return The Spherical Polynomial data.
  22014. */
  22015. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  22016. }
  22017. }
  22018. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  22019. import { Nullable } from "babylonjs/types";
  22020. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  22021. module "babylonjs/Materials/Textures/baseTexture" {
  22022. interface BaseTexture {
  22023. /**
  22024. * Get the polynomial representation of the texture data.
  22025. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  22026. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  22027. */
  22028. sphericalPolynomial: Nullable<SphericalPolynomial>;
  22029. }
  22030. }
  22031. }
  22032. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  22033. /** @hidden */
  22034. export var pbrFragmentDeclaration: {
  22035. name: string;
  22036. shader: string;
  22037. };
  22038. }
  22039. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  22040. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  22041. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  22042. /** @hidden */
  22043. export var pbrUboDeclaration: {
  22044. name: string;
  22045. shader: string;
  22046. };
  22047. }
  22048. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  22049. /** @hidden */
  22050. export var pbrFragmentExtraDeclaration: {
  22051. name: string;
  22052. shader: string;
  22053. };
  22054. }
  22055. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  22056. /** @hidden */
  22057. export var pbrFragmentSamplersDeclaration: {
  22058. name: string;
  22059. shader: string;
  22060. };
  22061. }
  22062. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  22063. /** @hidden */
  22064. export var subSurfaceScatteringFunctions: {
  22065. name: string;
  22066. shader: string;
  22067. };
  22068. }
  22069. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  22070. /** @hidden */
  22071. export var importanceSampling: {
  22072. name: string;
  22073. shader: string;
  22074. };
  22075. }
  22076. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  22077. /** @hidden */
  22078. export var pbrHelperFunctions: {
  22079. name: string;
  22080. shader: string;
  22081. };
  22082. }
  22083. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  22084. /** @hidden */
  22085. export var harmonicsFunctions: {
  22086. name: string;
  22087. shader: string;
  22088. };
  22089. }
  22090. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  22091. /** @hidden */
  22092. export var pbrDirectLightingSetupFunctions: {
  22093. name: string;
  22094. shader: string;
  22095. };
  22096. }
  22097. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  22098. /** @hidden */
  22099. export var pbrDirectLightingFalloffFunctions: {
  22100. name: string;
  22101. shader: string;
  22102. };
  22103. }
  22104. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  22105. /** @hidden */
  22106. export var pbrBRDFFunctions: {
  22107. name: string;
  22108. shader: string;
  22109. };
  22110. }
  22111. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  22112. /** @hidden */
  22113. export var hdrFilteringFunctions: {
  22114. name: string;
  22115. shader: string;
  22116. };
  22117. }
  22118. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  22119. /** @hidden */
  22120. export var pbrDirectLightingFunctions: {
  22121. name: string;
  22122. shader: string;
  22123. };
  22124. }
  22125. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  22126. /** @hidden */
  22127. export var pbrIBLFunctions: {
  22128. name: string;
  22129. shader: string;
  22130. };
  22131. }
  22132. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  22133. /** @hidden */
  22134. export var pbrBlockAlbedoOpacity: {
  22135. name: string;
  22136. shader: string;
  22137. };
  22138. }
  22139. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  22140. /** @hidden */
  22141. export var pbrBlockReflectivity: {
  22142. name: string;
  22143. shader: string;
  22144. };
  22145. }
  22146. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  22147. /** @hidden */
  22148. export var pbrBlockAmbientOcclusion: {
  22149. name: string;
  22150. shader: string;
  22151. };
  22152. }
  22153. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  22154. /** @hidden */
  22155. export var pbrBlockAlphaFresnel: {
  22156. name: string;
  22157. shader: string;
  22158. };
  22159. }
  22160. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  22161. /** @hidden */
  22162. export var pbrBlockAnisotropic: {
  22163. name: string;
  22164. shader: string;
  22165. };
  22166. }
  22167. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  22168. /** @hidden */
  22169. export var pbrBlockReflection: {
  22170. name: string;
  22171. shader: string;
  22172. };
  22173. }
  22174. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  22175. /** @hidden */
  22176. export var pbrBlockSheen: {
  22177. name: string;
  22178. shader: string;
  22179. };
  22180. }
  22181. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  22182. /** @hidden */
  22183. export var pbrBlockClearcoat: {
  22184. name: string;
  22185. shader: string;
  22186. };
  22187. }
  22188. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  22189. /** @hidden */
  22190. export var pbrBlockSubSurface: {
  22191. name: string;
  22192. shader: string;
  22193. };
  22194. }
  22195. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  22196. /** @hidden */
  22197. export var pbrBlockNormalGeometric: {
  22198. name: string;
  22199. shader: string;
  22200. };
  22201. }
  22202. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  22203. /** @hidden */
  22204. export var pbrBlockNormalFinal: {
  22205. name: string;
  22206. shader: string;
  22207. };
  22208. }
  22209. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  22210. /** @hidden */
  22211. export var pbrBlockLightmapInit: {
  22212. name: string;
  22213. shader: string;
  22214. };
  22215. }
  22216. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  22217. /** @hidden */
  22218. export var pbrBlockGeometryInfo: {
  22219. name: string;
  22220. shader: string;
  22221. };
  22222. }
  22223. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  22224. /** @hidden */
  22225. export var pbrBlockReflectance0: {
  22226. name: string;
  22227. shader: string;
  22228. };
  22229. }
  22230. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  22231. /** @hidden */
  22232. export var pbrBlockReflectance: {
  22233. name: string;
  22234. shader: string;
  22235. };
  22236. }
  22237. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  22238. /** @hidden */
  22239. export var pbrBlockDirectLighting: {
  22240. name: string;
  22241. shader: string;
  22242. };
  22243. }
  22244. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  22245. /** @hidden */
  22246. export var pbrBlockFinalLitComponents: {
  22247. name: string;
  22248. shader: string;
  22249. };
  22250. }
  22251. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  22252. /** @hidden */
  22253. export var pbrBlockFinalUnlitComponents: {
  22254. name: string;
  22255. shader: string;
  22256. };
  22257. }
  22258. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  22259. /** @hidden */
  22260. export var pbrBlockFinalColorComposition: {
  22261. name: string;
  22262. shader: string;
  22263. };
  22264. }
  22265. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  22266. /** @hidden */
  22267. export var pbrBlockImageProcessing: {
  22268. name: string;
  22269. shader: string;
  22270. };
  22271. }
  22272. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  22273. /** @hidden */
  22274. export var pbrDebug: {
  22275. name: string;
  22276. shader: string;
  22277. };
  22278. }
  22279. declare module "babylonjs/Shaders/pbr.fragment" {
  22280. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  22281. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  22282. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22283. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  22284. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  22285. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  22286. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  22287. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  22288. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  22289. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22290. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  22291. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22292. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  22293. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  22294. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  22295. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  22296. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  22297. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22298. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  22299. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  22300. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  22301. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  22302. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  22303. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  22304. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22305. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22306. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  22307. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  22308. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  22309. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  22310. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  22311. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  22312. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  22313. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  22314. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  22315. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  22316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  22317. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  22318. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22319. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  22320. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  22321. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  22322. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  22323. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  22324. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  22325. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  22326. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  22327. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  22328. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  22329. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  22330. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  22331. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  22332. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  22333. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  22334. /** @hidden */
  22335. export var pbrPixelShader: {
  22336. name: string;
  22337. shader: string;
  22338. };
  22339. }
  22340. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  22341. /** @hidden */
  22342. export var pbrVertexDeclaration: {
  22343. name: string;
  22344. shader: string;
  22345. };
  22346. }
  22347. declare module "babylonjs/Shaders/pbr.vertex" {
  22348. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  22349. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22351. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22352. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  22353. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22354. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  22355. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  22356. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  22357. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  22358. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  22359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22360. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22361. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22363. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22364. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22365. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  22366. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22367. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  22368. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  22369. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  22370. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  22371. /** @hidden */
  22372. export var pbrVertexShader: {
  22373. name: string;
  22374. shader: string;
  22375. };
  22376. }
  22377. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  22378. import { Nullable } from "babylonjs/types";
  22379. import { Scene } from "babylonjs/scene";
  22380. import { Matrix } from "babylonjs/Maths/math.vector";
  22381. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22383. import { Mesh } from "babylonjs/Meshes/mesh";
  22384. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  22385. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  22386. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  22387. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  22388. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  22389. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  22390. import { Color3 } from "babylonjs/Maths/math.color";
  22391. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22392. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  22393. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22394. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22396. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22397. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  22398. import "babylonjs/Shaders/pbr.fragment";
  22399. import "babylonjs/Shaders/pbr.vertex";
  22400. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  22401. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22402. /**
  22403. * Manages the defines for the PBR Material.
  22404. * @hidden
  22405. */
  22406. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  22407. PBR: boolean;
  22408. NUM_SAMPLES: string;
  22409. REALTIME_FILTERING: boolean;
  22410. MAINUV1: boolean;
  22411. MAINUV2: boolean;
  22412. UV1: boolean;
  22413. UV2: boolean;
  22414. ALBEDO: boolean;
  22415. GAMMAALBEDO: boolean;
  22416. ALBEDODIRECTUV: number;
  22417. VERTEXCOLOR: boolean;
  22418. DETAIL: boolean;
  22419. DETAILDIRECTUV: number;
  22420. DETAIL_NORMALBLENDMETHOD: number;
  22421. AMBIENT: boolean;
  22422. AMBIENTDIRECTUV: number;
  22423. AMBIENTINGRAYSCALE: boolean;
  22424. OPACITY: boolean;
  22425. VERTEXALPHA: boolean;
  22426. OPACITYDIRECTUV: number;
  22427. OPACITYRGB: boolean;
  22428. ALPHATEST: boolean;
  22429. DEPTHPREPASS: boolean;
  22430. ALPHABLEND: boolean;
  22431. ALPHAFROMALBEDO: boolean;
  22432. ALPHATESTVALUE: string;
  22433. SPECULAROVERALPHA: boolean;
  22434. RADIANCEOVERALPHA: boolean;
  22435. ALPHAFRESNEL: boolean;
  22436. LINEARALPHAFRESNEL: boolean;
  22437. PREMULTIPLYALPHA: boolean;
  22438. EMISSIVE: boolean;
  22439. EMISSIVEDIRECTUV: number;
  22440. REFLECTIVITY: boolean;
  22441. REFLECTIVITYDIRECTUV: number;
  22442. SPECULARTERM: boolean;
  22443. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  22444. MICROSURFACEAUTOMATIC: boolean;
  22445. LODBASEDMICROSFURACE: boolean;
  22446. MICROSURFACEMAP: boolean;
  22447. MICROSURFACEMAPDIRECTUV: number;
  22448. METALLICWORKFLOW: boolean;
  22449. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  22450. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  22451. METALLNESSSTOREINMETALMAPBLUE: boolean;
  22452. AOSTOREINMETALMAPRED: boolean;
  22453. METALLIC_REFLECTANCE: boolean;
  22454. METALLIC_REFLECTANCEDIRECTUV: number;
  22455. ENVIRONMENTBRDF: boolean;
  22456. ENVIRONMENTBRDF_RGBD: boolean;
  22457. NORMAL: boolean;
  22458. TANGENT: boolean;
  22459. BUMP: boolean;
  22460. BUMPDIRECTUV: number;
  22461. OBJECTSPACE_NORMALMAP: boolean;
  22462. PARALLAX: boolean;
  22463. PARALLAXOCCLUSION: boolean;
  22464. NORMALXYSCALE: boolean;
  22465. LIGHTMAP: boolean;
  22466. LIGHTMAPDIRECTUV: number;
  22467. USELIGHTMAPASSHADOWMAP: boolean;
  22468. GAMMALIGHTMAP: boolean;
  22469. RGBDLIGHTMAP: boolean;
  22470. REFLECTION: boolean;
  22471. REFLECTIONMAP_3D: boolean;
  22472. REFLECTIONMAP_SPHERICAL: boolean;
  22473. REFLECTIONMAP_PLANAR: boolean;
  22474. REFLECTIONMAP_CUBIC: boolean;
  22475. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22476. REFLECTIONMAP_PROJECTION: boolean;
  22477. REFLECTIONMAP_SKYBOX: boolean;
  22478. REFLECTIONMAP_EXPLICIT: boolean;
  22479. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22480. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22481. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22482. INVERTCUBICMAP: boolean;
  22483. USESPHERICALFROMREFLECTIONMAP: boolean;
  22484. USEIRRADIANCEMAP: boolean;
  22485. SPHERICAL_HARMONICS: boolean;
  22486. USESPHERICALINVERTEX: boolean;
  22487. REFLECTIONMAP_OPPOSITEZ: boolean;
  22488. LODINREFLECTIONALPHA: boolean;
  22489. GAMMAREFLECTION: boolean;
  22490. RGBDREFLECTION: boolean;
  22491. LINEARSPECULARREFLECTION: boolean;
  22492. RADIANCEOCCLUSION: boolean;
  22493. HORIZONOCCLUSION: boolean;
  22494. INSTANCES: boolean;
  22495. THIN_INSTANCES: boolean;
  22496. PREPASS: boolean;
  22497. PREPASS_IRRADIANCE: boolean;
  22498. PREPASS_IRRADIANCE_INDEX: number;
  22499. PREPASS_ALBEDO: boolean;
  22500. PREPASS_ALBEDO_INDEX: number;
  22501. PREPASS_DEPTHNORMAL: boolean;
  22502. PREPASS_DEPTHNORMAL_INDEX: number;
  22503. PREPASS_POSITION: boolean;
  22504. PREPASS_POSITION_INDEX: number;
  22505. PREPASS_VELOCITY: boolean;
  22506. PREPASS_VELOCITY_INDEX: number;
  22507. PREPASS_REFLECTIVITY: boolean;
  22508. PREPASS_REFLECTIVITY_INDEX: number;
  22509. SCENE_MRT_COUNT: number;
  22510. NUM_BONE_INFLUENCERS: number;
  22511. BonesPerMesh: number;
  22512. BONETEXTURE: boolean;
  22513. BONES_VELOCITY_ENABLED: boolean;
  22514. NONUNIFORMSCALING: boolean;
  22515. MORPHTARGETS: boolean;
  22516. MORPHTARGETS_NORMAL: boolean;
  22517. MORPHTARGETS_TANGENT: boolean;
  22518. MORPHTARGETS_UV: boolean;
  22519. NUM_MORPH_INFLUENCERS: number;
  22520. IMAGEPROCESSING: boolean;
  22521. VIGNETTE: boolean;
  22522. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22523. VIGNETTEBLENDMODEOPAQUE: boolean;
  22524. TONEMAPPING: boolean;
  22525. TONEMAPPING_ACES: boolean;
  22526. CONTRAST: boolean;
  22527. COLORCURVES: boolean;
  22528. COLORGRADING: boolean;
  22529. COLORGRADING3D: boolean;
  22530. SAMPLER3DGREENDEPTH: boolean;
  22531. SAMPLER3DBGRMAP: boolean;
  22532. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22533. EXPOSURE: boolean;
  22534. MULTIVIEW: boolean;
  22535. USEPHYSICALLIGHTFALLOFF: boolean;
  22536. USEGLTFLIGHTFALLOFF: boolean;
  22537. TWOSIDEDLIGHTING: boolean;
  22538. SHADOWFLOAT: boolean;
  22539. CLIPPLANE: boolean;
  22540. CLIPPLANE2: boolean;
  22541. CLIPPLANE3: boolean;
  22542. CLIPPLANE4: boolean;
  22543. CLIPPLANE5: boolean;
  22544. CLIPPLANE6: boolean;
  22545. POINTSIZE: boolean;
  22546. FOG: boolean;
  22547. LOGARITHMICDEPTH: boolean;
  22548. FORCENORMALFORWARD: boolean;
  22549. SPECULARAA: boolean;
  22550. CLEARCOAT: boolean;
  22551. CLEARCOAT_DEFAULTIOR: boolean;
  22552. CLEARCOAT_TEXTURE: boolean;
  22553. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  22554. CLEARCOAT_TEXTUREDIRECTUV: number;
  22555. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  22556. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22557. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22558. CLEARCOAT_BUMP: boolean;
  22559. CLEARCOAT_BUMPDIRECTUV: number;
  22560. CLEARCOAT_REMAP_F0: boolean;
  22561. CLEARCOAT_TINT: boolean;
  22562. CLEARCOAT_TINT_TEXTURE: boolean;
  22563. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  22564. ANISOTROPIC: boolean;
  22565. ANISOTROPIC_TEXTURE: boolean;
  22566. ANISOTROPIC_TEXTUREDIRECTUV: number;
  22567. BRDF_V_HEIGHT_CORRELATED: boolean;
  22568. MS_BRDF_ENERGY_CONSERVATION: boolean;
  22569. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  22570. SHEEN: boolean;
  22571. SHEEN_TEXTURE: boolean;
  22572. SHEEN_TEXTURE_ROUGHNESS: boolean;
  22573. SHEEN_TEXTUREDIRECTUV: number;
  22574. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  22575. SHEEN_LINKWITHALBEDO: boolean;
  22576. SHEEN_ROUGHNESS: boolean;
  22577. SHEEN_ALBEDOSCALING: boolean;
  22578. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22579. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22580. SUBSURFACE: boolean;
  22581. SS_REFRACTION: boolean;
  22582. SS_TRANSLUCENCY: boolean;
  22583. SS_SCATTERING: boolean;
  22584. SS_THICKNESSANDMASK_TEXTURE: boolean;
  22585. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  22586. SS_REFRACTIONMAP_3D: boolean;
  22587. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  22588. SS_LODINREFRACTIONALPHA: boolean;
  22589. SS_GAMMAREFRACTION: boolean;
  22590. SS_RGBDREFRACTION: boolean;
  22591. SS_LINEARSPECULARREFRACTION: boolean;
  22592. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  22593. SS_ALBEDOFORREFRACTIONTINT: boolean;
  22594. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  22595. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  22596. UNLIT: boolean;
  22597. DEBUGMODE: number;
  22598. /**
  22599. * Initializes the PBR Material defines.
  22600. */
  22601. constructor();
  22602. /**
  22603. * Resets the PBR Material defines.
  22604. */
  22605. reset(): void;
  22606. }
  22607. /**
  22608. * The Physically based material base class of BJS.
  22609. *
  22610. * This offers the main features of a standard PBR material.
  22611. * For more information, please refer to the documentation :
  22612. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22613. */
  22614. export abstract class PBRBaseMaterial extends PushMaterial {
  22615. /**
  22616. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22617. */
  22618. static readonly PBRMATERIAL_OPAQUE: number;
  22619. /**
  22620. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22621. */
  22622. static readonly PBRMATERIAL_ALPHATEST: number;
  22623. /**
  22624. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22625. */
  22626. static readonly PBRMATERIAL_ALPHABLEND: number;
  22627. /**
  22628. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22629. * They are also discarded below the alpha cutoff threshold to improve performances.
  22630. */
  22631. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22632. /**
  22633. * Defines the default value of how much AO map is occluding the analytical lights
  22634. * (point spot...).
  22635. */
  22636. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22637. /**
  22638. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  22639. */
  22640. static readonly LIGHTFALLOFF_PHYSICAL: number;
  22641. /**
  22642. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  22643. * to enhance interoperability with other engines.
  22644. */
  22645. static readonly LIGHTFALLOFF_GLTF: number;
  22646. /**
  22647. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  22648. * to enhance interoperability with other materials.
  22649. */
  22650. static readonly LIGHTFALLOFF_STANDARD: number;
  22651. /**
  22652. * Intensity of the direct lights e.g. the four lights available in your scene.
  22653. * This impacts both the direct diffuse and specular highlights.
  22654. */
  22655. protected _directIntensity: number;
  22656. /**
  22657. * Intensity of the emissive part of the material.
  22658. * This helps controlling the emissive effect without modifying the emissive color.
  22659. */
  22660. protected _emissiveIntensity: number;
  22661. /**
  22662. * Intensity of the environment e.g. how much the environment will light the object
  22663. * either through harmonics for rough material or through the refelction for shiny ones.
  22664. */
  22665. protected _environmentIntensity: number;
  22666. /**
  22667. * This is a special control allowing the reduction of the specular highlights coming from the
  22668. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22669. */
  22670. protected _specularIntensity: number;
  22671. /**
  22672. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  22673. */
  22674. private _lightingInfos;
  22675. /**
  22676. * Debug Control allowing disabling the bump map on this material.
  22677. */
  22678. protected _disableBumpMap: boolean;
  22679. /**
  22680. * AKA Diffuse Texture in standard nomenclature.
  22681. */
  22682. protected _albedoTexture: Nullable<BaseTexture>;
  22683. /**
  22684. * AKA Occlusion Texture in other nomenclature.
  22685. */
  22686. protected _ambientTexture: Nullable<BaseTexture>;
  22687. /**
  22688. * AKA Occlusion Texture Intensity in other nomenclature.
  22689. */
  22690. protected _ambientTextureStrength: number;
  22691. /**
  22692. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22693. * 1 means it completely occludes it
  22694. * 0 mean it has no impact
  22695. */
  22696. protected _ambientTextureImpactOnAnalyticalLights: number;
  22697. /**
  22698. * Stores the alpha values in a texture.
  22699. */
  22700. protected _opacityTexture: Nullable<BaseTexture>;
  22701. /**
  22702. * Stores the reflection values in a texture.
  22703. */
  22704. protected _reflectionTexture: Nullable<BaseTexture>;
  22705. /**
  22706. * Stores the emissive values in a texture.
  22707. */
  22708. protected _emissiveTexture: Nullable<BaseTexture>;
  22709. /**
  22710. * AKA Specular texture in other nomenclature.
  22711. */
  22712. protected _reflectivityTexture: Nullable<BaseTexture>;
  22713. /**
  22714. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22715. */
  22716. protected _metallicTexture: Nullable<BaseTexture>;
  22717. /**
  22718. * Specifies the metallic scalar of the metallic/roughness workflow.
  22719. * Can also be used to scale the metalness values of the metallic texture.
  22720. */
  22721. protected _metallic: Nullable<number>;
  22722. /**
  22723. * Specifies the roughness scalar of the metallic/roughness workflow.
  22724. * Can also be used to scale the roughness values of the metallic texture.
  22725. */
  22726. protected _roughness: Nullable<number>;
  22727. /**
  22728. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22729. * By default the indexOfrefraction is used to compute F0;
  22730. *
  22731. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22732. *
  22733. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22734. * F90 = metallicReflectanceColor;
  22735. */
  22736. protected _metallicF0Factor: number;
  22737. /**
  22738. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22739. * By default the F90 is always 1;
  22740. *
  22741. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22742. *
  22743. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22744. * F90 = metallicReflectanceColor;
  22745. */
  22746. protected _metallicReflectanceColor: Color3;
  22747. /**
  22748. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22749. * This is multiply against the scalar values defined in the material.
  22750. */
  22751. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22752. /**
  22753. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22754. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22755. */
  22756. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22757. /**
  22758. * Stores surface normal data used to displace a mesh in a texture.
  22759. */
  22760. protected _bumpTexture: Nullable<BaseTexture>;
  22761. /**
  22762. * Stores the pre-calculated light information of a mesh in a texture.
  22763. */
  22764. protected _lightmapTexture: Nullable<BaseTexture>;
  22765. /**
  22766. * The color of a material in ambient lighting.
  22767. */
  22768. protected _ambientColor: Color3;
  22769. /**
  22770. * AKA Diffuse Color in other nomenclature.
  22771. */
  22772. protected _albedoColor: Color3;
  22773. /**
  22774. * AKA Specular Color in other nomenclature.
  22775. */
  22776. protected _reflectivityColor: Color3;
  22777. /**
  22778. * The color applied when light is reflected from a material.
  22779. */
  22780. protected _reflectionColor: Color3;
  22781. /**
  22782. * The color applied when light is emitted from a material.
  22783. */
  22784. protected _emissiveColor: Color3;
  22785. /**
  22786. * AKA Glossiness in other nomenclature.
  22787. */
  22788. protected _microSurface: number;
  22789. /**
  22790. * Specifies that the material will use the light map as a show map.
  22791. */
  22792. protected _useLightmapAsShadowmap: boolean;
  22793. /**
  22794. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22795. * makes the reflect vector face the model (under horizon).
  22796. */
  22797. protected _useHorizonOcclusion: boolean;
  22798. /**
  22799. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22800. * too much the area relying on ambient texture to define their ambient occlusion.
  22801. */
  22802. protected _useRadianceOcclusion: boolean;
  22803. /**
  22804. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22805. */
  22806. protected _useAlphaFromAlbedoTexture: boolean;
  22807. /**
  22808. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  22809. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22810. */
  22811. protected _useSpecularOverAlpha: boolean;
  22812. /**
  22813. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22814. */
  22815. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22816. /**
  22817. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22818. */
  22819. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22820. /**
  22821. * Specifies if the metallic texture contains the roughness information in its green channel.
  22822. */
  22823. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22824. /**
  22825. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22826. */
  22827. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22828. /**
  22829. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22830. */
  22831. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22832. /**
  22833. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22834. */
  22835. protected _useAmbientInGrayScale: boolean;
  22836. /**
  22837. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22838. * The material will try to infer what glossiness each pixel should be.
  22839. */
  22840. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22841. /**
  22842. * Defines the falloff type used in this material.
  22843. * It by default is Physical.
  22844. */
  22845. protected _lightFalloff: number;
  22846. /**
  22847. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22848. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22849. */
  22850. protected _useRadianceOverAlpha: boolean;
  22851. /**
  22852. * Allows using an object space normal map (instead of tangent space).
  22853. */
  22854. protected _useObjectSpaceNormalMap: boolean;
  22855. /**
  22856. * Allows using the bump map in parallax mode.
  22857. */
  22858. protected _useParallax: boolean;
  22859. /**
  22860. * Allows using the bump map in parallax occlusion mode.
  22861. */
  22862. protected _useParallaxOcclusion: boolean;
  22863. /**
  22864. * Controls the scale bias of the parallax mode.
  22865. */
  22866. protected _parallaxScaleBias: number;
  22867. /**
  22868. * If sets to true, disables all the lights affecting the material.
  22869. */
  22870. protected _disableLighting: boolean;
  22871. /**
  22872. * Number of Simultaneous lights allowed on the material.
  22873. */
  22874. protected _maxSimultaneousLights: number;
  22875. /**
  22876. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22877. */
  22878. protected _invertNormalMapX: boolean;
  22879. /**
  22880. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22881. */
  22882. protected _invertNormalMapY: boolean;
  22883. /**
  22884. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22885. */
  22886. protected _twoSidedLighting: boolean;
  22887. /**
  22888. * Defines the alpha limits in alpha test mode.
  22889. */
  22890. protected _alphaCutOff: number;
  22891. /**
  22892. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22893. */
  22894. protected _forceAlphaTest: boolean;
  22895. /**
  22896. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22897. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22898. */
  22899. protected _useAlphaFresnel: boolean;
  22900. /**
  22901. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22902. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22903. */
  22904. protected _useLinearAlphaFresnel: boolean;
  22905. /**
  22906. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22907. * from cos thetav and roughness:
  22908. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22909. */
  22910. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22911. /**
  22912. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22913. */
  22914. protected _forceIrradianceInFragment: boolean;
  22915. private _realTimeFiltering;
  22916. /**
  22917. * Enables realtime filtering on the texture.
  22918. */
  22919. get realTimeFiltering(): boolean;
  22920. set realTimeFiltering(b: boolean);
  22921. private _realTimeFilteringQuality;
  22922. /**
  22923. * Quality switch for realtime filtering
  22924. */
  22925. get realTimeFilteringQuality(): number;
  22926. set realTimeFilteringQuality(n: number);
  22927. /**
  22928. * Can this material render to several textures at once
  22929. */
  22930. get canRenderToMRT(): boolean;
  22931. /**
  22932. * Force normal to face away from face.
  22933. */
  22934. protected _forceNormalForward: boolean;
  22935. /**
  22936. * Enables specular anti aliasing in the PBR shader.
  22937. * It will both interacts on the Geometry for analytical and IBL lighting.
  22938. * It also prefilter the roughness map based on the bump values.
  22939. */
  22940. protected _enableSpecularAntiAliasing: boolean;
  22941. /**
  22942. * Default configuration related to image processing available in the PBR Material.
  22943. */
  22944. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22945. /**
  22946. * Keep track of the image processing observer to allow dispose and replace.
  22947. */
  22948. private _imageProcessingObserver;
  22949. /**
  22950. * Attaches a new image processing configuration to the PBR Material.
  22951. * @param configuration
  22952. */
  22953. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22954. /**
  22955. * Stores the available render targets.
  22956. */
  22957. private _renderTargets;
  22958. /**
  22959. * Sets the global ambient color for the material used in lighting calculations.
  22960. */
  22961. private _globalAmbientColor;
  22962. /**
  22963. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22964. */
  22965. private _useLogarithmicDepth;
  22966. /**
  22967. * If set to true, no lighting calculations will be applied.
  22968. */
  22969. private _unlit;
  22970. private _debugMode;
  22971. /**
  22972. * @hidden
  22973. * This is reserved for the inspector.
  22974. * Defines the material debug mode.
  22975. * It helps seeing only some components of the material while troubleshooting.
  22976. */
  22977. debugMode: number;
  22978. /**
  22979. * @hidden
  22980. * This is reserved for the inspector.
  22981. * Specify from where on screen the debug mode should start.
  22982. * The value goes from -1 (full screen) to 1 (not visible)
  22983. * It helps with side by side comparison against the final render
  22984. * This defaults to -1
  22985. */
  22986. private debugLimit;
  22987. /**
  22988. * @hidden
  22989. * This is reserved for the inspector.
  22990. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22991. * You can use the factor to better multiply the final value.
  22992. */
  22993. private debugFactor;
  22994. /**
  22995. * Defines the clear coat layer parameters for the material.
  22996. */
  22997. readonly clearCoat: PBRClearCoatConfiguration;
  22998. /**
  22999. * Defines the anisotropic parameters for the material.
  23000. */
  23001. readonly anisotropy: PBRAnisotropicConfiguration;
  23002. /**
  23003. * Defines the BRDF parameters for the material.
  23004. */
  23005. readonly brdf: PBRBRDFConfiguration;
  23006. /**
  23007. * Defines the Sheen parameters for the material.
  23008. */
  23009. readonly sheen: PBRSheenConfiguration;
  23010. /**
  23011. * Defines the SubSurface parameters for the material.
  23012. */
  23013. readonly subSurface: PBRSubSurfaceConfiguration;
  23014. /**
  23015. * Defines additionnal PrePass parameters for the material.
  23016. */
  23017. readonly prePassConfiguration: PrePassConfiguration;
  23018. /**
  23019. * Defines the detail map parameters for the material.
  23020. */
  23021. readonly detailMap: DetailMapConfiguration;
  23022. protected _rebuildInParallel: boolean;
  23023. /**
  23024. * Instantiates a new PBRMaterial instance.
  23025. *
  23026. * @param name The material name
  23027. * @param scene The scene the material will be use in.
  23028. */
  23029. constructor(name: string, scene: Scene);
  23030. /**
  23031. * Gets a boolean indicating that current material needs to register RTT
  23032. */
  23033. get hasRenderTargetTextures(): boolean;
  23034. /**
  23035. * Gets the name of the material class.
  23036. */
  23037. getClassName(): string;
  23038. /**
  23039. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  23040. */
  23041. get useLogarithmicDepth(): boolean;
  23042. /**
  23043. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  23044. */
  23045. set useLogarithmicDepth(value: boolean);
  23046. /**
  23047. * Returns true if alpha blending should be disabled.
  23048. */
  23049. protected get _disableAlphaBlending(): boolean;
  23050. /**
  23051. * Specifies whether or not this material should be rendered in alpha blend mode.
  23052. */
  23053. needAlphaBlending(): boolean;
  23054. /**
  23055. * Specifies whether or not this material should be rendered in alpha test mode.
  23056. */
  23057. needAlphaTesting(): boolean;
  23058. /**
  23059. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  23060. */
  23061. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  23062. /**
  23063. * Specifies whether or not there is a usable alpha channel for transparency.
  23064. */
  23065. protected _hasAlphaChannel(): boolean;
  23066. /**
  23067. * Gets the texture used for the alpha test.
  23068. */
  23069. getAlphaTestTexture(): Nullable<BaseTexture>;
  23070. /**
  23071. * Specifies that the submesh is ready to be used.
  23072. * @param mesh - BJS mesh.
  23073. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  23074. * @param useInstances - Specifies that instances should be used.
  23075. * @returns - boolean indicating that the submesh is ready or not.
  23076. */
  23077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23078. /**
  23079. * Specifies if the material uses metallic roughness workflow.
  23080. * @returns boolean specifiying if the material uses metallic roughness workflow.
  23081. */
  23082. isMetallicWorkflow(): boolean;
  23083. private _prepareEffect;
  23084. private _prepareDefines;
  23085. /**
  23086. * Force shader compilation
  23087. */
  23088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  23089. /**
  23090. * Initializes the uniform buffer layout for the shader.
  23091. */
  23092. buildUniformLayout(): void;
  23093. /**
  23094. * Unbinds the material from the mesh
  23095. */
  23096. unbind(): void;
  23097. /**
  23098. * Binds the submesh data.
  23099. * @param world - The world matrix.
  23100. * @param mesh - The BJS mesh.
  23101. * @param subMesh - A submesh of the BJS mesh.
  23102. */
  23103. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23104. /**
  23105. * Returns the animatable textures.
  23106. * @returns - Array of animatable textures.
  23107. */
  23108. getAnimatables(): IAnimatable[];
  23109. /**
  23110. * Returns the texture used for reflections.
  23111. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  23112. */
  23113. private _getReflectionTexture;
  23114. /**
  23115. * Returns an array of the actively used textures.
  23116. * @returns - Array of BaseTextures
  23117. */
  23118. getActiveTextures(): BaseTexture[];
  23119. /**
  23120. * Checks to see if a texture is used in the material.
  23121. * @param texture - Base texture to use.
  23122. * @returns - Boolean specifying if a texture is used in the material.
  23123. */
  23124. hasTexture(texture: BaseTexture): boolean;
  23125. /**
  23126. * Sets the required values to the prepass renderer.
  23127. * @param prePassRenderer defines the prepass renderer to setup
  23128. */
  23129. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23130. /**
  23131. * Disposes the resources of the material.
  23132. * @param forceDisposeEffect - Forces the disposal of effects.
  23133. * @param forceDisposeTextures - Forces the disposal of all textures.
  23134. */
  23135. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23136. }
  23137. }
  23138. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  23139. import { Nullable } from "babylonjs/types";
  23140. import { Scene } from "babylonjs/scene";
  23141. import { Color3 } from "babylonjs/Maths/math.color";
  23142. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23143. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23144. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23145. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  23146. /**
  23147. * The Physically based material of BJS.
  23148. *
  23149. * This offers the main features of a standard PBR material.
  23150. * For more information, please refer to the documentation :
  23151. * https://doc.babylonjs.com/how_to/physically_based_rendering
  23152. */
  23153. export class PBRMaterial extends PBRBaseMaterial {
  23154. /**
  23155. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23156. */
  23157. static readonly PBRMATERIAL_OPAQUE: number;
  23158. /**
  23159. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23160. */
  23161. static readonly PBRMATERIAL_ALPHATEST: number;
  23162. /**
  23163. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23164. */
  23165. static readonly PBRMATERIAL_ALPHABLEND: number;
  23166. /**
  23167. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23168. * They are also discarded below the alpha cutoff threshold to improve performances.
  23169. */
  23170. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  23171. /**
  23172. * Defines the default value of how much AO map is occluding the analytical lights
  23173. * (point spot...).
  23174. */
  23175. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  23176. /**
  23177. * Intensity of the direct lights e.g. the four lights available in your scene.
  23178. * This impacts both the direct diffuse and specular highlights.
  23179. */
  23180. directIntensity: number;
  23181. /**
  23182. * Intensity of the emissive part of the material.
  23183. * This helps controlling the emissive effect without modifying the emissive color.
  23184. */
  23185. emissiveIntensity: number;
  23186. /**
  23187. * Intensity of the environment e.g. how much the environment will light the object
  23188. * either through harmonics for rough material or through the refelction for shiny ones.
  23189. */
  23190. environmentIntensity: number;
  23191. /**
  23192. * This is a special control allowing the reduction of the specular highlights coming from the
  23193. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  23194. */
  23195. specularIntensity: number;
  23196. /**
  23197. * Debug Control allowing disabling the bump map on this material.
  23198. */
  23199. disableBumpMap: boolean;
  23200. /**
  23201. * AKA Diffuse Texture in standard nomenclature.
  23202. */
  23203. albedoTexture: BaseTexture;
  23204. /**
  23205. * AKA Occlusion Texture in other nomenclature.
  23206. */
  23207. ambientTexture: BaseTexture;
  23208. /**
  23209. * AKA Occlusion Texture Intensity in other nomenclature.
  23210. */
  23211. ambientTextureStrength: number;
  23212. /**
  23213. * Defines how much the AO map is occluding the analytical lights (point spot...).
  23214. * 1 means it completely occludes it
  23215. * 0 mean it has no impact
  23216. */
  23217. ambientTextureImpactOnAnalyticalLights: number;
  23218. /**
  23219. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  23220. */
  23221. opacityTexture: BaseTexture;
  23222. /**
  23223. * Stores the reflection values in a texture.
  23224. */
  23225. reflectionTexture: Nullable<BaseTexture>;
  23226. /**
  23227. * Stores the emissive values in a texture.
  23228. */
  23229. emissiveTexture: BaseTexture;
  23230. /**
  23231. * AKA Specular texture in other nomenclature.
  23232. */
  23233. reflectivityTexture: BaseTexture;
  23234. /**
  23235. * Used to switch from specular/glossiness to metallic/roughness workflow.
  23236. */
  23237. metallicTexture: BaseTexture;
  23238. /**
  23239. * Specifies the metallic scalar of the metallic/roughness workflow.
  23240. * Can also be used to scale the metalness values of the metallic texture.
  23241. */
  23242. metallic: Nullable<number>;
  23243. /**
  23244. * Specifies the roughness scalar of the metallic/roughness workflow.
  23245. * Can also be used to scale the roughness values of the metallic texture.
  23246. */
  23247. roughness: Nullable<number>;
  23248. /**
  23249. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  23250. * By default the indexOfrefraction is used to compute F0;
  23251. *
  23252. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  23253. *
  23254. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  23255. * F90 = metallicReflectanceColor;
  23256. */
  23257. metallicF0Factor: number;
  23258. /**
  23259. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  23260. * By default the F90 is always 1;
  23261. *
  23262. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  23263. *
  23264. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  23265. * F90 = metallicReflectanceColor;
  23266. */
  23267. metallicReflectanceColor: Color3;
  23268. /**
  23269. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  23270. * This is multiply against the scalar values defined in the material.
  23271. */
  23272. metallicReflectanceTexture: Nullable<BaseTexture>;
  23273. /**
  23274. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  23275. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  23276. */
  23277. microSurfaceTexture: BaseTexture;
  23278. /**
  23279. * Stores surface normal data used to displace a mesh in a texture.
  23280. */
  23281. bumpTexture: BaseTexture;
  23282. /**
  23283. * Stores the pre-calculated light information of a mesh in a texture.
  23284. */
  23285. lightmapTexture: BaseTexture;
  23286. /**
  23287. * Stores the refracted light information in a texture.
  23288. */
  23289. get refractionTexture(): Nullable<BaseTexture>;
  23290. set refractionTexture(value: Nullable<BaseTexture>);
  23291. /**
  23292. * The color of a material in ambient lighting.
  23293. */
  23294. ambientColor: Color3;
  23295. /**
  23296. * AKA Diffuse Color in other nomenclature.
  23297. */
  23298. albedoColor: Color3;
  23299. /**
  23300. * AKA Specular Color in other nomenclature.
  23301. */
  23302. reflectivityColor: Color3;
  23303. /**
  23304. * The color reflected from the material.
  23305. */
  23306. reflectionColor: Color3;
  23307. /**
  23308. * The color emitted from the material.
  23309. */
  23310. emissiveColor: Color3;
  23311. /**
  23312. * AKA Glossiness in other nomenclature.
  23313. */
  23314. microSurface: number;
  23315. /**
  23316. * Index of refraction of the material base layer.
  23317. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  23318. *
  23319. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  23320. *
  23321. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  23322. */
  23323. get indexOfRefraction(): number;
  23324. set indexOfRefraction(value: number);
  23325. /**
  23326. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  23327. */
  23328. get invertRefractionY(): boolean;
  23329. set invertRefractionY(value: boolean);
  23330. /**
  23331. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  23332. * Materials half opaque for instance using refraction could benefit from this control.
  23333. */
  23334. get linkRefractionWithTransparency(): boolean;
  23335. set linkRefractionWithTransparency(value: boolean);
  23336. /**
  23337. * If true, the light map contains occlusion information instead of lighting info.
  23338. */
  23339. useLightmapAsShadowmap: boolean;
  23340. /**
  23341. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  23342. */
  23343. useAlphaFromAlbedoTexture: boolean;
  23344. /**
  23345. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23346. */
  23347. forceAlphaTest: boolean;
  23348. /**
  23349. * Defines the alpha limits in alpha test mode.
  23350. */
  23351. alphaCutOff: number;
  23352. /**
  23353. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23354. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23355. */
  23356. useSpecularOverAlpha: boolean;
  23357. /**
  23358. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  23359. */
  23360. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  23361. /**
  23362. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  23363. */
  23364. useRoughnessFromMetallicTextureAlpha: boolean;
  23365. /**
  23366. * Specifies if the metallic texture contains the roughness information in its green channel.
  23367. */
  23368. useRoughnessFromMetallicTextureGreen: boolean;
  23369. /**
  23370. * Specifies if the metallic texture contains the metallness information in its blue channel.
  23371. */
  23372. useMetallnessFromMetallicTextureBlue: boolean;
  23373. /**
  23374. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  23375. */
  23376. useAmbientOcclusionFromMetallicTextureRed: boolean;
  23377. /**
  23378. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  23379. */
  23380. useAmbientInGrayScale: boolean;
  23381. /**
  23382. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  23383. * The material will try to infer what glossiness each pixel should be.
  23384. */
  23385. useAutoMicroSurfaceFromReflectivityMap: boolean;
  23386. /**
  23387. * BJS is using an harcoded light falloff based on a manually sets up range.
  23388. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23389. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23390. */
  23391. get usePhysicalLightFalloff(): boolean;
  23392. /**
  23393. * BJS is using an harcoded light falloff based on a manually sets up range.
  23394. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23395. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23396. */
  23397. set usePhysicalLightFalloff(value: boolean);
  23398. /**
  23399. * In order to support the falloff compatibility with gltf, a special mode has been added
  23400. * to reproduce the gltf light falloff.
  23401. */
  23402. get useGLTFLightFalloff(): boolean;
  23403. /**
  23404. * In order to support the falloff compatibility with gltf, a special mode has been added
  23405. * to reproduce the gltf light falloff.
  23406. */
  23407. set useGLTFLightFalloff(value: boolean);
  23408. /**
  23409. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23410. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23411. */
  23412. useRadianceOverAlpha: boolean;
  23413. /**
  23414. * Allows using an object space normal map (instead of tangent space).
  23415. */
  23416. useObjectSpaceNormalMap: boolean;
  23417. /**
  23418. * Allows using the bump map in parallax mode.
  23419. */
  23420. useParallax: boolean;
  23421. /**
  23422. * Allows using the bump map in parallax occlusion mode.
  23423. */
  23424. useParallaxOcclusion: boolean;
  23425. /**
  23426. * Controls the scale bias of the parallax mode.
  23427. */
  23428. parallaxScaleBias: number;
  23429. /**
  23430. * If sets to true, disables all the lights affecting the material.
  23431. */
  23432. disableLighting: boolean;
  23433. /**
  23434. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23435. */
  23436. forceIrradianceInFragment: boolean;
  23437. /**
  23438. * Number of Simultaneous lights allowed on the material.
  23439. */
  23440. maxSimultaneousLights: number;
  23441. /**
  23442. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23443. */
  23444. invertNormalMapX: boolean;
  23445. /**
  23446. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23447. */
  23448. invertNormalMapY: boolean;
  23449. /**
  23450. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23451. */
  23452. twoSidedLighting: boolean;
  23453. /**
  23454. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23455. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23456. */
  23457. useAlphaFresnel: boolean;
  23458. /**
  23459. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23460. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23461. */
  23462. useLinearAlphaFresnel: boolean;
  23463. /**
  23464. * Let user defines the brdf lookup texture used for IBL.
  23465. * A default 8bit version is embedded but you could point at :
  23466. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  23467. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  23468. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  23469. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  23470. */
  23471. environmentBRDFTexture: Nullable<BaseTexture>;
  23472. /**
  23473. * Force normal to face away from face.
  23474. */
  23475. forceNormalForward: boolean;
  23476. /**
  23477. * Enables specular anti aliasing in the PBR shader.
  23478. * It will both interacts on the Geometry for analytical and IBL lighting.
  23479. * It also prefilter the roughness map based on the bump values.
  23480. */
  23481. enableSpecularAntiAliasing: boolean;
  23482. /**
  23483. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23484. * makes the reflect vector face the model (under horizon).
  23485. */
  23486. useHorizonOcclusion: boolean;
  23487. /**
  23488. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23489. * too much the area relying on ambient texture to define their ambient occlusion.
  23490. */
  23491. useRadianceOcclusion: boolean;
  23492. /**
  23493. * If set to true, no lighting calculations will be applied.
  23494. */
  23495. unlit: boolean;
  23496. /**
  23497. * Gets the image processing configuration used either in this material.
  23498. */
  23499. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23500. /**
  23501. * Sets the Default image processing configuration used either in the this material.
  23502. *
  23503. * If sets to null, the scene one is in use.
  23504. */
  23505. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23506. /**
  23507. * Gets wether the color curves effect is enabled.
  23508. */
  23509. get cameraColorCurvesEnabled(): boolean;
  23510. /**
  23511. * Sets wether the color curves effect is enabled.
  23512. */
  23513. set cameraColorCurvesEnabled(value: boolean);
  23514. /**
  23515. * Gets wether the color grading effect is enabled.
  23516. */
  23517. get cameraColorGradingEnabled(): boolean;
  23518. /**
  23519. * Gets wether the color grading effect is enabled.
  23520. */
  23521. set cameraColorGradingEnabled(value: boolean);
  23522. /**
  23523. * Gets wether tonemapping is enabled or not.
  23524. */
  23525. get cameraToneMappingEnabled(): boolean;
  23526. /**
  23527. * Sets wether tonemapping is enabled or not
  23528. */
  23529. set cameraToneMappingEnabled(value: boolean);
  23530. /**
  23531. * The camera exposure used on this material.
  23532. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23533. * This corresponds to a photographic exposure.
  23534. */
  23535. get cameraExposure(): number;
  23536. /**
  23537. * The camera exposure used on this material.
  23538. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23539. * This corresponds to a photographic exposure.
  23540. */
  23541. set cameraExposure(value: number);
  23542. /**
  23543. * Gets The camera contrast used on this material.
  23544. */
  23545. get cameraContrast(): number;
  23546. /**
  23547. * Sets The camera contrast used on this material.
  23548. */
  23549. set cameraContrast(value: number);
  23550. /**
  23551. * Gets the Color Grading 2D Lookup Texture.
  23552. */
  23553. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  23554. /**
  23555. * Sets the Color Grading 2D Lookup Texture.
  23556. */
  23557. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  23558. /**
  23559. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23560. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23561. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  23562. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23563. */
  23564. get cameraColorCurves(): Nullable<ColorCurves>;
  23565. /**
  23566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23568. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  23569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23570. */
  23571. set cameraColorCurves(value: Nullable<ColorCurves>);
  23572. /**
  23573. * Instantiates a new PBRMaterial instance.
  23574. *
  23575. * @param name The material name
  23576. * @param scene The scene the material will be use in.
  23577. */
  23578. constructor(name: string, scene: Scene);
  23579. /**
  23580. * Returns the name of this material class.
  23581. */
  23582. getClassName(): string;
  23583. /**
  23584. * Makes a duplicate of the current material.
  23585. * @param name - name to use for the new material.
  23586. */
  23587. clone(name: string): PBRMaterial;
  23588. /**
  23589. * Serializes this PBR Material.
  23590. * @returns - An object with the serialized material.
  23591. */
  23592. serialize(): any;
  23593. /**
  23594. * Parses a PBR Material from a serialized object.
  23595. * @param source - Serialized object.
  23596. * @param scene - BJS scene instance.
  23597. * @param rootUrl - url for the scene object
  23598. * @returns - PBRMaterial
  23599. */
  23600. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23601. }
  23602. }
  23603. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  23604. /** @hidden */
  23605. export var mrtFragmentDeclaration: {
  23606. name: string;
  23607. shader: string;
  23608. };
  23609. }
  23610. declare module "babylonjs/Shaders/geometry.fragment" {
  23611. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  23612. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  23613. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  23614. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  23615. /** @hidden */
  23616. export var geometryPixelShader: {
  23617. name: string;
  23618. shader: string;
  23619. };
  23620. }
  23621. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  23622. /** @hidden */
  23623. export var instancesDeclaration: {
  23624. name: string;
  23625. shader: string;
  23626. };
  23627. }
  23628. declare module "babylonjs/Shaders/geometry.vertex" {
  23629. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  23630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  23631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  23632. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  23633. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  23634. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  23635. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  23636. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  23637. /** @hidden */
  23638. export var geometryVertexShader: {
  23639. name: string;
  23640. shader: string;
  23641. };
  23642. }
  23643. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  23644. import { Matrix } from "babylonjs/Maths/math.vector";
  23645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23646. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23647. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23648. import { Effect } from "babylonjs/Materials/effect";
  23649. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23650. import { Scene } from "babylonjs/scene";
  23651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23652. import { Nullable } from "babylonjs/types";
  23653. import "babylonjs/Shaders/geometry.fragment";
  23654. import "babylonjs/Shaders/geometry.vertex";
  23655. /** @hidden */
  23656. interface ISavedTransformationMatrix {
  23657. world: Matrix;
  23658. viewProjection: Matrix;
  23659. }
  23660. /**
  23661. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  23662. */
  23663. export class GeometryBufferRenderer {
  23664. /**
  23665. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  23666. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  23667. */
  23668. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  23669. /**
  23670. * Constant used to retrieve the position texture index in the G-Buffer textures array
  23671. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  23672. */
  23673. static readonly POSITION_TEXTURE_TYPE: number;
  23674. /**
  23675. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  23676. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  23677. */
  23678. static readonly VELOCITY_TEXTURE_TYPE: number;
  23679. /**
  23680. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  23681. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  23682. */
  23683. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  23684. /**
  23685. * Dictionary used to store the previous transformation matrices of each rendered mesh
  23686. * in order to compute objects velocities when enableVelocity is set to "true"
  23687. * @hidden
  23688. */
  23689. _previousTransformationMatrices: {
  23690. [index: number]: ISavedTransformationMatrix;
  23691. };
  23692. /**
  23693. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  23694. * in order to compute objects velocities when enableVelocity is set to "true"
  23695. * @hidden
  23696. */
  23697. _previousBonesTransformationMatrices: {
  23698. [index: number]: Float32Array;
  23699. };
  23700. /**
  23701. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23702. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23703. */
  23704. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23705. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23706. renderTransparentMeshes: boolean;
  23707. private _scene;
  23708. private _resizeObserver;
  23709. private _multiRenderTarget;
  23710. private _ratio;
  23711. private _enablePosition;
  23712. private _enableVelocity;
  23713. private _enableReflectivity;
  23714. private _positionIndex;
  23715. private _velocityIndex;
  23716. private _reflectivityIndex;
  23717. private _depthNormalIndex;
  23718. private _linkedWithPrePass;
  23719. private _prePassRenderer;
  23720. private _attachments;
  23721. protected _effect: Effect;
  23722. protected _cachedDefines: string;
  23723. /**
  23724. * @hidden
  23725. * Sets up internal structures to share outputs with PrePassRenderer
  23726. * This method should only be called by the PrePassRenderer itself
  23727. */
  23728. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23729. /**
  23730. * @hidden
  23731. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23732. * This method should only be called by the PrePassRenderer itself
  23733. */
  23734. _unlinkPrePassRenderer(): void;
  23735. /**
  23736. * @hidden
  23737. * Resets the geometry buffer layout
  23738. */
  23739. _resetLayout(): void;
  23740. /**
  23741. * @hidden
  23742. * Replaces a texture in the geometry buffer renderer
  23743. * Useful when linking textures of the prepass renderer
  23744. */
  23745. _forceTextureType(geometryBufferType: number, index: number): void;
  23746. /**
  23747. * @hidden
  23748. * Sets texture attachments
  23749. * Useful when linking textures of the prepass renderer
  23750. */
  23751. _setAttachments(attachments: number[]): void;
  23752. /**
  23753. * @hidden
  23754. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23755. * Useful when linking textures of the prepass renderer
  23756. */
  23757. _linkInternalTexture(internalTexture: InternalTexture): void;
  23758. /**
  23759. * Gets the render list (meshes to be rendered) used in the G buffer.
  23760. */
  23761. get renderList(): Nullable<AbstractMesh[]>;
  23762. /**
  23763. * Set the render list (meshes to be rendered) used in the G buffer.
  23764. */
  23765. set renderList(meshes: Nullable<AbstractMesh[]>);
  23766. /**
  23767. * Gets wether or not G buffer are supported by the running hardware.
  23768. * This requires draw buffer supports
  23769. */
  23770. get isSupported(): boolean;
  23771. /**
  23772. * Returns the index of the given texture type in the G-Buffer textures array
  23773. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23774. * @returns the index of the given texture type in the G-Buffer textures array
  23775. */
  23776. getTextureIndex(textureType: number): number;
  23777. /**
  23778. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23779. */
  23780. get enablePosition(): boolean;
  23781. /**
  23782. * Sets whether or not objects positions are enabled for the G buffer.
  23783. */
  23784. set enablePosition(enable: boolean);
  23785. /**
  23786. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23787. */
  23788. get enableVelocity(): boolean;
  23789. /**
  23790. * Sets wether or not objects velocities are enabled for the G buffer.
  23791. */
  23792. set enableVelocity(enable: boolean);
  23793. /**
  23794. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23795. */
  23796. get enableReflectivity(): boolean;
  23797. /**
  23798. * Sets wether or not objects roughness are enabled for the G buffer.
  23799. */
  23800. set enableReflectivity(enable: boolean);
  23801. /**
  23802. * Gets the scene associated with the buffer.
  23803. */
  23804. get scene(): Scene;
  23805. /**
  23806. * Gets the ratio used by the buffer during its creation.
  23807. * How big is the buffer related to the main canvas.
  23808. */
  23809. get ratio(): number;
  23810. /** @hidden */
  23811. static _SceneComponentInitialization: (scene: Scene) => void;
  23812. /**
  23813. * Creates a new G Buffer for the scene
  23814. * @param scene The scene the buffer belongs to
  23815. * @param ratio How big is the buffer related to the main canvas.
  23816. */
  23817. constructor(scene: Scene, ratio?: number);
  23818. /**
  23819. * Checks wether everything is ready to render a submesh to the G buffer.
  23820. * @param subMesh the submesh to check readiness for
  23821. * @param useInstances is the mesh drawn using instance or not
  23822. * @returns true if ready otherwise false
  23823. */
  23824. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23825. /**
  23826. * Gets the current underlying G Buffer.
  23827. * @returns the buffer
  23828. */
  23829. getGBuffer(): MultiRenderTarget;
  23830. /**
  23831. * Gets the number of samples used to render the buffer (anti aliasing).
  23832. */
  23833. get samples(): number;
  23834. /**
  23835. * Sets the number of samples used to render the buffer (anti aliasing).
  23836. */
  23837. set samples(value: number);
  23838. /**
  23839. * Disposes the renderer and frees up associated resources.
  23840. */
  23841. dispose(): void;
  23842. private _assignRenderTargetIndices;
  23843. protected _createRenderTargets(): void;
  23844. private _copyBonesTransformationMatrices;
  23845. }
  23846. }
  23847. declare module "babylonjs/Rendering/prePassRenderer" {
  23848. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23849. import { Scene } from "babylonjs/scene";
  23850. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  23851. import { Effect } from "babylonjs/Materials/effect";
  23852. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23854. import { Material } from "babylonjs/Materials/material";
  23855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23856. /**
  23857. * Renders a pre pass of the scene
  23858. * This means every mesh in the scene will be rendered to a render target texture
  23859. * And then this texture will be composited to the rendering canvas with post processes
  23860. * It is necessary for effects like subsurface scattering or deferred shading
  23861. */
  23862. export class PrePassRenderer {
  23863. /** @hidden */
  23864. static _SceneComponentInitialization: (scene: Scene) => void;
  23865. private _textureFormats;
  23866. /**
  23867. * To save performance, we can excluded skinned meshes from the prepass
  23868. */
  23869. excludedSkinnedMesh: AbstractMesh[];
  23870. /**
  23871. * Force material to be excluded from the prepass
  23872. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23873. * and you don't want a material to show in the effect.
  23874. */
  23875. excludedMaterials: Material[];
  23876. private _textureIndices;
  23877. private _scene;
  23878. private _engine;
  23879. private _isDirty;
  23880. /**
  23881. * Number of textures in the multi render target texture where the scene is directly rendered
  23882. */
  23883. mrtCount: number;
  23884. /**
  23885. * The render target where the scene is directly rendered
  23886. */
  23887. prePassRT: MultiRenderTarget;
  23888. private _multiRenderAttachments;
  23889. private _defaultAttachments;
  23890. private _postProcesses;
  23891. private readonly _clearColor;
  23892. /**
  23893. * Image processing post process for composition
  23894. */
  23895. imageProcessingPostProcess: ImageProcessingPostProcess;
  23896. /**
  23897. * Configuration for prepass effects
  23898. */
  23899. private _effectConfigurations;
  23900. private _mrtFormats;
  23901. private _mrtLayout;
  23902. private _enabled;
  23903. /**
  23904. * Indicates if the prepass is enabled
  23905. */
  23906. get enabled(): boolean;
  23907. /**
  23908. * How many samples are used for MSAA of the scene render target
  23909. */
  23910. get samples(): number;
  23911. set samples(n: number);
  23912. private _geometryBuffer;
  23913. private _useGeometryBufferFallback;
  23914. /**
  23915. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23916. */
  23917. get useGeometryBufferFallback(): boolean;
  23918. set useGeometryBufferFallback(value: boolean);
  23919. /**
  23920. * Set to true to disable gamma transform in PrePass.
  23921. * Can be useful in case you already proceed to gamma transform on a material level
  23922. * and your post processes don't need to be in linear color space.
  23923. */
  23924. disableGammaTransform: boolean;
  23925. /**
  23926. * Instanciates a prepass renderer
  23927. * @param scene The scene
  23928. */
  23929. constructor(scene: Scene);
  23930. private _initializeAttachments;
  23931. private _createCompositionEffect;
  23932. /**
  23933. * Indicates if rendering a prepass is supported
  23934. */
  23935. get isSupported(): boolean;
  23936. /**
  23937. * Sets the proper output textures to draw in the engine.
  23938. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23939. * @param subMesh Submesh on which the effect is applied
  23940. */
  23941. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23942. /**
  23943. * Restores attachments for single texture draw.
  23944. */
  23945. restoreAttachments(): void;
  23946. /**
  23947. * @hidden
  23948. */
  23949. _beforeCameraDraw(): void;
  23950. /**
  23951. * @hidden
  23952. */
  23953. _afterCameraDraw(): void;
  23954. private _checkRTSize;
  23955. private _bindFrameBuffer;
  23956. /**
  23957. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23958. */
  23959. clear(): void;
  23960. private _setState;
  23961. private _updateGeometryBufferLayout;
  23962. /**
  23963. * Adds an effect configuration to the prepass.
  23964. * If an effect has already been added, it won't add it twice and will return the configuration
  23965. * already present.
  23966. * @param cfg the effect configuration
  23967. * @return the effect configuration now used by the prepass
  23968. */
  23969. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23970. /**
  23971. * Returns the index of a texture in the multi render target texture array.
  23972. * @param type Texture type
  23973. * @return The index
  23974. */
  23975. getIndex(type: number): number;
  23976. private _enable;
  23977. private _disable;
  23978. private _resetLayout;
  23979. private _resetPostProcessChain;
  23980. private _bindPostProcessChain;
  23981. /**
  23982. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23983. */
  23984. markAsDirty(): void;
  23985. /**
  23986. * Enables a texture on the MultiRenderTarget for prepass
  23987. */
  23988. private _enableTextures;
  23989. private _update;
  23990. private _markAllMaterialsAsPrePassDirty;
  23991. /**
  23992. * Disposes the prepass renderer.
  23993. */
  23994. dispose(): void;
  23995. }
  23996. }
  23997. declare module "babylonjs/PostProcesses/postProcess" {
  23998. import { Nullable } from "babylonjs/types";
  23999. import { SmartArray } from "babylonjs/Misc/smartArray";
  24000. import { Observable } from "babylonjs/Misc/observable";
  24001. import { Vector2 } from "babylonjs/Maths/math.vector";
  24002. import { Camera } from "babylonjs/Cameras/camera";
  24003. import { Effect } from "babylonjs/Materials/effect";
  24004. import "babylonjs/Shaders/postprocess.vertex";
  24005. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24006. import { Engine } from "babylonjs/Engines/engine";
  24007. import { Color4 } from "babylonjs/Maths/math.color";
  24008. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24009. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  24010. import { Scene } from "babylonjs/scene";
  24011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24012. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  24013. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24014. /**
  24015. * Size options for a post process
  24016. */
  24017. export type PostProcessOptions = {
  24018. width: number;
  24019. height: number;
  24020. };
  24021. /**
  24022. * PostProcess can be used to apply a shader to a texture after it has been rendered
  24023. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24024. */
  24025. export class PostProcess {
  24026. /**
  24027. * Gets or sets the unique id of the post process
  24028. */
  24029. uniqueId: number;
  24030. /** Name of the PostProcess. */
  24031. name: string;
  24032. /**
  24033. * Width of the texture to apply the post process on
  24034. */
  24035. width: number;
  24036. /**
  24037. * Height of the texture to apply the post process on
  24038. */
  24039. height: number;
  24040. /**
  24041. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  24042. */
  24043. nodeMaterialSource: Nullable<NodeMaterial>;
  24044. /**
  24045. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  24046. * @hidden
  24047. */
  24048. _outputTexture: Nullable<InternalTexture>;
  24049. /**
  24050. * Sampling mode used by the shader
  24051. * See https://doc.babylonjs.com/classes/3.1/texture
  24052. */
  24053. renderTargetSamplingMode: number;
  24054. /**
  24055. * Clear color to use when screen clearing
  24056. */
  24057. clearColor: Color4;
  24058. /**
  24059. * If the buffer needs to be cleared before applying the post process. (default: true)
  24060. * Should be set to false if shader will overwrite all previous pixels.
  24061. */
  24062. autoClear: boolean;
  24063. /**
  24064. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  24065. */
  24066. alphaMode: number;
  24067. /**
  24068. * Sets the setAlphaBlendConstants of the babylon engine
  24069. */
  24070. alphaConstants: Color4;
  24071. /**
  24072. * Animations to be used for the post processing
  24073. */
  24074. animations: import("babylonjs/Animations/animation").Animation[];
  24075. /**
  24076. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  24077. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  24078. */
  24079. enablePixelPerfectMode: boolean;
  24080. /**
  24081. * Force the postprocess to be applied without taking in account viewport
  24082. */
  24083. forceFullscreenViewport: boolean;
  24084. /**
  24085. * List of inspectable custom properties (used by the Inspector)
  24086. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24087. */
  24088. inspectableCustomProperties: IInspectable[];
  24089. /**
  24090. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24091. *
  24092. * | Value | Type | Description |
  24093. * | ----- | ----------------------------------- | ----------- |
  24094. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  24095. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  24096. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24097. *
  24098. */
  24099. scaleMode: number;
  24100. /**
  24101. * Force textures to be a power of two (default: false)
  24102. */
  24103. alwaysForcePOT: boolean;
  24104. private _samples;
  24105. /**
  24106. * Number of sample textures (default: 1)
  24107. */
  24108. get samples(): number;
  24109. set samples(n: number);
  24110. /**
  24111. * Modify the scale of the post process to be the same as the viewport (default: false)
  24112. */
  24113. adaptScaleToCurrentViewport: boolean;
  24114. private _camera;
  24115. protected _scene: Scene;
  24116. private _engine;
  24117. private _options;
  24118. private _reusable;
  24119. private _textureType;
  24120. private _textureFormat;
  24121. /**
  24122. * Smart array of input and output textures for the post process.
  24123. * @hidden
  24124. */
  24125. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24126. /**
  24127. * The index in _textures that corresponds to the output texture.
  24128. * @hidden
  24129. */
  24130. _currentRenderTextureInd: number;
  24131. private _effect;
  24132. private _samplers;
  24133. private _fragmentUrl;
  24134. private _vertexUrl;
  24135. private _parameters;
  24136. private _scaleRatio;
  24137. protected _indexParameters: any;
  24138. private _shareOutputWithPostProcess;
  24139. private _texelSize;
  24140. private _forcedOutputTexture;
  24141. /**
  24142. * Prepass configuration in case this post process needs a texture from prepass
  24143. * @hidden
  24144. */
  24145. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24146. /**
  24147. * Returns the fragment url or shader name used in the post process.
  24148. * @returns the fragment url or name in the shader store.
  24149. */
  24150. getEffectName(): string;
  24151. /**
  24152. * An event triggered when the postprocess is activated.
  24153. */
  24154. onActivateObservable: Observable<Camera>;
  24155. private _onActivateObserver;
  24156. /**
  24157. * A function that is added to the onActivateObservable
  24158. */
  24159. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24160. /**
  24161. * An event triggered when the postprocess changes its size.
  24162. */
  24163. onSizeChangedObservable: Observable<PostProcess>;
  24164. private _onSizeChangedObserver;
  24165. /**
  24166. * A function that is added to the onSizeChangedObservable
  24167. */
  24168. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24169. /**
  24170. * An event triggered when the postprocess applies its effect.
  24171. */
  24172. onApplyObservable: Observable<Effect>;
  24173. private _onApplyObserver;
  24174. /**
  24175. * A function that is added to the onApplyObservable
  24176. */
  24177. set onApply(callback: (effect: Effect) => void);
  24178. /**
  24179. * An event triggered before rendering the postprocess
  24180. */
  24181. onBeforeRenderObservable: Observable<Effect>;
  24182. private _onBeforeRenderObserver;
  24183. /**
  24184. * A function that is added to the onBeforeRenderObservable
  24185. */
  24186. set onBeforeRender(callback: (effect: Effect) => void);
  24187. /**
  24188. * An event triggered after rendering the postprocess
  24189. */
  24190. onAfterRenderObservable: Observable<Effect>;
  24191. private _onAfterRenderObserver;
  24192. /**
  24193. * A function that is added to the onAfterRenderObservable
  24194. */
  24195. set onAfterRender(callback: (efect: Effect) => void);
  24196. /**
  24197. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  24198. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24199. */
  24200. get inputTexture(): InternalTexture;
  24201. set inputTexture(value: InternalTexture);
  24202. /**
  24203. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24204. * the only way to unset it is to use this function to restore its internal state
  24205. */
  24206. restoreDefaultInputTexture(): void;
  24207. /**
  24208. * Gets the camera which post process is applied to.
  24209. * @returns The camera the post process is applied to.
  24210. */
  24211. getCamera(): Camera;
  24212. /**
  24213. * Gets the texel size of the postprocess.
  24214. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24215. */
  24216. get texelSize(): Vector2;
  24217. /**
  24218. * Creates a new instance PostProcess
  24219. * @param name The name of the PostProcess.
  24220. * @param fragmentUrl The url of the fragment shader to be used.
  24221. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24222. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24223. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24224. * @param camera The camera to apply the render pass to.
  24225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24226. * @param engine The engine which the post process will be applied. (default: current engine)
  24227. * @param reusable If the post process can be reused on the same frame. (default: false)
  24228. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24229. * @param textureType Type of textures used when performing the post process. (default: 0)
  24230. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24231. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  24232. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24233. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24234. */
  24235. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  24236. /**
  24237. * Gets a string identifying the name of the class
  24238. * @returns "PostProcess" string
  24239. */
  24240. getClassName(): string;
  24241. /**
  24242. * Gets the engine which this post process belongs to.
  24243. * @returns The engine the post process was enabled with.
  24244. */
  24245. getEngine(): Engine;
  24246. /**
  24247. * The effect that is created when initializing the post process.
  24248. * @returns The created effect corresponding the the postprocess.
  24249. */
  24250. getEffect(): Effect;
  24251. /**
  24252. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24253. * @param postProcess The post process to share the output with.
  24254. * @returns This post process.
  24255. */
  24256. shareOutputWith(postProcess: PostProcess): PostProcess;
  24257. /**
  24258. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24259. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24260. */
  24261. useOwnOutput(): void;
  24262. /**
  24263. * Updates the effect with the current post process compile time values and recompiles the shader.
  24264. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24265. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24266. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24267. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  24268. * @param onCompiled Called when the shader has been compiled.
  24269. * @param onError Called if there is an error when compiling a shader.
  24270. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24271. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24272. */
  24273. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  24274. /**
  24275. * The post process is reusable if it can be used multiple times within one frame.
  24276. * @returns If the post process is reusable
  24277. */
  24278. isReusable(): boolean;
  24279. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24280. markTextureDirty(): void;
  24281. /**
  24282. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24283. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  24284. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24285. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24286. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24287. * @returns The target texture that was bound to be written to.
  24288. */
  24289. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24290. /**
  24291. * If the post process is supported.
  24292. */
  24293. get isSupported(): boolean;
  24294. /**
  24295. * The aspect ratio of the output texture.
  24296. */
  24297. get aspectRatio(): number;
  24298. /**
  24299. * Get a value indicating if the post-process is ready to be used
  24300. * @returns true if the post-process is ready (shader is compiled)
  24301. */
  24302. isReady(): boolean;
  24303. /**
  24304. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24305. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24306. */
  24307. apply(): Nullable<Effect>;
  24308. private _disposeTextures;
  24309. /**
  24310. * Sets the required values to the prepass renderer.
  24311. * @param prePassRenderer defines the prepass renderer to setup.
  24312. * @returns true if the pre pass is needed.
  24313. */
  24314. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24315. /**
  24316. * Disposes the post process.
  24317. * @param camera The camera to dispose the post process on.
  24318. */
  24319. dispose(camera?: Camera): void;
  24320. /**
  24321. * Serializes the particle system to a JSON object
  24322. * @returns the JSON object
  24323. */
  24324. serialize(): any;
  24325. /**
  24326. * Creates a material from parsed material data
  24327. * @param parsedPostProcess defines parsed post process data
  24328. * @param scene defines the hosting scene
  24329. * @param rootUrl defines the root URL to use to load textures
  24330. * @returns a new post process
  24331. */
  24332. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24333. }
  24334. }
  24335. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24336. /** @hidden */
  24337. export var kernelBlurVaryingDeclaration: {
  24338. name: string;
  24339. shader: string;
  24340. };
  24341. }
  24342. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  24343. /** @hidden */
  24344. export var packingFunctions: {
  24345. name: string;
  24346. shader: string;
  24347. };
  24348. }
  24349. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24350. /** @hidden */
  24351. export var kernelBlurFragment: {
  24352. name: string;
  24353. shader: string;
  24354. };
  24355. }
  24356. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24357. /** @hidden */
  24358. export var kernelBlurFragment2: {
  24359. name: string;
  24360. shader: string;
  24361. };
  24362. }
  24363. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24364. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24365. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24366. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24367. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24368. /** @hidden */
  24369. export var kernelBlurPixelShader: {
  24370. name: string;
  24371. shader: string;
  24372. };
  24373. }
  24374. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24375. /** @hidden */
  24376. export var kernelBlurVertex: {
  24377. name: string;
  24378. shader: string;
  24379. };
  24380. }
  24381. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24382. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24383. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24384. /** @hidden */
  24385. export var kernelBlurVertexShader: {
  24386. name: string;
  24387. shader: string;
  24388. };
  24389. }
  24390. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24391. import { Vector2 } from "babylonjs/Maths/math.vector";
  24392. import { Nullable } from "babylonjs/types";
  24393. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24394. import { Camera } from "babylonjs/Cameras/camera";
  24395. import { Effect } from "babylonjs/Materials/effect";
  24396. import { Engine } from "babylonjs/Engines/engine";
  24397. import "babylonjs/Shaders/kernelBlur.fragment";
  24398. import "babylonjs/Shaders/kernelBlur.vertex";
  24399. import { Scene } from "babylonjs/scene";
  24400. /**
  24401. * The Blur Post Process which blurs an image based on a kernel and direction.
  24402. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24403. */
  24404. export class BlurPostProcess extends PostProcess {
  24405. private blockCompilation;
  24406. protected _kernel: number;
  24407. protected _idealKernel: number;
  24408. protected _packedFloat: boolean;
  24409. private _staticDefines;
  24410. /** The direction in which to blur the image. */
  24411. direction: Vector2;
  24412. /**
  24413. * Sets the length in pixels of the blur sample region
  24414. */
  24415. set kernel(v: number);
  24416. /**
  24417. * Gets the length in pixels of the blur sample region
  24418. */
  24419. get kernel(): number;
  24420. /**
  24421. * Sets wether or not the blur needs to unpack/repack floats
  24422. */
  24423. set packedFloat(v: boolean);
  24424. /**
  24425. * Gets wether or not the blur is unpacking/repacking floats
  24426. */
  24427. get packedFloat(): boolean;
  24428. /**
  24429. * Gets a string identifying the name of the class
  24430. * @returns "BlurPostProcess" string
  24431. */
  24432. getClassName(): string;
  24433. /**
  24434. * Creates a new instance BlurPostProcess
  24435. * @param name The name of the effect.
  24436. * @param direction The direction in which to blur the image.
  24437. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  24438. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24439. * @param camera The camera to apply the render pass to.
  24440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24441. * @param engine The engine which the post process will be applied. (default: current engine)
  24442. * @param reusable If the post process can be reused on the same frame. (default: false)
  24443. * @param textureType Type of textures used when performing the post process. (default: 0)
  24444. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  24445. */
  24446. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  24447. /**
  24448. * Updates the effect with the current post process compile time values and recompiles the shader.
  24449. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24450. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24451. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24452. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  24453. * @param onCompiled Called when the shader has been compiled.
  24454. * @param onError Called if there is an error when compiling a shader.
  24455. */
  24456. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24457. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24458. /**
  24459. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24460. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24461. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24462. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24463. * The gaps between physical kernels are compensated for in the weighting of the samples
  24464. * @param idealKernel Ideal blur kernel.
  24465. * @return Nearest best kernel.
  24466. */
  24467. protected _nearestBestKernel(idealKernel: number): number;
  24468. /**
  24469. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24470. * @param x The point on the Gaussian distribution to sample.
  24471. * @return the value of the Gaussian function at x.
  24472. */
  24473. protected _gaussianWeight(x: number): number;
  24474. /**
  24475. * Generates a string that can be used as a floating point number in GLSL.
  24476. * @param x Value to print.
  24477. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24478. * @return GLSL float string.
  24479. */
  24480. protected _glslFloat(x: number, decimalFigures?: number): string;
  24481. /** @hidden */
  24482. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24483. }
  24484. }
  24485. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24486. import { Scene } from "babylonjs/scene";
  24487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24488. import { Plane } from "babylonjs/Maths/math.plane";
  24489. /**
  24490. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24491. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24492. * You can then easily use it as a reflectionTexture on a flat surface.
  24493. * In case the surface is not a plane, please consider relying on reflection probes.
  24494. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24495. */
  24496. export class MirrorTexture extends RenderTargetTexture {
  24497. private scene;
  24498. /**
  24499. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24500. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  24501. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24502. */
  24503. mirrorPlane: Plane;
  24504. /**
  24505. * Define the blur ratio used to blur the reflection if needed.
  24506. */
  24507. set blurRatio(value: number);
  24508. get blurRatio(): number;
  24509. /**
  24510. * Define the adaptive blur kernel used to blur the reflection if needed.
  24511. * This will autocompute the closest best match for the `blurKernel`
  24512. */
  24513. set adaptiveBlurKernel(value: number);
  24514. /**
  24515. * Define the blur kernel used to blur the reflection if needed.
  24516. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24517. */
  24518. set blurKernel(value: number);
  24519. /**
  24520. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24521. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24522. */
  24523. set blurKernelX(value: number);
  24524. get blurKernelX(): number;
  24525. /**
  24526. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24527. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24528. */
  24529. set blurKernelY(value: number);
  24530. get blurKernelY(): number;
  24531. private _autoComputeBlurKernel;
  24532. protected _onRatioRescale(): void;
  24533. private _updateGammaSpace;
  24534. private _imageProcessingConfigChangeObserver;
  24535. private _transformMatrix;
  24536. private _mirrorMatrix;
  24537. private _savedViewMatrix;
  24538. private _blurX;
  24539. private _blurY;
  24540. private _adaptiveBlurKernel;
  24541. private _blurKernelX;
  24542. private _blurKernelY;
  24543. private _blurRatio;
  24544. /**
  24545. * Instantiates a Mirror Texture.
  24546. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24547. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24548. * You can then easily use it as a reflectionTexture on a flat surface.
  24549. * In case the surface is not a plane, please consider relying on reflection probes.
  24550. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24551. * @param name
  24552. * @param size
  24553. * @param scene
  24554. * @param generateMipMaps
  24555. * @param type
  24556. * @param samplingMode
  24557. * @param generateDepthBuffer
  24558. */
  24559. constructor(name: string, size: number | {
  24560. width: number;
  24561. height: number;
  24562. } | {
  24563. ratio: number;
  24564. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24565. private _preparePostProcesses;
  24566. /**
  24567. * Clone the mirror texture.
  24568. * @returns the cloned texture
  24569. */
  24570. clone(): MirrorTexture;
  24571. /**
  24572. * Serialize the texture to a JSON representation you could use in Parse later on
  24573. * @returns the serialized JSON representation
  24574. */
  24575. serialize(): any;
  24576. /**
  24577. * Dispose the texture and release its associated resources.
  24578. */
  24579. dispose(): void;
  24580. }
  24581. }
  24582. declare module "babylonjs/Materials/Textures/texture" {
  24583. import { Observable } from "babylonjs/Misc/observable";
  24584. import { Nullable } from "babylonjs/types";
  24585. import { Matrix } from "babylonjs/Maths/math.vector";
  24586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24587. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24588. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24589. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24590. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24591. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24592. import { Scene } from "babylonjs/scene";
  24593. /**
  24594. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24595. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24596. */
  24597. export class Texture extends BaseTexture {
  24598. /**
  24599. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24600. */
  24601. static SerializeBuffers: boolean;
  24602. /**
  24603. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  24604. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  24605. */
  24606. static ForceSerializeBuffers: boolean;
  24607. /** @hidden */
  24608. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24609. /** @hidden */
  24610. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24611. /** @hidden */
  24612. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24613. /** nearest is mag = nearest and min = nearest and mip = linear */
  24614. static readonly NEAREST_SAMPLINGMODE: number;
  24615. /** nearest is mag = nearest and min = nearest and mip = linear */
  24616. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24617. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24618. static readonly BILINEAR_SAMPLINGMODE: number;
  24619. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24620. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24621. /** Trilinear is mag = linear and min = linear and mip = linear */
  24622. static readonly TRILINEAR_SAMPLINGMODE: number;
  24623. /** Trilinear is mag = linear and min = linear and mip = linear */
  24624. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24625. /** mag = nearest and min = nearest and mip = nearest */
  24626. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24627. /** mag = nearest and min = linear and mip = nearest */
  24628. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24629. /** mag = nearest and min = linear and mip = linear */
  24630. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24631. /** mag = nearest and min = linear and mip = none */
  24632. static readonly NEAREST_LINEAR: number;
  24633. /** mag = nearest and min = nearest and mip = none */
  24634. static readonly NEAREST_NEAREST: number;
  24635. /** mag = linear and min = nearest and mip = nearest */
  24636. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24637. /** mag = linear and min = nearest and mip = linear */
  24638. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24639. /** mag = linear and min = linear and mip = none */
  24640. static readonly LINEAR_LINEAR: number;
  24641. /** mag = linear and min = nearest and mip = none */
  24642. static readonly LINEAR_NEAREST: number;
  24643. /** Explicit coordinates mode */
  24644. static readonly EXPLICIT_MODE: number;
  24645. /** Spherical coordinates mode */
  24646. static readonly SPHERICAL_MODE: number;
  24647. /** Planar coordinates mode */
  24648. static readonly PLANAR_MODE: number;
  24649. /** Cubic coordinates mode */
  24650. static readonly CUBIC_MODE: number;
  24651. /** Projection coordinates mode */
  24652. static readonly PROJECTION_MODE: number;
  24653. /** Inverse Cubic coordinates mode */
  24654. static readonly SKYBOX_MODE: number;
  24655. /** Inverse Cubic coordinates mode */
  24656. static readonly INVCUBIC_MODE: number;
  24657. /** Equirectangular coordinates mode */
  24658. static readonly EQUIRECTANGULAR_MODE: number;
  24659. /** Equirectangular Fixed coordinates mode */
  24660. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24661. /** Equirectangular Fixed Mirrored coordinates mode */
  24662. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24663. /** Texture is not repeating outside of 0..1 UVs */
  24664. static readonly CLAMP_ADDRESSMODE: number;
  24665. /** Texture is repeating outside of 0..1 UVs */
  24666. static readonly WRAP_ADDRESSMODE: number;
  24667. /** Texture is repeating and mirrored */
  24668. static readonly MIRROR_ADDRESSMODE: number;
  24669. /**
  24670. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  24671. */
  24672. static UseSerializedUrlIfAny: boolean;
  24673. /**
  24674. * Define the url of the texture.
  24675. */
  24676. url: Nullable<string>;
  24677. /**
  24678. * Define an offset on the texture to offset the u coordinates of the UVs
  24679. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24680. */
  24681. uOffset: number;
  24682. /**
  24683. * Define an offset on the texture to offset the v coordinates of the UVs
  24684. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24685. */
  24686. vOffset: number;
  24687. /**
  24688. * Define an offset on the texture to scale the u coordinates of the UVs
  24689. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24690. */
  24691. uScale: number;
  24692. /**
  24693. * Define an offset on the texture to scale the v coordinates of the UVs
  24694. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24695. */
  24696. vScale: number;
  24697. /**
  24698. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24699. * @see https://doc.babylonjs.com/how_to/more_materials
  24700. */
  24701. uAng: number;
  24702. /**
  24703. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24704. * @see https://doc.babylonjs.com/how_to/more_materials
  24705. */
  24706. vAng: number;
  24707. /**
  24708. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24709. * @see https://doc.babylonjs.com/how_to/more_materials
  24710. */
  24711. wAng: number;
  24712. /**
  24713. * Defines the center of rotation (U)
  24714. */
  24715. uRotationCenter: number;
  24716. /**
  24717. * Defines the center of rotation (V)
  24718. */
  24719. vRotationCenter: number;
  24720. /**
  24721. * Defines the center of rotation (W)
  24722. */
  24723. wRotationCenter: number;
  24724. /**
  24725. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24726. */
  24727. homogeneousRotationInUVTransform: boolean;
  24728. /**
  24729. * Are mip maps generated for this texture or not.
  24730. */
  24731. get noMipmap(): boolean;
  24732. /**
  24733. * List of inspectable custom properties (used by the Inspector)
  24734. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24735. */
  24736. inspectableCustomProperties: Nullable<IInspectable[]>;
  24737. private _noMipmap;
  24738. /** @hidden */
  24739. _invertY: boolean;
  24740. private _rowGenerationMatrix;
  24741. private _cachedTextureMatrix;
  24742. private _projectionModeMatrix;
  24743. private _t0;
  24744. private _t1;
  24745. private _t2;
  24746. private _cachedUOffset;
  24747. private _cachedVOffset;
  24748. private _cachedUScale;
  24749. private _cachedVScale;
  24750. private _cachedUAng;
  24751. private _cachedVAng;
  24752. private _cachedWAng;
  24753. private _cachedProjectionMatrixId;
  24754. private _cachedURotationCenter;
  24755. private _cachedVRotationCenter;
  24756. private _cachedWRotationCenter;
  24757. private _cachedHomogeneousRotationInUVTransform;
  24758. private _cachedCoordinatesMode;
  24759. /** @hidden */
  24760. protected _initialSamplingMode: number;
  24761. /** @hidden */
  24762. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24763. private _deleteBuffer;
  24764. protected _format: Nullable<number>;
  24765. private _delayedOnLoad;
  24766. private _delayedOnError;
  24767. private _mimeType?;
  24768. private _loaderOptions?;
  24769. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24770. get mimeType(): string | undefined;
  24771. /**
  24772. * Observable triggered once the texture has been loaded.
  24773. */
  24774. onLoadObservable: Observable<Texture>;
  24775. protected _isBlocking: boolean;
  24776. /**
  24777. * Is the texture preventing material to render while loading.
  24778. * If false, a default texture will be used instead of the loading one during the preparation step.
  24779. */
  24780. set isBlocking(value: boolean);
  24781. get isBlocking(): boolean;
  24782. /**
  24783. * Get the current sampling mode associated with the texture.
  24784. */
  24785. get samplingMode(): number;
  24786. /**
  24787. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24788. */
  24789. get invertY(): boolean;
  24790. /**
  24791. * Instantiates a new texture.
  24792. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24793. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24794. * @param url defines the url of the picture to load as a texture
  24795. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24796. * @param noMipmap defines if the texture will require mip maps or not
  24797. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24798. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24799. * @param onLoad defines a callback triggered when the texture has been loaded
  24800. * @param onError defines a callback triggered when an error occurred during the loading session
  24801. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24802. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24803. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24804. * @param mimeType defines an optional mime type information
  24805. * @param loaderOptions options to be passed to the loader
  24806. */
  24807. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  24808. /**
  24809. * Update the url (and optional buffer) of this texture if url was null during construction.
  24810. * @param url the url of the texture
  24811. * @param buffer the buffer of the texture (defaults to null)
  24812. * @param onLoad callback called when the texture is loaded (defaults to null)
  24813. */
  24814. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24815. /**
  24816. * Finish the loading sequence of a texture flagged as delayed load.
  24817. * @hidden
  24818. */
  24819. delayLoad(): void;
  24820. private _prepareRowForTextureGeneration;
  24821. /**
  24822. * Checks if the texture has the same transform matrix than another texture
  24823. * @param texture texture to check against
  24824. * @returns true if the transforms are the same, else false
  24825. */
  24826. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24827. /**
  24828. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24829. * @returns the transform matrix of the texture.
  24830. */
  24831. getTextureMatrix(uBase?: number): Matrix;
  24832. /**
  24833. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24834. * @returns The reflection texture transform
  24835. */
  24836. getReflectionTextureMatrix(): Matrix;
  24837. /**
  24838. * Clones the texture.
  24839. * @returns the cloned texture
  24840. */
  24841. clone(): Texture;
  24842. /**
  24843. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24844. * @returns The JSON representation of the texture
  24845. */
  24846. serialize(): any;
  24847. /**
  24848. * Get the current class name of the texture useful for serialization or dynamic coding.
  24849. * @returns "Texture"
  24850. */
  24851. getClassName(): string;
  24852. /**
  24853. * Dispose the texture and release its associated resources.
  24854. */
  24855. dispose(): void;
  24856. /**
  24857. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24858. * @param parsedTexture Define the JSON representation of the texture
  24859. * @param scene Define the scene the parsed texture should be instantiated in
  24860. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24861. * @returns The parsed texture if successful
  24862. */
  24863. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24864. /**
  24865. * Creates a texture from its base 64 representation.
  24866. * @param data Define the base64 payload without the data: prefix
  24867. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24868. * @param scene Define the scene the texture should belong to
  24869. * @param noMipmap Forces the texture to not create mip map information if true
  24870. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24871. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24872. * @param onLoad define a callback triggered when the texture has been loaded
  24873. * @param onError define a callback triggered when an error occurred during the loading session
  24874. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24875. * @returns the created texture
  24876. */
  24877. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24878. /**
  24879. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24880. * @param data Define the base64 payload without the data: prefix
  24881. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24882. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24883. * @param scene Define the scene the texture should belong to
  24884. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24885. * @param noMipmap Forces the texture to not create mip map information if true
  24886. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24887. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24888. * @param onLoad define a callback triggered when the texture has been loaded
  24889. * @param onError define a callback triggered when an error occurred during the loading session
  24890. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24891. * @returns the created texture
  24892. */
  24893. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  24894. }
  24895. }
  24896. declare module "babylonjs/Sprites/thinSprite" {
  24897. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24898. import { Nullable } from "babylonjs/types";
  24899. /**
  24900. * ThinSprite Class used to represent a thin sprite
  24901. * This is the base class for sprites but can also directly be used with ThinEngine
  24902. * @see https://doc.babylonjs.com/babylon101/sprites
  24903. */
  24904. export class ThinSprite {
  24905. /** Gets or sets the cell index in the sprite sheet */
  24906. cellIndex: number;
  24907. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24908. cellRef: string;
  24909. /** Gets or sets the current world position */
  24910. position: IVector3Like;
  24911. /** Gets or sets the main color */
  24912. color: IColor4Like;
  24913. /** Gets or sets the width */
  24914. width: number;
  24915. /** Gets or sets the height */
  24916. height: number;
  24917. /** Gets or sets rotation angle */
  24918. angle: number;
  24919. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24920. invertU: boolean;
  24921. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24922. invertV: boolean;
  24923. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24924. isVisible: boolean;
  24925. /**
  24926. * Returns a boolean indicating if the animation is started
  24927. */
  24928. get animationStarted(): boolean;
  24929. /** Gets the initial key for the animation (setting it will restart the animation) */
  24930. get fromIndex(): number;
  24931. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24932. get toIndex(): number;
  24933. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24934. get loopAnimation(): boolean;
  24935. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24936. get delay(): number;
  24937. /** @hidden */
  24938. _xOffset: number;
  24939. /** @hidden */
  24940. _yOffset: number;
  24941. /** @hidden */
  24942. _xSize: number;
  24943. /** @hidden */
  24944. _ySize: number;
  24945. private _animationStarted;
  24946. protected _loopAnimation: boolean;
  24947. protected _fromIndex: number;
  24948. protected _toIndex: number;
  24949. protected _delay: number;
  24950. private _direction;
  24951. private _time;
  24952. private _onBaseAnimationEnd;
  24953. /**
  24954. * Creates a new Thin Sprite
  24955. */
  24956. constructor();
  24957. /**
  24958. * Starts an animation
  24959. * @param from defines the initial key
  24960. * @param to defines the end key
  24961. * @param loop defines if the animation must loop
  24962. * @param delay defines the start delay (in ms)
  24963. * @param onAnimationEnd defines a callback for when the animation ends
  24964. */
  24965. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24966. /** Stops current animation (if any) */
  24967. stopAnimation(): void;
  24968. /** @hidden */
  24969. _animate(deltaTime: number): void;
  24970. }
  24971. }
  24972. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24973. /** @hidden */
  24974. export var imageProcessingCompatibility: {
  24975. name: string;
  24976. shader: string;
  24977. };
  24978. }
  24979. declare module "babylonjs/Shaders/sprites.fragment" {
  24980. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24981. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24982. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24983. /** @hidden */
  24984. export var spritesPixelShader: {
  24985. name: string;
  24986. shader: string;
  24987. };
  24988. }
  24989. declare module "babylonjs/Shaders/sprites.vertex" {
  24990. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24991. /** @hidden */
  24992. export var spritesVertexShader: {
  24993. name: string;
  24994. shader: string;
  24995. };
  24996. }
  24997. declare module "babylonjs/Sprites/spriteRenderer" {
  24998. import { Nullable } from "babylonjs/types";
  24999. import { IMatrixLike } from "babylonjs/Maths/math.like";
  25000. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  25001. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  25002. import { ISize } from "babylonjs/Maths/math.size";
  25003. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  25004. import { Scene } from "babylonjs/scene";
  25005. import "babylonjs/Engines/Extensions/engine.alpha";
  25006. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  25007. import "babylonjs/Shaders/sprites.fragment";
  25008. import "babylonjs/Shaders/sprites.vertex";
  25009. /**
  25010. * Class used to render sprites.
  25011. *
  25012. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  25013. */
  25014. export class SpriteRenderer {
  25015. /**
  25016. * Defines the texture of the spritesheet
  25017. */
  25018. texture: Nullable<ThinTexture>;
  25019. /**
  25020. * Defines the default width of a cell in the spritesheet
  25021. */
  25022. cellWidth: number;
  25023. /**
  25024. * Defines the default height of a cell in the spritesheet
  25025. */
  25026. cellHeight: number;
  25027. /**
  25028. * Blend mode use to render the particle, it can be any of
  25029. * the static Constants.ALPHA_x properties provided in this class.
  25030. * Default value is Constants.ALPHA_COMBINE
  25031. */
  25032. blendMode: number;
  25033. /**
  25034. * Gets or sets a boolean indicating if alpha mode is automatically
  25035. * reset.
  25036. */
  25037. autoResetAlpha: boolean;
  25038. /**
  25039. * Disables writing to the depth buffer when rendering the sprites.
  25040. * It can be handy to disable depth writing when using textures without alpha channel
  25041. * and setting some specific blend modes.
  25042. */
  25043. disableDepthWrite: boolean;
  25044. /**
  25045. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  25046. */
  25047. fogEnabled: boolean;
  25048. /**
  25049. * Gets the capacity of the manager
  25050. */
  25051. get capacity(): number;
  25052. private readonly _engine;
  25053. private readonly _useVAO;
  25054. private readonly _useInstancing;
  25055. private readonly _scene;
  25056. private readonly _capacity;
  25057. private readonly _epsilon;
  25058. private _vertexBufferSize;
  25059. private _vertexData;
  25060. private _buffer;
  25061. private _vertexBuffers;
  25062. private _spriteBuffer;
  25063. private _indexBuffer;
  25064. private _effectBase;
  25065. private _effectFog;
  25066. private _vertexArrayObject;
  25067. /**
  25068. * Creates a new sprite Renderer
  25069. * @param engine defines the engine the renderer works with
  25070. * @param capacity defines the maximum allowed number of sprites
  25071. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  25072. * @param scene defines the hosting scene
  25073. */
  25074. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  25075. /**
  25076. * Render all child sprites
  25077. * @param sprites defines the list of sprites to render
  25078. * @param deltaTime defines the time since last frame
  25079. * @param viewMatrix defines the viewMatrix to use to render the sprites
  25080. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  25081. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  25082. */
  25083. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  25084. private _appendSpriteVertex;
  25085. /**
  25086. * Release associated resources
  25087. */
  25088. dispose(): void;
  25089. }
  25090. }
  25091. declare module "babylonjs/Sprites/spriteManager" {
  25092. import { IDisposable, Scene } from "babylonjs/scene";
  25093. import { Nullable } from "babylonjs/types";
  25094. import { Observable } from "babylonjs/Misc/observable";
  25095. import { Sprite } from "babylonjs/Sprites/sprite";
  25096. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25097. import { Camera } from "babylonjs/Cameras/camera";
  25098. import { Texture } from "babylonjs/Materials/Textures/texture";
  25099. import { Ray } from "babylonjs/Culling/ray";
  25100. /**
  25101. * Defines the minimum interface to fullfil in order to be a sprite manager.
  25102. */
  25103. export interface ISpriteManager extends IDisposable {
  25104. /**
  25105. * Gets manager's name
  25106. */
  25107. name: string;
  25108. /**
  25109. * Restricts the camera to viewing objects with the same layerMask.
  25110. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  25111. */
  25112. layerMask: number;
  25113. /**
  25114. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25115. */
  25116. isPickable: boolean;
  25117. /**
  25118. * Gets the hosting scene
  25119. */
  25120. scene: Scene;
  25121. /**
  25122. * Specifies the rendering group id for this mesh (0 by default)
  25123. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25124. */
  25125. renderingGroupId: number;
  25126. /**
  25127. * Defines the list of sprites managed by the manager.
  25128. */
  25129. sprites: Array<Sprite>;
  25130. /**
  25131. * Gets or sets the spritesheet texture
  25132. */
  25133. texture: Texture;
  25134. /** Defines the default width of a cell in the spritesheet */
  25135. cellWidth: number;
  25136. /** Defines the default height of a cell in the spritesheet */
  25137. cellHeight: number;
  25138. /**
  25139. * Tests the intersection of a sprite with a specific ray.
  25140. * @param ray The ray we are sending to test the collision
  25141. * @param camera The camera space we are sending rays in
  25142. * @param predicate A predicate allowing excluding sprites from the list of object to test
  25143. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25144. * @returns picking info or null.
  25145. */
  25146. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25147. /**
  25148. * Intersects the sprites with a ray
  25149. * @param ray defines the ray to intersect with
  25150. * @param camera defines the current active camera
  25151. * @param predicate defines a predicate used to select candidate sprites
  25152. * @returns null if no hit or a PickingInfo array
  25153. */
  25154. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25155. /**
  25156. * Renders the list of sprites on screen.
  25157. */
  25158. render(): void;
  25159. }
  25160. /**
  25161. * Class used to manage multiple sprites on the same spritesheet
  25162. * @see https://doc.babylonjs.com/babylon101/sprites
  25163. */
  25164. export class SpriteManager implements ISpriteManager {
  25165. /** defines the manager's name */
  25166. name: string;
  25167. /** Define the Url to load snippets */
  25168. static SnippetUrl: string;
  25169. /** Snippet ID if the manager was created from the snippet server */
  25170. snippetId: string;
  25171. /** Gets the list of sprites */
  25172. sprites: Sprite[];
  25173. /** Gets or sets the rendering group id (0 by default) */
  25174. renderingGroupId: number;
  25175. /** Gets or sets camera layer mask */
  25176. layerMask: number;
  25177. /** Gets or sets a boolean indicating if the sprites are pickable */
  25178. isPickable: boolean;
  25179. /**
  25180. * An event triggered when the manager is disposed.
  25181. */
  25182. onDisposeObservable: Observable<SpriteManager>;
  25183. /**
  25184. * Callback called when the manager is disposed
  25185. */
  25186. set onDispose(callback: () => void);
  25187. /**
  25188. * Gets or sets the unique id of the sprite
  25189. */
  25190. uniqueId: number;
  25191. /**
  25192. * Gets the array of sprites
  25193. */
  25194. get children(): Sprite[];
  25195. /**
  25196. * Gets the hosting scene
  25197. */
  25198. get scene(): Scene;
  25199. /**
  25200. * Gets the capacity of the manager
  25201. */
  25202. get capacity(): number;
  25203. /**
  25204. * Gets or sets the spritesheet texture
  25205. */
  25206. get texture(): Texture;
  25207. set texture(value: Texture);
  25208. /** Defines the default width of a cell in the spritesheet */
  25209. get cellWidth(): number;
  25210. set cellWidth(value: number);
  25211. /** Defines the default height of a cell in the spritesheet */
  25212. get cellHeight(): number;
  25213. set cellHeight(value: number);
  25214. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  25215. get fogEnabled(): boolean;
  25216. set fogEnabled(value: boolean);
  25217. /**
  25218. * Blend mode use to render the particle, it can be any of
  25219. * the static Constants.ALPHA_x properties provided in this class.
  25220. * Default value is Constants.ALPHA_COMBINE
  25221. */
  25222. get blendMode(): number;
  25223. set blendMode(blendMode: number);
  25224. /** Disables writing to the depth buffer when rendering the sprites.
  25225. * It can be handy to disable depth writing when using textures without alpha channel
  25226. * and setting some specific blend modes.
  25227. */
  25228. disableDepthWrite: boolean;
  25229. private _spriteRenderer;
  25230. /** Associative array from JSON sprite data file */
  25231. private _cellData;
  25232. /** Array of sprite names from JSON sprite data file */
  25233. private _spriteMap;
  25234. /** True when packed cell data from JSON file is ready*/
  25235. private _packedAndReady;
  25236. private _textureContent;
  25237. private _onDisposeObserver;
  25238. private _fromPacked;
  25239. private _scene;
  25240. /**
  25241. * Creates a new sprite manager
  25242. * @param name defines the manager's name
  25243. * @param imgUrl defines the sprite sheet url
  25244. * @param capacity defines the maximum allowed number of sprites
  25245. * @param cellSize defines the size of a sprite cell
  25246. * @param scene defines the hosting scene
  25247. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  25248. * @param samplingMode defines the smapling mode to use with spritesheet
  25249. * @param fromPacked set to false; do not alter
  25250. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  25251. */
  25252. constructor(
  25253. /** defines the manager's name */
  25254. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  25255. /**
  25256. * Returns the string "SpriteManager"
  25257. * @returns "SpriteManager"
  25258. */
  25259. getClassName(): string;
  25260. private _makePacked;
  25261. private _checkTextureAlpha;
  25262. /**
  25263. * Intersects the sprites with a ray
  25264. * @param ray defines the ray to intersect with
  25265. * @param camera defines the current active camera
  25266. * @param predicate defines a predicate used to select candidate sprites
  25267. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  25268. * @returns null if no hit or a PickingInfo
  25269. */
  25270. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25271. /**
  25272. * Intersects the sprites with a ray
  25273. * @param ray defines the ray to intersect with
  25274. * @param camera defines the current active camera
  25275. * @param predicate defines a predicate used to select candidate sprites
  25276. * @returns null if no hit or a PickingInfo array
  25277. */
  25278. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25279. /**
  25280. * Render all child sprites
  25281. */
  25282. render(): void;
  25283. private _customUpdate;
  25284. /**
  25285. * Release associated resources
  25286. */
  25287. dispose(): void;
  25288. /**
  25289. * Serializes the sprite manager to a JSON object
  25290. * @param serializeTexture defines if the texture must be serialized as well
  25291. * @returns the JSON object
  25292. */
  25293. serialize(serializeTexture?: boolean): any;
  25294. /**
  25295. * Parses a JSON object to create a new sprite manager.
  25296. * @param parsedManager The JSON object to parse
  25297. * @param scene The scene to create the sprite managerin
  25298. * @param rootUrl The root url to use to load external dependencies like texture
  25299. * @returns the new sprite manager
  25300. */
  25301. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  25302. /**
  25303. * Creates a sprite manager from a snippet saved in a remote file
  25304. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  25305. * @param url defines the url to load from
  25306. * @param scene defines the hosting scene
  25307. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25308. * @returns a promise that will resolve to the new sprite manager
  25309. */
  25310. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25311. /**
  25312. * Creates a sprite manager from a snippet saved by the sprite editor
  25313. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  25314. * @param scene defines the hosting scene
  25315. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25316. * @returns a promise that will resolve to the new sprite manager
  25317. */
  25318. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25319. }
  25320. }
  25321. declare module "babylonjs/Sprites/sprite" {
  25322. import { Vector3 } from "babylonjs/Maths/math.vector";
  25323. import { Nullable } from "babylonjs/types";
  25324. import { ActionManager } from "babylonjs/Actions/actionManager";
  25325. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  25326. import { Color4 } from "babylonjs/Maths/math.color";
  25327. import { Observable } from "babylonjs/Misc/observable";
  25328. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25329. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  25330. import { Animation } from "babylonjs/Animations/animation";
  25331. /**
  25332. * Class used to represent a sprite
  25333. * @see https://doc.babylonjs.com/babylon101/sprites
  25334. */
  25335. export class Sprite extends ThinSprite implements IAnimatable {
  25336. /** defines the name */
  25337. name: string;
  25338. /** Gets or sets the current world position */
  25339. position: Vector3;
  25340. /** Gets or sets the main color */
  25341. color: Color4;
  25342. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  25343. disposeWhenFinishedAnimating: boolean;
  25344. /** Gets the list of attached animations */
  25345. animations: Nullable<Array<Animation>>;
  25346. /** Gets or sets a boolean indicating if the sprite can be picked */
  25347. isPickable: boolean;
  25348. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  25349. useAlphaForPicking: boolean;
  25350. /**
  25351. * Gets or sets the associated action manager
  25352. */
  25353. actionManager: Nullable<ActionManager>;
  25354. /**
  25355. * An event triggered when the control has been disposed
  25356. */
  25357. onDisposeObservable: Observable<Sprite>;
  25358. private _manager;
  25359. private _onAnimationEnd;
  25360. /**
  25361. * Gets or sets the sprite size
  25362. */
  25363. get size(): number;
  25364. set size(value: number);
  25365. /**
  25366. * Gets or sets the unique id of the sprite
  25367. */
  25368. uniqueId: number;
  25369. /**
  25370. * Gets the manager of this sprite
  25371. */
  25372. get manager(): ISpriteManager;
  25373. /**
  25374. * Creates a new Sprite
  25375. * @param name defines the name
  25376. * @param manager defines the manager
  25377. */
  25378. constructor(
  25379. /** defines the name */
  25380. name: string, manager: ISpriteManager);
  25381. /**
  25382. * Returns the string "Sprite"
  25383. * @returns "Sprite"
  25384. */
  25385. getClassName(): string;
  25386. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  25387. get fromIndex(): number;
  25388. set fromIndex(value: number);
  25389. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  25390. get toIndex(): number;
  25391. set toIndex(value: number);
  25392. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  25393. get loopAnimation(): boolean;
  25394. set loopAnimation(value: boolean);
  25395. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  25396. get delay(): number;
  25397. set delay(value: number);
  25398. /**
  25399. * Starts an animation
  25400. * @param from defines the initial key
  25401. * @param to defines the end key
  25402. * @param loop defines if the animation must loop
  25403. * @param delay defines the start delay (in ms)
  25404. * @param onAnimationEnd defines a callback to call when animation ends
  25405. */
  25406. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  25407. private _endAnimation;
  25408. /** Release associated resources */
  25409. dispose(): void;
  25410. /**
  25411. * Serializes the sprite to a JSON object
  25412. * @returns the JSON object
  25413. */
  25414. serialize(): any;
  25415. /**
  25416. * Parses a JSON object to create a new sprite
  25417. * @param parsedSprite The JSON object to parse
  25418. * @param manager defines the hosting manager
  25419. * @returns the new sprite
  25420. */
  25421. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  25422. }
  25423. }
  25424. declare module "babylonjs/Collisions/pickingInfo" {
  25425. import { Nullable } from "babylonjs/types";
  25426. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25428. import { Sprite } from "babylonjs/Sprites/sprite";
  25429. import { Ray } from "babylonjs/Culling/ray";
  25430. /**
  25431. * Information about the result of picking within a scene
  25432. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  25433. */
  25434. export class PickingInfo {
  25435. /** @hidden */
  25436. _pickingUnavailable: boolean;
  25437. /**
  25438. * If the pick collided with an object
  25439. */
  25440. hit: boolean;
  25441. /**
  25442. * Distance away where the pick collided
  25443. */
  25444. distance: number;
  25445. /**
  25446. * The location of pick collision
  25447. */
  25448. pickedPoint: Nullable<Vector3>;
  25449. /**
  25450. * The mesh corresponding the the pick collision
  25451. */
  25452. pickedMesh: Nullable<AbstractMesh>;
  25453. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  25454. bu: number;
  25455. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  25456. bv: number;
  25457. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25458. faceId: number;
  25459. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25460. subMeshFaceId: number;
  25461. /** Id of the the submesh that was picked */
  25462. subMeshId: number;
  25463. /** If a sprite was picked, this will be the sprite the pick collided with */
  25464. pickedSprite: Nullable<Sprite>;
  25465. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  25466. thinInstanceIndex: number;
  25467. /**
  25468. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  25469. */
  25470. originMesh: Nullable<AbstractMesh>;
  25471. /**
  25472. * The ray that was used to perform the picking.
  25473. */
  25474. ray: Nullable<Ray>;
  25475. /**
  25476. * Gets the normal correspodning to the face the pick collided with
  25477. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25478. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25479. * @returns The normal correspodning to the face the pick collided with
  25480. */
  25481. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  25482. /**
  25483. * Gets the texture coordinates of where the pick occured
  25484. * @returns the vector containing the coordnates of the texture
  25485. */
  25486. getTextureCoordinates(): Nullable<Vector2>;
  25487. }
  25488. }
  25489. declare module "babylonjs/Events/pointerEvents" {
  25490. import { Nullable } from "babylonjs/types";
  25491. import { Vector2 } from "babylonjs/Maths/math.vector";
  25492. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25493. import { Ray } from "babylonjs/Culling/ray";
  25494. /**
  25495. * Gather the list of pointer event types as constants.
  25496. */
  25497. export class PointerEventTypes {
  25498. /**
  25499. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  25500. */
  25501. static readonly POINTERDOWN: number;
  25502. /**
  25503. * The pointerup event is fired when a pointer is no longer active.
  25504. */
  25505. static readonly POINTERUP: number;
  25506. /**
  25507. * The pointermove event is fired when a pointer changes coordinates.
  25508. */
  25509. static readonly POINTERMOVE: number;
  25510. /**
  25511. * The pointerwheel event is fired when a mouse wheel has been rotated.
  25512. */
  25513. static readonly POINTERWHEEL: number;
  25514. /**
  25515. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  25516. */
  25517. static readonly POINTERPICK: number;
  25518. /**
  25519. * The pointertap event is fired when a the object has been touched and released without drag.
  25520. */
  25521. static readonly POINTERTAP: number;
  25522. /**
  25523. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  25524. */
  25525. static readonly POINTERDOUBLETAP: number;
  25526. }
  25527. /**
  25528. * Base class of pointer info types.
  25529. */
  25530. export class PointerInfoBase {
  25531. /**
  25532. * Defines the type of event (PointerEventTypes)
  25533. */
  25534. type: number;
  25535. /**
  25536. * Defines the related dom event
  25537. */
  25538. event: PointerEvent | MouseWheelEvent;
  25539. /**
  25540. * Instantiates the base class of pointers info.
  25541. * @param type Defines the type of event (PointerEventTypes)
  25542. * @param event Defines the related dom event
  25543. */
  25544. constructor(
  25545. /**
  25546. * Defines the type of event (PointerEventTypes)
  25547. */
  25548. type: number,
  25549. /**
  25550. * Defines the related dom event
  25551. */
  25552. event: PointerEvent | MouseWheelEvent);
  25553. }
  25554. /**
  25555. * This class is used to store pointer related info for the onPrePointerObservable event.
  25556. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  25557. */
  25558. export class PointerInfoPre extends PointerInfoBase {
  25559. /**
  25560. * Ray from a pointer if availible (eg. 6dof controller)
  25561. */
  25562. ray: Nullable<Ray>;
  25563. /**
  25564. * Defines the local position of the pointer on the canvas.
  25565. */
  25566. localPosition: Vector2;
  25567. /**
  25568. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  25569. */
  25570. skipOnPointerObservable: boolean;
  25571. /**
  25572. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  25573. * @param type Defines the type of event (PointerEventTypes)
  25574. * @param event Defines the related dom event
  25575. * @param localX Defines the local x coordinates of the pointer when the event occured
  25576. * @param localY Defines the local y coordinates of the pointer when the event occured
  25577. */
  25578. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  25579. }
  25580. /**
  25581. * This type contains all the data related to a pointer event in Babylon.js.
  25582. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  25583. */
  25584. export class PointerInfo extends PointerInfoBase {
  25585. /**
  25586. * Defines the picking info associated to the info (if any)\
  25587. */
  25588. pickInfo: Nullable<PickingInfo>;
  25589. /**
  25590. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  25591. * @param type Defines the type of event (PointerEventTypes)
  25592. * @param event Defines the related dom event
  25593. * @param pickInfo Defines the picking info associated to the info (if any)\
  25594. */
  25595. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  25596. /**
  25597. * Defines the picking info associated to the info (if any)\
  25598. */
  25599. pickInfo: Nullable<PickingInfo>);
  25600. }
  25601. /**
  25602. * Data relating to a touch event on the screen.
  25603. */
  25604. export interface PointerTouch {
  25605. /**
  25606. * X coordinate of touch.
  25607. */
  25608. x: number;
  25609. /**
  25610. * Y coordinate of touch.
  25611. */
  25612. y: number;
  25613. /**
  25614. * Id of touch. Unique for each finger.
  25615. */
  25616. pointerId: number;
  25617. /**
  25618. * Event type passed from DOM.
  25619. */
  25620. type: any;
  25621. }
  25622. }
  25623. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  25624. import { Observable } from "babylonjs/Misc/observable";
  25625. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25626. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25627. /**
  25628. * Manage the mouse inputs to control the movement of a free camera.
  25629. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25630. */
  25631. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25632. /**
  25633. * Define if touch is enabled in the mouse input
  25634. */
  25635. touchEnabled: boolean;
  25636. /**
  25637. * Defines the camera the input is attached to.
  25638. */
  25639. camera: FreeCamera;
  25640. /**
  25641. * Defines the buttons associated with the input to handle camera move.
  25642. */
  25643. buttons: number[];
  25644. /**
  25645. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  25646. */
  25647. angularSensibility: number;
  25648. private _pointerInput;
  25649. private _onMouseMove;
  25650. private _observer;
  25651. private previousPosition;
  25652. /**
  25653. * Observable for when a pointer move event occurs containing the move offset
  25654. */
  25655. onPointerMovedObservable: Observable<{
  25656. offsetX: number;
  25657. offsetY: number;
  25658. }>;
  25659. /**
  25660. * @hidden
  25661. * If the camera should be rotated automatically based on pointer movement
  25662. */
  25663. _allowCameraRotation: boolean;
  25664. /**
  25665. * Manage the mouse inputs to control the movement of a free camera.
  25666. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25667. * @param touchEnabled Defines if touch is enabled or not
  25668. */
  25669. constructor(
  25670. /**
  25671. * Define if touch is enabled in the mouse input
  25672. */
  25673. touchEnabled?: boolean);
  25674. /**
  25675. * Attach the input controls to a specific dom element to get the input from.
  25676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25677. */
  25678. attachControl(noPreventDefault?: boolean): void;
  25679. /**
  25680. * Called on JS contextmenu event.
  25681. * Override this method to provide functionality.
  25682. */
  25683. protected onContextMenu(evt: PointerEvent): void;
  25684. /**
  25685. * Detach the current controls from the specified dom element.
  25686. */
  25687. detachControl(): void;
  25688. /**
  25689. * Gets the class name of the current intput.
  25690. * @returns the class name
  25691. */
  25692. getClassName(): string;
  25693. /**
  25694. * Get the friendly name associated with the input class.
  25695. * @returns the input friendly name
  25696. */
  25697. getSimpleName(): string;
  25698. }
  25699. }
  25700. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  25701. import { Observable } from "babylonjs/Misc/observable";
  25702. import { Camera } from "babylonjs/Cameras/camera";
  25703. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25704. /**
  25705. * Base class for mouse wheel input..
  25706. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  25707. * for example usage.
  25708. */
  25709. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  25710. /**
  25711. * Defines the camera the input is attached to.
  25712. */
  25713. abstract camera: Camera;
  25714. /**
  25715. * How fast is the camera moves in relation to X axis mouseWheel events.
  25716. * Use negative value to reverse direction.
  25717. */
  25718. wheelPrecisionX: number;
  25719. /**
  25720. * How fast is the camera moves in relation to Y axis mouseWheel events.
  25721. * Use negative value to reverse direction.
  25722. */
  25723. wheelPrecisionY: number;
  25724. /**
  25725. * How fast is the camera moves in relation to Z axis mouseWheel events.
  25726. * Use negative value to reverse direction.
  25727. */
  25728. wheelPrecisionZ: number;
  25729. /**
  25730. * Observable for when a mouse wheel move event occurs.
  25731. */
  25732. onChangedObservable: Observable<{
  25733. wheelDeltaX: number;
  25734. wheelDeltaY: number;
  25735. wheelDeltaZ: number;
  25736. }>;
  25737. private _wheel;
  25738. private _observer;
  25739. /**
  25740. * Attach the input controls to a specific dom element to get the input from.
  25741. * @param noPreventDefault Defines whether event caught by the controls
  25742. * should call preventdefault().
  25743. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25744. */
  25745. attachControl(noPreventDefault?: boolean): void;
  25746. /**
  25747. * Detach the current controls from the specified dom element.
  25748. */
  25749. detachControl(): void;
  25750. /**
  25751. * Called for each rendered frame.
  25752. */
  25753. checkInputs(): void;
  25754. /**
  25755. * Gets the class name of the current intput.
  25756. * @returns the class name
  25757. */
  25758. getClassName(): string;
  25759. /**
  25760. * Get the friendly name associated with the input class.
  25761. * @returns the input friendly name
  25762. */
  25763. getSimpleName(): string;
  25764. /**
  25765. * Incremental value of multiple mouse wheel movements of the X axis.
  25766. * Should be zero-ed when read.
  25767. */
  25768. protected _wheelDeltaX: number;
  25769. /**
  25770. * Incremental value of multiple mouse wheel movements of the Y axis.
  25771. * Should be zero-ed when read.
  25772. */
  25773. protected _wheelDeltaY: number;
  25774. /**
  25775. * Incremental value of multiple mouse wheel movements of the Z axis.
  25776. * Should be zero-ed when read.
  25777. */
  25778. protected _wheelDeltaZ: number;
  25779. /**
  25780. * Firefox uses a different scheme to report scroll distances to other
  25781. * browsers. Rather than use complicated methods to calculate the exact
  25782. * multiple we need to apply, let's just cheat and use a constant.
  25783. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25784. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25785. */
  25786. private readonly _ffMultiplier;
  25787. /**
  25788. * Different event attributes for wheel data fall into a few set ranges.
  25789. * Some relevant but dated date here:
  25790. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25791. */
  25792. private readonly _normalize;
  25793. }
  25794. }
  25795. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  25796. import { Nullable } from "babylonjs/types";
  25797. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25798. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  25799. import { Coordinate } from "babylonjs/Maths/math.axis";
  25800. /**
  25801. * Manage the mouse wheel inputs to control a free camera.
  25802. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25803. */
  25804. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25805. /**
  25806. * Defines the camera the input is attached to.
  25807. */
  25808. camera: FreeCamera;
  25809. /**
  25810. * Gets the class name of the current input.
  25811. * @returns the class name
  25812. */
  25813. getClassName(): string;
  25814. /**
  25815. * Set which movement axis (relative to camera's orientation) the mouse
  25816. * wheel's X axis controls.
  25817. * @param axis The axis to be moved. Set null to clear.
  25818. */
  25819. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25820. /**
  25821. * Get the configured movement axis (relative to camera's orientation) the
  25822. * mouse wheel's X axis controls.
  25823. * @returns The configured axis or null if none.
  25824. */
  25825. get wheelXMoveRelative(): Nullable<Coordinate>;
  25826. /**
  25827. * Set which movement axis (relative to camera's orientation) the mouse
  25828. * wheel's Y axis controls.
  25829. * @param axis The axis to be moved. Set null to clear.
  25830. */
  25831. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25832. /**
  25833. * Get the configured movement axis (relative to camera's orientation) the
  25834. * mouse wheel's Y axis controls.
  25835. * @returns The configured axis or null if none.
  25836. */
  25837. get wheelYMoveRelative(): Nullable<Coordinate>;
  25838. /**
  25839. * Set which movement axis (relative to camera's orientation) the mouse
  25840. * wheel's Z axis controls.
  25841. * @param axis The axis to be moved. Set null to clear.
  25842. */
  25843. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25844. /**
  25845. * Get the configured movement axis (relative to camera's orientation) the
  25846. * mouse wheel's Z axis controls.
  25847. * @returns The configured axis or null if none.
  25848. */
  25849. get wheelZMoveRelative(): Nullable<Coordinate>;
  25850. /**
  25851. * Set which rotation axis (relative to camera's orientation) the mouse
  25852. * wheel's X axis controls.
  25853. * @param axis The axis to be moved. Set null to clear.
  25854. */
  25855. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25856. /**
  25857. * Get the configured rotation axis (relative to camera's orientation) the
  25858. * mouse wheel's X axis controls.
  25859. * @returns The configured axis or null if none.
  25860. */
  25861. get wheelXRotateRelative(): Nullable<Coordinate>;
  25862. /**
  25863. * Set which rotation axis (relative to camera's orientation) the mouse
  25864. * wheel's Y axis controls.
  25865. * @param axis The axis to be moved. Set null to clear.
  25866. */
  25867. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25868. /**
  25869. * Get the configured rotation axis (relative to camera's orientation) the
  25870. * mouse wheel's Y axis controls.
  25871. * @returns The configured axis or null if none.
  25872. */
  25873. get wheelYRotateRelative(): Nullable<Coordinate>;
  25874. /**
  25875. * Set which rotation axis (relative to camera's orientation) the mouse
  25876. * wheel's Z axis controls.
  25877. * @param axis The axis to be moved. Set null to clear.
  25878. */
  25879. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25880. /**
  25881. * Get the configured rotation axis (relative to camera's orientation) the
  25882. * mouse wheel's Z axis controls.
  25883. * @returns The configured axis or null if none.
  25884. */
  25885. get wheelZRotateRelative(): Nullable<Coordinate>;
  25886. /**
  25887. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25888. * controls.
  25889. * @param axis The axis to be moved. Set null to clear.
  25890. */
  25891. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25892. /**
  25893. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25894. * X axis controls.
  25895. * @returns The configured axis or null if none.
  25896. */
  25897. get wheelXMoveScene(): Nullable<Coordinate>;
  25898. /**
  25899. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25900. * controls.
  25901. * @param axis The axis to be moved. Set null to clear.
  25902. */
  25903. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25904. /**
  25905. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25906. * Y axis controls.
  25907. * @returns The configured axis or null if none.
  25908. */
  25909. get wheelYMoveScene(): Nullable<Coordinate>;
  25910. /**
  25911. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25912. * controls.
  25913. * @param axis The axis to be moved. Set null to clear.
  25914. */
  25915. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25916. /**
  25917. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25918. * Z axis controls.
  25919. * @returns The configured axis or null if none.
  25920. */
  25921. get wheelZMoveScene(): Nullable<Coordinate>;
  25922. /**
  25923. * Called for each rendered frame.
  25924. */
  25925. checkInputs(): void;
  25926. private _moveRelative;
  25927. private _rotateRelative;
  25928. private _moveScene;
  25929. /**
  25930. * These are set to the desired default behaviour.
  25931. */
  25932. private _wheelXAction;
  25933. private _wheelXActionCoordinate;
  25934. private _wheelYAction;
  25935. private _wheelYActionCoordinate;
  25936. private _wheelZAction;
  25937. private _wheelZActionCoordinate;
  25938. /**
  25939. * Update the camera according to any configured properties for the 3
  25940. * mouse-wheel axis.
  25941. */
  25942. private _updateCamera;
  25943. /**
  25944. * Update one property of the camera.
  25945. */
  25946. private _updateCameraProperty;
  25947. }
  25948. }
  25949. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25952. /**
  25953. * Manage the touch inputs to control the movement of a free camera.
  25954. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25955. */
  25956. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25957. /**
  25958. * Define if mouse events can be treated as touch events
  25959. */
  25960. allowMouse: boolean;
  25961. /**
  25962. * Defines the camera the input is attached to.
  25963. */
  25964. camera: FreeCamera;
  25965. /**
  25966. * Defines the touch sensibility for rotation.
  25967. * The higher the faster.
  25968. */
  25969. touchAngularSensibility: number;
  25970. /**
  25971. * Defines the touch sensibility for move.
  25972. * The higher the faster.
  25973. */
  25974. touchMoveSensibility: number;
  25975. private _offsetX;
  25976. private _offsetY;
  25977. private _pointerPressed;
  25978. private _pointerInput?;
  25979. private _observer;
  25980. private _onLostFocus;
  25981. /**
  25982. * Manage the touch inputs to control the movement of a free camera.
  25983. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25984. * @param allowMouse Defines if mouse events can be treated as touch events
  25985. */
  25986. constructor(
  25987. /**
  25988. * Define if mouse events can be treated as touch events
  25989. */
  25990. allowMouse?: boolean);
  25991. /**
  25992. * Attach the input controls to a specific dom element to get the input from.
  25993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25994. */
  25995. attachControl(noPreventDefault?: boolean): void;
  25996. /**
  25997. * Detach the current controls from the specified dom element.
  25998. */
  25999. detachControl(): void;
  26000. /**
  26001. * Update the current camera state depending on the inputs that have been used this frame.
  26002. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  26003. */
  26004. checkInputs(): void;
  26005. /**
  26006. * Gets the class name of the current intput.
  26007. * @returns the class name
  26008. */
  26009. getClassName(): string;
  26010. /**
  26011. * Get the friendly name associated with the input class.
  26012. * @returns the input friendly name
  26013. */
  26014. getSimpleName(): string;
  26015. }
  26016. }
  26017. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  26018. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26019. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26020. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  26021. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  26022. import { Nullable } from "babylonjs/types";
  26023. /**
  26024. * Default Inputs manager for the FreeCamera.
  26025. * It groups all the default supported inputs for ease of use.
  26026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  26027. */
  26028. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  26029. /**
  26030. * @hidden
  26031. */
  26032. _mouseInput: Nullable<FreeCameraMouseInput>;
  26033. /**
  26034. * @hidden
  26035. */
  26036. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  26037. /**
  26038. * Instantiates a new FreeCameraInputsManager.
  26039. * @param camera Defines the camera the inputs belong to
  26040. */
  26041. constructor(camera: FreeCamera);
  26042. /**
  26043. * Add keyboard input support to the input manager.
  26044. * @returns the current input manager
  26045. */
  26046. addKeyboard(): FreeCameraInputsManager;
  26047. /**
  26048. * Add mouse input support to the input manager.
  26049. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  26050. * @returns the current input manager
  26051. */
  26052. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  26053. /**
  26054. * Removes the mouse input support from the manager
  26055. * @returns the current input manager
  26056. */
  26057. removeMouse(): FreeCameraInputsManager;
  26058. /**
  26059. * Add mouse wheel input support to the input manager.
  26060. * @returns the current input manager
  26061. */
  26062. addMouseWheel(): FreeCameraInputsManager;
  26063. /**
  26064. * Removes the mouse wheel input support from the manager
  26065. * @returns the current input manager
  26066. */
  26067. removeMouseWheel(): FreeCameraInputsManager;
  26068. /**
  26069. * Add touch input support to the input manager.
  26070. * @returns the current input manager
  26071. */
  26072. addTouch(): FreeCameraInputsManager;
  26073. /**
  26074. * Remove all attached input methods from a camera
  26075. */
  26076. clear(): void;
  26077. }
  26078. }
  26079. declare module "babylonjs/Cameras/freeCamera" {
  26080. import { Vector3 } from "babylonjs/Maths/math.vector";
  26081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26082. import { Scene } from "babylonjs/scene";
  26083. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  26084. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  26085. /**
  26086. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26087. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  26088. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26089. */
  26090. export class FreeCamera extends TargetCamera {
  26091. /**
  26092. * Define the collision ellipsoid of the camera.
  26093. * This is helpful to simulate a camera body like the player body around the camera
  26094. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  26095. */
  26096. ellipsoid: Vector3;
  26097. /**
  26098. * Define an offset for the position of the ellipsoid around the camera.
  26099. * This can be helpful to determine the center of the body near the gravity center of the body
  26100. * instead of its head.
  26101. */
  26102. ellipsoidOffset: Vector3;
  26103. /**
  26104. * Enable or disable collisions of the camera with the rest of the scene objects.
  26105. */
  26106. checkCollisions: boolean;
  26107. /**
  26108. * Enable or disable gravity on the camera.
  26109. */
  26110. applyGravity: boolean;
  26111. /**
  26112. * Define the input manager associated to the camera.
  26113. */
  26114. inputs: FreeCameraInputsManager;
  26115. /**
  26116. * Gets the input sensibility for a mouse input. (default is 2000.0)
  26117. * Higher values reduce sensitivity.
  26118. */
  26119. get angularSensibility(): number;
  26120. /**
  26121. * Sets the input sensibility for a mouse input. (default is 2000.0)
  26122. * Higher values reduce sensitivity.
  26123. */
  26124. set angularSensibility(value: number);
  26125. /**
  26126. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  26127. */
  26128. get keysUp(): number[];
  26129. set keysUp(value: number[]);
  26130. /**
  26131. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  26132. */
  26133. get keysUpward(): number[];
  26134. set keysUpward(value: number[]);
  26135. /**
  26136. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  26137. */
  26138. get keysDown(): number[];
  26139. set keysDown(value: number[]);
  26140. /**
  26141. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  26142. */
  26143. get keysDownward(): number[];
  26144. set keysDownward(value: number[]);
  26145. /**
  26146. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  26147. */
  26148. get keysLeft(): number[];
  26149. set keysLeft(value: number[]);
  26150. /**
  26151. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  26152. */
  26153. get keysRight(): number[];
  26154. set keysRight(value: number[]);
  26155. /**
  26156. * Event raised when the camera collide with a mesh in the scene.
  26157. */
  26158. onCollide: (collidedMesh: AbstractMesh) => void;
  26159. private _collider;
  26160. private _needMoveForGravity;
  26161. private _oldPosition;
  26162. private _diffPosition;
  26163. private _newPosition;
  26164. /** @hidden */
  26165. _localDirection: Vector3;
  26166. /** @hidden */
  26167. _transformedDirection: Vector3;
  26168. /**
  26169. * Instantiates a Free Camera.
  26170. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26171. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  26172. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26173. * @param name Define the name of the camera in the scene
  26174. * @param position Define the start position of the camera in the scene
  26175. * @param scene Define the scene the camera belongs to
  26176. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  26177. */
  26178. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26179. /**
  26180. * Attach the input controls to a specific dom element to get the input from.
  26181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26182. */
  26183. attachControl(noPreventDefault?: boolean): void;
  26184. /**
  26185. * Attach the input controls to a specific dom element to get the input from.
  26186. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  26187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26188. * BACK COMPAT SIGNATURE ONLY.
  26189. */
  26190. attachControl(ignored: any, noPreventDefault?: boolean): void;
  26191. /**
  26192. * Detach the current controls from the specified dom element.
  26193. */
  26194. detachControl(): void;
  26195. /**
  26196. * Detach the current controls from the specified dom element.
  26197. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  26198. */
  26199. detachControl(ignored: any): void;
  26200. private _collisionMask;
  26201. /**
  26202. * Define a collision mask to limit the list of object the camera can collide with
  26203. */
  26204. get collisionMask(): number;
  26205. set collisionMask(mask: number);
  26206. /** @hidden */
  26207. _collideWithWorld(displacement: Vector3): void;
  26208. private _onCollisionPositionChange;
  26209. /** @hidden */
  26210. _checkInputs(): void;
  26211. /** @hidden */
  26212. _decideIfNeedsToMove(): boolean;
  26213. /** @hidden */
  26214. _updatePosition(): void;
  26215. /**
  26216. * Destroy the camera and release the current resources hold by it.
  26217. */
  26218. dispose(): void;
  26219. /**
  26220. * Gets the current object class name.
  26221. * @return the class name
  26222. */
  26223. getClassName(): string;
  26224. }
  26225. }
  26226. declare module "babylonjs/Gamepads/gamepad" {
  26227. import { Observable } from "babylonjs/Misc/observable";
  26228. /**
  26229. * Represents a gamepad control stick position
  26230. */
  26231. export class StickValues {
  26232. /**
  26233. * The x component of the control stick
  26234. */
  26235. x: number;
  26236. /**
  26237. * The y component of the control stick
  26238. */
  26239. y: number;
  26240. /**
  26241. * Initializes the gamepad x and y control stick values
  26242. * @param x The x component of the gamepad control stick value
  26243. * @param y The y component of the gamepad control stick value
  26244. */
  26245. constructor(
  26246. /**
  26247. * The x component of the control stick
  26248. */
  26249. x: number,
  26250. /**
  26251. * The y component of the control stick
  26252. */
  26253. y: number);
  26254. }
  26255. /**
  26256. * An interface which manages callbacks for gamepad button changes
  26257. */
  26258. export interface GamepadButtonChanges {
  26259. /**
  26260. * Called when a gamepad has been changed
  26261. */
  26262. changed: boolean;
  26263. /**
  26264. * Called when a gamepad press event has been triggered
  26265. */
  26266. pressChanged: boolean;
  26267. /**
  26268. * Called when a touch event has been triggered
  26269. */
  26270. touchChanged: boolean;
  26271. /**
  26272. * Called when a value has changed
  26273. */
  26274. valueChanged: boolean;
  26275. }
  26276. /**
  26277. * Represents a gamepad
  26278. */
  26279. export class Gamepad {
  26280. /**
  26281. * The id of the gamepad
  26282. */
  26283. id: string;
  26284. /**
  26285. * The index of the gamepad
  26286. */
  26287. index: number;
  26288. /**
  26289. * The browser gamepad
  26290. */
  26291. browserGamepad: any;
  26292. /**
  26293. * Specifies what type of gamepad this represents
  26294. */
  26295. type: number;
  26296. private _leftStick;
  26297. private _rightStick;
  26298. /** @hidden */
  26299. _isConnected: boolean;
  26300. private _leftStickAxisX;
  26301. private _leftStickAxisY;
  26302. private _rightStickAxisX;
  26303. private _rightStickAxisY;
  26304. /**
  26305. * Triggered when the left control stick has been changed
  26306. */
  26307. private _onleftstickchanged;
  26308. /**
  26309. * Triggered when the right control stick has been changed
  26310. */
  26311. private _onrightstickchanged;
  26312. /**
  26313. * Represents a gamepad controller
  26314. */
  26315. static GAMEPAD: number;
  26316. /**
  26317. * Represents a generic controller
  26318. */
  26319. static GENERIC: number;
  26320. /**
  26321. * Represents an XBox controller
  26322. */
  26323. static XBOX: number;
  26324. /**
  26325. * Represents a pose-enabled controller
  26326. */
  26327. static POSE_ENABLED: number;
  26328. /**
  26329. * Represents an Dual Shock controller
  26330. */
  26331. static DUALSHOCK: number;
  26332. /**
  26333. * Specifies whether the left control stick should be Y-inverted
  26334. */
  26335. protected _invertLeftStickY: boolean;
  26336. /**
  26337. * Specifies if the gamepad has been connected
  26338. */
  26339. get isConnected(): boolean;
  26340. /**
  26341. * Initializes the gamepad
  26342. * @param id The id of the gamepad
  26343. * @param index The index of the gamepad
  26344. * @param browserGamepad The browser gamepad
  26345. * @param leftStickX The x component of the left joystick
  26346. * @param leftStickY The y component of the left joystick
  26347. * @param rightStickX The x component of the right joystick
  26348. * @param rightStickY The y component of the right joystick
  26349. */
  26350. constructor(
  26351. /**
  26352. * The id of the gamepad
  26353. */
  26354. id: string,
  26355. /**
  26356. * The index of the gamepad
  26357. */
  26358. index: number,
  26359. /**
  26360. * The browser gamepad
  26361. */
  26362. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  26363. /**
  26364. * Callback triggered when the left joystick has changed
  26365. * @param callback
  26366. */
  26367. onleftstickchanged(callback: (values: StickValues) => void): void;
  26368. /**
  26369. * Callback triggered when the right joystick has changed
  26370. * @param callback
  26371. */
  26372. onrightstickchanged(callback: (values: StickValues) => void): void;
  26373. /**
  26374. * Gets the left joystick
  26375. */
  26376. get leftStick(): StickValues;
  26377. /**
  26378. * Sets the left joystick values
  26379. */
  26380. set leftStick(newValues: StickValues);
  26381. /**
  26382. * Gets the right joystick
  26383. */
  26384. get rightStick(): StickValues;
  26385. /**
  26386. * Sets the right joystick value
  26387. */
  26388. set rightStick(newValues: StickValues);
  26389. /**
  26390. * Updates the gamepad joystick positions
  26391. */
  26392. update(): void;
  26393. /**
  26394. * Disposes the gamepad
  26395. */
  26396. dispose(): void;
  26397. }
  26398. /**
  26399. * Represents a generic gamepad
  26400. */
  26401. export class GenericPad extends Gamepad {
  26402. private _buttons;
  26403. private _onbuttondown;
  26404. private _onbuttonup;
  26405. /**
  26406. * Observable triggered when a button has been pressed
  26407. */
  26408. onButtonDownObservable: Observable<number>;
  26409. /**
  26410. * Observable triggered when a button has been released
  26411. */
  26412. onButtonUpObservable: Observable<number>;
  26413. /**
  26414. * Callback triggered when a button has been pressed
  26415. * @param callback Called when a button has been pressed
  26416. */
  26417. onbuttondown(callback: (buttonPressed: number) => void): void;
  26418. /**
  26419. * Callback triggered when a button has been released
  26420. * @param callback Called when a button has been released
  26421. */
  26422. onbuttonup(callback: (buttonReleased: number) => void): void;
  26423. /**
  26424. * Initializes the generic gamepad
  26425. * @param id The id of the generic gamepad
  26426. * @param index The index of the generic gamepad
  26427. * @param browserGamepad The browser gamepad
  26428. */
  26429. constructor(id: string, index: number, browserGamepad: any);
  26430. private _setButtonValue;
  26431. /**
  26432. * Updates the generic gamepad
  26433. */
  26434. update(): void;
  26435. /**
  26436. * Disposes the generic gamepad
  26437. */
  26438. dispose(): void;
  26439. }
  26440. }
  26441. declare module "babylonjs/Animations/runtimeAnimation" {
  26442. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  26443. import { Animatable } from "babylonjs/Animations/animatable";
  26444. import { Scene } from "babylonjs/scene";
  26445. /**
  26446. * Defines a runtime animation
  26447. */
  26448. export class RuntimeAnimation {
  26449. private _events;
  26450. /**
  26451. * The current frame of the runtime animation
  26452. */
  26453. private _currentFrame;
  26454. /**
  26455. * The animation used by the runtime animation
  26456. */
  26457. private _animation;
  26458. /**
  26459. * The target of the runtime animation
  26460. */
  26461. private _target;
  26462. /**
  26463. * The initiating animatable
  26464. */
  26465. private _host;
  26466. /**
  26467. * The original value of the runtime animation
  26468. */
  26469. private _originalValue;
  26470. /**
  26471. * The original blend value of the runtime animation
  26472. */
  26473. private _originalBlendValue;
  26474. /**
  26475. * The offsets cache of the runtime animation
  26476. */
  26477. private _offsetsCache;
  26478. /**
  26479. * The high limits cache of the runtime animation
  26480. */
  26481. private _highLimitsCache;
  26482. /**
  26483. * Specifies if the runtime animation has been stopped
  26484. */
  26485. private _stopped;
  26486. /**
  26487. * The blending factor of the runtime animation
  26488. */
  26489. private _blendingFactor;
  26490. /**
  26491. * The BabylonJS scene
  26492. */
  26493. private _scene;
  26494. /**
  26495. * The current value of the runtime animation
  26496. */
  26497. private _currentValue;
  26498. /** @hidden */
  26499. _animationState: _IAnimationState;
  26500. /**
  26501. * The active target of the runtime animation
  26502. */
  26503. private _activeTargets;
  26504. private _currentActiveTarget;
  26505. private _directTarget;
  26506. /**
  26507. * The target path of the runtime animation
  26508. */
  26509. private _targetPath;
  26510. /**
  26511. * The weight of the runtime animation
  26512. */
  26513. private _weight;
  26514. /**
  26515. * The ratio offset of the runtime animation
  26516. */
  26517. private _ratioOffset;
  26518. /**
  26519. * The previous delay of the runtime animation
  26520. */
  26521. private _previousDelay;
  26522. /**
  26523. * The previous ratio of the runtime animation
  26524. */
  26525. private _previousRatio;
  26526. private _enableBlending;
  26527. private _keys;
  26528. private _minFrame;
  26529. private _maxFrame;
  26530. private _minValue;
  26531. private _maxValue;
  26532. private _targetIsArray;
  26533. /**
  26534. * Gets the current frame of the runtime animation
  26535. */
  26536. get currentFrame(): number;
  26537. /**
  26538. * Gets the weight of the runtime animation
  26539. */
  26540. get weight(): number;
  26541. /**
  26542. * Gets the current value of the runtime animation
  26543. */
  26544. get currentValue(): any;
  26545. /**
  26546. * Gets the target path of the runtime animation
  26547. */
  26548. get targetPath(): string;
  26549. /**
  26550. * Gets the actual target of the runtime animation
  26551. */
  26552. get target(): any;
  26553. /**
  26554. * Gets the additive state of the runtime animation
  26555. */
  26556. get isAdditive(): boolean;
  26557. /** @hidden */
  26558. _onLoop: () => void;
  26559. /**
  26560. * Create a new RuntimeAnimation object
  26561. * @param target defines the target of the animation
  26562. * @param animation defines the source animation object
  26563. * @param scene defines the hosting scene
  26564. * @param host defines the initiating Animatable
  26565. */
  26566. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  26567. private _preparePath;
  26568. /**
  26569. * Gets the animation from the runtime animation
  26570. */
  26571. get animation(): Animation;
  26572. /**
  26573. * Resets the runtime animation to the beginning
  26574. * @param restoreOriginal defines whether to restore the target property to the original value
  26575. */
  26576. reset(restoreOriginal?: boolean): void;
  26577. /**
  26578. * Specifies if the runtime animation is stopped
  26579. * @returns Boolean specifying if the runtime animation is stopped
  26580. */
  26581. isStopped(): boolean;
  26582. /**
  26583. * Disposes of the runtime animation
  26584. */
  26585. dispose(): void;
  26586. /**
  26587. * Apply the interpolated value to the target
  26588. * @param currentValue defines the value computed by the animation
  26589. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  26590. */
  26591. setValue(currentValue: any, weight: number): void;
  26592. private _getOriginalValues;
  26593. private _setValue;
  26594. /**
  26595. * Gets the loop pmode of the runtime animation
  26596. * @returns Loop Mode
  26597. */
  26598. private _getCorrectLoopMode;
  26599. /**
  26600. * Move the current animation to a given frame
  26601. * @param frame defines the frame to move to
  26602. */
  26603. goToFrame(frame: number): void;
  26604. /**
  26605. * @hidden Internal use only
  26606. */
  26607. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  26608. /**
  26609. * Execute the current animation
  26610. * @param delay defines the delay to add to the current frame
  26611. * @param from defines the lower bound of the animation range
  26612. * @param to defines the upper bound of the animation range
  26613. * @param loop defines if the current animation must loop
  26614. * @param speedRatio defines the current speed ratio
  26615. * @param weight defines the weight of the animation (default is -1 so no weight)
  26616. * @param onLoop optional callback called when animation loops
  26617. * @returns a boolean indicating if the animation is running
  26618. */
  26619. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  26620. }
  26621. }
  26622. declare module "babylonjs/Animations/animatable" {
  26623. import { Animation } from "babylonjs/Animations/animation";
  26624. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26625. import { Nullable } from "babylonjs/types";
  26626. import { Observable } from "babylonjs/Misc/observable";
  26627. import { Scene } from "babylonjs/scene";
  26628. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  26629. import { Node } from "babylonjs/node";
  26630. /**
  26631. * Class used to store an actual running animation
  26632. */
  26633. export class Animatable {
  26634. /** defines the target object */
  26635. target: any;
  26636. /** defines the starting frame number (default is 0) */
  26637. fromFrame: number;
  26638. /** defines the ending frame number (default is 100) */
  26639. toFrame: number;
  26640. /** defines if the animation must loop (default is false) */
  26641. loopAnimation: boolean;
  26642. /** defines a callback to call when animation ends if it is not looping */
  26643. onAnimationEnd?: (() => void) | null | undefined;
  26644. /** defines a callback to call when animation loops */
  26645. onAnimationLoop?: (() => void) | null | undefined;
  26646. /** defines whether the animation should be evaluated additively */
  26647. isAdditive: boolean;
  26648. private _localDelayOffset;
  26649. private _pausedDelay;
  26650. private _runtimeAnimations;
  26651. private _paused;
  26652. private _scene;
  26653. private _speedRatio;
  26654. private _weight;
  26655. private _syncRoot;
  26656. /**
  26657. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  26658. * This will only apply for non looping animation (default is true)
  26659. */
  26660. disposeOnEnd: boolean;
  26661. /**
  26662. * Gets a boolean indicating if the animation has started
  26663. */
  26664. animationStarted: boolean;
  26665. /**
  26666. * Observer raised when the animation ends
  26667. */
  26668. onAnimationEndObservable: Observable<Animatable>;
  26669. /**
  26670. * Observer raised when the animation loops
  26671. */
  26672. onAnimationLoopObservable: Observable<Animatable>;
  26673. /**
  26674. * Gets the root Animatable used to synchronize and normalize animations
  26675. */
  26676. get syncRoot(): Nullable<Animatable>;
  26677. /**
  26678. * Gets the current frame of the first RuntimeAnimation
  26679. * Used to synchronize Animatables
  26680. */
  26681. get masterFrame(): number;
  26682. /**
  26683. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  26684. */
  26685. get weight(): number;
  26686. set weight(value: number);
  26687. /**
  26688. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  26689. */
  26690. get speedRatio(): number;
  26691. set speedRatio(value: number);
  26692. /**
  26693. * Creates a new Animatable
  26694. * @param scene defines the hosting scene
  26695. * @param target defines the target object
  26696. * @param fromFrame defines the starting frame number (default is 0)
  26697. * @param toFrame defines the ending frame number (default is 100)
  26698. * @param loopAnimation defines if the animation must loop (default is false)
  26699. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  26700. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  26701. * @param animations defines a group of animation to add to the new Animatable
  26702. * @param onAnimationLoop defines a callback to call when animation loops
  26703. * @param isAdditive defines whether the animation should be evaluated additively
  26704. */
  26705. constructor(scene: Scene,
  26706. /** defines the target object */
  26707. target: any,
  26708. /** defines the starting frame number (default is 0) */
  26709. fromFrame?: number,
  26710. /** defines the ending frame number (default is 100) */
  26711. toFrame?: number,
  26712. /** defines if the animation must loop (default is false) */
  26713. loopAnimation?: boolean, speedRatio?: number,
  26714. /** defines a callback to call when animation ends if it is not looping */
  26715. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  26716. /** defines a callback to call when animation loops */
  26717. onAnimationLoop?: (() => void) | null | undefined,
  26718. /** defines whether the animation should be evaluated additively */
  26719. isAdditive?: boolean);
  26720. /**
  26721. * Synchronize and normalize current Animatable with a source Animatable
  26722. * This is useful when using animation weights and when animations are not of the same length
  26723. * @param root defines the root Animatable to synchronize with
  26724. * @returns the current Animatable
  26725. */
  26726. syncWith(root: Animatable): Animatable;
  26727. /**
  26728. * Gets the list of runtime animations
  26729. * @returns an array of RuntimeAnimation
  26730. */
  26731. getAnimations(): RuntimeAnimation[];
  26732. /**
  26733. * Adds more animations to the current animatable
  26734. * @param target defines the target of the animations
  26735. * @param animations defines the new animations to add
  26736. */
  26737. appendAnimations(target: any, animations: Animation[]): void;
  26738. /**
  26739. * Gets the source animation for a specific property
  26740. * @param property defines the propertyu to look for
  26741. * @returns null or the source animation for the given property
  26742. */
  26743. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  26744. /**
  26745. * Gets the runtime animation for a specific property
  26746. * @param property defines the propertyu to look for
  26747. * @returns null or the runtime animation for the given property
  26748. */
  26749. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  26750. /**
  26751. * Resets the animatable to its original state
  26752. */
  26753. reset(): void;
  26754. /**
  26755. * Allows the animatable to blend with current running animations
  26756. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26757. * @param blendingSpeed defines the blending speed to use
  26758. */
  26759. enableBlending(blendingSpeed: number): void;
  26760. /**
  26761. * Disable animation blending
  26762. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26763. */
  26764. disableBlending(): void;
  26765. /**
  26766. * Jump directly to a given frame
  26767. * @param frame defines the frame to jump to
  26768. */
  26769. goToFrame(frame: number): void;
  26770. /**
  26771. * Pause the animation
  26772. */
  26773. pause(): void;
  26774. /**
  26775. * Restart the animation
  26776. */
  26777. restart(): void;
  26778. private _raiseOnAnimationEnd;
  26779. /**
  26780. * Stop and delete the current animation
  26781. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26782. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  26783. */
  26784. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26785. /**
  26786. * Wait asynchronously for the animation to end
  26787. * @returns a promise which will be fullfilled when the animation ends
  26788. */
  26789. waitAsync(): Promise<Animatable>;
  26790. /** @hidden */
  26791. _animate(delay: number): boolean;
  26792. }
  26793. module "babylonjs/scene" {
  26794. interface Scene {
  26795. /** @hidden */
  26796. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26797. /** @hidden */
  26798. _processLateAnimationBindingsForMatrices(holder: {
  26799. totalWeight: number;
  26800. totalAdditiveWeight: number;
  26801. animations: RuntimeAnimation[];
  26802. additiveAnimations: RuntimeAnimation[];
  26803. originalValue: Matrix;
  26804. }): any;
  26805. /** @hidden */
  26806. _processLateAnimationBindingsForQuaternions(holder: {
  26807. totalWeight: number;
  26808. totalAdditiveWeight: number;
  26809. animations: RuntimeAnimation[];
  26810. additiveAnimations: RuntimeAnimation[];
  26811. originalValue: Quaternion;
  26812. }, refQuaternion: Quaternion): Quaternion;
  26813. /** @hidden */
  26814. _processLateAnimationBindings(): void;
  26815. /**
  26816. * Will start the animation sequence of a given target
  26817. * @param target defines the target
  26818. * @param from defines from which frame should animation start
  26819. * @param to defines until which frame should animation run.
  26820. * @param weight defines the weight to apply to the animation (1.0 by default)
  26821. * @param loop defines if the animation loops
  26822. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26823. * @param onAnimationEnd defines the function to be executed when the animation ends
  26824. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26825. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26826. * @param onAnimationLoop defines the callback to call when an animation loops
  26827. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26828. * @returns the animatable object created for this animation
  26829. */
  26830. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26831. /**
  26832. * Will start the animation sequence of a given target
  26833. * @param target defines the target
  26834. * @param from defines from which frame should animation start
  26835. * @param to defines until which frame should animation run.
  26836. * @param loop defines if the animation loops
  26837. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26838. * @param onAnimationEnd defines the function to be executed when the animation ends
  26839. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26840. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26841. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26842. * @param onAnimationLoop defines the callback to call when an animation loops
  26843. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26844. * @returns the animatable object created for this animation
  26845. */
  26846. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26847. /**
  26848. * Will start the animation sequence of a given target and its hierarchy
  26849. * @param target defines the target
  26850. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  26851. * @param from defines from which frame should animation start
  26852. * @param to defines until which frame should animation run.
  26853. * @param loop defines if the animation loops
  26854. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26855. * @param onAnimationEnd defines the function to be executed when the animation ends
  26856. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26857. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26858. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26859. * @param onAnimationLoop defines the callback to call when an animation loops
  26860. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26861. * @returns the list of created animatables
  26862. */
  26863. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26864. /**
  26865. * Begin a new animation on a given node
  26866. * @param target defines the target where the animation will take place
  26867. * @param animations defines the list of animations to start
  26868. * @param from defines the initial value
  26869. * @param to defines the final value
  26870. * @param loop defines if you want animation to loop (off by default)
  26871. * @param speedRatio defines the speed ratio to apply to all animations
  26872. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26873. * @param onAnimationLoop defines the callback to call when an animation loops
  26874. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26875. * @returns the list of created animatables
  26876. */
  26877. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26878. /**
  26879. * Begin a new animation on a given node and its hierarchy
  26880. * @param target defines the root node where the animation will take place
  26881. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  26882. * @param animations defines the list of animations to start
  26883. * @param from defines the initial value
  26884. * @param to defines the final value
  26885. * @param loop defines if you want animation to loop (off by default)
  26886. * @param speedRatio defines the speed ratio to apply to all animations
  26887. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26888. * @param onAnimationLoop defines the callback to call when an animation loops
  26889. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26890. * @returns the list of animatables created for all nodes
  26891. */
  26892. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26893. /**
  26894. * Gets the animatable associated with a specific target
  26895. * @param target defines the target of the animatable
  26896. * @returns the required animatable if found
  26897. */
  26898. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26899. /**
  26900. * Gets all animatables associated with a given target
  26901. * @param target defines the target to look animatables for
  26902. * @returns an array of Animatables
  26903. */
  26904. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26905. /**
  26906. * Stops and removes all animations that have been applied to the scene
  26907. */
  26908. stopAllAnimations(): void;
  26909. /**
  26910. * Gets the current delta time used by animation engine
  26911. */
  26912. deltaTime: number;
  26913. }
  26914. }
  26915. module "babylonjs/Bones/bone" {
  26916. interface Bone {
  26917. /**
  26918. * Copy an animation range from another bone
  26919. * @param source defines the source bone
  26920. * @param rangeName defines the range name to copy
  26921. * @param frameOffset defines the frame offset
  26922. * @param rescaleAsRequired defines if rescaling must be applied if required
  26923. * @param skelDimensionsRatio defines the scaling ratio
  26924. * @returns true if operation was successful
  26925. */
  26926. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26927. }
  26928. }
  26929. }
  26930. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26931. /**
  26932. * Class used to override all child animations of a given target
  26933. */
  26934. export class AnimationPropertiesOverride {
  26935. /**
  26936. * Gets or sets a value indicating if animation blending must be used
  26937. */
  26938. enableBlending: boolean;
  26939. /**
  26940. * Gets or sets the blending speed to use when enableBlending is true
  26941. */
  26942. blendingSpeed: number;
  26943. /**
  26944. * Gets or sets the default loop mode to use
  26945. */
  26946. loopMode: number;
  26947. }
  26948. }
  26949. declare module "babylonjs/Bones/skeleton" {
  26950. import { Bone } from "babylonjs/Bones/bone";
  26951. import { Observable } from "babylonjs/Misc/observable";
  26952. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26953. import { Scene } from "babylonjs/scene";
  26954. import { Nullable } from "babylonjs/types";
  26955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26956. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26957. import { Animatable } from "babylonjs/Animations/animatable";
  26958. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26959. import { Animation } from "babylonjs/Animations/animation";
  26960. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26961. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26962. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26963. /**
  26964. * Class used to handle skinning animations
  26965. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26966. */
  26967. export class Skeleton implements IAnimatable {
  26968. /** defines the skeleton name */
  26969. name: string;
  26970. /** defines the skeleton Id */
  26971. id: string;
  26972. /**
  26973. * Defines the list of child bones
  26974. */
  26975. bones: Bone[];
  26976. /**
  26977. * Defines an estimate of the dimension of the skeleton at rest
  26978. */
  26979. dimensionsAtRest: Vector3;
  26980. /**
  26981. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26982. */
  26983. needInitialSkinMatrix: boolean;
  26984. /**
  26985. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26986. */
  26987. overrideMesh: Nullable<AbstractMesh>;
  26988. /**
  26989. * Gets the list of animations attached to this skeleton
  26990. */
  26991. animations: Array<Animation>;
  26992. private _scene;
  26993. private _isDirty;
  26994. private _transformMatrices;
  26995. private _transformMatrixTexture;
  26996. private _meshesWithPoseMatrix;
  26997. private _animatables;
  26998. private _identity;
  26999. private _synchronizedWithMesh;
  27000. private _ranges;
  27001. private _lastAbsoluteTransformsUpdateId;
  27002. private _canUseTextureForBones;
  27003. private _uniqueId;
  27004. /** @hidden */
  27005. _numBonesWithLinkedTransformNode: number;
  27006. /** @hidden */
  27007. _hasWaitingData: Nullable<boolean>;
  27008. /** @hidden */
  27009. _waitingOverrideMeshId: Nullable<string>;
  27010. /**
  27011. * Specifies if the skeleton should be serialized
  27012. */
  27013. doNotSerialize: boolean;
  27014. private _useTextureToStoreBoneMatrices;
  27015. /**
  27016. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  27017. * Please note that this option is not available if the hardware does not support it
  27018. */
  27019. get useTextureToStoreBoneMatrices(): boolean;
  27020. set useTextureToStoreBoneMatrices(value: boolean);
  27021. private _animationPropertiesOverride;
  27022. /**
  27023. * Gets or sets the animation properties override
  27024. */
  27025. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27026. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27027. /**
  27028. * List of inspectable custom properties (used by the Inspector)
  27029. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27030. */
  27031. inspectableCustomProperties: IInspectable[];
  27032. /**
  27033. * An observable triggered before computing the skeleton's matrices
  27034. */
  27035. onBeforeComputeObservable: Observable<Skeleton>;
  27036. /**
  27037. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  27038. */
  27039. get isUsingTextureForMatrices(): boolean;
  27040. /**
  27041. * Gets the unique ID of this skeleton
  27042. */
  27043. get uniqueId(): number;
  27044. /**
  27045. * Creates a new skeleton
  27046. * @param name defines the skeleton name
  27047. * @param id defines the skeleton Id
  27048. * @param scene defines the hosting scene
  27049. */
  27050. constructor(
  27051. /** defines the skeleton name */
  27052. name: string,
  27053. /** defines the skeleton Id */
  27054. id: string, scene: Scene);
  27055. /**
  27056. * Gets the current object class name.
  27057. * @return the class name
  27058. */
  27059. getClassName(): string;
  27060. /**
  27061. * Returns an array containing the root bones
  27062. * @returns an array containing the root bones
  27063. */
  27064. getChildren(): Array<Bone>;
  27065. /**
  27066. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  27067. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  27068. * @returns a Float32Array containing matrices data
  27069. */
  27070. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  27071. /**
  27072. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  27073. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  27074. * @returns a raw texture containing the data
  27075. */
  27076. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  27077. /**
  27078. * Gets the current hosting scene
  27079. * @returns a scene object
  27080. */
  27081. getScene(): Scene;
  27082. /**
  27083. * Gets a string representing the current skeleton data
  27084. * @param fullDetails defines a boolean indicating if we want a verbose version
  27085. * @returns a string representing the current skeleton data
  27086. */
  27087. toString(fullDetails?: boolean): string;
  27088. /**
  27089. * Get bone's index searching by name
  27090. * @param name defines bone's name to search for
  27091. * @return the indice of the bone. Returns -1 if not found
  27092. */
  27093. getBoneIndexByName(name: string): number;
  27094. /**
  27095. * Creater a new animation range
  27096. * @param name defines the name of the range
  27097. * @param from defines the start key
  27098. * @param to defines the end key
  27099. */
  27100. createAnimationRange(name: string, from: number, to: number): void;
  27101. /**
  27102. * Delete a specific animation range
  27103. * @param name defines the name of the range
  27104. * @param deleteFrames defines if frames must be removed as well
  27105. */
  27106. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27107. /**
  27108. * Gets a specific animation range
  27109. * @param name defines the name of the range to look for
  27110. * @returns the requested animation range or null if not found
  27111. */
  27112. getAnimationRange(name: string): Nullable<AnimationRange>;
  27113. /**
  27114. * Gets the list of all animation ranges defined on this skeleton
  27115. * @returns an array
  27116. */
  27117. getAnimationRanges(): Nullable<AnimationRange>[];
  27118. /**
  27119. * Copy animation range from a source skeleton.
  27120. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  27121. * @param source defines the source skeleton
  27122. * @param name defines the name of the range to copy
  27123. * @param rescaleAsRequired defines if rescaling must be applied if required
  27124. * @returns true if operation was successful
  27125. */
  27126. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  27127. /**
  27128. * Forces the skeleton to go to rest pose
  27129. */
  27130. returnToRest(): void;
  27131. private _getHighestAnimationFrame;
  27132. /**
  27133. * Begin a specific animation range
  27134. * @param name defines the name of the range to start
  27135. * @param loop defines if looping must be turned on (false by default)
  27136. * @param speedRatio defines the speed ratio to apply (1 by default)
  27137. * @param onAnimationEnd defines a callback which will be called when animation will end
  27138. * @returns a new animatable
  27139. */
  27140. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27141. /**
  27142. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  27143. * @param skeleton defines the Skeleton containing the animation range to convert
  27144. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  27145. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  27146. * @returns the original skeleton
  27147. */
  27148. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  27149. /** @hidden */
  27150. _markAsDirty(): void;
  27151. /** @hidden */
  27152. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27153. /** @hidden */
  27154. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27155. private _computeTransformMatrices;
  27156. /**
  27157. * Build all resources required to render a skeleton
  27158. */
  27159. prepare(): void;
  27160. /**
  27161. * Gets the list of animatables currently running for this skeleton
  27162. * @returns an array of animatables
  27163. */
  27164. getAnimatables(): IAnimatable[];
  27165. /**
  27166. * Clone the current skeleton
  27167. * @param name defines the name of the new skeleton
  27168. * @param id defines the id of the new skeleton
  27169. * @returns the new skeleton
  27170. */
  27171. clone(name: string, id?: string): Skeleton;
  27172. /**
  27173. * Enable animation blending for this skeleton
  27174. * @param blendingSpeed defines the blending speed to apply
  27175. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  27176. */
  27177. enableBlending(blendingSpeed?: number): void;
  27178. /**
  27179. * Releases all resources associated with the current skeleton
  27180. */
  27181. dispose(): void;
  27182. /**
  27183. * Serialize the skeleton in a JSON object
  27184. * @returns a JSON object
  27185. */
  27186. serialize(): any;
  27187. /**
  27188. * Creates a new skeleton from serialized data
  27189. * @param parsedSkeleton defines the serialized data
  27190. * @param scene defines the hosting scene
  27191. * @returns a new skeleton
  27192. */
  27193. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  27194. /**
  27195. * Compute all node absolute transforms
  27196. * @param forceUpdate defines if computation must be done even if cache is up to date
  27197. */
  27198. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  27199. /**
  27200. * Gets the root pose matrix
  27201. * @returns a matrix
  27202. */
  27203. getPoseMatrix(): Nullable<Matrix>;
  27204. /**
  27205. * Sorts bones per internal index
  27206. */
  27207. sortBones(): void;
  27208. private _sortBones;
  27209. /**
  27210. * Set the current local matrix as the restPose for all bones in the skeleton.
  27211. */
  27212. setCurrentPoseAsRest(): void;
  27213. }
  27214. }
  27215. declare module "babylonjs/Bones/bone" {
  27216. import { Skeleton } from "babylonjs/Bones/skeleton";
  27217. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  27218. import { Nullable } from "babylonjs/types";
  27219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27220. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27221. import { Node } from "babylonjs/node";
  27222. import { Space } from "babylonjs/Maths/math.axis";
  27223. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27224. /**
  27225. * Class used to store bone information
  27226. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27227. */
  27228. export class Bone extends Node {
  27229. /**
  27230. * defines the bone name
  27231. */
  27232. name: string;
  27233. private static _tmpVecs;
  27234. private static _tmpQuat;
  27235. private static _tmpMats;
  27236. /**
  27237. * Gets the list of child bones
  27238. */
  27239. children: Bone[];
  27240. /** Gets the animations associated with this bone */
  27241. animations: import("babylonjs/Animations/animation").Animation[];
  27242. /**
  27243. * Gets or sets bone length
  27244. */
  27245. length: number;
  27246. /**
  27247. * @hidden Internal only
  27248. * Set this value to map this bone to a different index in the transform matrices
  27249. * Set this value to -1 to exclude the bone from the transform matrices
  27250. */
  27251. _index: Nullable<number>;
  27252. private _skeleton;
  27253. private _localMatrix;
  27254. private _restPose;
  27255. private _bindPose;
  27256. private _baseMatrix;
  27257. private _absoluteTransform;
  27258. private _invertedAbsoluteTransform;
  27259. private _parent;
  27260. private _scalingDeterminant;
  27261. private _worldTransform;
  27262. private _localScaling;
  27263. private _localRotation;
  27264. private _localPosition;
  27265. private _needToDecompose;
  27266. private _needToCompose;
  27267. /** @hidden */
  27268. _linkedTransformNode: Nullable<TransformNode>;
  27269. /** @hidden */
  27270. _waitingTransformNodeId: Nullable<string>;
  27271. /** @hidden */
  27272. get _matrix(): Matrix;
  27273. /** @hidden */
  27274. set _matrix(value: Matrix);
  27275. /**
  27276. * Create a new bone
  27277. * @param name defines the bone name
  27278. * @param skeleton defines the parent skeleton
  27279. * @param parentBone defines the parent (can be null if the bone is the root)
  27280. * @param localMatrix defines the local matrix
  27281. * @param restPose defines the rest pose matrix
  27282. * @param baseMatrix defines the base matrix
  27283. * @param index defines index of the bone in the hiearchy
  27284. */
  27285. constructor(
  27286. /**
  27287. * defines the bone name
  27288. */
  27289. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  27290. /**
  27291. * Gets the current object class name.
  27292. * @return the class name
  27293. */
  27294. getClassName(): string;
  27295. /**
  27296. * Gets the parent skeleton
  27297. * @returns a skeleton
  27298. */
  27299. getSkeleton(): Skeleton;
  27300. /**
  27301. * Gets parent bone
  27302. * @returns a bone or null if the bone is the root of the bone hierarchy
  27303. */
  27304. getParent(): Nullable<Bone>;
  27305. /**
  27306. * Returns an array containing the root bones
  27307. * @returns an array containing the root bones
  27308. */
  27309. getChildren(): Array<Bone>;
  27310. /**
  27311. * Gets the node index in matrix array generated for rendering
  27312. * @returns the node index
  27313. */
  27314. getIndex(): number;
  27315. /**
  27316. * Sets the parent bone
  27317. * @param parent defines the parent (can be null if the bone is the root)
  27318. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27319. */
  27320. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  27321. /**
  27322. * Gets the local matrix
  27323. * @returns a matrix
  27324. */
  27325. getLocalMatrix(): Matrix;
  27326. /**
  27327. * Gets the base matrix (initial matrix which remains unchanged)
  27328. * @returns a matrix
  27329. */
  27330. getBaseMatrix(): Matrix;
  27331. /**
  27332. * Gets the rest pose matrix
  27333. * @returns a matrix
  27334. */
  27335. getRestPose(): Matrix;
  27336. /**
  27337. * Sets the rest pose matrix
  27338. * @param matrix the local-space rest pose to set for this bone
  27339. */
  27340. setRestPose(matrix: Matrix): void;
  27341. /**
  27342. * Gets the bind pose matrix
  27343. * @returns the bind pose matrix
  27344. */
  27345. getBindPose(): Matrix;
  27346. /**
  27347. * Sets the bind pose matrix
  27348. * @param matrix the local-space bind pose to set for this bone
  27349. */
  27350. setBindPose(matrix: Matrix): void;
  27351. /**
  27352. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  27353. */
  27354. getWorldMatrix(): Matrix;
  27355. /**
  27356. * Sets the local matrix to rest pose matrix
  27357. */
  27358. returnToRest(): void;
  27359. /**
  27360. * Gets the inverse of the absolute transform matrix.
  27361. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  27362. * @returns a matrix
  27363. */
  27364. getInvertedAbsoluteTransform(): Matrix;
  27365. /**
  27366. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  27367. * @returns a matrix
  27368. */
  27369. getAbsoluteTransform(): Matrix;
  27370. /**
  27371. * Links with the given transform node.
  27372. * The local matrix of this bone is copied from the transform node every frame.
  27373. * @param transformNode defines the transform node to link to
  27374. */
  27375. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  27376. /**
  27377. * Gets the node used to drive the bone's transformation
  27378. * @returns a transform node or null
  27379. */
  27380. getTransformNode(): Nullable<TransformNode>;
  27381. /** Gets or sets current position (in local space) */
  27382. get position(): Vector3;
  27383. set position(newPosition: Vector3);
  27384. /** Gets or sets current rotation (in local space) */
  27385. get rotation(): Vector3;
  27386. set rotation(newRotation: Vector3);
  27387. /** Gets or sets current rotation quaternion (in local space) */
  27388. get rotationQuaternion(): Quaternion;
  27389. set rotationQuaternion(newRotation: Quaternion);
  27390. /** Gets or sets current scaling (in local space) */
  27391. get scaling(): Vector3;
  27392. set scaling(newScaling: Vector3);
  27393. /**
  27394. * Gets the animation properties override
  27395. */
  27396. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27397. private _decompose;
  27398. private _compose;
  27399. /**
  27400. * Update the base and local matrices
  27401. * @param matrix defines the new base or local matrix
  27402. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27403. * @param updateLocalMatrix defines if the local matrix should be updated
  27404. */
  27405. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  27406. /** @hidden */
  27407. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  27408. /**
  27409. * Flag the bone as dirty (Forcing it to update everything)
  27410. */
  27411. markAsDirty(): void;
  27412. /** @hidden */
  27413. _markAsDirtyAndCompose(): void;
  27414. private _markAsDirtyAndDecompose;
  27415. /**
  27416. * Translate the bone in local or world space
  27417. * @param vec The amount to translate the bone
  27418. * @param space The space that the translation is in
  27419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27420. */
  27421. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27422. /**
  27423. * Set the postion of the bone in local or world space
  27424. * @param position The position to set the bone
  27425. * @param space The space that the position is in
  27426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27427. */
  27428. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27429. /**
  27430. * Set the absolute position of the bone (world space)
  27431. * @param position The position to set the bone
  27432. * @param mesh The mesh that this bone is attached to
  27433. */
  27434. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  27435. /**
  27436. * Scale the bone on the x, y and z axes (in local space)
  27437. * @param x The amount to scale the bone on the x axis
  27438. * @param y The amount to scale the bone on the y axis
  27439. * @param z The amount to scale the bone on the z axis
  27440. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  27441. */
  27442. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  27443. /**
  27444. * Set the bone scaling in local space
  27445. * @param scale defines the scaling vector
  27446. */
  27447. setScale(scale: Vector3): void;
  27448. /**
  27449. * Gets the current scaling in local space
  27450. * @returns the current scaling vector
  27451. */
  27452. getScale(): Vector3;
  27453. /**
  27454. * Gets the current scaling in local space and stores it in a target vector
  27455. * @param result defines the target vector
  27456. */
  27457. getScaleToRef(result: Vector3): void;
  27458. /**
  27459. * Set the yaw, pitch, and roll of the bone in local or world space
  27460. * @param yaw The rotation of the bone on the y axis
  27461. * @param pitch The rotation of the bone on the x axis
  27462. * @param roll The rotation of the bone on the z axis
  27463. * @param space The space that the axes of rotation are in
  27464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27465. */
  27466. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  27467. /**
  27468. * Add a rotation to the bone on an axis in local or world space
  27469. * @param axis The axis to rotate the bone on
  27470. * @param amount The amount to rotate the bone
  27471. * @param space The space that the axis is in
  27472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27473. */
  27474. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  27475. /**
  27476. * Set the rotation of the bone to a particular axis angle in local or world space
  27477. * @param axis The axis to rotate the bone on
  27478. * @param angle The angle that the bone should be rotated to
  27479. * @param space The space that the axis is in
  27480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27481. */
  27482. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  27483. /**
  27484. * Set the euler rotation of the bone in local or world space
  27485. * @param rotation The euler rotation that the bone should be set to
  27486. * @param space The space that the rotation is in
  27487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27488. */
  27489. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27490. /**
  27491. * Set the quaternion rotation of the bone in local or world space
  27492. * @param quat The quaternion rotation that the bone should be set to
  27493. * @param space The space that the rotation is in
  27494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27495. */
  27496. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  27497. /**
  27498. * Set the rotation matrix of the bone in local or world space
  27499. * @param rotMat The rotation matrix that the bone should be set to
  27500. * @param space The space that the rotation is in
  27501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27502. */
  27503. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  27504. private _rotateWithMatrix;
  27505. private _getNegativeRotationToRef;
  27506. /**
  27507. * Get the position of the bone in local or world space
  27508. * @param space The space that the returned position is in
  27509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27510. * @returns The position of the bone
  27511. */
  27512. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27513. /**
  27514. * Copy the position of the bone to a vector3 in local or world space
  27515. * @param space The space that the returned position is in
  27516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27517. * @param result The vector3 to copy the position to
  27518. */
  27519. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  27520. /**
  27521. * Get the absolute position of the bone (world space)
  27522. * @param mesh The mesh that this bone is attached to
  27523. * @returns The absolute position of the bone
  27524. */
  27525. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  27526. /**
  27527. * Copy the absolute position of the bone (world space) to the result param
  27528. * @param mesh The mesh that this bone is attached to
  27529. * @param result The vector3 to copy the absolute position to
  27530. */
  27531. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  27532. /**
  27533. * Compute the absolute transforms of this bone and its children
  27534. */
  27535. computeAbsoluteTransforms(): void;
  27536. /**
  27537. * Get the world direction from an axis that is in the local space of the bone
  27538. * @param localAxis The local direction that is used to compute the world direction
  27539. * @param mesh The mesh that this bone is attached to
  27540. * @returns The world direction
  27541. */
  27542. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27543. /**
  27544. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  27545. * @param localAxis The local direction that is used to compute the world direction
  27546. * @param mesh The mesh that this bone is attached to
  27547. * @param result The vector3 that the world direction will be copied to
  27548. */
  27549. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27550. /**
  27551. * Get the euler rotation of the bone in local or world space
  27552. * @param space The space that the rotation should be in
  27553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27554. * @returns The euler rotation
  27555. */
  27556. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27557. /**
  27558. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  27559. * @param space The space that the rotation should be in
  27560. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27561. * @param result The vector3 that the rotation should be copied to
  27562. */
  27563. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27564. /**
  27565. * Get the quaternion rotation of the bone in either local or world space
  27566. * @param space The space that the rotation should be in
  27567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27568. * @returns The quaternion rotation
  27569. */
  27570. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  27571. /**
  27572. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  27573. * @param space The space that the rotation should be in
  27574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27575. * @param result The quaternion that the rotation should be copied to
  27576. */
  27577. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  27578. /**
  27579. * Get the rotation matrix of the bone in local or world space
  27580. * @param space The space that the rotation should be in
  27581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27582. * @returns The rotation matrix
  27583. */
  27584. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  27585. /**
  27586. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  27587. * @param space The space that the rotation should be in
  27588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27589. * @param result The quaternion that the rotation should be copied to
  27590. */
  27591. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  27592. /**
  27593. * Get the world position of a point that is in the local space of the bone
  27594. * @param position The local position
  27595. * @param mesh The mesh that this bone is attached to
  27596. * @returns The world position
  27597. */
  27598. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27599. /**
  27600. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  27601. * @param position The local position
  27602. * @param mesh The mesh that this bone is attached to
  27603. * @param result The vector3 that the world position should be copied to
  27604. */
  27605. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27606. /**
  27607. * Get the local position of a point that is in world space
  27608. * @param position The world position
  27609. * @param mesh The mesh that this bone is attached to
  27610. * @returns The local position
  27611. */
  27612. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27613. /**
  27614. * Get the local position of a point that is in world space and copy it to the result param
  27615. * @param position The world position
  27616. * @param mesh The mesh that this bone is attached to
  27617. * @param result The vector3 that the local position should be copied to
  27618. */
  27619. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27620. /**
  27621. * Set the current local matrix as the restPose for this bone.
  27622. */
  27623. setCurrentPoseAsRest(): void;
  27624. }
  27625. }
  27626. declare module "babylonjs/Meshes/transformNode" {
  27627. import { DeepImmutable } from "babylonjs/types";
  27628. import { Observable } from "babylonjs/Misc/observable";
  27629. import { Nullable } from "babylonjs/types";
  27630. import { Camera } from "babylonjs/Cameras/camera";
  27631. import { Scene } from "babylonjs/scene";
  27632. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27633. import { Node } from "babylonjs/node";
  27634. import { Bone } from "babylonjs/Bones/bone";
  27635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27636. import { Space } from "babylonjs/Maths/math.axis";
  27637. /**
  27638. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  27639. * @see https://doc.babylonjs.com/how_to/transformnode
  27640. */
  27641. export class TransformNode extends Node {
  27642. /**
  27643. * Object will not rotate to face the camera
  27644. */
  27645. static BILLBOARDMODE_NONE: number;
  27646. /**
  27647. * Object will rotate to face the camera but only on the x axis
  27648. */
  27649. static BILLBOARDMODE_X: number;
  27650. /**
  27651. * Object will rotate to face the camera but only on the y axis
  27652. */
  27653. static BILLBOARDMODE_Y: number;
  27654. /**
  27655. * Object will rotate to face the camera but only on the z axis
  27656. */
  27657. static BILLBOARDMODE_Z: number;
  27658. /**
  27659. * Object will rotate to face the camera
  27660. */
  27661. static BILLBOARDMODE_ALL: number;
  27662. /**
  27663. * Object will rotate to face the camera's position instead of orientation
  27664. */
  27665. static BILLBOARDMODE_USE_POSITION: number;
  27666. private static _TmpRotation;
  27667. private static _TmpScaling;
  27668. private static _TmpTranslation;
  27669. private _forward;
  27670. private _forwardInverted;
  27671. private _up;
  27672. private _right;
  27673. private _rightInverted;
  27674. private _position;
  27675. private _rotation;
  27676. private _rotationQuaternion;
  27677. protected _scaling: Vector3;
  27678. protected _isDirty: boolean;
  27679. private _transformToBoneReferal;
  27680. private _isAbsoluteSynced;
  27681. private _billboardMode;
  27682. /**
  27683. * Gets or sets the billboard mode. Default is 0.
  27684. *
  27685. * | Value | Type | Description |
  27686. * | --- | --- | --- |
  27687. * | 0 | BILLBOARDMODE_NONE | |
  27688. * | 1 | BILLBOARDMODE_X | |
  27689. * | 2 | BILLBOARDMODE_Y | |
  27690. * | 4 | BILLBOARDMODE_Z | |
  27691. * | 7 | BILLBOARDMODE_ALL | |
  27692. *
  27693. */
  27694. get billboardMode(): number;
  27695. set billboardMode(value: number);
  27696. private _preserveParentRotationForBillboard;
  27697. /**
  27698. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  27699. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  27700. */
  27701. get preserveParentRotationForBillboard(): boolean;
  27702. set preserveParentRotationForBillboard(value: boolean);
  27703. /**
  27704. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  27705. */
  27706. scalingDeterminant: number;
  27707. private _infiniteDistance;
  27708. /**
  27709. * Gets or sets the distance of the object to max, often used by skybox
  27710. */
  27711. get infiniteDistance(): boolean;
  27712. set infiniteDistance(value: boolean);
  27713. /**
  27714. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  27715. * By default the system will update normals to compensate
  27716. */
  27717. ignoreNonUniformScaling: boolean;
  27718. /**
  27719. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  27720. */
  27721. reIntegrateRotationIntoRotationQuaternion: boolean;
  27722. /** @hidden */
  27723. _poseMatrix: Nullable<Matrix>;
  27724. /** @hidden */
  27725. _localMatrix: Matrix;
  27726. private _usePivotMatrix;
  27727. private _absolutePosition;
  27728. private _absoluteScaling;
  27729. private _absoluteRotationQuaternion;
  27730. private _pivotMatrix;
  27731. private _pivotMatrixInverse;
  27732. /** @hidden */
  27733. _postMultiplyPivotMatrix: boolean;
  27734. protected _isWorldMatrixFrozen: boolean;
  27735. /** @hidden */
  27736. _indexInSceneTransformNodesArray: number;
  27737. /**
  27738. * An event triggered after the world matrix is updated
  27739. */
  27740. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  27741. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  27742. /**
  27743. * Gets a string identifying the name of the class
  27744. * @returns "TransformNode" string
  27745. */
  27746. getClassName(): string;
  27747. /**
  27748. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  27749. */
  27750. get position(): Vector3;
  27751. set position(newPosition: Vector3);
  27752. /**
  27753. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  27754. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  27755. */
  27756. get rotation(): Vector3;
  27757. set rotation(newRotation: Vector3);
  27758. /**
  27759. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  27760. */
  27761. get scaling(): Vector3;
  27762. set scaling(newScaling: Vector3);
  27763. /**
  27764. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  27765. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  27766. */
  27767. get rotationQuaternion(): Nullable<Quaternion>;
  27768. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  27769. /**
  27770. * The forward direction of that transform in world space.
  27771. */
  27772. get forward(): Vector3;
  27773. /**
  27774. * The up direction of that transform in world space.
  27775. */
  27776. get up(): Vector3;
  27777. /**
  27778. * The right direction of that transform in world space.
  27779. */
  27780. get right(): Vector3;
  27781. /**
  27782. * Copies the parameter passed Matrix into the mesh Pose matrix.
  27783. * @param matrix the matrix to copy the pose from
  27784. * @returns this TransformNode.
  27785. */
  27786. updatePoseMatrix(matrix: Matrix): TransformNode;
  27787. /**
  27788. * Returns the mesh Pose matrix.
  27789. * @returns the pose matrix
  27790. */
  27791. getPoseMatrix(): Matrix;
  27792. /** @hidden */
  27793. _isSynchronized(): boolean;
  27794. /** @hidden */
  27795. _initCache(): void;
  27796. /**
  27797. * Flag the transform node as dirty (Forcing it to update everything)
  27798. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  27799. * @returns this transform node
  27800. */
  27801. markAsDirty(property: string): TransformNode;
  27802. /**
  27803. * Returns the current mesh absolute position.
  27804. * Returns a Vector3.
  27805. */
  27806. get absolutePosition(): Vector3;
  27807. /**
  27808. * Returns the current mesh absolute scaling.
  27809. * Returns a Vector3.
  27810. */
  27811. get absoluteScaling(): Vector3;
  27812. /**
  27813. * Returns the current mesh absolute rotation.
  27814. * Returns a Quaternion.
  27815. */
  27816. get absoluteRotationQuaternion(): Quaternion;
  27817. /**
  27818. * Sets a new matrix to apply before all other transformation
  27819. * @param matrix defines the transform matrix
  27820. * @returns the current TransformNode
  27821. */
  27822. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27823. /**
  27824. * Sets a new pivot matrix to the current node
  27825. * @param matrix defines the new pivot matrix to use
  27826. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  27827. * @returns the current TransformNode
  27828. */
  27829. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27830. /**
  27831. * Returns the mesh pivot matrix.
  27832. * Default : Identity.
  27833. * @returns the matrix
  27834. */
  27835. getPivotMatrix(): Matrix;
  27836. /**
  27837. * Instantiate (when possible) or clone that node with its hierarchy
  27838. * @param newParent defines the new parent to use for the instance (or clone)
  27839. * @param options defines options to configure how copy is done
  27840. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27841. * @returns an instance (or a clone) of the current node with its hiearchy
  27842. */
  27843. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27844. doNotInstantiate: boolean;
  27845. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27846. /**
  27847. * Prevents the World matrix to be computed any longer
  27848. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27849. * @returns the TransformNode.
  27850. */
  27851. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27852. /**
  27853. * Allows back the World matrix computation.
  27854. * @returns the TransformNode.
  27855. */
  27856. unfreezeWorldMatrix(): this;
  27857. /**
  27858. * True if the World matrix has been frozen.
  27859. */
  27860. get isWorldMatrixFrozen(): boolean;
  27861. /**
  27862. * Retuns the mesh absolute position in the World.
  27863. * @returns a Vector3.
  27864. */
  27865. getAbsolutePosition(): Vector3;
  27866. /**
  27867. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27868. * @param absolutePosition the absolute position to set
  27869. * @returns the TransformNode.
  27870. */
  27871. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27872. /**
  27873. * Sets the mesh position in its local space.
  27874. * @param vector3 the position to set in localspace
  27875. * @returns the TransformNode.
  27876. */
  27877. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27878. /**
  27879. * Returns the mesh position in the local space from the current World matrix values.
  27880. * @returns a new Vector3.
  27881. */
  27882. getPositionExpressedInLocalSpace(): Vector3;
  27883. /**
  27884. * Translates the mesh along the passed Vector3 in its local space.
  27885. * @param vector3 the distance to translate in localspace
  27886. * @returns the TransformNode.
  27887. */
  27888. locallyTranslate(vector3: Vector3): TransformNode;
  27889. private static _lookAtVectorCache;
  27890. /**
  27891. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27892. * @param targetPoint the position (must be in same space as current mesh) to look at
  27893. * @param yawCor optional yaw (y-axis) correction in radians
  27894. * @param pitchCor optional pitch (x-axis) correction in radians
  27895. * @param rollCor optional roll (z-axis) correction in radians
  27896. * @param space the choosen space of the target
  27897. * @returns the TransformNode.
  27898. */
  27899. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27900. /**
  27901. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27902. * This Vector3 is expressed in the World space.
  27903. * @param localAxis axis to rotate
  27904. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27905. */
  27906. getDirection(localAxis: Vector3): Vector3;
  27907. /**
  27908. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27909. * localAxis is expressed in the mesh local space.
  27910. * result is computed in the Wordl space from the mesh World matrix.
  27911. * @param localAxis axis to rotate
  27912. * @param result the resulting transformnode
  27913. * @returns this TransformNode.
  27914. */
  27915. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27916. /**
  27917. * Sets this transform node rotation to the given local axis.
  27918. * @param localAxis the axis in local space
  27919. * @param yawCor optional yaw (y-axis) correction in radians
  27920. * @param pitchCor optional pitch (x-axis) correction in radians
  27921. * @param rollCor optional roll (z-axis) correction in radians
  27922. * @returns this TransformNode
  27923. */
  27924. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27925. /**
  27926. * Sets a new pivot point to the current node
  27927. * @param point defines the new pivot point to use
  27928. * @param space defines if the point is in world or local space (local by default)
  27929. * @returns the current TransformNode
  27930. */
  27931. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27932. /**
  27933. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27934. * @returns the pivot point
  27935. */
  27936. getPivotPoint(): Vector3;
  27937. /**
  27938. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27939. * @param result the vector3 to store the result
  27940. * @returns this TransformNode.
  27941. */
  27942. getPivotPointToRef(result: Vector3): TransformNode;
  27943. /**
  27944. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27945. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27946. */
  27947. getAbsolutePivotPoint(): Vector3;
  27948. /**
  27949. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27950. * @param result vector3 to store the result
  27951. * @returns this TransformNode.
  27952. */
  27953. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27954. /**
  27955. * Defines the passed node as the parent of the current node.
  27956. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27957. * @see https://doc.babylonjs.com/how_to/parenting
  27958. * @param node the node ot set as the parent
  27959. * @returns this TransformNode.
  27960. */
  27961. setParent(node: Nullable<Node>): TransformNode;
  27962. private _nonUniformScaling;
  27963. /**
  27964. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27965. */
  27966. get nonUniformScaling(): boolean;
  27967. /** @hidden */
  27968. _updateNonUniformScalingState(value: boolean): boolean;
  27969. /**
  27970. * Attach the current TransformNode to another TransformNode associated with a bone
  27971. * @param bone Bone affecting the TransformNode
  27972. * @param affectedTransformNode TransformNode associated with the bone
  27973. * @returns this object
  27974. */
  27975. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27976. /**
  27977. * Detach the transform node if its associated with a bone
  27978. * @returns this object
  27979. */
  27980. detachFromBone(): TransformNode;
  27981. private static _rotationAxisCache;
  27982. /**
  27983. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27984. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27985. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27986. * The passed axis is also normalized.
  27987. * @param axis the axis to rotate around
  27988. * @param amount the amount to rotate in radians
  27989. * @param space Space to rotate in (Default: local)
  27990. * @returns the TransformNode.
  27991. */
  27992. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27993. /**
  27994. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27995. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27996. * The passed axis is also normalized. .
  27997. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27998. * @param point the point to rotate around
  27999. * @param axis the axis to rotate around
  28000. * @param amount the amount to rotate in radians
  28001. * @returns the TransformNode
  28002. */
  28003. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  28004. /**
  28005. * Translates the mesh along the axis vector for the passed distance in the given space.
  28006. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  28007. * @param axis the axis to translate in
  28008. * @param distance the distance to translate
  28009. * @param space Space to rotate in (Default: local)
  28010. * @returns the TransformNode.
  28011. */
  28012. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28013. /**
  28014. * Adds a rotation step to the mesh current rotation.
  28015. * x, y, z are Euler angles expressed in radians.
  28016. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  28017. * This means this rotation is made in the mesh local space only.
  28018. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  28019. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  28020. * ```javascript
  28021. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  28022. * ```
  28023. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  28024. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  28025. * @param x Rotation to add
  28026. * @param y Rotation to add
  28027. * @param z Rotation to add
  28028. * @returns the TransformNode.
  28029. */
  28030. addRotation(x: number, y: number, z: number): TransformNode;
  28031. /**
  28032. * @hidden
  28033. */
  28034. protected _getEffectiveParent(): Nullable<Node>;
  28035. /**
  28036. * Computes the world matrix of the node
  28037. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28038. * @returns the world matrix
  28039. */
  28040. computeWorldMatrix(force?: boolean): Matrix;
  28041. /**
  28042. * Resets this nodeTransform's local matrix to Matrix.Identity().
  28043. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  28044. */
  28045. resetLocalMatrix(independentOfChildren?: boolean): void;
  28046. protected _afterComputeWorldMatrix(): void;
  28047. /**
  28048. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  28049. * @param func callback function to add
  28050. *
  28051. * @returns the TransformNode.
  28052. */
  28053. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28054. /**
  28055. * Removes a registered callback function.
  28056. * @param func callback function to remove
  28057. * @returns the TransformNode.
  28058. */
  28059. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28060. /**
  28061. * Gets the position of the current mesh in camera space
  28062. * @param camera defines the camera to use
  28063. * @returns a position
  28064. */
  28065. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  28066. /**
  28067. * Returns the distance from the mesh to the active camera
  28068. * @param camera defines the camera to use
  28069. * @returns the distance
  28070. */
  28071. getDistanceToCamera(camera?: Nullable<Camera>): number;
  28072. /**
  28073. * Clone the current transform node
  28074. * @param name Name of the new clone
  28075. * @param newParent New parent for the clone
  28076. * @param doNotCloneChildren Do not clone children hierarchy
  28077. * @returns the new transform node
  28078. */
  28079. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  28080. /**
  28081. * Serializes the objects information.
  28082. * @param currentSerializationObject defines the object to serialize in
  28083. * @returns the serialized object
  28084. */
  28085. serialize(currentSerializationObject?: any): any;
  28086. /**
  28087. * Returns a new TransformNode object parsed from the source provided.
  28088. * @param parsedTransformNode is the source.
  28089. * @param scene the scne the object belongs to
  28090. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  28091. * @returns a new TransformNode object parsed from the source provided.
  28092. */
  28093. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  28094. /**
  28095. * Get all child-transformNodes of this node
  28096. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  28097. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  28098. * @returns an array of TransformNode
  28099. */
  28100. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  28101. /**
  28102. * Releases resources associated with this transform node.
  28103. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28104. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28105. */
  28106. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28107. /**
  28108. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28109. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28110. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28111. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28112. * @returns the current mesh
  28113. */
  28114. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  28115. private _syncAbsoluteScalingAndRotation;
  28116. }
  28117. }
  28118. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  28119. import { Observable } from "babylonjs/Misc/observable";
  28120. import { Nullable } from "babylonjs/types";
  28121. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28122. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28124. import { Ray } from "babylonjs/Culling/ray";
  28125. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  28126. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  28127. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  28128. /**
  28129. * Defines the types of pose enabled controllers that are supported
  28130. */
  28131. export enum PoseEnabledControllerType {
  28132. /**
  28133. * HTC Vive
  28134. */
  28135. VIVE = 0,
  28136. /**
  28137. * Oculus Rift
  28138. */
  28139. OCULUS = 1,
  28140. /**
  28141. * Windows mixed reality
  28142. */
  28143. WINDOWS = 2,
  28144. /**
  28145. * Samsung gear VR
  28146. */
  28147. GEAR_VR = 3,
  28148. /**
  28149. * Google Daydream
  28150. */
  28151. DAYDREAM = 4,
  28152. /**
  28153. * Generic
  28154. */
  28155. GENERIC = 5
  28156. }
  28157. /**
  28158. * Defines the MutableGamepadButton interface for the state of a gamepad button
  28159. */
  28160. export interface MutableGamepadButton {
  28161. /**
  28162. * Value of the button/trigger
  28163. */
  28164. value: number;
  28165. /**
  28166. * If the button/trigger is currently touched
  28167. */
  28168. touched: boolean;
  28169. /**
  28170. * If the button/trigger is currently pressed
  28171. */
  28172. pressed: boolean;
  28173. }
  28174. /**
  28175. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  28176. * @hidden
  28177. */
  28178. export interface ExtendedGamepadButton extends GamepadButton {
  28179. /**
  28180. * If the button/trigger is currently pressed
  28181. */
  28182. readonly pressed: boolean;
  28183. /**
  28184. * If the button/trigger is currently touched
  28185. */
  28186. readonly touched: boolean;
  28187. /**
  28188. * Value of the button/trigger
  28189. */
  28190. readonly value: number;
  28191. }
  28192. /** @hidden */
  28193. export interface _GamePadFactory {
  28194. /**
  28195. * Returns whether or not the current gamepad can be created for this type of controller.
  28196. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28197. * @returns true if it can be created, otherwise false
  28198. */
  28199. canCreate(gamepadInfo: any): boolean;
  28200. /**
  28201. * Creates a new instance of the Gamepad.
  28202. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28203. * @returns the new gamepad instance
  28204. */
  28205. create(gamepadInfo: any): Gamepad;
  28206. }
  28207. /**
  28208. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28209. */
  28210. export class PoseEnabledControllerHelper {
  28211. /** @hidden */
  28212. static _ControllerFactories: _GamePadFactory[];
  28213. /** @hidden */
  28214. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  28215. /**
  28216. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28217. * @param vrGamepad the gamepad to initialized
  28218. * @returns a vr controller of the type the gamepad identified as
  28219. */
  28220. static InitiateController(vrGamepad: any): Gamepad;
  28221. }
  28222. /**
  28223. * Defines the PoseEnabledController object that contains state of a vr capable controller
  28224. */
  28225. export class PoseEnabledController extends Gamepad implements PoseControlled {
  28226. /**
  28227. * If the controller is used in a webXR session
  28228. */
  28229. isXR: boolean;
  28230. private _deviceRoomPosition;
  28231. private _deviceRoomRotationQuaternion;
  28232. /**
  28233. * The device position in babylon space
  28234. */
  28235. devicePosition: Vector3;
  28236. /**
  28237. * The device rotation in babylon space
  28238. */
  28239. deviceRotationQuaternion: Quaternion;
  28240. /**
  28241. * The scale factor of the device in babylon space
  28242. */
  28243. deviceScaleFactor: number;
  28244. /**
  28245. * (Likely devicePosition should be used instead) The device position in its room space
  28246. */
  28247. position: Vector3;
  28248. /**
  28249. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  28250. */
  28251. rotationQuaternion: Quaternion;
  28252. /**
  28253. * The type of controller (Eg. Windows mixed reality)
  28254. */
  28255. controllerType: PoseEnabledControllerType;
  28256. protected _calculatedPosition: Vector3;
  28257. private _calculatedRotation;
  28258. /**
  28259. * The raw pose from the device
  28260. */
  28261. rawPose: DevicePose;
  28262. private _trackPosition;
  28263. private _maxRotationDistFromHeadset;
  28264. private _draggedRoomRotation;
  28265. /**
  28266. * @hidden
  28267. */
  28268. _disableTrackPosition(fixedPosition: Vector3): void;
  28269. /**
  28270. * Internal, the mesh attached to the controller
  28271. * @hidden
  28272. */
  28273. _mesh: Nullable<AbstractMesh>;
  28274. private _poseControlledCamera;
  28275. private _leftHandSystemQuaternion;
  28276. /**
  28277. * Internal, matrix used to convert room space to babylon space
  28278. * @hidden
  28279. */
  28280. _deviceToWorld: Matrix;
  28281. /**
  28282. * Node to be used when casting a ray from the controller
  28283. * @hidden
  28284. */
  28285. _pointingPoseNode: Nullable<TransformNode>;
  28286. /**
  28287. * Name of the child mesh that can be used to cast a ray from the controller
  28288. */
  28289. static readonly POINTING_POSE: string;
  28290. /**
  28291. * Creates a new PoseEnabledController from a gamepad
  28292. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  28293. */
  28294. constructor(browserGamepad: any);
  28295. private _workingMatrix;
  28296. /**
  28297. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  28298. */
  28299. update(): void;
  28300. /**
  28301. * Updates only the pose device and mesh without doing any button event checking
  28302. */
  28303. protected _updatePoseAndMesh(): void;
  28304. /**
  28305. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  28306. * @param poseData raw pose fromthe device
  28307. */
  28308. updateFromDevice(poseData: DevicePose): void;
  28309. /**
  28310. * @hidden
  28311. */
  28312. _meshAttachedObservable: Observable<AbstractMesh>;
  28313. /**
  28314. * Attaches a mesh to the controller
  28315. * @param mesh the mesh to be attached
  28316. */
  28317. attachToMesh(mesh: AbstractMesh): void;
  28318. /**
  28319. * Attaches the controllers mesh to a camera
  28320. * @param camera the camera the mesh should be attached to
  28321. */
  28322. attachToPoseControlledCamera(camera: TargetCamera): void;
  28323. /**
  28324. * Disposes of the controller
  28325. */
  28326. dispose(): void;
  28327. /**
  28328. * The mesh that is attached to the controller
  28329. */
  28330. get mesh(): Nullable<AbstractMesh>;
  28331. /**
  28332. * Gets the ray of the controller in the direction the controller is pointing
  28333. * @param length the length the resulting ray should be
  28334. * @returns a ray in the direction the controller is pointing
  28335. */
  28336. getForwardRay(length?: number): Ray;
  28337. }
  28338. }
  28339. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  28340. import { Observable } from "babylonjs/Misc/observable";
  28341. import { Scene } from "babylonjs/scene";
  28342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28343. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  28344. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  28345. import { Nullable } from "babylonjs/types";
  28346. /**
  28347. * Defines the WebVRController object that represents controllers tracked in 3D space
  28348. */
  28349. export abstract class WebVRController extends PoseEnabledController {
  28350. /**
  28351. * Internal, the default controller model for the controller
  28352. */
  28353. protected _defaultModel: Nullable<AbstractMesh>;
  28354. /**
  28355. * Fired when the trigger state has changed
  28356. */
  28357. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  28358. /**
  28359. * Fired when the main button state has changed
  28360. */
  28361. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28362. /**
  28363. * Fired when the secondary button state has changed
  28364. */
  28365. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28366. /**
  28367. * Fired when the pad state has changed
  28368. */
  28369. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  28370. /**
  28371. * Fired when controllers stick values have changed
  28372. */
  28373. onPadValuesChangedObservable: Observable<StickValues>;
  28374. /**
  28375. * Array of button availible on the controller
  28376. */
  28377. protected _buttons: Array<MutableGamepadButton>;
  28378. private _onButtonStateChange;
  28379. /**
  28380. * Fired when a controller button's state has changed
  28381. * @param callback the callback containing the button that was modified
  28382. */
  28383. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  28384. /**
  28385. * X and Y axis corresponding to the controllers joystick
  28386. */
  28387. pad: StickValues;
  28388. /**
  28389. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  28390. */
  28391. hand: string;
  28392. /**
  28393. * The default controller model for the controller
  28394. */
  28395. get defaultModel(): Nullable<AbstractMesh>;
  28396. /**
  28397. * Creates a new WebVRController from a gamepad
  28398. * @param vrGamepad the gamepad that the WebVRController should be created from
  28399. */
  28400. constructor(vrGamepad: any);
  28401. /**
  28402. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  28403. */
  28404. update(): void;
  28405. /**
  28406. * Function to be called when a button is modified
  28407. */
  28408. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28409. /**
  28410. * Loads a mesh and attaches it to the controller
  28411. * @param scene the scene the mesh should be added to
  28412. * @param meshLoaded callback for when the mesh has been loaded
  28413. */
  28414. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28415. private _setButtonValue;
  28416. private _changes;
  28417. private _checkChanges;
  28418. /**
  28419. * Disposes of th webVRCOntroller
  28420. */
  28421. dispose(): void;
  28422. }
  28423. }
  28424. declare module "babylonjs/Lights/hemisphericLight" {
  28425. import { Nullable } from "babylonjs/types";
  28426. import { Scene } from "babylonjs/scene";
  28427. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28428. import { Color3 } from "babylonjs/Maths/math.color";
  28429. import { Effect } from "babylonjs/Materials/effect";
  28430. import { Light } from "babylonjs/Lights/light";
  28431. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  28432. /**
  28433. * The HemisphericLight simulates the ambient environment light,
  28434. * so the passed direction is the light reflection direction, not the incoming direction.
  28435. */
  28436. export class HemisphericLight extends Light {
  28437. /**
  28438. * The groundColor is the light in the opposite direction to the one specified during creation.
  28439. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  28440. */
  28441. groundColor: Color3;
  28442. /**
  28443. * The light reflection direction, not the incoming direction.
  28444. */
  28445. direction: Vector3;
  28446. /**
  28447. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  28448. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  28449. * The HemisphericLight can't cast shadows.
  28450. * Documentation : https://doc.babylonjs.com/babylon101/lights
  28451. * @param name The friendly name of the light
  28452. * @param direction The direction of the light reflection
  28453. * @param scene The scene the light belongs to
  28454. */
  28455. constructor(name: string, direction: Vector3, scene: Scene);
  28456. protected _buildUniformLayout(): void;
  28457. /**
  28458. * Returns the string "HemisphericLight".
  28459. * @return The class name
  28460. */
  28461. getClassName(): string;
  28462. /**
  28463. * Sets the HemisphericLight direction towards the passed target (Vector3).
  28464. * Returns the updated direction.
  28465. * @param target The target the direction should point to
  28466. * @return The computed direction
  28467. */
  28468. setDirectionToTarget(target: Vector3): Vector3;
  28469. /**
  28470. * Returns the shadow generator associated to the light.
  28471. * @returns Always null for hemispheric lights because it does not support shadows.
  28472. */
  28473. getShadowGenerator(): Nullable<IShadowGenerator>;
  28474. /**
  28475. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  28476. * @param effect The effect to update
  28477. * @param lightIndex The index of the light in the effect to update
  28478. * @returns The hemispheric light
  28479. */
  28480. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  28481. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  28482. /**
  28483. * Computes the world matrix of the node
  28484. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28485. * @param useWasUpdatedFlag defines a reserved property
  28486. * @returns the world matrix
  28487. */
  28488. computeWorldMatrix(): Matrix;
  28489. /**
  28490. * Returns the integer 3.
  28491. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  28492. */
  28493. getTypeID(): number;
  28494. /**
  28495. * Prepares the list of defines specific to the light type.
  28496. * @param defines the list of defines
  28497. * @param lightIndex defines the index of the light for the effect
  28498. */
  28499. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  28500. }
  28501. }
  28502. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  28503. /** @hidden */
  28504. export var vrMultiviewToSingleviewPixelShader: {
  28505. name: string;
  28506. shader: string;
  28507. };
  28508. }
  28509. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  28510. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28511. import { Scene } from "babylonjs/scene";
  28512. /**
  28513. * Renders to multiple views with a single draw call
  28514. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  28515. */
  28516. export class MultiviewRenderTarget extends RenderTargetTexture {
  28517. /**
  28518. * Creates a multiview render target
  28519. * @param scene scene used with the render target
  28520. * @param size the size of the render target (used for each view)
  28521. */
  28522. constructor(scene: Scene, size?: number | {
  28523. width: number;
  28524. height: number;
  28525. } | {
  28526. ratio: number;
  28527. });
  28528. /**
  28529. * @hidden
  28530. * @param faceIndex the face index, if its a cube texture
  28531. */
  28532. _bindFrameBuffer(faceIndex?: number): void;
  28533. /**
  28534. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28535. * @returns the view count
  28536. */
  28537. getViewCount(): number;
  28538. }
  28539. }
  28540. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  28541. import { Camera } from "babylonjs/Cameras/camera";
  28542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28543. import { Nullable } from "babylonjs/types";
  28544. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28545. import { Matrix } from "babylonjs/Maths/math.vector";
  28546. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28547. module "babylonjs/Engines/engine" {
  28548. interface Engine {
  28549. /**
  28550. * Creates a new multiview render target
  28551. * @param width defines the width of the texture
  28552. * @param height defines the height of the texture
  28553. * @returns the created multiview texture
  28554. */
  28555. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  28556. /**
  28557. * Binds a multiview framebuffer to be drawn to
  28558. * @param multiviewTexture texture to bind
  28559. */
  28560. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  28561. }
  28562. }
  28563. module "babylonjs/Cameras/camera" {
  28564. interface Camera {
  28565. /**
  28566. * @hidden
  28567. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  28568. */
  28569. _useMultiviewToSingleView: boolean;
  28570. /**
  28571. * @hidden
  28572. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  28573. */
  28574. _multiviewTexture: Nullable<RenderTargetTexture>;
  28575. /**
  28576. * @hidden
  28577. * ensures the multiview texture of the camera exists and has the specified width/height
  28578. * @param width height to set on the multiview texture
  28579. * @param height width to set on the multiview texture
  28580. */
  28581. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  28582. }
  28583. }
  28584. module "babylonjs/scene" {
  28585. interface Scene {
  28586. /** @hidden */
  28587. _transformMatrixR: Matrix;
  28588. /** @hidden */
  28589. _multiviewSceneUbo: Nullable<UniformBuffer>;
  28590. /** @hidden */
  28591. _createMultiviewUbo(): void;
  28592. /** @hidden */
  28593. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  28594. /** @hidden */
  28595. _renderMultiviewToSingleView(camera: Camera): void;
  28596. }
  28597. }
  28598. }
  28599. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  28600. import { Camera } from "babylonjs/Cameras/camera";
  28601. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28602. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  28603. import "babylonjs/Engines/Extensions/engine.multiview";
  28604. /**
  28605. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  28606. * This will not be used for webXR as it supports displaying texture arrays directly
  28607. */
  28608. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  28609. /**
  28610. * Gets a string identifying the name of the class
  28611. * @returns "VRMultiviewToSingleviewPostProcess" string
  28612. */
  28613. getClassName(): string;
  28614. /**
  28615. * Initializes a VRMultiviewToSingleview
  28616. * @param name name of the post process
  28617. * @param camera camera to be applied to
  28618. * @param scaleFactor scaling factor to the size of the output texture
  28619. */
  28620. constructor(name: string, camera: Camera, scaleFactor: number);
  28621. }
  28622. }
  28623. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  28624. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  28625. import { Nullable } from "babylonjs/types";
  28626. import { Size } from "babylonjs/Maths/math.size";
  28627. import { Observable } from "babylonjs/Misc/observable";
  28628. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  28629. /**
  28630. * Interface used to define additional presentation attributes
  28631. */
  28632. export interface IVRPresentationAttributes {
  28633. /**
  28634. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  28635. */
  28636. highRefreshRate: boolean;
  28637. /**
  28638. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  28639. */
  28640. foveationLevel: number;
  28641. }
  28642. module "babylonjs/Engines/engine" {
  28643. interface Engine {
  28644. /** @hidden */
  28645. _vrDisplay: any;
  28646. /** @hidden */
  28647. _vrSupported: boolean;
  28648. /** @hidden */
  28649. _oldSize: Size;
  28650. /** @hidden */
  28651. _oldHardwareScaleFactor: number;
  28652. /** @hidden */
  28653. _vrExclusivePointerMode: boolean;
  28654. /** @hidden */
  28655. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  28656. /** @hidden */
  28657. _onVRDisplayPointerRestricted: () => void;
  28658. /** @hidden */
  28659. _onVRDisplayPointerUnrestricted: () => void;
  28660. /** @hidden */
  28661. _onVrDisplayConnect: Nullable<(display: any) => void>;
  28662. /** @hidden */
  28663. _onVrDisplayDisconnect: Nullable<() => void>;
  28664. /** @hidden */
  28665. _onVrDisplayPresentChange: Nullable<() => void>;
  28666. /**
  28667. * Observable signaled when VR display mode changes
  28668. */
  28669. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28670. /**
  28671. * Observable signaled when VR request present is complete
  28672. */
  28673. onVRRequestPresentComplete: Observable<boolean>;
  28674. /**
  28675. * Observable signaled when VR request present starts
  28676. */
  28677. onVRRequestPresentStart: Observable<Engine>;
  28678. /**
  28679. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28680. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28681. */
  28682. isInVRExclusivePointerMode: boolean;
  28683. /**
  28684. * Gets a boolean indicating if a webVR device was detected
  28685. * @returns true if a webVR device was detected
  28686. */
  28687. isVRDevicePresent(): boolean;
  28688. /**
  28689. * Gets the current webVR device
  28690. * @returns the current webVR device (or null)
  28691. */
  28692. getVRDevice(): any;
  28693. /**
  28694. * Initializes a webVR display and starts listening to display change events
  28695. * The onVRDisplayChangedObservable will be notified upon these changes
  28696. * @returns A promise containing a VRDisplay and if vr is supported
  28697. */
  28698. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28699. /** @hidden */
  28700. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  28701. /**
  28702. * Gets or sets the presentation attributes used to configure VR rendering
  28703. */
  28704. vrPresentationAttributes?: IVRPresentationAttributes;
  28705. /**
  28706. * Call this function to switch to webVR mode
  28707. * Will do nothing if webVR is not supported or if there is no webVR device
  28708. * @param options the webvr options provided to the camera. mainly used for multiview
  28709. * @see https://doc.babylonjs.com/how_to/webvr_camera
  28710. */
  28711. enableVR(options: WebVROptions): void;
  28712. /** @hidden */
  28713. _onVRFullScreenTriggered(): void;
  28714. }
  28715. }
  28716. }
  28717. declare module "babylonjs/Cameras/VR/webVRCamera" {
  28718. import { Nullable } from "babylonjs/types";
  28719. import { Observable } from "babylonjs/Misc/observable";
  28720. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  28721. import { Scene } from "babylonjs/scene";
  28722. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28723. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  28724. import { Node } from "babylonjs/node";
  28725. import { Ray } from "babylonjs/Culling/ray";
  28726. import "babylonjs/Cameras/RigModes/webVRRigMode";
  28727. import "babylonjs/Engines/Extensions/engine.webVR";
  28728. /**
  28729. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28730. * IMPORTANT!! The data is right-hand data.
  28731. * @export
  28732. * @interface DevicePose
  28733. */
  28734. export interface DevicePose {
  28735. /**
  28736. * The position of the device, values in array are [x,y,z].
  28737. */
  28738. readonly position: Nullable<Float32Array>;
  28739. /**
  28740. * The linearVelocity of the device, values in array are [x,y,z].
  28741. */
  28742. readonly linearVelocity: Nullable<Float32Array>;
  28743. /**
  28744. * The linearAcceleration of the device, values in array are [x,y,z].
  28745. */
  28746. readonly linearAcceleration: Nullable<Float32Array>;
  28747. /**
  28748. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28749. */
  28750. readonly orientation: Nullable<Float32Array>;
  28751. /**
  28752. * The angularVelocity of the device, values in array are [x,y,z].
  28753. */
  28754. readonly angularVelocity: Nullable<Float32Array>;
  28755. /**
  28756. * The angularAcceleration of the device, values in array are [x,y,z].
  28757. */
  28758. readonly angularAcceleration: Nullable<Float32Array>;
  28759. }
  28760. /**
  28761. * Interface representing a pose controlled object in Babylon.
  28762. * A pose controlled object has both regular pose values as well as pose values
  28763. * from an external device such as a VR head mounted display
  28764. */
  28765. export interface PoseControlled {
  28766. /**
  28767. * The position of the object in babylon space.
  28768. */
  28769. position: Vector3;
  28770. /**
  28771. * The rotation quaternion of the object in babylon space.
  28772. */
  28773. rotationQuaternion: Quaternion;
  28774. /**
  28775. * The position of the device in babylon space.
  28776. */
  28777. devicePosition?: Vector3;
  28778. /**
  28779. * The rotation quaternion of the device in babylon space.
  28780. */
  28781. deviceRotationQuaternion: Quaternion;
  28782. /**
  28783. * The raw pose coming from the device.
  28784. */
  28785. rawPose: Nullable<DevicePose>;
  28786. /**
  28787. * The scale of the device to be used when translating from device space to babylon space.
  28788. */
  28789. deviceScaleFactor: number;
  28790. /**
  28791. * Updates the poseControlled values based on the input device pose.
  28792. * @param poseData the pose data to update the object with
  28793. */
  28794. updateFromDevice(poseData: DevicePose): void;
  28795. }
  28796. /**
  28797. * Set of options to customize the webVRCamera
  28798. */
  28799. export interface WebVROptions {
  28800. /**
  28801. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  28802. */
  28803. trackPosition?: boolean;
  28804. /**
  28805. * Sets the scale of the vrDevice in babylon space. (default: 1)
  28806. */
  28807. positionScale?: number;
  28808. /**
  28809. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  28810. */
  28811. displayName?: string;
  28812. /**
  28813. * Should the native controller meshes be initialized. (default: true)
  28814. */
  28815. controllerMeshes?: boolean;
  28816. /**
  28817. * Creating a default HemiLight only on controllers. (default: true)
  28818. */
  28819. defaultLightingOnControllers?: boolean;
  28820. /**
  28821. * If you don't want to use the default VR button of the helper. (default: false)
  28822. */
  28823. useCustomVRButton?: boolean;
  28824. /**
  28825. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28826. */
  28827. customVRButton?: HTMLButtonElement;
  28828. /**
  28829. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28830. */
  28831. rayLength?: number;
  28832. /**
  28833. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28834. */
  28835. defaultHeight?: number;
  28836. /**
  28837. * If multiview should be used if availible (default: false)
  28838. */
  28839. useMultiview?: boolean;
  28840. }
  28841. /**
  28842. * This represents a WebVR camera.
  28843. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28844. * @example https://doc.babylonjs.com/how_to/webvr_camera
  28845. */
  28846. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28847. private webVROptions;
  28848. /**
  28849. * @hidden
  28850. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28851. */
  28852. _vrDevice: any;
  28853. /**
  28854. * The rawPose of the vrDevice.
  28855. */
  28856. rawPose: Nullable<DevicePose>;
  28857. private _onVREnabled;
  28858. private _specsVersion;
  28859. private _attached;
  28860. private _frameData;
  28861. protected _descendants: Array<Node>;
  28862. private _deviceRoomPosition;
  28863. /** @hidden */
  28864. _deviceRoomRotationQuaternion: Quaternion;
  28865. private _standingMatrix;
  28866. /**
  28867. * Represents device position in babylon space.
  28868. */
  28869. devicePosition: Vector3;
  28870. /**
  28871. * Represents device rotation in babylon space.
  28872. */
  28873. deviceRotationQuaternion: Quaternion;
  28874. /**
  28875. * The scale of the device to be used when translating from device space to babylon space.
  28876. */
  28877. deviceScaleFactor: number;
  28878. private _deviceToWorld;
  28879. private _worldToDevice;
  28880. /**
  28881. * References to the webVR controllers for the vrDevice.
  28882. */
  28883. controllers: Array<WebVRController>;
  28884. /**
  28885. * Emits an event when a controller is attached.
  28886. */
  28887. onControllersAttachedObservable: Observable<WebVRController[]>;
  28888. /**
  28889. * Emits an event when a controller's mesh has been loaded;
  28890. */
  28891. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28892. /**
  28893. * Emits an event when the HMD's pose has been updated.
  28894. */
  28895. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28896. private _poseSet;
  28897. /**
  28898. * If the rig cameras be used as parent instead of this camera.
  28899. */
  28900. rigParenting: boolean;
  28901. private _lightOnControllers;
  28902. private _defaultHeight?;
  28903. /**
  28904. * Instantiates a WebVRFreeCamera.
  28905. * @param name The name of the WebVRFreeCamera
  28906. * @param position The starting anchor position for the camera
  28907. * @param scene The scene the camera belongs to
  28908. * @param webVROptions a set of customizable options for the webVRCamera
  28909. */
  28910. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28911. /**
  28912. * Gets the device distance from the ground in meters.
  28913. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  28914. */
  28915. deviceDistanceToRoomGround(): number;
  28916. /**
  28917. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28918. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28919. */
  28920. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28921. /**
  28922. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28923. * @returns A promise with a boolean set to if the standing matrix is supported.
  28924. */
  28925. useStandingMatrixAsync(): Promise<boolean>;
  28926. /**
  28927. * Disposes the camera
  28928. */
  28929. dispose(): void;
  28930. /**
  28931. * Gets a vrController by name.
  28932. * @param name The name of the controller to retreive
  28933. * @returns the controller matching the name specified or null if not found
  28934. */
  28935. getControllerByName(name: string): Nullable<WebVRController>;
  28936. private _leftController;
  28937. /**
  28938. * The controller corresponding to the users left hand.
  28939. */
  28940. get leftController(): Nullable<WebVRController>;
  28941. private _rightController;
  28942. /**
  28943. * The controller corresponding to the users right hand.
  28944. */
  28945. get rightController(): Nullable<WebVRController>;
  28946. /**
  28947. * Casts a ray forward from the vrCamera's gaze.
  28948. * @param length Length of the ray (default: 100)
  28949. * @returns the ray corresponding to the gaze
  28950. */
  28951. getForwardRay(length?: number): Ray;
  28952. /**
  28953. * @hidden
  28954. * Updates the camera based on device's frame data
  28955. */
  28956. _checkInputs(): void;
  28957. /**
  28958. * Updates the poseControlled values based on the input device pose.
  28959. * @param poseData Pose coming from the device
  28960. */
  28961. updateFromDevice(poseData: DevicePose): void;
  28962. private _detachIfAttached;
  28963. /**
  28964. * WebVR's attach control will start broadcasting frames to the device.
  28965. * Note that in certain browsers (chrome for example) this function must be called
  28966. * within a user-interaction callback. Example:
  28967. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28968. *
  28969. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28970. */
  28971. attachControl(noPreventDefault?: boolean): void;
  28972. /**
  28973. * Detach the current controls from the specified dom element.
  28974. */
  28975. detachControl(): void;
  28976. /**
  28977. * @returns the name of this class
  28978. */
  28979. getClassName(): string;
  28980. /**
  28981. * Calls resetPose on the vrDisplay
  28982. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28983. */
  28984. resetToCurrentRotation(): void;
  28985. /**
  28986. * @hidden
  28987. * Updates the rig cameras (left and right eye)
  28988. */
  28989. _updateRigCameras(): void;
  28990. private _workingVector;
  28991. private _oneVector;
  28992. private _workingMatrix;
  28993. private updateCacheCalled;
  28994. private _correctPositionIfNotTrackPosition;
  28995. /**
  28996. * @hidden
  28997. * Updates the cached values of the camera
  28998. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28999. */
  29000. _updateCache(ignoreParentClass?: boolean): void;
  29001. /**
  29002. * @hidden
  29003. * Get current device position in babylon world
  29004. */
  29005. _computeDevicePosition(): void;
  29006. /**
  29007. * Updates the current device position and rotation in the babylon world
  29008. */
  29009. update(): void;
  29010. /**
  29011. * @hidden
  29012. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  29013. * @returns an identity matrix
  29014. */
  29015. _getViewMatrix(): Matrix;
  29016. private _tmpMatrix;
  29017. /**
  29018. * This function is called by the two RIG cameras.
  29019. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  29020. * @hidden
  29021. */
  29022. _getWebVRViewMatrix(): Matrix;
  29023. /** @hidden */
  29024. _getWebVRProjectionMatrix(): Matrix;
  29025. private _onGamepadConnectedObserver;
  29026. private _onGamepadDisconnectedObserver;
  29027. private _updateCacheWhenTrackingDisabledObserver;
  29028. /**
  29029. * Initializes the controllers and their meshes
  29030. */
  29031. initControllers(): void;
  29032. }
  29033. }
  29034. declare module "babylonjs/Materials/materialHelper" {
  29035. import { Nullable } from "babylonjs/types";
  29036. import { Scene } from "babylonjs/scene";
  29037. import { Engine } from "babylonjs/Engines/engine";
  29038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29039. import { Light } from "babylonjs/Lights/light";
  29040. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  29041. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29042. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29044. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29045. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  29046. import { Vector4 } from "babylonjs/Maths/math.vector";
  29047. /**
  29048. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  29049. *
  29050. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  29051. *
  29052. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  29053. */
  29054. export class MaterialHelper {
  29055. /**
  29056. * Bind the current view position to an effect.
  29057. * @param effect The effect to be bound
  29058. * @param scene The scene the eyes position is used from
  29059. * @param variableName name of the shader variable that will hold the eye position
  29060. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  29061. * @return the computed eye position
  29062. */
  29063. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  29064. /**
  29065. * Helps preparing the defines values about the UVs in used in the effect.
  29066. * UVs are shared as much as we can accross channels in the shaders.
  29067. * @param texture The texture we are preparing the UVs for
  29068. * @param defines The defines to update
  29069. * @param key The channel key "diffuse", "specular"... used in the shader
  29070. */
  29071. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  29072. /**
  29073. * Binds a texture matrix value to its corrsponding uniform
  29074. * @param texture The texture to bind the matrix for
  29075. * @param uniformBuffer The uniform buffer receivin the data
  29076. * @param key The channel key "diffuse", "specular"... used in the shader
  29077. */
  29078. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  29079. /**
  29080. * Gets the current status of the fog (should it be enabled?)
  29081. * @param mesh defines the mesh to evaluate for fog support
  29082. * @param scene defines the hosting scene
  29083. * @returns true if fog must be enabled
  29084. */
  29085. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  29086. /**
  29087. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  29088. * @param mesh defines the current mesh
  29089. * @param scene defines the current scene
  29090. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  29091. * @param pointsCloud defines if point cloud rendering has to be turned on
  29092. * @param fogEnabled defines if fog has to be turned on
  29093. * @param alphaTest defines if alpha testing has to be turned on
  29094. * @param defines defines the current list of defines
  29095. */
  29096. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  29097. /**
  29098. * Helper used to prepare the list of defines associated with frame values for shader compilation
  29099. * @param scene defines the current scene
  29100. * @param engine defines the current engine
  29101. * @param defines specifies the list of active defines
  29102. * @param useInstances defines if instances have to be turned on
  29103. * @param useClipPlane defines if clip plane have to be turned on
  29104. * @param useInstances defines if instances have to be turned on
  29105. * @param useThinInstances defines if thin instances have to be turned on
  29106. */
  29107. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  29108. /**
  29109. * Prepares the defines for bones
  29110. * @param mesh The mesh containing the geometry data we will draw
  29111. * @param defines The defines to update
  29112. */
  29113. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  29114. /**
  29115. * Prepares the defines for morph targets
  29116. * @param mesh The mesh containing the geometry data we will draw
  29117. * @param defines The defines to update
  29118. */
  29119. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  29120. /**
  29121. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  29122. * @param mesh The mesh containing the geometry data we will draw
  29123. * @param defines The defines to update
  29124. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  29125. * @param useBones Precise whether bones should be used or not (override mesh info)
  29126. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  29127. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  29128. * @returns false if defines are considered not dirty and have not been checked
  29129. */
  29130. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  29131. /**
  29132. * Prepares the defines related to multiview
  29133. * @param scene The scene we are intending to draw
  29134. * @param defines The defines to update
  29135. */
  29136. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  29137. /**
  29138. * Prepares the defines related to the prepass
  29139. * @param scene The scene we are intending to draw
  29140. * @param defines The defines to update
  29141. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  29142. */
  29143. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  29144. /**
  29145. * Prepares the defines related to the light information passed in parameter
  29146. * @param scene The scene we are intending to draw
  29147. * @param mesh The mesh the effect is compiling for
  29148. * @param light The light the effect is compiling for
  29149. * @param lightIndex The index of the light
  29150. * @param defines The defines to update
  29151. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29152. * @param state Defines the current state regarding what is needed (normals, etc...)
  29153. */
  29154. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  29155. needNormals: boolean;
  29156. needRebuild: boolean;
  29157. shadowEnabled: boolean;
  29158. specularEnabled: boolean;
  29159. lightmapMode: boolean;
  29160. }): void;
  29161. /**
  29162. * Prepares the defines related to the light information passed in parameter
  29163. * @param scene The scene we are intending to draw
  29164. * @param mesh The mesh the effect is compiling for
  29165. * @param defines The defines to update
  29166. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29167. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  29168. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  29169. * @returns true if normals will be required for the rest of the effect
  29170. */
  29171. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  29172. /**
  29173. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  29174. * @param lightIndex defines the light index
  29175. * @param uniformsList The uniform list
  29176. * @param samplersList The sampler list
  29177. * @param projectedLightTexture defines if projected texture must be used
  29178. * @param uniformBuffersList defines an optional list of uniform buffers
  29179. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  29180. */
  29181. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  29182. /**
  29183. * Prepares the uniforms and samplers list to be used in the effect
  29184. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  29185. * @param samplersList The sampler list
  29186. * @param defines The defines helping in the list generation
  29187. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  29188. */
  29189. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  29190. /**
  29191. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  29192. * @param defines The defines to update while falling back
  29193. * @param fallbacks The authorized effect fallbacks
  29194. * @param maxSimultaneousLights The maximum number of lights allowed
  29195. * @param rank the current rank of the Effect
  29196. * @returns The newly affected rank
  29197. */
  29198. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  29199. private static _TmpMorphInfluencers;
  29200. /**
  29201. * Prepares the list of attributes required for morph targets according to the effect defines.
  29202. * @param attribs The current list of supported attribs
  29203. * @param mesh The mesh to prepare the morph targets attributes for
  29204. * @param influencers The number of influencers
  29205. */
  29206. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  29207. /**
  29208. * Prepares the list of attributes required for morph targets according to the effect defines.
  29209. * @param attribs The current list of supported attribs
  29210. * @param mesh The mesh to prepare the morph targets attributes for
  29211. * @param defines The current Defines of the effect
  29212. */
  29213. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  29214. /**
  29215. * Prepares the list of attributes required for bones according to the effect defines.
  29216. * @param attribs The current list of supported attribs
  29217. * @param mesh The mesh to prepare the bones attributes for
  29218. * @param defines The current Defines of the effect
  29219. * @param fallbacks The current efffect fallback strategy
  29220. */
  29221. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  29222. /**
  29223. * Check and prepare the list of attributes required for instances according to the effect defines.
  29224. * @param attribs The current list of supported attribs
  29225. * @param defines The current MaterialDefines of the effect
  29226. */
  29227. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  29228. /**
  29229. * Add the list of attributes required for instances to the attribs array.
  29230. * @param attribs The current list of supported attribs
  29231. */
  29232. static PushAttributesForInstances(attribs: string[]): void;
  29233. /**
  29234. * Binds the light information to the effect.
  29235. * @param light The light containing the generator
  29236. * @param effect The effect we are binding the data to
  29237. * @param lightIndex The light index in the effect used to render
  29238. */
  29239. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  29240. /**
  29241. * Binds the lights information from the scene to the effect for the given mesh.
  29242. * @param light Light to bind
  29243. * @param lightIndex Light index
  29244. * @param scene The scene where the light belongs to
  29245. * @param effect The effect we are binding the data to
  29246. * @param useSpecular Defines if specular is supported
  29247. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29248. */
  29249. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  29250. /**
  29251. * Binds the lights information from the scene to the effect for the given mesh.
  29252. * @param scene The scene the lights belongs to
  29253. * @param mesh The mesh we are binding the information to render
  29254. * @param effect The effect we are binding the data to
  29255. * @param defines The generated defines for the effect
  29256. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  29257. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29258. */
  29259. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  29260. private static _tempFogColor;
  29261. /**
  29262. * Binds the fog information from the scene to the effect for the given mesh.
  29263. * @param scene The scene the lights belongs to
  29264. * @param mesh The mesh we are binding the information to render
  29265. * @param effect The effect we are binding the data to
  29266. * @param linearSpace Defines if the fog effect is applied in linear space
  29267. */
  29268. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  29269. /**
  29270. * Binds the bones information from the mesh to the effect.
  29271. * @param mesh The mesh we are binding the information to render
  29272. * @param effect The effect we are binding the data to
  29273. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  29274. */
  29275. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  29276. private static _CopyBonesTransformationMatrices;
  29277. /**
  29278. * Binds the morph targets information from the mesh to the effect.
  29279. * @param abstractMesh The mesh we are binding the information to render
  29280. * @param effect The effect we are binding the data to
  29281. */
  29282. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  29283. /**
  29284. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  29285. * @param defines The generated defines used in the effect
  29286. * @param effect The effect we are binding the data to
  29287. * @param scene The scene we are willing to render with logarithmic scale for
  29288. */
  29289. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  29290. /**
  29291. * Binds the clip plane information from the scene to the effect.
  29292. * @param scene The scene the clip plane information are extracted from
  29293. * @param effect The effect we are binding the data to
  29294. */
  29295. static BindClipPlane(effect: Effect, scene: Scene): void;
  29296. }
  29297. }
  29298. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  29299. /** @hidden */
  29300. export var bayerDitherFunctions: {
  29301. name: string;
  29302. shader: string;
  29303. };
  29304. }
  29305. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  29306. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29307. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  29308. /** @hidden */
  29309. export var shadowMapFragmentDeclaration: {
  29310. name: string;
  29311. shader: string;
  29312. };
  29313. }
  29314. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  29315. /** @hidden */
  29316. export var shadowMapFragment: {
  29317. name: string;
  29318. shader: string;
  29319. };
  29320. }
  29321. declare module "babylonjs/Shaders/shadowMap.fragment" {
  29322. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  29323. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29324. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29325. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  29326. /** @hidden */
  29327. export var shadowMapPixelShader: {
  29328. name: string;
  29329. shader: string;
  29330. };
  29331. }
  29332. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  29333. /** @hidden */
  29334. export var shadowMapVertexDeclaration: {
  29335. name: string;
  29336. shader: string;
  29337. };
  29338. }
  29339. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  29340. /** @hidden */
  29341. export var shadowMapVertexNormalBias: {
  29342. name: string;
  29343. shader: string;
  29344. };
  29345. }
  29346. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  29347. /** @hidden */
  29348. export var shadowMapVertexMetric: {
  29349. name: string;
  29350. shader: string;
  29351. };
  29352. }
  29353. declare module "babylonjs/Shaders/shadowMap.vertex" {
  29354. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29355. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  29356. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  29357. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29358. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  29359. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  29360. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29361. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  29362. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29363. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29364. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  29365. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  29366. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29367. /** @hidden */
  29368. export var shadowMapVertexShader: {
  29369. name: string;
  29370. shader: string;
  29371. };
  29372. }
  29373. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  29374. /** @hidden */
  29375. export var depthBoxBlurPixelShader: {
  29376. name: string;
  29377. shader: string;
  29378. };
  29379. }
  29380. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  29381. /** @hidden */
  29382. export var shadowMapFragmentSoftTransparentShadow: {
  29383. name: string;
  29384. shader: string;
  29385. };
  29386. }
  29387. declare module "babylonjs/Meshes/instancedMesh" {
  29388. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29389. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29390. import { Camera } from "babylonjs/Cameras/camera";
  29391. import { Node } from "babylonjs/node";
  29392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29393. import { Mesh } from "babylonjs/Meshes/mesh";
  29394. import { Material } from "babylonjs/Materials/material";
  29395. import { Skeleton } from "babylonjs/Bones/skeleton";
  29396. import { Light } from "babylonjs/Lights/light";
  29397. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29398. /**
  29399. * Creates an instance based on a source mesh.
  29400. */
  29401. export class InstancedMesh extends AbstractMesh {
  29402. private _sourceMesh;
  29403. private _currentLOD;
  29404. /** @hidden */
  29405. _indexInSourceMeshInstanceArray: number;
  29406. constructor(name: string, source: Mesh);
  29407. /**
  29408. * Returns the string "InstancedMesh".
  29409. */
  29410. getClassName(): string;
  29411. /** Gets the list of lights affecting that mesh */
  29412. get lightSources(): Light[];
  29413. _resyncLightSources(): void;
  29414. _resyncLightSource(light: Light): void;
  29415. _removeLightSource(light: Light, dispose: boolean): void;
  29416. /**
  29417. * If the source mesh receives shadows
  29418. */
  29419. get receiveShadows(): boolean;
  29420. /**
  29421. * The material of the source mesh
  29422. */
  29423. get material(): Nullable<Material>;
  29424. /**
  29425. * Visibility of the source mesh
  29426. */
  29427. get visibility(): number;
  29428. /**
  29429. * Skeleton of the source mesh
  29430. */
  29431. get skeleton(): Nullable<Skeleton>;
  29432. /**
  29433. * Rendering ground id of the source mesh
  29434. */
  29435. get renderingGroupId(): number;
  29436. set renderingGroupId(value: number);
  29437. /**
  29438. * Returns the total number of vertices (integer).
  29439. */
  29440. getTotalVertices(): number;
  29441. /**
  29442. * Returns a positive integer : the total number of indices in this mesh geometry.
  29443. * @returns the numner of indices or zero if the mesh has no geometry.
  29444. */
  29445. getTotalIndices(): number;
  29446. /**
  29447. * The source mesh of the instance
  29448. */
  29449. get sourceMesh(): Mesh;
  29450. /**
  29451. * Creates a new InstancedMesh object from the mesh model.
  29452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29453. * @param name defines the name of the new instance
  29454. * @returns a new InstancedMesh
  29455. */
  29456. createInstance(name: string): InstancedMesh;
  29457. /**
  29458. * Is this node ready to be used/rendered
  29459. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29460. * @return {boolean} is it ready
  29461. */
  29462. isReady(completeCheck?: boolean): boolean;
  29463. /**
  29464. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29465. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  29466. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  29467. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  29468. */
  29469. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  29470. /**
  29471. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29472. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29473. * The `data` are either a numeric array either a Float32Array.
  29474. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  29475. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  29476. * Note that a new underlying VertexBuffer object is created each call.
  29477. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29478. *
  29479. * Possible `kind` values :
  29480. * - VertexBuffer.PositionKind
  29481. * - VertexBuffer.UVKind
  29482. * - VertexBuffer.UV2Kind
  29483. * - VertexBuffer.UV3Kind
  29484. * - VertexBuffer.UV4Kind
  29485. * - VertexBuffer.UV5Kind
  29486. * - VertexBuffer.UV6Kind
  29487. * - VertexBuffer.ColorKind
  29488. * - VertexBuffer.MatricesIndicesKind
  29489. * - VertexBuffer.MatricesIndicesExtraKind
  29490. * - VertexBuffer.MatricesWeightsKind
  29491. * - VertexBuffer.MatricesWeightsExtraKind
  29492. *
  29493. * Returns the Mesh.
  29494. */
  29495. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29496. /**
  29497. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29498. * If the mesh has no geometry, it is simply returned as it is.
  29499. * The `data` are either a numeric array either a Float32Array.
  29500. * No new underlying VertexBuffer object is created.
  29501. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29502. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  29503. *
  29504. * Possible `kind` values :
  29505. * - VertexBuffer.PositionKind
  29506. * - VertexBuffer.UVKind
  29507. * - VertexBuffer.UV2Kind
  29508. * - VertexBuffer.UV3Kind
  29509. * - VertexBuffer.UV4Kind
  29510. * - VertexBuffer.UV5Kind
  29511. * - VertexBuffer.UV6Kind
  29512. * - VertexBuffer.ColorKind
  29513. * - VertexBuffer.MatricesIndicesKind
  29514. * - VertexBuffer.MatricesIndicesExtraKind
  29515. * - VertexBuffer.MatricesWeightsKind
  29516. * - VertexBuffer.MatricesWeightsExtraKind
  29517. *
  29518. * Returns the Mesh.
  29519. */
  29520. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  29521. /**
  29522. * Sets the mesh indices.
  29523. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  29524. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29525. * This method creates a new index buffer each call.
  29526. * Returns the Mesh.
  29527. */
  29528. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  29529. /**
  29530. * Boolean : True if the mesh owns the requested kind of data.
  29531. */
  29532. isVerticesDataPresent(kind: string): boolean;
  29533. /**
  29534. * Returns an array of indices (IndicesArray).
  29535. */
  29536. getIndices(): Nullable<IndicesArray>;
  29537. get _positions(): Nullable<Vector3[]>;
  29538. /**
  29539. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29540. * This means the mesh underlying bounding box and sphere are recomputed.
  29541. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29542. * @returns the current mesh
  29543. */
  29544. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  29545. /** @hidden */
  29546. _preActivate(): InstancedMesh;
  29547. /** @hidden */
  29548. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29549. /** @hidden */
  29550. _postActivate(): void;
  29551. getWorldMatrix(): Matrix;
  29552. get isAnInstance(): boolean;
  29553. /**
  29554. * Returns the current associated LOD AbstractMesh.
  29555. */
  29556. getLOD(camera: Camera): AbstractMesh;
  29557. /** @hidden */
  29558. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29559. /** @hidden */
  29560. _syncSubMeshes(): InstancedMesh;
  29561. /** @hidden */
  29562. _generatePointsArray(): boolean;
  29563. /** @hidden */
  29564. _updateBoundingInfo(): AbstractMesh;
  29565. /**
  29566. * Creates a new InstancedMesh from the current mesh.
  29567. * - name (string) : the cloned mesh name
  29568. * - newParent (optional Node) : the optional Node to parent the clone to.
  29569. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  29570. *
  29571. * Returns the clone.
  29572. */
  29573. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  29574. /**
  29575. * Disposes the InstancedMesh.
  29576. * Returns nothing.
  29577. */
  29578. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29579. }
  29580. module "babylonjs/Meshes/mesh" {
  29581. interface Mesh {
  29582. /**
  29583. * Register a custom buffer that will be instanced
  29584. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29585. * @param kind defines the buffer kind
  29586. * @param stride defines the stride in floats
  29587. */
  29588. registerInstancedBuffer(kind: string, stride: number): void;
  29589. /**
  29590. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  29591. */
  29592. _invalidateInstanceVertexArrayObject(): void;
  29593. /**
  29594. * true to use the edge renderer for all instances of this mesh
  29595. */
  29596. edgesShareWithInstances: boolean;
  29597. /** @hidden */
  29598. _userInstancedBuffersStorage: {
  29599. data: {
  29600. [key: string]: Float32Array;
  29601. };
  29602. sizes: {
  29603. [key: string]: number;
  29604. };
  29605. vertexBuffers: {
  29606. [key: string]: Nullable<VertexBuffer>;
  29607. };
  29608. strides: {
  29609. [key: string]: number;
  29610. };
  29611. vertexArrayObjects?: {
  29612. [key: string]: WebGLVertexArrayObject;
  29613. };
  29614. };
  29615. }
  29616. }
  29617. module "babylonjs/Meshes/abstractMesh" {
  29618. interface AbstractMesh {
  29619. /**
  29620. * Object used to store instanced buffers defined by user
  29621. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29622. */
  29623. instancedBuffers: {
  29624. [key: string]: any;
  29625. };
  29626. }
  29627. }
  29628. }
  29629. declare module "babylonjs/Materials/shaderMaterial" {
  29630. import { Nullable } from "babylonjs/types";
  29631. import { Scene } from "babylonjs/scene";
  29632. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29634. import { Mesh } from "babylonjs/Meshes/mesh";
  29635. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29636. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29637. import { Effect } from "babylonjs/Materials/effect";
  29638. import { Material } from "babylonjs/Materials/material";
  29639. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29640. /**
  29641. * Defines the options associated with the creation of a shader material.
  29642. */
  29643. export interface IShaderMaterialOptions {
  29644. /**
  29645. * Does the material work in alpha blend mode
  29646. */
  29647. needAlphaBlending: boolean;
  29648. /**
  29649. * Does the material work in alpha test mode
  29650. */
  29651. needAlphaTesting: boolean;
  29652. /**
  29653. * The list of attribute names used in the shader
  29654. */
  29655. attributes: string[];
  29656. /**
  29657. * The list of unifrom names used in the shader
  29658. */
  29659. uniforms: string[];
  29660. /**
  29661. * The list of UBO names used in the shader
  29662. */
  29663. uniformBuffers: string[];
  29664. /**
  29665. * The list of sampler names used in the shader
  29666. */
  29667. samplers: string[];
  29668. /**
  29669. * The list of defines used in the shader
  29670. */
  29671. defines: string[];
  29672. }
  29673. /**
  29674. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  29675. *
  29676. * This returned material effects how the mesh will look based on the code in the shaders.
  29677. *
  29678. * @see https://doc.babylonjs.com/how_to/shader_material
  29679. */
  29680. export class ShaderMaterial extends Material {
  29681. private _shaderPath;
  29682. private _options;
  29683. private _textures;
  29684. private _textureArrays;
  29685. private _floats;
  29686. private _ints;
  29687. private _floatsArrays;
  29688. private _colors3;
  29689. private _colors3Arrays;
  29690. private _colors4;
  29691. private _colors4Arrays;
  29692. private _vectors2;
  29693. private _vectors3;
  29694. private _vectors4;
  29695. private _matrices;
  29696. private _matrixArrays;
  29697. private _matrices3x3;
  29698. private _matrices2x2;
  29699. private _vectors2Arrays;
  29700. private _vectors3Arrays;
  29701. private _vectors4Arrays;
  29702. private _cachedWorldViewMatrix;
  29703. private _cachedWorldViewProjectionMatrix;
  29704. private _renderId;
  29705. private _multiview;
  29706. private _cachedDefines;
  29707. /** Define the Url to load snippets */
  29708. static SnippetUrl: string;
  29709. /** Snippet ID if the material was created from the snippet server */
  29710. snippetId: string;
  29711. /**
  29712. * Instantiate a new shader material.
  29713. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  29714. * This returned material effects how the mesh will look based on the code in the shaders.
  29715. * @see https://doc.babylonjs.com/how_to/shader_material
  29716. * @param name Define the name of the material in the scene
  29717. * @param scene Define the scene the material belongs to
  29718. * @param shaderPath Defines the route to the shader code in one of three ways:
  29719. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  29720. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  29721. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  29722. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  29723. * @param options Define the options used to create the shader
  29724. */
  29725. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  29726. /**
  29727. * Gets the shader path used to define the shader code
  29728. * It can be modified to trigger a new compilation
  29729. */
  29730. get shaderPath(): any;
  29731. /**
  29732. * Sets the shader path used to define the shader code
  29733. * It can be modified to trigger a new compilation
  29734. */
  29735. set shaderPath(shaderPath: any);
  29736. /**
  29737. * Gets the options used to compile the shader.
  29738. * They can be modified to trigger a new compilation
  29739. */
  29740. get options(): IShaderMaterialOptions;
  29741. /**
  29742. * Gets the current class name of the material e.g. "ShaderMaterial"
  29743. * Mainly use in serialization.
  29744. * @returns the class name
  29745. */
  29746. getClassName(): string;
  29747. /**
  29748. * Specifies if the material will require alpha blending
  29749. * @returns a boolean specifying if alpha blending is needed
  29750. */
  29751. needAlphaBlending(): boolean;
  29752. /**
  29753. * Specifies if this material should be rendered in alpha test mode
  29754. * @returns a boolean specifying if an alpha test is needed.
  29755. */
  29756. needAlphaTesting(): boolean;
  29757. private _checkUniform;
  29758. /**
  29759. * Set a texture in the shader.
  29760. * @param name Define the name of the uniform samplers as defined in the shader
  29761. * @param texture Define the texture to bind to this sampler
  29762. * @return the material itself allowing "fluent" like uniform updates
  29763. */
  29764. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  29765. /**
  29766. * Set a texture array in the shader.
  29767. * @param name Define the name of the uniform sampler array as defined in the shader
  29768. * @param textures Define the list of textures to bind to this sampler
  29769. * @return the material itself allowing "fluent" like uniform updates
  29770. */
  29771. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  29772. /**
  29773. * Set a float in the shader.
  29774. * @param name Define the name of the uniform as defined in the shader
  29775. * @param value Define the value to give to the uniform
  29776. * @return the material itself allowing "fluent" like uniform updates
  29777. */
  29778. setFloat(name: string, value: number): ShaderMaterial;
  29779. /**
  29780. * Set a int in the shader.
  29781. * @param name Define the name of the uniform as defined in the shader
  29782. * @param value Define the value to give to the uniform
  29783. * @return the material itself allowing "fluent" like uniform updates
  29784. */
  29785. setInt(name: string, value: number): ShaderMaterial;
  29786. /**
  29787. * Set an array of floats in the shader.
  29788. * @param name Define the name of the uniform as defined in the shader
  29789. * @param value Define the value to give to the uniform
  29790. * @return the material itself allowing "fluent" like uniform updates
  29791. */
  29792. setFloats(name: string, value: number[]): ShaderMaterial;
  29793. /**
  29794. * Set a vec3 in the shader from a Color3.
  29795. * @param name Define the name of the uniform as defined in the shader
  29796. * @param value Define the value to give to the uniform
  29797. * @return the material itself allowing "fluent" like uniform updates
  29798. */
  29799. setColor3(name: string, value: Color3): ShaderMaterial;
  29800. /**
  29801. * Set a vec3 array in the shader from a Color3 array.
  29802. * @param name Define the name of the uniform as defined in the shader
  29803. * @param value Define the value to give to the uniform
  29804. * @return the material itself allowing "fluent" like uniform updates
  29805. */
  29806. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  29807. /**
  29808. * Set a vec4 in the shader from a Color4.
  29809. * @param name Define the name of the uniform as defined in the shader
  29810. * @param value Define the value to give to the uniform
  29811. * @return the material itself allowing "fluent" like uniform updates
  29812. */
  29813. setColor4(name: string, value: Color4): ShaderMaterial;
  29814. /**
  29815. * Set a vec4 array in the shader from a Color4 array.
  29816. * @param name Define the name of the uniform as defined in the shader
  29817. * @param value Define the value to give to the uniform
  29818. * @return the material itself allowing "fluent" like uniform updates
  29819. */
  29820. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  29821. /**
  29822. * Set a vec2 in the shader from a Vector2.
  29823. * @param name Define the name of the uniform as defined in the shader
  29824. * @param value Define the value to give to the uniform
  29825. * @return the material itself allowing "fluent" like uniform updates
  29826. */
  29827. setVector2(name: string, value: Vector2): ShaderMaterial;
  29828. /**
  29829. * Set a vec3 in the shader from a Vector3.
  29830. * @param name Define the name of the uniform as defined in the shader
  29831. * @param value Define the value to give to the uniform
  29832. * @return the material itself allowing "fluent" like uniform updates
  29833. */
  29834. setVector3(name: string, value: Vector3): ShaderMaterial;
  29835. /**
  29836. * Set a vec4 in the shader from a Vector4.
  29837. * @param name Define the name of the uniform as defined in the shader
  29838. * @param value Define the value to give to the uniform
  29839. * @return the material itself allowing "fluent" like uniform updates
  29840. */
  29841. setVector4(name: string, value: Vector4): ShaderMaterial;
  29842. /**
  29843. * Set a mat4 in the shader from a Matrix.
  29844. * @param name Define the name of the uniform as defined in the shader
  29845. * @param value Define the value to give to the uniform
  29846. * @return the material itself allowing "fluent" like uniform updates
  29847. */
  29848. setMatrix(name: string, value: Matrix): ShaderMaterial;
  29849. /**
  29850. * Set a float32Array in the shader from a matrix array.
  29851. * @param name Define the name of the uniform as defined in the shader
  29852. * @param value Define the value to give to the uniform
  29853. * @return the material itself allowing "fluent" like uniform updates
  29854. */
  29855. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  29856. /**
  29857. * Set a mat3 in the shader from a Float32Array.
  29858. * @param name Define the name of the uniform as defined in the shader
  29859. * @param value Define the value to give to the uniform
  29860. * @return the material itself allowing "fluent" like uniform updates
  29861. */
  29862. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29863. /**
  29864. * Set a mat2 in the shader from a Float32Array.
  29865. * @param name Define the name of the uniform as defined in the shader
  29866. * @param value Define the value to give to the uniform
  29867. * @return the material itself allowing "fluent" like uniform updates
  29868. */
  29869. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29870. /**
  29871. * Set a vec2 array in the shader from a number array.
  29872. * @param name Define the name of the uniform as defined in the shader
  29873. * @param value Define the value to give to the uniform
  29874. * @return the material itself allowing "fluent" like uniform updates
  29875. */
  29876. setArray2(name: string, value: number[]): ShaderMaterial;
  29877. /**
  29878. * Set a vec3 array in the shader from a number array.
  29879. * @param name Define the name of the uniform as defined in the shader
  29880. * @param value Define the value to give to the uniform
  29881. * @return the material itself allowing "fluent" like uniform updates
  29882. */
  29883. setArray3(name: string, value: number[]): ShaderMaterial;
  29884. /**
  29885. * Set a vec4 array in the shader from a number array.
  29886. * @param name Define the name of the uniform as defined in the shader
  29887. * @param value Define the value to give to the uniform
  29888. * @return the material itself allowing "fluent" like uniform updates
  29889. */
  29890. setArray4(name: string, value: number[]): ShaderMaterial;
  29891. private _checkCache;
  29892. /**
  29893. * Specifies that the submesh is ready to be used
  29894. * @param mesh defines the mesh to check
  29895. * @param subMesh defines which submesh to check
  29896. * @param useInstances specifies that instances should be used
  29897. * @returns a boolean indicating that the submesh is ready or not
  29898. */
  29899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29900. /**
  29901. * Checks if the material is ready to render the requested mesh
  29902. * @param mesh Define the mesh to render
  29903. * @param useInstances Define whether or not the material is used with instances
  29904. * @returns true if ready, otherwise false
  29905. */
  29906. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29907. /**
  29908. * Binds the world matrix to the material
  29909. * @param world defines the world transformation matrix
  29910. * @param effectOverride - If provided, use this effect instead of internal effect
  29911. */
  29912. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29913. /**
  29914. * Binds the submesh to this material by preparing the effect and shader to draw
  29915. * @param world defines the world transformation matrix
  29916. * @param mesh defines the mesh containing the submesh
  29917. * @param subMesh defines the submesh to bind the material to
  29918. */
  29919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29920. /**
  29921. * Binds the material to the mesh
  29922. * @param world defines the world transformation matrix
  29923. * @param mesh defines the mesh to bind the material to
  29924. * @param effectOverride - If provided, use this effect instead of internal effect
  29925. */
  29926. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29927. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29928. /**
  29929. * Gets the active textures from the material
  29930. * @returns an array of textures
  29931. */
  29932. getActiveTextures(): BaseTexture[];
  29933. /**
  29934. * Specifies if the material uses a texture
  29935. * @param texture defines the texture to check against the material
  29936. * @returns a boolean specifying if the material uses the texture
  29937. */
  29938. hasTexture(texture: BaseTexture): boolean;
  29939. /**
  29940. * Makes a duplicate of the material, and gives it a new name
  29941. * @param name defines the new name for the duplicated material
  29942. * @returns the cloned material
  29943. */
  29944. clone(name: string): ShaderMaterial;
  29945. /**
  29946. * Disposes the material
  29947. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29948. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29949. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29950. */
  29951. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29952. /**
  29953. * Serializes this material in a JSON representation
  29954. * @returns the serialized material object
  29955. */
  29956. serialize(): any;
  29957. /**
  29958. * Creates a shader material from parsed shader material data
  29959. * @param source defines the JSON represnetation of the material
  29960. * @param scene defines the hosting scene
  29961. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29962. * @returns a new material
  29963. */
  29964. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29965. /**
  29966. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29967. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29968. * @param url defines the url to load from
  29969. * @param scene defines the hosting scene
  29970. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29971. * @returns a promise that will resolve to the new ShaderMaterial
  29972. */
  29973. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29974. /**
  29975. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29976. * @param snippetId defines the snippet to load
  29977. * @param scene defines the hosting scene
  29978. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29979. * @returns a promise that will resolve to the new ShaderMaterial
  29980. */
  29981. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29982. }
  29983. }
  29984. declare module "babylonjs/Shaders/color.fragment" {
  29985. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29986. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29987. /** @hidden */
  29988. export var colorPixelShader: {
  29989. name: string;
  29990. shader: string;
  29991. };
  29992. }
  29993. declare module "babylonjs/Shaders/color.vertex" {
  29994. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29995. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29996. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29997. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29998. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29999. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30000. /** @hidden */
  30001. export var colorVertexShader: {
  30002. name: string;
  30003. shader: string;
  30004. };
  30005. }
  30006. declare module "babylonjs/Meshes/linesMesh" {
  30007. import { Nullable } from "babylonjs/types";
  30008. import { Scene } from "babylonjs/scene";
  30009. import { Color3 } from "babylonjs/Maths/math.color";
  30010. import { Node } from "babylonjs/node";
  30011. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30012. import { Mesh } from "babylonjs/Meshes/mesh";
  30013. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  30014. import { Effect } from "babylonjs/Materials/effect";
  30015. import { Material } from "babylonjs/Materials/material";
  30016. import "babylonjs/Shaders/color.fragment";
  30017. import "babylonjs/Shaders/color.vertex";
  30018. /**
  30019. * Line mesh
  30020. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  30021. */
  30022. export class LinesMesh extends Mesh {
  30023. /**
  30024. * If vertex color should be applied to the mesh
  30025. */
  30026. readonly useVertexColor?: boolean | undefined;
  30027. /**
  30028. * If vertex alpha should be applied to the mesh
  30029. */
  30030. readonly useVertexAlpha?: boolean | undefined;
  30031. /**
  30032. * Color of the line (Default: White)
  30033. */
  30034. color: Color3;
  30035. /**
  30036. * Alpha of the line (Default: 1)
  30037. */
  30038. alpha: number;
  30039. /**
  30040. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  30041. * This margin is expressed in world space coordinates, so its value may vary.
  30042. * Default value is 0.1
  30043. */
  30044. intersectionThreshold: number;
  30045. private _colorShader;
  30046. private color4;
  30047. /**
  30048. * Creates a new LinesMesh
  30049. * @param name defines the name
  30050. * @param scene defines the hosting scene
  30051. * @param parent defines the parent mesh if any
  30052. * @param source defines the optional source LinesMesh used to clone data from
  30053. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  30054. * When false, achieved by calling a clone(), also passing False.
  30055. * This will make creation of children, recursive.
  30056. * @param useVertexColor defines if this LinesMesh supports vertex color
  30057. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  30058. */
  30059. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  30060. /**
  30061. * If vertex color should be applied to the mesh
  30062. */
  30063. useVertexColor?: boolean | undefined,
  30064. /**
  30065. * If vertex alpha should be applied to the mesh
  30066. */
  30067. useVertexAlpha?: boolean | undefined);
  30068. private _addClipPlaneDefine;
  30069. private _removeClipPlaneDefine;
  30070. isReady(): boolean;
  30071. /**
  30072. * Returns the string "LineMesh"
  30073. */
  30074. getClassName(): string;
  30075. /**
  30076. * @hidden
  30077. */
  30078. get material(): Material;
  30079. /**
  30080. * @hidden
  30081. */
  30082. set material(value: Material);
  30083. /**
  30084. * @hidden
  30085. */
  30086. get checkCollisions(): boolean;
  30087. set checkCollisions(value: boolean);
  30088. /** @hidden */
  30089. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  30090. /** @hidden */
  30091. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  30092. /**
  30093. * Disposes of the line mesh
  30094. * @param doNotRecurse If children should be disposed
  30095. */
  30096. dispose(doNotRecurse?: boolean): void;
  30097. /**
  30098. * Returns a new LineMesh object cloned from the current one.
  30099. */
  30100. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  30101. /**
  30102. * Creates a new InstancedLinesMesh object from the mesh model.
  30103. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30104. * @param name defines the name of the new instance
  30105. * @returns a new InstancedLinesMesh
  30106. */
  30107. createInstance(name: string): InstancedLinesMesh;
  30108. }
  30109. /**
  30110. * Creates an instance based on a source LinesMesh
  30111. */
  30112. export class InstancedLinesMesh extends InstancedMesh {
  30113. /**
  30114. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  30115. * This margin is expressed in world space coordinates, so its value may vary.
  30116. * Initilized with the intersectionThreshold value of the source LinesMesh
  30117. */
  30118. intersectionThreshold: number;
  30119. constructor(name: string, source: LinesMesh);
  30120. /**
  30121. * Returns the string "InstancedLinesMesh".
  30122. */
  30123. getClassName(): string;
  30124. }
  30125. }
  30126. declare module "babylonjs/Shaders/line.fragment" {
  30127. /** @hidden */
  30128. export var linePixelShader: {
  30129. name: string;
  30130. shader: string;
  30131. };
  30132. }
  30133. declare module "babylonjs/Shaders/line.vertex" {
  30134. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30135. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30136. /** @hidden */
  30137. export var lineVertexShader: {
  30138. name: string;
  30139. shader: string;
  30140. };
  30141. }
  30142. declare module "babylonjs/Rendering/edgesRenderer" {
  30143. import { Immutable, Nullable } from "babylonjs/types";
  30144. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30146. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  30147. import { IDisposable } from "babylonjs/scene";
  30148. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  30149. import "babylonjs/Shaders/line.fragment";
  30150. import "babylonjs/Shaders/line.vertex";
  30151. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30152. import { SmartArray } from "babylonjs/Misc/smartArray";
  30153. module "babylonjs/scene" {
  30154. interface Scene {
  30155. /** @hidden */
  30156. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  30157. }
  30158. }
  30159. module "babylonjs/Meshes/abstractMesh" {
  30160. interface AbstractMesh {
  30161. /**
  30162. * Gets the edgesRenderer associated with the mesh
  30163. */
  30164. edgesRenderer: Nullable<EdgesRenderer>;
  30165. }
  30166. }
  30167. module "babylonjs/Meshes/linesMesh" {
  30168. interface LinesMesh {
  30169. /**
  30170. * Enables the edge rendering mode on the mesh.
  30171. * This mode makes the mesh edges visible
  30172. * @param epsilon defines the maximal distance between two angles to detect a face
  30173. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30174. * @returns the currentAbstractMesh
  30175. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30176. */
  30177. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30178. }
  30179. }
  30180. module "babylonjs/Meshes/linesMesh" {
  30181. interface InstancedLinesMesh {
  30182. /**
  30183. * Enables the edge rendering mode on the mesh.
  30184. * This mode makes the mesh edges visible
  30185. * @param epsilon defines the maximal distance between two angles to detect a face
  30186. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30187. * @returns the current InstancedLinesMesh
  30188. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30189. */
  30190. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  30191. }
  30192. }
  30193. /**
  30194. * Defines the minimum contract an Edges renderer should follow.
  30195. */
  30196. export interface IEdgesRenderer extends IDisposable {
  30197. /**
  30198. * Gets or sets a boolean indicating if the edgesRenderer is active
  30199. */
  30200. isEnabled: boolean;
  30201. /**
  30202. * Renders the edges of the attached mesh,
  30203. */
  30204. render(): void;
  30205. /**
  30206. * Checks wether or not the edges renderer is ready to render.
  30207. * @return true if ready, otherwise false.
  30208. */
  30209. isReady(): boolean;
  30210. /**
  30211. * List of instances to render in case the source mesh has instances
  30212. */
  30213. customInstances: SmartArray<Matrix>;
  30214. }
  30215. /**
  30216. * Defines the additional options of the edges renderer
  30217. */
  30218. export interface IEdgesRendererOptions {
  30219. /**
  30220. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  30221. * If not defined, the default value is true
  30222. */
  30223. useAlternateEdgeFinder?: boolean;
  30224. /**
  30225. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  30226. * If not defined, the default value is true.
  30227. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  30228. * This option is used only if useAlternateEdgeFinder = true
  30229. */
  30230. useFastVertexMerger?: boolean;
  30231. /**
  30232. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  30233. * The default value is 1e-6
  30234. * This option is used only if useAlternateEdgeFinder = true
  30235. */
  30236. epsilonVertexMerge?: number;
  30237. /**
  30238. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  30239. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  30240. * This option is used only if useAlternateEdgeFinder = true
  30241. */
  30242. applyTessellation?: boolean;
  30243. /**
  30244. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  30245. * The default value is 1e-6
  30246. * This option is used only if useAlternateEdgeFinder = true
  30247. */
  30248. epsilonVertexAligned?: number;
  30249. }
  30250. /**
  30251. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  30252. */
  30253. export class EdgesRenderer implements IEdgesRenderer {
  30254. /**
  30255. * Define the size of the edges with an orthographic camera
  30256. */
  30257. edgesWidthScalerForOrthographic: number;
  30258. /**
  30259. * Define the size of the edges with a perspective camera
  30260. */
  30261. edgesWidthScalerForPerspective: number;
  30262. protected _source: AbstractMesh;
  30263. protected _linesPositions: number[];
  30264. protected _linesNormals: number[];
  30265. protected _linesIndices: number[];
  30266. protected _epsilon: number;
  30267. protected _indicesCount: number;
  30268. protected _lineShader: ShaderMaterial;
  30269. protected _ib: DataBuffer;
  30270. protected _buffers: {
  30271. [key: string]: Nullable<VertexBuffer>;
  30272. };
  30273. protected _buffersForInstances: {
  30274. [key: string]: Nullable<VertexBuffer>;
  30275. };
  30276. protected _checkVerticesInsteadOfIndices: boolean;
  30277. protected _options: Nullable<IEdgesRendererOptions>;
  30278. private _meshRebuildObserver;
  30279. private _meshDisposeObserver;
  30280. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  30281. isEnabled: boolean;
  30282. /** Gets the vertices generated by the edge renderer */
  30283. get linesPositions(): Immutable<Array<number>>;
  30284. /** Gets the normals generated by the edge renderer */
  30285. get linesNormals(): Immutable<Array<number>>;
  30286. /** Gets the indices generated by the edge renderer */
  30287. get linesIndices(): Immutable<Array<number>>;
  30288. /**
  30289. * List of instances to render in case the source mesh has instances
  30290. */
  30291. customInstances: SmartArray<Matrix>;
  30292. private static GetShader;
  30293. /**
  30294. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  30295. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  30296. * @param source Mesh used to create edges
  30297. * @param epsilon sum of angles in adjacency to check for edge
  30298. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  30299. * @param generateEdgesLines - should generate Lines or only prepare resources.
  30300. * @param options The options to apply when generating the edges
  30301. */
  30302. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  30303. protected _prepareRessources(): void;
  30304. /** @hidden */
  30305. _rebuild(): void;
  30306. /**
  30307. * Releases the required resources for the edges renderer
  30308. */
  30309. dispose(): void;
  30310. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  30311. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  30312. /**
  30313. * Checks if the pair of p0 and p1 is en edge
  30314. * @param faceIndex
  30315. * @param edge
  30316. * @param faceNormals
  30317. * @param p0
  30318. * @param p1
  30319. * @private
  30320. */
  30321. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  30322. /**
  30323. * push line into the position, normal and index buffer
  30324. * @protected
  30325. */
  30326. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  30327. /**
  30328. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  30329. */
  30330. private _tessellateTriangle;
  30331. private _generateEdgesLinesAlternate;
  30332. /**
  30333. * Generates lines edges from adjacencjes
  30334. * @private
  30335. */
  30336. _generateEdgesLines(): void;
  30337. /**
  30338. * Checks wether or not the edges renderer is ready to render.
  30339. * @return true if ready, otherwise false.
  30340. */
  30341. isReady(): boolean;
  30342. /**
  30343. * Renders the edges of the attached mesh,
  30344. */
  30345. render(): void;
  30346. }
  30347. /**
  30348. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  30349. */
  30350. export class LineEdgesRenderer extends EdgesRenderer {
  30351. /**
  30352. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  30353. * @param source LineMesh used to generate edges
  30354. * @param epsilon not important (specified angle for edge detection)
  30355. * @param checkVerticesInsteadOfIndices not important for LineMesh
  30356. */
  30357. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  30358. /**
  30359. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  30360. */
  30361. _generateEdgesLines(): void;
  30362. }
  30363. }
  30364. declare module "babylonjs/Rendering/renderingGroup" {
  30365. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  30366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30368. import { Nullable } from "babylonjs/types";
  30369. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30370. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  30371. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30372. import { Material } from "babylonjs/Materials/material";
  30373. import { Scene } from "babylonjs/scene";
  30374. /**
  30375. * This represents the object necessary to create a rendering group.
  30376. * This is exclusively used and created by the rendering manager.
  30377. * To modify the behavior, you use the available helpers in your scene or meshes.
  30378. * @hidden
  30379. */
  30380. export class RenderingGroup {
  30381. index: number;
  30382. private static _zeroVector;
  30383. private _scene;
  30384. private _opaqueSubMeshes;
  30385. private _transparentSubMeshes;
  30386. private _alphaTestSubMeshes;
  30387. private _depthOnlySubMeshes;
  30388. private _particleSystems;
  30389. private _spriteManagers;
  30390. private _opaqueSortCompareFn;
  30391. private _alphaTestSortCompareFn;
  30392. private _transparentSortCompareFn;
  30393. private _renderOpaque;
  30394. private _renderAlphaTest;
  30395. private _renderTransparent;
  30396. /** @hidden */
  30397. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  30398. onBeforeTransparentRendering: () => void;
  30399. /**
  30400. * Set the opaque sort comparison function.
  30401. * If null the sub meshes will be render in the order they were created
  30402. */
  30403. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30404. /**
  30405. * Set the alpha test sort comparison function.
  30406. * If null the sub meshes will be render in the order they were created
  30407. */
  30408. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30409. /**
  30410. * Set the transparent sort comparison function.
  30411. * If null the sub meshes will be render in the order they were created
  30412. */
  30413. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30414. /**
  30415. * Creates a new rendering group.
  30416. * @param index The rendering group index
  30417. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  30418. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  30419. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  30420. */
  30421. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30422. /**
  30423. * Render all the sub meshes contained in the group.
  30424. * @param customRenderFunction Used to override the default render behaviour of the group.
  30425. * @returns true if rendered some submeshes.
  30426. */
  30427. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  30428. /**
  30429. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  30430. * @param subMeshes The submeshes to render
  30431. */
  30432. private renderOpaqueSorted;
  30433. /**
  30434. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  30435. * @param subMeshes The submeshes to render
  30436. */
  30437. private renderAlphaTestSorted;
  30438. /**
  30439. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  30440. * @param subMeshes The submeshes to render
  30441. */
  30442. private renderTransparentSorted;
  30443. /**
  30444. * Renders the submeshes in a specified order.
  30445. * @param subMeshes The submeshes to sort before render
  30446. * @param sortCompareFn The comparison function use to sort
  30447. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  30448. * @param transparent Specifies to activate blending if true
  30449. */
  30450. private static renderSorted;
  30451. /**
  30452. * Renders the submeshes in the order they were dispatched (no sort applied).
  30453. * @param subMeshes The submeshes to render
  30454. */
  30455. private static renderUnsorted;
  30456. /**
  30457. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30458. * are rendered back to front if in the same alpha index.
  30459. *
  30460. * @param a The first submesh
  30461. * @param b The second submesh
  30462. * @returns The result of the comparison
  30463. */
  30464. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  30465. /**
  30466. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30467. * are rendered back to front.
  30468. *
  30469. * @param a The first submesh
  30470. * @param b The second submesh
  30471. * @returns The result of the comparison
  30472. */
  30473. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  30474. /**
  30475. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30476. * are rendered front to back (prevent overdraw).
  30477. *
  30478. * @param a The first submesh
  30479. * @param b The second submesh
  30480. * @returns The result of the comparison
  30481. */
  30482. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  30483. /**
  30484. * Resets the different lists of submeshes to prepare a new frame.
  30485. */
  30486. prepare(): void;
  30487. dispose(): void;
  30488. /**
  30489. * Inserts the submesh in its correct queue depending on its material.
  30490. * @param subMesh The submesh to dispatch
  30491. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30492. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30493. */
  30494. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30495. dispatchSprites(spriteManager: ISpriteManager): void;
  30496. dispatchParticles(particleSystem: IParticleSystem): void;
  30497. private _renderParticles;
  30498. private _renderSprites;
  30499. }
  30500. }
  30501. declare module "babylonjs/Rendering/renderingManager" {
  30502. import { Nullable } from "babylonjs/types";
  30503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30504. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30505. import { SmartArray } from "babylonjs/Misc/smartArray";
  30506. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30507. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30508. import { Material } from "babylonjs/Materials/material";
  30509. import { Scene } from "babylonjs/scene";
  30510. import { Camera } from "babylonjs/Cameras/camera";
  30511. /**
  30512. * Interface describing the different options available in the rendering manager
  30513. * regarding Auto Clear between groups.
  30514. */
  30515. export interface IRenderingManagerAutoClearSetup {
  30516. /**
  30517. * Defines whether or not autoclear is enable.
  30518. */
  30519. autoClear: boolean;
  30520. /**
  30521. * Defines whether or not to autoclear the depth buffer.
  30522. */
  30523. depth: boolean;
  30524. /**
  30525. * Defines whether or not to autoclear the stencil buffer.
  30526. */
  30527. stencil: boolean;
  30528. }
  30529. /**
  30530. * This class is used by the onRenderingGroupObservable
  30531. */
  30532. export class RenderingGroupInfo {
  30533. /**
  30534. * The Scene that being rendered
  30535. */
  30536. scene: Scene;
  30537. /**
  30538. * The camera currently used for the rendering pass
  30539. */
  30540. camera: Nullable<Camera>;
  30541. /**
  30542. * The ID of the renderingGroup being processed
  30543. */
  30544. renderingGroupId: number;
  30545. }
  30546. /**
  30547. * This is the manager responsible of all the rendering for meshes sprites and particles.
  30548. * It is enable to manage the different groups as well as the different necessary sort functions.
  30549. * This should not be used directly aside of the few static configurations
  30550. */
  30551. export class RenderingManager {
  30552. /**
  30553. * The max id used for rendering groups (not included)
  30554. */
  30555. static MAX_RENDERINGGROUPS: number;
  30556. /**
  30557. * The min id used for rendering groups (included)
  30558. */
  30559. static MIN_RENDERINGGROUPS: number;
  30560. /**
  30561. * Used to globally prevent autoclearing scenes.
  30562. */
  30563. static AUTOCLEAR: boolean;
  30564. /**
  30565. * @hidden
  30566. */
  30567. _useSceneAutoClearSetup: boolean;
  30568. private _scene;
  30569. private _renderingGroups;
  30570. private _depthStencilBufferAlreadyCleaned;
  30571. private _autoClearDepthStencil;
  30572. private _customOpaqueSortCompareFn;
  30573. private _customAlphaTestSortCompareFn;
  30574. private _customTransparentSortCompareFn;
  30575. private _renderingGroupInfo;
  30576. /**
  30577. * Instantiates a new rendering group for a particular scene
  30578. * @param scene Defines the scene the groups belongs to
  30579. */
  30580. constructor(scene: Scene);
  30581. private _clearDepthStencilBuffer;
  30582. /**
  30583. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  30584. * @hidden
  30585. */
  30586. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  30587. /**
  30588. * Resets the different information of the group to prepare a new frame
  30589. * @hidden
  30590. */
  30591. reset(): void;
  30592. /**
  30593. * Dispose and release the group and its associated resources.
  30594. * @hidden
  30595. */
  30596. dispose(): void;
  30597. /**
  30598. * Clear the info related to rendering groups preventing retention points during dispose.
  30599. */
  30600. freeRenderingGroups(): void;
  30601. private _prepareRenderingGroup;
  30602. /**
  30603. * Add a sprite manager to the rendering manager in order to render it this frame.
  30604. * @param spriteManager Define the sprite manager to render
  30605. */
  30606. dispatchSprites(spriteManager: ISpriteManager): void;
  30607. /**
  30608. * Add a particle system to the rendering manager in order to render it this frame.
  30609. * @param particleSystem Define the particle system to render
  30610. */
  30611. dispatchParticles(particleSystem: IParticleSystem): void;
  30612. /**
  30613. * Add a submesh to the manager in order to render it this frame
  30614. * @param subMesh The submesh to dispatch
  30615. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30616. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30617. */
  30618. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30619. /**
  30620. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30621. * This allowed control for front to back rendering or reversly depending of the special needs.
  30622. *
  30623. * @param renderingGroupId The rendering group id corresponding to its index
  30624. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30625. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30626. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30627. */
  30628. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  30629. /**
  30630. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30631. *
  30632. * @param renderingGroupId The rendering group id corresponding to its index
  30633. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30634. * @param depth Automatically clears depth between groups if true and autoClear is true.
  30635. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  30636. */
  30637. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  30638. /**
  30639. * Gets the current auto clear configuration for one rendering group of the rendering
  30640. * manager.
  30641. * @param index the rendering group index to get the information for
  30642. * @returns The auto clear setup for the requested rendering group
  30643. */
  30644. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  30645. }
  30646. }
  30647. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  30648. import { SmartArray } from "babylonjs/Misc/smartArray";
  30649. import { Nullable } from "babylonjs/types";
  30650. import { Scene } from "babylonjs/scene";
  30651. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30654. import { Mesh } from "babylonjs/Meshes/mesh";
  30655. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  30656. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30657. import { Effect } from "babylonjs/Materials/effect";
  30658. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30659. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30660. import "babylonjs/Shaders/shadowMap.fragment";
  30661. import "babylonjs/Shaders/shadowMap.vertex";
  30662. import "babylonjs/Shaders/depthBoxBlur.fragment";
  30663. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  30664. import { Observable } from "babylonjs/Misc/observable";
  30665. /**
  30666. * Defines the options associated with the creation of a custom shader for a shadow generator.
  30667. */
  30668. export interface ICustomShaderOptions {
  30669. /**
  30670. * Gets or sets the custom shader name to use
  30671. */
  30672. shaderName: string;
  30673. /**
  30674. * The list of attribute names used in the shader
  30675. */
  30676. attributes?: string[];
  30677. /**
  30678. * The list of unifrom names used in the shader
  30679. */
  30680. uniforms?: string[];
  30681. /**
  30682. * The list of sampler names used in the shader
  30683. */
  30684. samplers?: string[];
  30685. /**
  30686. * The list of defines used in the shader
  30687. */
  30688. defines?: string[];
  30689. }
  30690. /**
  30691. * Interface to implement to create a shadow generator compatible with BJS.
  30692. */
  30693. export interface IShadowGenerator {
  30694. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30695. id: string;
  30696. /**
  30697. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30698. * @returns The render target texture if present otherwise, null
  30699. */
  30700. getShadowMap(): Nullable<RenderTargetTexture>;
  30701. /**
  30702. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30703. * @param subMesh The submesh we want to render in the shadow map
  30704. * @param useInstances Defines wether will draw in the map using instances
  30705. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30706. * @returns true if ready otherwise, false
  30707. */
  30708. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30709. /**
  30710. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30711. * @param defines Defines of the material we want to update
  30712. * @param lightIndex Index of the light in the enabled light list of the material
  30713. */
  30714. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30715. /**
  30716. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30717. * defined in the generator but impacting the effect).
  30718. * It implies the unifroms available on the materials are the standard BJS ones.
  30719. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30720. * @param effect The effect we are binfing the information for
  30721. */
  30722. bindShadowLight(lightIndex: string, effect: Effect): void;
  30723. /**
  30724. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30725. * (eq to shadow prjection matrix * light transform matrix)
  30726. * @returns The transform matrix used to create the shadow map
  30727. */
  30728. getTransformMatrix(): Matrix;
  30729. /**
  30730. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30731. * Cube and 2D textures for instance.
  30732. */
  30733. recreateShadowMap(): void;
  30734. /**
  30735. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30736. * @param onCompiled Callback triggered at the and of the effects compilation
  30737. * @param options Sets of optional options forcing the compilation with different modes
  30738. */
  30739. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30740. useInstances: boolean;
  30741. }>): void;
  30742. /**
  30743. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30744. * @param options Sets of optional options forcing the compilation with different modes
  30745. * @returns A promise that resolves when the compilation completes
  30746. */
  30747. forceCompilationAsync(options?: Partial<{
  30748. useInstances: boolean;
  30749. }>): Promise<void>;
  30750. /**
  30751. * Serializes the shadow generator setup to a json object.
  30752. * @returns The serialized JSON object
  30753. */
  30754. serialize(): any;
  30755. /**
  30756. * Disposes the Shadow map and related Textures and effects.
  30757. */
  30758. dispose(): void;
  30759. }
  30760. /**
  30761. * Default implementation IShadowGenerator.
  30762. * This is the main object responsible of generating shadows in the framework.
  30763. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30764. */
  30765. export class ShadowGenerator implements IShadowGenerator {
  30766. private static _Counter;
  30767. /**
  30768. * Name of the shadow generator class
  30769. */
  30770. static CLASSNAME: string;
  30771. /**
  30772. * Shadow generator mode None: no filtering applied.
  30773. */
  30774. static readonly FILTER_NONE: number;
  30775. /**
  30776. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30777. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30778. */
  30779. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30780. /**
  30781. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30782. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30783. */
  30784. static readonly FILTER_POISSONSAMPLING: number;
  30785. /**
  30786. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30788. */
  30789. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30790. /**
  30791. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30792. * edge artifacts on steep falloff.
  30793. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30794. */
  30795. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30796. /**
  30797. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30798. * edge artifacts on steep falloff.
  30799. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30800. */
  30801. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30802. /**
  30803. * Shadow generator mode PCF: Percentage Closer Filtering
  30804. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30805. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30806. */
  30807. static readonly FILTER_PCF: number;
  30808. /**
  30809. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30810. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30811. * Contact Hardening
  30812. */
  30813. static readonly FILTER_PCSS: number;
  30814. /**
  30815. * Reserved for PCF and PCSS
  30816. * Highest Quality.
  30817. *
  30818. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30819. *
  30820. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30821. */
  30822. static readonly QUALITY_HIGH: number;
  30823. /**
  30824. * Reserved for PCF and PCSS
  30825. * Good tradeoff for quality/perf cross devices
  30826. *
  30827. * Execute PCF on a 3*3 kernel.
  30828. *
  30829. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30830. */
  30831. static readonly QUALITY_MEDIUM: number;
  30832. /**
  30833. * Reserved for PCF and PCSS
  30834. * The lowest quality but the fastest.
  30835. *
  30836. * Execute PCF on a 1*1 kernel.
  30837. *
  30838. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30839. */
  30840. static readonly QUALITY_LOW: number;
  30841. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30842. id: string;
  30843. /** Gets or sets the custom shader name to use */
  30844. customShaderOptions: ICustomShaderOptions;
  30845. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  30846. customAllowRendering: (subMesh: SubMesh) => boolean;
  30847. /**
  30848. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  30849. */
  30850. onBeforeShadowMapRenderObservable: Observable<Effect>;
  30851. /**
  30852. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  30853. */
  30854. onAfterShadowMapRenderObservable: Observable<Effect>;
  30855. /**
  30856. * Observable triggered before a mesh is rendered in the shadow map.
  30857. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  30858. */
  30859. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  30860. /**
  30861. * Observable triggered after a mesh is rendered in the shadow map.
  30862. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30863. */
  30864. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30865. protected _bias: number;
  30866. /**
  30867. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30868. */
  30869. get bias(): number;
  30870. /**
  30871. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30872. */
  30873. set bias(bias: number);
  30874. protected _normalBias: number;
  30875. /**
  30876. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30877. */
  30878. get normalBias(): number;
  30879. /**
  30880. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30881. */
  30882. set normalBias(normalBias: number);
  30883. protected _blurBoxOffset: number;
  30884. /**
  30885. * Gets the blur box offset: offset applied during the blur pass.
  30886. * Only useful if useKernelBlur = false
  30887. */
  30888. get blurBoxOffset(): number;
  30889. /**
  30890. * Sets the blur box offset: offset applied during the blur pass.
  30891. * Only useful if useKernelBlur = false
  30892. */
  30893. set blurBoxOffset(value: number);
  30894. protected _blurScale: number;
  30895. /**
  30896. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30897. * 2 means half of the size.
  30898. */
  30899. get blurScale(): number;
  30900. /**
  30901. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30902. * 2 means half of the size.
  30903. */
  30904. set blurScale(value: number);
  30905. protected _blurKernel: number;
  30906. /**
  30907. * Gets the blur kernel: kernel size of the blur pass.
  30908. * Only useful if useKernelBlur = true
  30909. */
  30910. get blurKernel(): number;
  30911. /**
  30912. * Sets the blur kernel: kernel size of the blur pass.
  30913. * Only useful if useKernelBlur = true
  30914. */
  30915. set blurKernel(value: number);
  30916. protected _useKernelBlur: boolean;
  30917. /**
  30918. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30919. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30920. */
  30921. get useKernelBlur(): boolean;
  30922. /**
  30923. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30924. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30925. */
  30926. set useKernelBlur(value: boolean);
  30927. protected _depthScale: number;
  30928. /**
  30929. * Gets the depth scale used in ESM mode.
  30930. */
  30931. get depthScale(): number;
  30932. /**
  30933. * Sets the depth scale used in ESM mode.
  30934. * This can override the scale stored on the light.
  30935. */
  30936. set depthScale(value: number);
  30937. protected _validateFilter(filter: number): number;
  30938. protected _filter: number;
  30939. /**
  30940. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30941. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30942. */
  30943. get filter(): number;
  30944. /**
  30945. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30946. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30947. */
  30948. set filter(value: number);
  30949. /**
  30950. * Gets if the current filter is set to Poisson Sampling.
  30951. */
  30952. get usePoissonSampling(): boolean;
  30953. /**
  30954. * Sets the current filter to Poisson Sampling.
  30955. */
  30956. set usePoissonSampling(value: boolean);
  30957. /**
  30958. * Gets if the current filter is set to ESM.
  30959. */
  30960. get useExponentialShadowMap(): boolean;
  30961. /**
  30962. * Sets the current filter is to ESM.
  30963. */
  30964. set useExponentialShadowMap(value: boolean);
  30965. /**
  30966. * Gets if the current filter is set to filtered ESM.
  30967. */
  30968. get useBlurExponentialShadowMap(): boolean;
  30969. /**
  30970. * Gets if the current filter is set to filtered ESM.
  30971. */
  30972. set useBlurExponentialShadowMap(value: boolean);
  30973. /**
  30974. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30975. * exponential to prevent steep falloff artifacts).
  30976. */
  30977. get useCloseExponentialShadowMap(): boolean;
  30978. /**
  30979. * Sets the current filter to "close ESM" (using the inverse of the
  30980. * exponential to prevent steep falloff artifacts).
  30981. */
  30982. set useCloseExponentialShadowMap(value: boolean);
  30983. /**
  30984. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30985. * exponential to prevent steep falloff artifacts).
  30986. */
  30987. get useBlurCloseExponentialShadowMap(): boolean;
  30988. /**
  30989. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30990. * exponential to prevent steep falloff artifacts).
  30991. */
  30992. set useBlurCloseExponentialShadowMap(value: boolean);
  30993. /**
  30994. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30995. */
  30996. get usePercentageCloserFiltering(): boolean;
  30997. /**
  30998. * Sets the current filter to "PCF" (percentage closer filtering).
  30999. */
  31000. set usePercentageCloserFiltering(value: boolean);
  31001. protected _filteringQuality: number;
  31002. /**
  31003. * Gets the PCF or PCSS Quality.
  31004. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31005. */
  31006. get filteringQuality(): number;
  31007. /**
  31008. * Sets the PCF or PCSS Quality.
  31009. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31010. */
  31011. set filteringQuality(filteringQuality: number);
  31012. /**
  31013. * Gets if the current filter is set to "PCSS" (contact hardening).
  31014. */
  31015. get useContactHardeningShadow(): boolean;
  31016. /**
  31017. * Sets the current filter to "PCSS" (contact hardening).
  31018. */
  31019. set useContactHardeningShadow(value: boolean);
  31020. protected _contactHardeningLightSizeUVRatio: number;
  31021. /**
  31022. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31023. * Using a ratio helps keeping shape stability independently of the map size.
  31024. *
  31025. * It does not account for the light projection as it was having too much
  31026. * instability during the light setup or during light position changes.
  31027. *
  31028. * Only valid if useContactHardeningShadow is true.
  31029. */
  31030. get contactHardeningLightSizeUVRatio(): number;
  31031. /**
  31032. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31033. * Using a ratio helps keeping shape stability independently of the map size.
  31034. *
  31035. * It does not account for the light projection as it was having too much
  31036. * instability during the light setup or during light position changes.
  31037. *
  31038. * Only valid if useContactHardeningShadow is true.
  31039. */
  31040. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  31041. protected _darkness: number;
  31042. /** Gets or sets the actual darkness of a shadow */
  31043. get darkness(): number;
  31044. set darkness(value: number);
  31045. /**
  31046. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31047. * 0 means strongest and 1 would means no shadow.
  31048. * @returns the darkness.
  31049. */
  31050. getDarkness(): number;
  31051. /**
  31052. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31053. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31054. * @returns the shadow generator allowing fluent coding.
  31055. */
  31056. setDarkness(darkness: number): ShadowGenerator;
  31057. protected _transparencyShadow: boolean;
  31058. /** Gets or sets the ability to have transparent shadow */
  31059. get transparencyShadow(): boolean;
  31060. set transparencyShadow(value: boolean);
  31061. /**
  31062. * Sets the ability to have transparent shadow (boolean).
  31063. * @param transparent True if transparent else False
  31064. * @returns the shadow generator allowing fluent coding
  31065. */
  31066. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31067. /**
  31068. * Enables or disables shadows with varying strength based on the transparency
  31069. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  31070. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  31071. * mesh.visibility * alphaTexture.a
  31072. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  31073. */
  31074. enableSoftTransparentShadow: boolean;
  31075. protected _shadowMap: Nullable<RenderTargetTexture>;
  31076. protected _shadowMap2: Nullable<RenderTargetTexture>;
  31077. /**
  31078. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31079. * @returns The render target texture if present otherwise, null
  31080. */
  31081. getShadowMap(): Nullable<RenderTargetTexture>;
  31082. /**
  31083. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31084. * @returns The render target texture if the shadow map is present otherwise, null
  31085. */
  31086. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31087. /**
  31088. * Gets the class name of that object
  31089. * @returns "ShadowGenerator"
  31090. */
  31091. getClassName(): string;
  31092. /**
  31093. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31094. * @param mesh Mesh to add
  31095. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31096. * @returns the Shadow Generator itself
  31097. */
  31098. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31099. /**
  31100. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31101. * @param mesh Mesh to remove
  31102. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31103. * @returns the Shadow Generator itself
  31104. */
  31105. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31106. /**
  31107. * Controls the extent to which the shadows fade out at the edge of the frustum
  31108. */
  31109. frustumEdgeFalloff: number;
  31110. protected _light: IShadowLight;
  31111. /**
  31112. * Returns the associated light object.
  31113. * @returns the light generating the shadow
  31114. */
  31115. getLight(): IShadowLight;
  31116. /**
  31117. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31118. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31119. * It might on the other hand introduce peter panning.
  31120. */
  31121. forceBackFacesOnly: boolean;
  31122. protected _scene: Scene;
  31123. protected _lightDirection: Vector3;
  31124. protected _viewMatrix: Matrix;
  31125. protected _projectionMatrix: Matrix;
  31126. protected _transformMatrix: Matrix;
  31127. protected _cachedPosition: Vector3;
  31128. protected _cachedDirection: Vector3;
  31129. protected _cachedDefines: string;
  31130. protected _currentRenderID: number;
  31131. protected _boxBlurPostprocess: Nullable<PostProcess>;
  31132. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  31133. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  31134. protected _blurPostProcesses: PostProcess[];
  31135. protected _mapSize: number;
  31136. protected _currentFaceIndex: number;
  31137. protected _currentFaceIndexCache: number;
  31138. protected _textureType: number;
  31139. protected _defaultTextureMatrix: Matrix;
  31140. protected _storedUniqueId: Nullable<number>;
  31141. protected _nameForCustomEffect: string;
  31142. /** @hidden */
  31143. static _SceneComponentInitialization: (scene: Scene) => void;
  31144. /**
  31145. * Gets or sets the size of the texture what stores the shadows
  31146. */
  31147. get mapSize(): number;
  31148. set mapSize(size: number);
  31149. /**
  31150. * Creates a ShadowGenerator object.
  31151. * A ShadowGenerator is the required tool to use the shadows.
  31152. * Each light casting shadows needs to use its own ShadowGenerator.
  31153. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  31154. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31155. * @param light The light object generating the shadows.
  31156. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  31157. */
  31158. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  31159. protected _initializeGenerator(): void;
  31160. protected _createTargetRenderTexture(): void;
  31161. protected _initializeShadowMap(): void;
  31162. protected _initializeBlurRTTAndPostProcesses(): void;
  31163. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  31164. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  31165. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  31166. protected _applyFilterValues(): void;
  31167. /**
  31168. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31169. * @param onCompiled Callback triggered at the and of the effects compilation
  31170. * @param options Sets of optional options forcing the compilation with different modes
  31171. */
  31172. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  31173. useInstances: boolean;
  31174. }>): void;
  31175. /**
  31176. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31177. * @param options Sets of optional options forcing the compilation with different modes
  31178. * @returns A promise that resolves when the compilation completes
  31179. */
  31180. forceCompilationAsync(options?: Partial<{
  31181. useInstances: boolean;
  31182. }>): Promise<void>;
  31183. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  31184. private _prepareShadowDefines;
  31185. /**
  31186. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31187. * @param subMesh The submesh we want to render in the shadow map
  31188. * @param useInstances Defines wether will draw in the map using instances
  31189. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  31190. * @returns true if ready otherwise, false
  31191. */
  31192. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  31193. /**
  31194. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31195. * @param defines Defines of the material we want to update
  31196. * @param lightIndex Index of the light in the enabled light list of the material
  31197. */
  31198. prepareDefines(defines: any, lightIndex: number): void;
  31199. /**
  31200. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31201. * defined in the generator but impacting the effect).
  31202. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31203. * @param effect The effect we are binfing the information for
  31204. */
  31205. bindShadowLight(lightIndex: string, effect: Effect): void;
  31206. /**
  31207. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31208. * (eq to shadow prjection matrix * light transform matrix)
  31209. * @returns The transform matrix used to create the shadow map
  31210. */
  31211. getTransformMatrix(): Matrix;
  31212. /**
  31213. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31214. * Cube and 2D textures for instance.
  31215. */
  31216. recreateShadowMap(): void;
  31217. protected _disposeBlurPostProcesses(): void;
  31218. protected _disposeRTTandPostProcesses(): void;
  31219. /**
  31220. * Disposes the ShadowGenerator.
  31221. * Returns nothing.
  31222. */
  31223. dispose(): void;
  31224. /**
  31225. * Serializes the shadow generator setup to a json object.
  31226. * @returns The serialized JSON object
  31227. */
  31228. serialize(): any;
  31229. /**
  31230. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31231. * @param parsedShadowGenerator The JSON object to parse
  31232. * @param scene The scene to create the shadow map for
  31233. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  31234. * @returns The parsed shadow generator
  31235. */
  31236. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  31237. }
  31238. }
  31239. declare module "babylonjs/Materials/shadowDepthWrapper" {
  31240. import { Nullable } from "babylonjs/types";
  31241. import { Scene } from "babylonjs/scene";
  31242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31243. import { Material } from "babylonjs/Materials/material";
  31244. import { Effect } from "babylonjs/Materials/effect";
  31245. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  31246. /**
  31247. * Options to be used when creating a shadow depth material
  31248. */
  31249. export interface IIOptionShadowDepthMaterial {
  31250. /** Variables in the vertex shader code that need to have their names remapped.
  31251. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  31252. * "var_name" should be either: worldPos or vNormalW
  31253. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  31254. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  31255. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  31256. */
  31257. remappedVariables?: string[];
  31258. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  31259. standalone?: boolean;
  31260. }
  31261. /**
  31262. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  31263. */
  31264. export class ShadowDepthWrapper {
  31265. private _scene;
  31266. private _options?;
  31267. private _baseMaterial;
  31268. private _onEffectCreatedObserver;
  31269. private _subMeshToEffect;
  31270. private _subMeshToDepthEffect;
  31271. private _meshes;
  31272. /** @hidden */
  31273. _matriceNames: any;
  31274. /** Gets the standalone status of the wrapper */
  31275. get standalone(): boolean;
  31276. /** Gets the base material the wrapper is built upon */
  31277. get baseMaterial(): Material;
  31278. /**
  31279. * Instantiate a new shadow depth wrapper.
  31280. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  31281. * generate the shadow depth map. For more information, please refer to the documentation:
  31282. * https://doc.babylonjs.com/babylon101/shadows
  31283. * @param baseMaterial Material to wrap
  31284. * @param scene Define the scene the material belongs to
  31285. * @param options Options used to create the wrapper
  31286. */
  31287. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  31288. /**
  31289. * Gets the effect to use to generate the depth map
  31290. * @param subMesh subMesh to get the effect for
  31291. * @param shadowGenerator shadow generator to get the effect for
  31292. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  31293. */
  31294. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  31295. /**
  31296. * Specifies that the submesh is ready to be used for depth rendering
  31297. * @param subMesh submesh to check
  31298. * @param defines the list of defines to take into account when checking the effect
  31299. * @param shadowGenerator combined with subMesh, it defines the effect to check
  31300. * @param useInstances specifies that instances should be used
  31301. * @returns a boolean indicating that the submesh is ready or not
  31302. */
  31303. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  31304. /**
  31305. * Disposes the resources
  31306. */
  31307. dispose(): void;
  31308. private _makeEffect;
  31309. }
  31310. }
  31311. declare module "babylonjs/Materials/material" {
  31312. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31313. import { SmartArray } from "babylonjs/Misc/smartArray";
  31314. import { Observable } from "babylonjs/Misc/observable";
  31315. import { Nullable } from "babylonjs/types";
  31316. import { Matrix } from "babylonjs/Maths/math.vector";
  31317. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31320. import { Effect } from "babylonjs/Materials/effect";
  31321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31322. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31323. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31324. import { IInspectable } from "babylonjs/Misc/iInspectable";
  31325. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  31326. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  31327. import { Mesh } from "babylonjs/Meshes/mesh";
  31328. import { Animation } from "babylonjs/Animations/animation";
  31329. import { Scene } from "babylonjs/scene";
  31330. /**
  31331. * Options for compiling materials.
  31332. */
  31333. export interface IMaterialCompilationOptions {
  31334. /**
  31335. * Defines whether clip planes are enabled.
  31336. */
  31337. clipPlane: boolean;
  31338. /**
  31339. * Defines whether instances are enabled.
  31340. */
  31341. useInstances: boolean;
  31342. }
  31343. /**
  31344. * Options passed when calling customShaderNameResolve
  31345. */
  31346. export interface ICustomShaderNameResolveOptions {
  31347. /**
  31348. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  31349. */
  31350. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  31351. }
  31352. /**
  31353. * Base class for the main features of a material in Babylon.js
  31354. */
  31355. export class Material implements IAnimatable {
  31356. /**
  31357. * Returns the triangle fill mode
  31358. */
  31359. static readonly TriangleFillMode: number;
  31360. /**
  31361. * Returns the wireframe mode
  31362. */
  31363. static readonly WireFrameFillMode: number;
  31364. /**
  31365. * Returns the point fill mode
  31366. */
  31367. static readonly PointFillMode: number;
  31368. /**
  31369. * Returns the point list draw mode
  31370. */
  31371. static readonly PointListDrawMode: number;
  31372. /**
  31373. * Returns the line list draw mode
  31374. */
  31375. static readonly LineListDrawMode: number;
  31376. /**
  31377. * Returns the line loop draw mode
  31378. */
  31379. static readonly LineLoopDrawMode: number;
  31380. /**
  31381. * Returns the line strip draw mode
  31382. */
  31383. static readonly LineStripDrawMode: number;
  31384. /**
  31385. * Returns the triangle strip draw mode
  31386. */
  31387. static readonly TriangleStripDrawMode: number;
  31388. /**
  31389. * Returns the triangle fan draw mode
  31390. */
  31391. static readonly TriangleFanDrawMode: number;
  31392. /**
  31393. * Stores the clock-wise side orientation
  31394. */
  31395. static readonly ClockWiseSideOrientation: number;
  31396. /**
  31397. * Stores the counter clock-wise side orientation
  31398. */
  31399. static readonly CounterClockWiseSideOrientation: number;
  31400. /**
  31401. * The dirty texture flag value
  31402. */
  31403. static readonly TextureDirtyFlag: number;
  31404. /**
  31405. * The dirty light flag value
  31406. */
  31407. static readonly LightDirtyFlag: number;
  31408. /**
  31409. * The dirty fresnel flag value
  31410. */
  31411. static readonly FresnelDirtyFlag: number;
  31412. /**
  31413. * The dirty attribute flag value
  31414. */
  31415. static readonly AttributesDirtyFlag: number;
  31416. /**
  31417. * The dirty misc flag value
  31418. */
  31419. static readonly MiscDirtyFlag: number;
  31420. /**
  31421. * The dirty prepass flag value
  31422. */
  31423. static readonly PrePassDirtyFlag: number;
  31424. /**
  31425. * The all dirty flag value
  31426. */
  31427. static readonly AllDirtyFlag: number;
  31428. /**
  31429. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31430. */
  31431. static readonly MATERIAL_OPAQUE: number;
  31432. /**
  31433. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31434. */
  31435. static readonly MATERIAL_ALPHATEST: number;
  31436. /**
  31437. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31438. */
  31439. static readonly MATERIAL_ALPHABLEND: number;
  31440. /**
  31441. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31442. * They are also discarded below the alpha cutoff threshold to improve performances.
  31443. */
  31444. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  31445. /**
  31446. * The Whiteout method is used to blend normals.
  31447. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31448. */
  31449. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  31450. /**
  31451. * The Reoriented Normal Mapping method is used to blend normals.
  31452. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31453. */
  31454. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  31455. /**
  31456. * Custom callback helping to override the default shader used in the material.
  31457. */
  31458. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  31459. /**
  31460. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  31461. */
  31462. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  31463. /**
  31464. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  31465. * This means that the material can keep using a previous shader while a new one is being compiled.
  31466. * This is mostly used when shader parallel compilation is supported (true by default)
  31467. */
  31468. allowShaderHotSwapping: boolean;
  31469. /**
  31470. * The ID of the material
  31471. */
  31472. id: string;
  31473. /**
  31474. * Gets or sets the unique id of the material
  31475. */
  31476. uniqueId: number;
  31477. /**
  31478. * The name of the material
  31479. */
  31480. name: string;
  31481. /**
  31482. * Gets or sets user defined metadata
  31483. */
  31484. metadata: any;
  31485. /**
  31486. * For internal use only. Please do not use.
  31487. */
  31488. reservedDataStore: any;
  31489. /**
  31490. * Specifies if the ready state should be checked on each call
  31491. */
  31492. checkReadyOnEveryCall: boolean;
  31493. /**
  31494. * Specifies if the ready state should be checked once
  31495. */
  31496. checkReadyOnlyOnce: boolean;
  31497. /**
  31498. * The state of the material
  31499. */
  31500. state: string;
  31501. /**
  31502. * If the material can be rendered to several textures with MRT extension
  31503. */
  31504. get canRenderToMRT(): boolean;
  31505. /**
  31506. * The alpha value of the material
  31507. */
  31508. protected _alpha: number;
  31509. /**
  31510. * List of inspectable custom properties (used by the Inspector)
  31511. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31512. */
  31513. inspectableCustomProperties: IInspectable[];
  31514. /**
  31515. * Sets the alpha value of the material
  31516. */
  31517. set alpha(value: number);
  31518. /**
  31519. * Gets the alpha value of the material
  31520. */
  31521. get alpha(): number;
  31522. /**
  31523. * Specifies if back face culling is enabled
  31524. */
  31525. protected _backFaceCulling: boolean;
  31526. /**
  31527. * Sets the back-face culling state
  31528. */
  31529. set backFaceCulling(value: boolean);
  31530. /**
  31531. * Gets the back-face culling state
  31532. */
  31533. get backFaceCulling(): boolean;
  31534. /**
  31535. * Stores the value for side orientation
  31536. */
  31537. sideOrientation: number;
  31538. /**
  31539. * Callback triggered when the material is compiled
  31540. */
  31541. onCompiled: Nullable<(effect: Effect) => void>;
  31542. /**
  31543. * Callback triggered when an error occurs
  31544. */
  31545. onError: Nullable<(effect: Effect, errors: string) => void>;
  31546. /**
  31547. * Callback triggered to get the render target textures
  31548. */
  31549. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  31550. /**
  31551. * Gets a boolean indicating that current material needs to register RTT
  31552. */
  31553. get hasRenderTargetTextures(): boolean;
  31554. /**
  31555. * Specifies if the material should be serialized
  31556. */
  31557. doNotSerialize: boolean;
  31558. /**
  31559. * @hidden
  31560. */
  31561. _storeEffectOnSubMeshes: boolean;
  31562. /**
  31563. * Stores the animations for the material
  31564. */
  31565. animations: Nullable<Array<Animation>>;
  31566. /**
  31567. * An event triggered when the material is disposed
  31568. */
  31569. onDisposeObservable: Observable<Material>;
  31570. /**
  31571. * An observer which watches for dispose events
  31572. */
  31573. private _onDisposeObserver;
  31574. private _onUnBindObservable;
  31575. /**
  31576. * Called during a dispose event
  31577. */
  31578. set onDispose(callback: () => void);
  31579. private _onBindObservable;
  31580. /**
  31581. * An event triggered when the material is bound
  31582. */
  31583. get onBindObservable(): Observable<AbstractMesh>;
  31584. /**
  31585. * An observer which watches for bind events
  31586. */
  31587. private _onBindObserver;
  31588. /**
  31589. * Called during a bind event
  31590. */
  31591. set onBind(callback: (Mesh: AbstractMesh) => void);
  31592. /**
  31593. * An event triggered when the material is unbound
  31594. */
  31595. get onUnBindObservable(): Observable<Material>;
  31596. protected _onEffectCreatedObservable: Nullable<Observable<{
  31597. effect: Effect;
  31598. subMesh: Nullable<SubMesh>;
  31599. }>>;
  31600. /**
  31601. * An event triggered when the effect is (re)created
  31602. */
  31603. get onEffectCreatedObservable(): Observable<{
  31604. effect: Effect;
  31605. subMesh: Nullable<SubMesh>;
  31606. }>;
  31607. /**
  31608. * Stores the value of the alpha mode
  31609. */
  31610. private _alphaMode;
  31611. /**
  31612. * Sets the value of the alpha mode.
  31613. *
  31614. * | Value | Type | Description |
  31615. * | --- | --- | --- |
  31616. * | 0 | ALPHA_DISABLE | |
  31617. * | 1 | ALPHA_ADD | |
  31618. * | 2 | ALPHA_COMBINE | |
  31619. * | 3 | ALPHA_SUBTRACT | |
  31620. * | 4 | ALPHA_MULTIPLY | |
  31621. * | 5 | ALPHA_MAXIMIZED | |
  31622. * | 6 | ALPHA_ONEONE | |
  31623. * | 7 | ALPHA_PREMULTIPLIED | |
  31624. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  31625. * | 9 | ALPHA_INTERPOLATE | |
  31626. * | 10 | ALPHA_SCREENMODE | |
  31627. *
  31628. */
  31629. set alphaMode(value: number);
  31630. /**
  31631. * Gets the value of the alpha mode
  31632. */
  31633. get alphaMode(): number;
  31634. /**
  31635. * Stores the state of the need depth pre-pass value
  31636. */
  31637. private _needDepthPrePass;
  31638. /**
  31639. * Sets the need depth pre-pass value
  31640. */
  31641. set needDepthPrePass(value: boolean);
  31642. /**
  31643. * Gets the depth pre-pass value
  31644. */
  31645. get needDepthPrePass(): boolean;
  31646. /**
  31647. * Specifies if depth writing should be disabled
  31648. */
  31649. disableDepthWrite: boolean;
  31650. /**
  31651. * Specifies if color writing should be disabled
  31652. */
  31653. disableColorWrite: boolean;
  31654. /**
  31655. * Specifies if depth writing should be forced
  31656. */
  31657. forceDepthWrite: boolean;
  31658. /**
  31659. * Specifies the depth function that should be used. 0 means the default engine function
  31660. */
  31661. depthFunction: number;
  31662. /**
  31663. * Specifies if there should be a separate pass for culling
  31664. */
  31665. separateCullingPass: boolean;
  31666. /**
  31667. * Stores the state specifing if fog should be enabled
  31668. */
  31669. private _fogEnabled;
  31670. /**
  31671. * Sets the state for enabling fog
  31672. */
  31673. set fogEnabled(value: boolean);
  31674. /**
  31675. * Gets the value of the fog enabled state
  31676. */
  31677. get fogEnabled(): boolean;
  31678. /**
  31679. * Stores the size of points
  31680. */
  31681. pointSize: number;
  31682. /**
  31683. * Stores the z offset value
  31684. */
  31685. zOffset: number;
  31686. get wireframe(): boolean;
  31687. /**
  31688. * Sets the state of wireframe mode
  31689. */
  31690. set wireframe(value: boolean);
  31691. /**
  31692. * Gets the value specifying if point clouds are enabled
  31693. */
  31694. get pointsCloud(): boolean;
  31695. /**
  31696. * Sets the state of point cloud mode
  31697. */
  31698. set pointsCloud(value: boolean);
  31699. /**
  31700. * Gets the material fill mode
  31701. */
  31702. get fillMode(): number;
  31703. /**
  31704. * Sets the material fill mode
  31705. */
  31706. set fillMode(value: number);
  31707. /**
  31708. * @hidden
  31709. * Stores the effects for the material
  31710. */
  31711. _effect: Nullable<Effect>;
  31712. /**
  31713. * Specifies if uniform buffers should be used
  31714. */
  31715. private _useUBO;
  31716. /**
  31717. * Stores a reference to the scene
  31718. */
  31719. private _scene;
  31720. private _needToBindSceneUbo;
  31721. /**
  31722. * Stores the fill mode state
  31723. */
  31724. private _fillMode;
  31725. /**
  31726. * Specifies if the depth write state should be cached
  31727. */
  31728. private _cachedDepthWriteState;
  31729. /**
  31730. * Specifies if the color write state should be cached
  31731. */
  31732. private _cachedColorWriteState;
  31733. /**
  31734. * Specifies if the depth function state should be cached
  31735. */
  31736. private _cachedDepthFunctionState;
  31737. /**
  31738. * Stores the uniform buffer
  31739. */
  31740. protected _uniformBuffer: UniformBuffer;
  31741. /** @hidden */
  31742. _indexInSceneMaterialArray: number;
  31743. /** @hidden */
  31744. meshMap: Nullable<{
  31745. [id: string]: AbstractMesh | undefined;
  31746. }>;
  31747. /**
  31748. * Creates a material instance
  31749. * @param name defines the name of the material
  31750. * @param scene defines the scene to reference
  31751. * @param doNotAdd specifies if the material should be added to the scene
  31752. */
  31753. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  31754. /**
  31755. * Returns a string representation of the current material
  31756. * @param fullDetails defines a boolean indicating which levels of logging is desired
  31757. * @returns a string with material information
  31758. */
  31759. toString(fullDetails?: boolean): string;
  31760. /**
  31761. * Gets the class name of the material
  31762. * @returns a string with the class name of the material
  31763. */
  31764. getClassName(): string;
  31765. /**
  31766. * Specifies if updates for the material been locked
  31767. */
  31768. get isFrozen(): boolean;
  31769. /**
  31770. * Locks updates for the material
  31771. */
  31772. freeze(): void;
  31773. /**
  31774. * Unlocks updates for the material
  31775. */
  31776. unfreeze(): void;
  31777. /**
  31778. * Specifies if the material is ready to be used
  31779. * @param mesh defines the mesh to check
  31780. * @param useInstances specifies if instances should be used
  31781. * @returns a boolean indicating if the material is ready to be used
  31782. */
  31783. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  31784. /**
  31785. * Specifies that the submesh is ready to be used
  31786. * @param mesh defines the mesh to check
  31787. * @param subMesh defines which submesh to check
  31788. * @param useInstances specifies that instances should be used
  31789. * @returns a boolean indicating that the submesh is ready or not
  31790. */
  31791. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31792. /**
  31793. * Returns the material effect
  31794. * @returns the effect associated with the material
  31795. */
  31796. getEffect(): Nullable<Effect>;
  31797. /**
  31798. * Returns the current scene
  31799. * @returns a Scene
  31800. */
  31801. getScene(): Scene;
  31802. /**
  31803. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31804. */
  31805. protected _forceAlphaTest: boolean;
  31806. /**
  31807. * The transparency mode of the material.
  31808. */
  31809. protected _transparencyMode: Nullable<number>;
  31810. /**
  31811. * Gets the current transparency mode.
  31812. */
  31813. get transparencyMode(): Nullable<number>;
  31814. /**
  31815. * Sets the transparency mode of the material.
  31816. *
  31817. * | Value | Type | Description |
  31818. * | ----- | ----------------------------------- | ----------- |
  31819. * | 0 | OPAQUE | |
  31820. * | 1 | ALPHATEST | |
  31821. * | 2 | ALPHABLEND | |
  31822. * | 3 | ALPHATESTANDBLEND | |
  31823. *
  31824. */
  31825. set transparencyMode(value: Nullable<number>);
  31826. /**
  31827. * Returns true if alpha blending should be disabled.
  31828. */
  31829. protected get _disableAlphaBlending(): boolean;
  31830. /**
  31831. * Specifies whether or not this material should be rendered in alpha blend mode.
  31832. * @returns a boolean specifying if alpha blending is needed
  31833. */
  31834. needAlphaBlending(): boolean;
  31835. /**
  31836. * Specifies if the mesh will require alpha blending
  31837. * @param mesh defines the mesh to check
  31838. * @returns a boolean specifying if alpha blending is needed for the mesh
  31839. */
  31840. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31841. /**
  31842. * Specifies whether or not this material should be rendered in alpha test mode.
  31843. * @returns a boolean specifying if an alpha test is needed.
  31844. */
  31845. needAlphaTesting(): boolean;
  31846. /**
  31847. * Specifies if material alpha testing should be turned on for the mesh
  31848. * @param mesh defines the mesh to check
  31849. */
  31850. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  31851. /**
  31852. * Gets the texture used for the alpha test
  31853. * @returns the texture to use for alpha testing
  31854. */
  31855. getAlphaTestTexture(): Nullable<BaseTexture>;
  31856. /**
  31857. * Marks the material to indicate that it needs to be re-calculated
  31858. */
  31859. markDirty(): void;
  31860. /** @hidden */
  31861. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  31862. /**
  31863. * Binds the material to the mesh
  31864. * @param world defines the world transformation matrix
  31865. * @param mesh defines the mesh to bind the material to
  31866. */
  31867. bind(world: Matrix, mesh?: Mesh): void;
  31868. /**
  31869. * Binds the submesh to the material
  31870. * @param world defines the world transformation matrix
  31871. * @param mesh defines the mesh containing the submesh
  31872. * @param subMesh defines the submesh to bind the material to
  31873. */
  31874. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31875. /**
  31876. * Binds the world matrix to the material
  31877. * @param world defines the world transformation matrix
  31878. */
  31879. bindOnlyWorldMatrix(world: Matrix): void;
  31880. /**
  31881. * Update the scene ubo before it can be used in rendering processing
  31882. * @param scene the scene to retrieve the ubo from
  31883. * @returns the scene UniformBuffer
  31884. */
  31885. finalizeSceneUbo(scene: Scene): UniformBuffer;
  31886. /**
  31887. * Binds the scene's uniform buffer to the effect.
  31888. * @param effect defines the effect to bind to the scene uniform buffer
  31889. * @param sceneUbo defines the uniform buffer storing scene data
  31890. */
  31891. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31892. /**
  31893. * Binds the view matrix to the effect
  31894. * @param effect defines the effect to bind the view matrix to
  31895. */
  31896. bindView(effect: Effect): void;
  31897. /**
  31898. * Binds the view projection and projection matrices to the effect
  31899. * @param effect defines the effect to bind the view projection and projection matrices to
  31900. */
  31901. bindViewProjection(effect: Effect): void;
  31902. /**
  31903. * Binds the view matrix to the effect
  31904. * @param effect defines the effect to bind the view matrix to
  31905. * @param variableName name of the shader variable that will hold the eye position
  31906. */
  31907. bindEyePosition(effect: Effect, variableName?: string): void;
  31908. /**
  31909. * Processes to execute after binding the material to a mesh
  31910. * @param mesh defines the rendered mesh
  31911. */
  31912. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  31913. /**
  31914. * Unbinds the material from the mesh
  31915. */
  31916. unbind(): void;
  31917. /**
  31918. * Gets the active textures from the material
  31919. * @returns an array of textures
  31920. */
  31921. getActiveTextures(): BaseTexture[];
  31922. /**
  31923. * Specifies if the material uses a texture
  31924. * @param texture defines the texture to check against the material
  31925. * @returns a boolean specifying if the material uses the texture
  31926. */
  31927. hasTexture(texture: BaseTexture): boolean;
  31928. /**
  31929. * Makes a duplicate of the material, and gives it a new name
  31930. * @param name defines the new name for the duplicated material
  31931. * @returns the cloned material
  31932. */
  31933. clone(name: string): Nullable<Material>;
  31934. /**
  31935. * Gets the meshes bound to the material
  31936. * @returns an array of meshes bound to the material
  31937. */
  31938. getBindedMeshes(): AbstractMesh[];
  31939. /**
  31940. * Force shader compilation
  31941. * @param mesh defines the mesh associated with this material
  31942. * @param onCompiled defines a function to execute once the material is compiled
  31943. * @param options defines the options to configure the compilation
  31944. * @param onError defines a function to execute if the material fails compiling
  31945. */
  31946. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31947. /**
  31948. * Force shader compilation
  31949. * @param mesh defines the mesh that will use this material
  31950. * @param options defines additional options for compiling the shaders
  31951. * @returns a promise that resolves when the compilation completes
  31952. */
  31953. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31954. private static readonly _AllDirtyCallBack;
  31955. private static readonly _ImageProcessingDirtyCallBack;
  31956. private static readonly _TextureDirtyCallBack;
  31957. private static readonly _FresnelDirtyCallBack;
  31958. private static readonly _MiscDirtyCallBack;
  31959. private static readonly _PrePassDirtyCallBack;
  31960. private static readonly _LightsDirtyCallBack;
  31961. private static readonly _AttributeDirtyCallBack;
  31962. private static _FresnelAndMiscDirtyCallBack;
  31963. private static _TextureAndMiscDirtyCallBack;
  31964. private static readonly _DirtyCallbackArray;
  31965. private static readonly _RunDirtyCallBacks;
  31966. /**
  31967. * Marks a define in the material to indicate that it needs to be re-computed
  31968. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31969. */
  31970. markAsDirty(flag: number): void;
  31971. /**
  31972. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31973. * @param func defines a function which checks material defines against the submeshes
  31974. */
  31975. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31976. /**
  31977. * Indicates that the scene should check if the rendering now needs a prepass
  31978. */
  31979. protected _markScenePrePassDirty(): void;
  31980. /**
  31981. * Indicates that we need to re-calculated for all submeshes
  31982. */
  31983. protected _markAllSubMeshesAsAllDirty(): void;
  31984. /**
  31985. * Indicates that image processing needs to be re-calculated for all submeshes
  31986. */
  31987. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31988. /**
  31989. * Indicates that textures need to be re-calculated for all submeshes
  31990. */
  31991. protected _markAllSubMeshesAsTexturesDirty(): void;
  31992. /**
  31993. * Indicates that fresnel needs to be re-calculated for all submeshes
  31994. */
  31995. protected _markAllSubMeshesAsFresnelDirty(): void;
  31996. /**
  31997. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31998. */
  31999. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  32000. /**
  32001. * Indicates that lights need to be re-calculated for all submeshes
  32002. */
  32003. protected _markAllSubMeshesAsLightsDirty(): void;
  32004. /**
  32005. * Indicates that attributes need to be re-calculated for all submeshes
  32006. */
  32007. protected _markAllSubMeshesAsAttributesDirty(): void;
  32008. /**
  32009. * Indicates that misc needs to be re-calculated for all submeshes
  32010. */
  32011. protected _markAllSubMeshesAsMiscDirty(): void;
  32012. /**
  32013. * Indicates that prepass needs to be re-calculated for all submeshes
  32014. */
  32015. protected _markAllSubMeshesAsPrePassDirty(): void;
  32016. /**
  32017. * Indicates that textures and misc need to be re-calculated for all submeshes
  32018. */
  32019. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  32020. /**
  32021. * Sets the required values to the prepass renderer.
  32022. * @param prePassRenderer defines the prepass renderer to setup.
  32023. * @returns true if the pre pass is needed.
  32024. */
  32025. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  32026. /**
  32027. * Disposes the material
  32028. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32029. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32030. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  32031. */
  32032. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  32033. /** @hidden */
  32034. private releaseVertexArrayObject;
  32035. /**
  32036. * Serializes this material
  32037. * @returns the serialized material object
  32038. */
  32039. serialize(): any;
  32040. /**
  32041. * Creates a material from parsed material data
  32042. * @param parsedMaterial defines parsed material data
  32043. * @param scene defines the hosting scene
  32044. * @param rootUrl defines the root URL to use to load textures
  32045. * @returns a new material
  32046. */
  32047. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  32048. }
  32049. }
  32050. declare module "babylonjs/Materials/multiMaterial" {
  32051. import { Nullable } from "babylonjs/types";
  32052. import { Scene } from "babylonjs/scene";
  32053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32054. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32056. import { Material } from "babylonjs/Materials/material";
  32057. /**
  32058. * A multi-material is used to apply different materials to different parts of the same object without the need of
  32059. * separate meshes. This can be use to improve performances.
  32060. * @see https://doc.babylonjs.com/how_to/multi_materials
  32061. */
  32062. export class MultiMaterial extends Material {
  32063. private _subMaterials;
  32064. /**
  32065. * Gets or Sets the list of Materials used within the multi material.
  32066. * They need to be ordered according to the submeshes order in the associated mesh
  32067. */
  32068. get subMaterials(): Nullable<Material>[];
  32069. set subMaterials(value: Nullable<Material>[]);
  32070. /**
  32071. * Function used to align with Node.getChildren()
  32072. * @returns the list of Materials used within the multi material
  32073. */
  32074. getChildren(): Nullable<Material>[];
  32075. /**
  32076. * Instantiates a new Multi Material
  32077. * A multi-material is used to apply different materials to different parts of the same object without the need of
  32078. * separate meshes. This can be use to improve performances.
  32079. * @see https://doc.babylonjs.com/how_to/multi_materials
  32080. * @param name Define the name in the scene
  32081. * @param scene Define the scene the material belongs to
  32082. */
  32083. constructor(name: string, scene: Scene);
  32084. private _hookArray;
  32085. /**
  32086. * Get one of the submaterial by its index in the submaterials array
  32087. * @param index The index to look the sub material at
  32088. * @returns The Material if the index has been defined
  32089. */
  32090. getSubMaterial(index: number): Nullable<Material>;
  32091. /**
  32092. * Get the list of active textures for the whole sub materials list.
  32093. * @returns All the textures that will be used during the rendering
  32094. */
  32095. getActiveTextures(): BaseTexture[];
  32096. /**
  32097. * Specifies if any sub-materials of this multi-material use a given texture.
  32098. * @param texture Defines the texture to check against this multi-material's sub-materials.
  32099. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  32100. */
  32101. hasTexture(texture: BaseTexture): boolean;
  32102. /**
  32103. * Gets the current class name of the material e.g. "MultiMaterial"
  32104. * Mainly use in serialization.
  32105. * @returns the class name
  32106. */
  32107. getClassName(): string;
  32108. /**
  32109. * Checks if the material is ready to render the requested sub mesh
  32110. * @param mesh Define the mesh the submesh belongs to
  32111. * @param subMesh Define the sub mesh to look readyness for
  32112. * @param useInstances Define whether or not the material is used with instances
  32113. * @returns true if ready, otherwise false
  32114. */
  32115. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32116. /**
  32117. * Clones the current material and its related sub materials
  32118. * @param name Define the name of the newly cloned material
  32119. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  32120. * @returns the cloned material
  32121. */
  32122. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  32123. /**
  32124. * Serializes the materials into a JSON representation.
  32125. * @returns the JSON representation
  32126. */
  32127. serialize(): any;
  32128. /**
  32129. * Dispose the material and release its associated resources
  32130. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  32131. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  32132. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  32133. */
  32134. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  32135. /**
  32136. * Creates a MultiMaterial from parsed MultiMaterial data.
  32137. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  32138. * @param scene defines the hosting scene
  32139. * @returns a new MultiMaterial
  32140. */
  32141. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  32142. }
  32143. }
  32144. declare module "babylonjs/Meshes/subMesh" {
  32145. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  32146. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32147. import { Engine } from "babylonjs/Engines/engine";
  32148. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  32149. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32150. import { Effect } from "babylonjs/Materials/effect";
  32151. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32152. import { Plane } from "babylonjs/Maths/math.plane";
  32153. import { Collider } from "babylonjs/Collisions/collider";
  32154. import { Material } from "babylonjs/Materials/material";
  32155. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  32156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32157. import { Mesh } from "babylonjs/Meshes/mesh";
  32158. import { Ray } from "babylonjs/Culling/ray";
  32159. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32160. /** @hidden */
  32161. export interface ICustomEffect {
  32162. effect: Effect;
  32163. defines: string;
  32164. }
  32165. /**
  32166. * Defines a subdivision inside a mesh
  32167. */
  32168. export class SubMesh implements ICullable {
  32169. /** the material index to use */
  32170. materialIndex: number;
  32171. /** vertex index start */
  32172. verticesStart: number;
  32173. /** vertices count */
  32174. verticesCount: number;
  32175. /** index start */
  32176. indexStart: number;
  32177. /** indices count */
  32178. indexCount: number;
  32179. /** @hidden */
  32180. _materialDefines: Nullable<MaterialDefines>;
  32181. /** @hidden */
  32182. _materialEffect: Nullable<Effect>;
  32183. /** @hidden */
  32184. _effectOverride: Nullable<Effect>;
  32185. private _customEffects;
  32186. /**
  32187. * Gets material defines used by the effect associated to the sub mesh
  32188. */
  32189. get materialDefines(): Nullable<MaterialDefines>;
  32190. /**
  32191. * Sets material defines used by the effect associated to the sub mesh
  32192. */
  32193. set materialDefines(defines: Nullable<MaterialDefines>);
  32194. /** @hidden */
  32195. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  32196. /** @hidden */
  32197. _removeCustomEffect(name: string): void;
  32198. /**
  32199. * Gets associated effect
  32200. */
  32201. get effect(): Nullable<Effect>;
  32202. /**
  32203. * Sets associated effect (effect used to render this submesh)
  32204. * @param effect defines the effect to associate with
  32205. * @param defines defines the set of defines used to compile this effect
  32206. */
  32207. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  32208. /** @hidden */
  32209. _linesIndexCount: number;
  32210. private _mesh;
  32211. private _renderingMesh;
  32212. private _boundingInfo;
  32213. private _linesIndexBuffer;
  32214. /** @hidden */
  32215. _lastColliderWorldVertices: Nullable<Vector3[]>;
  32216. /** @hidden */
  32217. _trianglePlanes: Plane[];
  32218. /** @hidden */
  32219. _lastColliderTransformMatrix: Nullable<Matrix>;
  32220. /** @hidden */
  32221. _renderId: number;
  32222. /** @hidden */
  32223. _alphaIndex: number;
  32224. /** @hidden */
  32225. _distanceToCamera: number;
  32226. /** @hidden */
  32227. _id: number;
  32228. private _currentMaterial;
  32229. /**
  32230. * Add a new submesh to a mesh
  32231. * @param materialIndex defines the material index to use
  32232. * @param verticesStart defines vertex index start
  32233. * @param verticesCount defines vertices count
  32234. * @param indexStart defines index start
  32235. * @param indexCount defines indices count
  32236. * @param mesh defines the parent mesh
  32237. * @param renderingMesh defines an optional rendering mesh
  32238. * @param createBoundingBox defines if bounding box should be created for this submesh
  32239. * @returns the new submesh
  32240. */
  32241. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  32242. /**
  32243. * Creates a new submesh
  32244. * @param materialIndex defines the material index to use
  32245. * @param verticesStart defines vertex index start
  32246. * @param verticesCount defines vertices count
  32247. * @param indexStart defines index start
  32248. * @param indexCount defines indices count
  32249. * @param mesh defines the parent mesh
  32250. * @param renderingMesh defines an optional rendering mesh
  32251. * @param createBoundingBox defines if bounding box should be created for this submesh
  32252. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  32253. */
  32254. constructor(
  32255. /** the material index to use */
  32256. materialIndex: number,
  32257. /** vertex index start */
  32258. verticesStart: number,
  32259. /** vertices count */
  32260. verticesCount: number,
  32261. /** index start */
  32262. indexStart: number,
  32263. /** indices count */
  32264. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  32265. /**
  32266. * Returns true if this submesh covers the entire parent mesh
  32267. * @ignorenaming
  32268. */
  32269. get IsGlobal(): boolean;
  32270. /**
  32271. * Returns the submesh BoudingInfo object
  32272. * @returns current bounding info (or mesh's one if the submesh is global)
  32273. */
  32274. getBoundingInfo(): BoundingInfo;
  32275. /**
  32276. * Sets the submesh BoundingInfo
  32277. * @param boundingInfo defines the new bounding info to use
  32278. * @returns the SubMesh
  32279. */
  32280. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  32281. /**
  32282. * Returns the mesh of the current submesh
  32283. * @return the parent mesh
  32284. */
  32285. getMesh(): AbstractMesh;
  32286. /**
  32287. * Returns the rendering mesh of the submesh
  32288. * @returns the rendering mesh (could be different from parent mesh)
  32289. */
  32290. getRenderingMesh(): Mesh;
  32291. /**
  32292. * Returns the replacement mesh of the submesh
  32293. * @returns the replacement mesh (could be different from parent mesh)
  32294. */
  32295. getReplacementMesh(): Nullable<AbstractMesh>;
  32296. /**
  32297. * Returns the effective mesh of the submesh
  32298. * @returns the effective mesh (could be different from parent mesh)
  32299. */
  32300. getEffectiveMesh(): AbstractMesh;
  32301. /**
  32302. * Returns the submesh material
  32303. * @returns null or the current material
  32304. */
  32305. getMaterial(): Nullable<Material>;
  32306. private _IsMultiMaterial;
  32307. /**
  32308. * Sets a new updated BoundingInfo object to the submesh
  32309. * @param data defines an optional position array to use to determine the bounding info
  32310. * @returns the SubMesh
  32311. */
  32312. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  32313. /** @hidden */
  32314. _checkCollision(collider: Collider): boolean;
  32315. /**
  32316. * Updates the submesh BoundingInfo
  32317. * @param world defines the world matrix to use to update the bounding info
  32318. * @returns the submesh
  32319. */
  32320. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  32321. /**
  32322. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  32323. * @param frustumPlanes defines the frustum planes
  32324. * @returns true if the submesh is intersecting with the frustum
  32325. */
  32326. isInFrustum(frustumPlanes: Plane[]): boolean;
  32327. /**
  32328. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  32329. * @param frustumPlanes defines the frustum planes
  32330. * @returns true if the submesh is inside the frustum
  32331. */
  32332. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32333. /**
  32334. * Renders the submesh
  32335. * @param enableAlphaMode defines if alpha needs to be used
  32336. * @returns the submesh
  32337. */
  32338. render(enableAlphaMode: boolean): SubMesh;
  32339. /**
  32340. * @hidden
  32341. */
  32342. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  32343. /**
  32344. * Checks if the submesh intersects with a ray
  32345. * @param ray defines the ray to test
  32346. * @returns true is the passed ray intersects the submesh bounding box
  32347. */
  32348. canIntersects(ray: Ray): boolean;
  32349. /**
  32350. * Intersects current submesh with a ray
  32351. * @param ray defines the ray to test
  32352. * @param positions defines mesh's positions array
  32353. * @param indices defines mesh's indices array
  32354. * @param fastCheck defines if the first intersection will be used (and not the closest)
  32355. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32356. * @returns intersection info or null if no intersection
  32357. */
  32358. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  32359. /** @hidden */
  32360. private _intersectLines;
  32361. /** @hidden */
  32362. private _intersectUnIndexedLines;
  32363. /** @hidden */
  32364. private _intersectTriangles;
  32365. /** @hidden */
  32366. private _intersectUnIndexedTriangles;
  32367. /** @hidden */
  32368. _rebuild(): void;
  32369. /**
  32370. * Creates a new submesh from the passed mesh
  32371. * @param newMesh defines the new hosting mesh
  32372. * @param newRenderingMesh defines an optional rendering mesh
  32373. * @returns the new submesh
  32374. */
  32375. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  32376. /**
  32377. * Release associated resources
  32378. */
  32379. dispose(): void;
  32380. /**
  32381. * Gets the class name
  32382. * @returns the string "SubMesh".
  32383. */
  32384. getClassName(): string;
  32385. /**
  32386. * Creates a new submesh from indices data
  32387. * @param materialIndex the index of the main mesh material
  32388. * @param startIndex the index where to start the copy in the mesh indices array
  32389. * @param indexCount the number of indices to copy then from the startIndex
  32390. * @param mesh the main mesh to create the submesh from
  32391. * @param renderingMesh the optional rendering mesh
  32392. * @returns a new submesh
  32393. */
  32394. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  32395. }
  32396. }
  32397. declare module "babylonjs/Loading/sceneLoaderFlags" {
  32398. /**
  32399. * Class used to represent data loading progression
  32400. */
  32401. export class SceneLoaderFlags {
  32402. private static _ForceFullSceneLoadingForIncremental;
  32403. private static _ShowLoadingScreen;
  32404. private static _CleanBoneMatrixWeights;
  32405. private static _loggingLevel;
  32406. /**
  32407. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  32408. */
  32409. static get ForceFullSceneLoadingForIncremental(): boolean;
  32410. static set ForceFullSceneLoadingForIncremental(value: boolean);
  32411. /**
  32412. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  32413. */
  32414. static get ShowLoadingScreen(): boolean;
  32415. static set ShowLoadingScreen(value: boolean);
  32416. /**
  32417. * Defines the current logging level (while loading the scene)
  32418. * @ignorenaming
  32419. */
  32420. static get loggingLevel(): number;
  32421. static set loggingLevel(value: number);
  32422. /**
  32423. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  32424. */
  32425. static get CleanBoneMatrixWeights(): boolean;
  32426. static set CleanBoneMatrixWeights(value: boolean);
  32427. }
  32428. }
  32429. declare module "babylonjs/Meshes/geometry" {
  32430. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  32431. import { Scene } from "babylonjs/scene";
  32432. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32433. import { Engine } from "babylonjs/Engines/engine";
  32434. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  32435. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32436. import { Effect } from "babylonjs/Materials/effect";
  32437. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32438. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32439. import { Mesh } from "babylonjs/Meshes/mesh";
  32440. /**
  32441. * Class used to store geometry data (vertex buffers + index buffer)
  32442. */
  32443. export class Geometry implements IGetSetVerticesData {
  32444. /**
  32445. * Gets or sets the ID of the geometry
  32446. */
  32447. id: string;
  32448. /**
  32449. * Gets or sets the unique ID of the geometry
  32450. */
  32451. uniqueId: number;
  32452. /**
  32453. * Gets the delay loading state of the geometry (none by default which means not delayed)
  32454. */
  32455. delayLoadState: number;
  32456. /**
  32457. * Gets the file containing the data to load when running in delay load state
  32458. */
  32459. delayLoadingFile: Nullable<string>;
  32460. /**
  32461. * Callback called when the geometry is updated
  32462. */
  32463. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  32464. private _scene;
  32465. private _engine;
  32466. private _meshes;
  32467. private _totalVertices;
  32468. /** @hidden */
  32469. _indices: IndicesArray;
  32470. /** @hidden */
  32471. _vertexBuffers: {
  32472. [key: string]: VertexBuffer;
  32473. };
  32474. private _isDisposed;
  32475. private _extend;
  32476. private _boundingBias;
  32477. /** @hidden */
  32478. _delayInfo: Array<string>;
  32479. private _indexBuffer;
  32480. private _indexBufferIsUpdatable;
  32481. /** @hidden */
  32482. _boundingInfo: Nullable<BoundingInfo>;
  32483. /** @hidden */
  32484. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  32485. /** @hidden */
  32486. _softwareSkinningFrameId: number;
  32487. private _vertexArrayObjects;
  32488. private _updatable;
  32489. /** @hidden */
  32490. _positions: Nullable<Vector3[]>;
  32491. private _positionsCache;
  32492. /**
  32493. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  32494. */
  32495. get boundingBias(): Vector2;
  32496. /**
  32497. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  32498. */
  32499. set boundingBias(value: Vector2);
  32500. /**
  32501. * Static function used to attach a new empty geometry to a mesh
  32502. * @param mesh defines the mesh to attach the geometry to
  32503. * @returns the new Geometry
  32504. */
  32505. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  32506. /** Get the list of meshes using this geometry */
  32507. get meshes(): Mesh[];
  32508. /**
  32509. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  32510. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  32511. */
  32512. useBoundingInfoFromGeometry: boolean;
  32513. /**
  32514. * Creates a new geometry
  32515. * @param id defines the unique ID
  32516. * @param scene defines the hosting scene
  32517. * @param vertexData defines the VertexData used to get geometry data
  32518. * @param updatable defines if geometry must be updatable (false by default)
  32519. * @param mesh defines the mesh that will be associated with the geometry
  32520. */
  32521. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  32522. /**
  32523. * Gets the current extend of the geometry
  32524. */
  32525. get extend(): {
  32526. minimum: Vector3;
  32527. maximum: Vector3;
  32528. };
  32529. /**
  32530. * Gets the hosting scene
  32531. * @returns the hosting Scene
  32532. */
  32533. getScene(): Scene;
  32534. /**
  32535. * Gets the hosting engine
  32536. * @returns the hosting Engine
  32537. */
  32538. getEngine(): Engine;
  32539. /**
  32540. * Defines if the geometry is ready to use
  32541. * @returns true if the geometry is ready to be used
  32542. */
  32543. isReady(): boolean;
  32544. /**
  32545. * Gets a value indicating that the geometry should not be serialized
  32546. */
  32547. get doNotSerialize(): boolean;
  32548. /** @hidden */
  32549. _rebuild(): void;
  32550. /**
  32551. * Affects all geometry data in one call
  32552. * @param vertexData defines the geometry data
  32553. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  32554. */
  32555. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  32556. /**
  32557. * Set specific vertex data
  32558. * @param kind defines the data kind (Position, normal, etc...)
  32559. * @param data defines the vertex data to use
  32560. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  32561. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  32562. */
  32563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  32564. /**
  32565. * Removes a specific vertex data
  32566. * @param kind defines the data kind (Position, normal, etc...)
  32567. */
  32568. removeVerticesData(kind: string): void;
  32569. /**
  32570. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  32571. * @param buffer defines the vertex buffer to use
  32572. * @param totalVertices defines the total number of vertices for position kind (could be null)
  32573. */
  32574. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  32575. /**
  32576. * Update a specific vertex buffer
  32577. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  32578. * It will do nothing if the buffer is not updatable
  32579. * @param kind defines the data kind (Position, normal, etc...)
  32580. * @param data defines the data to use
  32581. * @param offset defines the offset in the target buffer where to store the data
  32582. * @param useBytes set to true if the offset is in bytes
  32583. */
  32584. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  32585. /**
  32586. * Update a specific vertex buffer
  32587. * This function will create a new buffer if the current one is not updatable
  32588. * @param kind defines the data kind (Position, normal, etc...)
  32589. * @param data defines the data to use
  32590. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  32591. */
  32592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  32593. private _updateBoundingInfo;
  32594. /** @hidden */
  32595. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  32596. [kind: string]: Nullable<VertexBuffer>;
  32597. }, overrideVertexArrayObjects?: {
  32598. [key: string]: WebGLVertexArrayObject;
  32599. }): void;
  32600. /**
  32601. * Gets total number of vertices
  32602. * @returns the total number of vertices
  32603. */
  32604. getTotalVertices(): number;
  32605. /**
  32606. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  32607. * @param kind defines the data kind (Position, normal, etc...)
  32608. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32609. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32610. * @returns a float array containing vertex data
  32611. */
  32612. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32613. /**
  32614. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  32615. * @param kind defines the data kind (Position, normal, etc...)
  32616. * @returns true if the vertex buffer with the specified kind is updatable
  32617. */
  32618. isVertexBufferUpdatable(kind: string): boolean;
  32619. /**
  32620. * Gets a specific vertex buffer
  32621. * @param kind defines the data kind (Position, normal, etc...)
  32622. * @returns a VertexBuffer
  32623. */
  32624. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32625. /**
  32626. * Returns all vertex buffers
  32627. * @return an object holding all vertex buffers indexed by kind
  32628. */
  32629. getVertexBuffers(): Nullable<{
  32630. [key: string]: VertexBuffer;
  32631. }>;
  32632. /**
  32633. * Gets a boolean indicating if specific vertex buffer is present
  32634. * @param kind defines the data kind (Position, normal, etc...)
  32635. * @returns true if data is present
  32636. */
  32637. isVerticesDataPresent(kind: string): boolean;
  32638. /**
  32639. * Gets a list of all attached data kinds (Position, normal, etc...)
  32640. * @returns a list of string containing all kinds
  32641. */
  32642. getVerticesDataKinds(): string[];
  32643. /**
  32644. * Update index buffer
  32645. * @param indices defines the indices to store in the index buffer
  32646. * @param offset defines the offset in the target buffer where to store the data
  32647. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  32648. */
  32649. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  32650. /**
  32651. * Creates a new index buffer
  32652. * @param indices defines the indices to store in the index buffer
  32653. * @param totalVertices defines the total number of vertices (could be null)
  32654. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  32655. */
  32656. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  32657. /**
  32658. * Return the total number of indices
  32659. * @returns the total number of indices
  32660. */
  32661. getTotalIndices(): number;
  32662. /**
  32663. * Gets the index buffer array
  32664. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32665. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32666. * @returns the index buffer array
  32667. */
  32668. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32669. /**
  32670. * Gets the index buffer
  32671. * @return the index buffer
  32672. */
  32673. getIndexBuffer(): Nullable<DataBuffer>;
  32674. /** @hidden */
  32675. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  32676. /**
  32677. * Release the associated resources for a specific mesh
  32678. * @param mesh defines the source mesh
  32679. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  32680. */
  32681. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  32682. /**
  32683. * Apply current geometry to a given mesh
  32684. * @param mesh defines the mesh to apply geometry to
  32685. */
  32686. applyToMesh(mesh: Mesh): void;
  32687. private _updateExtend;
  32688. private _applyToMesh;
  32689. private notifyUpdate;
  32690. /**
  32691. * Load the geometry if it was flagged as delay loaded
  32692. * @param scene defines the hosting scene
  32693. * @param onLoaded defines a callback called when the geometry is loaded
  32694. */
  32695. load(scene: Scene, onLoaded?: () => void): void;
  32696. private _queueLoad;
  32697. /**
  32698. * Invert the geometry to move from a right handed system to a left handed one.
  32699. */
  32700. toLeftHanded(): void;
  32701. /** @hidden */
  32702. _resetPointsArrayCache(): void;
  32703. /** @hidden */
  32704. _generatePointsArray(): boolean;
  32705. /**
  32706. * Gets a value indicating if the geometry is disposed
  32707. * @returns true if the geometry was disposed
  32708. */
  32709. isDisposed(): boolean;
  32710. private _disposeVertexArrayObjects;
  32711. /**
  32712. * Free all associated resources
  32713. */
  32714. dispose(): void;
  32715. /**
  32716. * Clone the current geometry into a new geometry
  32717. * @param id defines the unique ID of the new geometry
  32718. * @returns a new geometry object
  32719. */
  32720. copy(id: string): Geometry;
  32721. /**
  32722. * Serialize the current geometry info (and not the vertices data) into a JSON object
  32723. * @return a JSON representation of the current geometry data (without the vertices data)
  32724. */
  32725. serialize(): any;
  32726. private toNumberArray;
  32727. /**
  32728. * Serialize all vertices data into a JSON oject
  32729. * @returns a JSON representation of the current geometry data
  32730. */
  32731. serializeVerticeData(): any;
  32732. /**
  32733. * Extracts a clone of a mesh geometry
  32734. * @param mesh defines the source mesh
  32735. * @param id defines the unique ID of the new geometry object
  32736. * @returns the new geometry object
  32737. */
  32738. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  32739. /**
  32740. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  32741. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32742. * Be aware Math.random() could cause collisions, but:
  32743. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  32744. * @returns a string containing a new GUID
  32745. */
  32746. static RandomId(): string;
  32747. /** @hidden */
  32748. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  32749. private static _CleanMatricesWeights;
  32750. /**
  32751. * Create a new geometry from persisted data (Using .babylon file format)
  32752. * @param parsedVertexData defines the persisted data
  32753. * @param scene defines the hosting scene
  32754. * @param rootUrl defines the root url to use to load assets (like delayed data)
  32755. * @returns the new geometry object
  32756. */
  32757. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  32758. }
  32759. }
  32760. declare module "babylonjs/Morph/morphTarget" {
  32761. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32762. import { Observable } from "babylonjs/Misc/observable";
  32763. import { Nullable, FloatArray } from "babylonjs/types";
  32764. import { Scene } from "babylonjs/scene";
  32765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32766. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32767. /**
  32768. * Defines a target to use with MorphTargetManager
  32769. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32770. */
  32771. export class MorphTarget implements IAnimatable {
  32772. /** defines the name of the target */
  32773. name: string;
  32774. /**
  32775. * Gets or sets the list of animations
  32776. */
  32777. animations: import("babylonjs/Animations/animation").Animation[];
  32778. private _scene;
  32779. private _positions;
  32780. private _normals;
  32781. private _tangents;
  32782. private _uvs;
  32783. private _influence;
  32784. private _uniqueId;
  32785. /**
  32786. * Observable raised when the influence changes
  32787. */
  32788. onInfluenceChanged: Observable<boolean>;
  32789. /** @hidden */
  32790. _onDataLayoutChanged: Observable<void>;
  32791. /**
  32792. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32793. */
  32794. get influence(): number;
  32795. set influence(influence: number);
  32796. /**
  32797. * Gets or sets the id of the morph Target
  32798. */
  32799. id: string;
  32800. private _animationPropertiesOverride;
  32801. /**
  32802. * Gets or sets the animation properties override
  32803. */
  32804. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32805. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32806. /**
  32807. * Creates a new MorphTarget
  32808. * @param name defines the name of the target
  32809. * @param influence defines the influence to use
  32810. * @param scene defines the scene the morphtarget belongs to
  32811. */
  32812. constructor(
  32813. /** defines the name of the target */
  32814. name: string, influence?: number, scene?: Nullable<Scene>);
  32815. /**
  32816. * Gets the unique ID of this manager
  32817. */
  32818. get uniqueId(): number;
  32819. /**
  32820. * Gets a boolean defining if the target contains position data
  32821. */
  32822. get hasPositions(): boolean;
  32823. /**
  32824. * Gets a boolean defining if the target contains normal data
  32825. */
  32826. get hasNormals(): boolean;
  32827. /**
  32828. * Gets a boolean defining if the target contains tangent data
  32829. */
  32830. get hasTangents(): boolean;
  32831. /**
  32832. * Gets a boolean defining if the target contains texture coordinates data
  32833. */
  32834. get hasUVs(): boolean;
  32835. /**
  32836. * Affects position data to this target
  32837. * @param data defines the position data to use
  32838. */
  32839. setPositions(data: Nullable<FloatArray>): void;
  32840. /**
  32841. * Gets the position data stored in this target
  32842. * @returns a FloatArray containing the position data (or null if not present)
  32843. */
  32844. getPositions(): Nullable<FloatArray>;
  32845. /**
  32846. * Affects normal data to this target
  32847. * @param data defines the normal data to use
  32848. */
  32849. setNormals(data: Nullable<FloatArray>): void;
  32850. /**
  32851. * Gets the normal data stored in this target
  32852. * @returns a FloatArray containing the normal data (or null if not present)
  32853. */
  32854. getNormals(): Nullable<FloatArray>;
  32855. /**
  32856. * Affects tangent data to this target
  32857. * @param data defines the tangent data to use
  32858. */
  32859. setTangents(data: Nullable<FloatArray>): void;
  32860. /**
  32861. * Gets the tangent data stored in this target
  32862. * @returns a FloatArray containing the tangent data (or null if not present)
  32863. */
  32864. getTangents(): Nullable<FloatArray>;
  32865. /**
  32866. * Affects texture coordinates data to this target
  32867. * @param data defines the texture coordinates data to use
  32868. */
  32869. setUVs(data: Nullable<FloatArray>): void;
  32870. /**
  32871. * Gets the texture coordinates data stored in this target
  32872. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32873. */
  32874. getUVs(): Nullable<FloatArray>;
  32875. /**
  32876. * Clone the current target
  32877. * @returns a new MorphTarget
  32878. */
  32879. clone(): MorphTarget;
  32880. /**
  32881. * Serializes the current target into a Serialization object
  32882. * @returns the serialized object
  32883. */
  32884. serialize(): any;
  32885. /**
  32886. * Returns the string "MorphTarget"
  32887. * @returns "MorphTarget"
  32888. */
  32889. getClassName(): string;
  32890. /**
  32891. * Creates a new target from serialized data
  32892. * @param serializationObject defines the serialized data to use
  32893. * @returns a new MorphTarget
  32894. */
  32895. static Parse(serializationObject: any): MorphTarget;
  32896. /**
  32897. * Creates a MorphTarget from mesh data
  32898. * @param mesh defines the source mesh
  32899. * @param name defines the name to use for the new target
  32900. * @param influence defines the influence to attach to the target
  32901. * @returns a new MorphTarget
  32902. */
  32903. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32904. }
  32905. }
  32906. declare module "babylonjs/Morph/morphTargetManager" {
  32907. import { Nullable } from "babylonjs/types";
  32908. import { Scene } from "babylonjs/scene";
  32909. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32910. /**
  32911. * This class is used to deform meshes using morphing between different targets
  32912. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32913. */
  32914. export class MorphTargetManager {
  32915. private _targets;
  32916. private _targetInfluenceChangedObservers;
  32917. private _targetDataLayoutChangedObservers;
  32918. private _activeTargets;
  32919. private _scene;
  32920. private _influences;
  32921. private _supportsNormals;
  32922. private _supportsTangents;
  32923. private _supportsUVs;
  32924. private _vertexCount;
  32925. private _uniqueId;
  32926. private _tempInfluences;
  32927. /**
  32928. * Gets or sets a boolean indicating if normals must be morphed
  32929. */
  32930. enableNormalMorphing: boolean;
  32931. /**
  32932. * Gets or sets a boolean indicating if tangents must be morphed
  32933. */
  32934. enableTangentMorphing: boolean;
  32935. /**
  32936. * Gets or sets a boolean indicating if UV must be morphed
  32937. */
  32938. enableUVMorphing: boolean;
  32939. /**
  32940. * Creates a new MorphTargetManager
  32941. * @param scene defines the current scene
  32942. */
  32943. constructor(scene?: Nullable<Scene>);
  32944. /**
  32945. * Gets the unique ID of this manager
  32946. */
  32947. get uniqueId(): number;
  32948. /**
  32949. * Gets the number of vertices handled by this manager
  32950. */
  32951. get vertexCount(): number;
  32952. /**
  32953. * Gets a boolean indicating if this manager supports morphing of normals
  32954. */
  32955. get supportsNormals(): boolean;
  32956. /**
  32957. * Gets a boolean indicating if this manager supports morphing of tangents
  32958. */
  32959. get supportsTangents(): boolean;
  32960. /**
  32961. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32962. */
  32963. get supportsUVs(): boolean;
  32964. /**
  32965. * Gets the number of targets stored in this manager
  32966. */
  32967. get numTargets(): number;
  32968. /**
  32969. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32970. */
  32971. get numInfluencers(): number;
  32972. /**
  32973. * Gets the list of influences (one per target)
  32974. */
  32975. get influences(): Float32Array;
  32976. /**
  32977. * Gets the active target at specified index. An active target is a target with an influence > 0
  32978. * @param index defines the index to check
  32979. * @returns the requested target
  32980. */
  32981. getActiveTarget(index: number): MorphTarget;
  32982. /**
  32983. * Gets the target at specified index
  32984. * @param index defines the index to check
  32985. * @returns the requested target
  32986. */
  32987. getTarget(index: number): MorphTarget;
  32988. /**
  32989. * Add a new target to this manager
  32990. * @param target defines the target to add
  32991. */
  32992. addTarget(target: MorphTarget): void;
  32993. /**
  32994. * Removes a target from the manager
  32995. * @param target defines the target to remove
  32996. */
  32997. removeTarget(target: MorphTarget): void;
  32998. /**
  32999. * Clone the current manager
  33000. * @returns a new MorphTargetManager
  33001. */
  33002. clone(): MorphTargetManager;
  33003. /**
  33004. * Serializes the current manager into a Serialization object
  33005. * @returns the serialized object
  33006. */
  33007. serialize(): any;
  33008. private _syncActiveTargets;
  33009. /**
  33010. * Syncrhonize the targets with all the meshes using this morph target manager
  33011. */
  33012. synchronize(): void;
  33013. /**
  33014. * Creates a new MorphTargetManager from serialized data
  33015. * @param serializationObject defines the serialized data
  33016. * @param scene defines the hosting scene
  33017. * @returns the new MorphTargetManager
  33018. */
  33019. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  33020. }
  33021. }
  33022. declare module "babylonjs/Meshes/meshLODLevel" {
  33023. import { Mesh } from "babylonjs/Meshes/mesh";
  33024. import { Nullable } from "babylonjs/types";
  33025. /**
  33026. * Class used to represent a specific level of detail of a mesh
  33027. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33028. */
  33029. export class MeshLODLevel {
  33030. /** Defines the distance where this level should start being displayed */
  33031. distance: number;
  33032. /** Defines the mesh to use to render this level */
  33033. mesh: Nullable<Mesh>;
  33034. /**
  33035. * Creates a new LOD level
  33036. * @param distance defines the distance where this level should star being displayed
  33037. * @param mesh defines the mesh to use to render this level
  33038. */
  33039. constructor(
  33040. /** Defines the distance where this level should start being displayed */
  33041. distance: number,
  33042. /** Defines the mesh to use to render this level */
  33043. mesh: Nullable<Mesh>);
  33044. }
  33045. }
  33046. declare module "babylonjs/Misc/canvasGenerator" {
  33047. /**
  33048. * Helper class used to generate a canvas to manipulate images
  33049. */
  33050. export class CanvasGenerator {
  33051. /**
  33052. * Create a new canvas (or offscreen canvas depending on the context)
  33053. * @param width defines the expected width
  33054. * @param height defines the expected height
  33055. * @return a new canvas or offscreen canvas
  33056. */
  33057. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  33058. }
  33059. }
  33060. declare module "babylonjs/Meshes/groundMesh" {
  33061. import { Scene } from "babylonjs/scene";
  33062. import { Vector3 } from "babylonjs/Maths/math.vector";
  33063. import { Mesh } from "babylonjs/Meshes/mesh";
  33064. /**
  33065. * Mesh representing the gorund
  33066. */
  33067. export class GroundMesh extends Mesh {
  33068. /** If octree should be generated */
  33069. generateOctree: boolean;
  33070. private _heightQuads;
  33071. /** @hidden */
  33072. _subdivisionsX: number;
  33073. /** @hidden */
  33074. _subdivisionsY: number;
  33075. /** @hidden */
  33076. _width: number;
  33077. /** @hidden */
  33078. _height: number;
  33079. /** @hidden */
  33080. _minX: number;
  33081. /** @hidden */
  33082. _maxX: number;
  33083. /** @hidden */
  33084. _minZ: number;
  33085. /** @hidden */
  33086. _maxZ: number;
  33087. constructor(name: string, scene: Scene);
  33088. /**
  33089. * "GroundMesh"
  33090. * @returns "GroundMesh"
  33091. */
  33092. getClassName(): string;
  33093. /**
  33094. * The minimum of x and y subdivisions
  33095. */
  33096. get subdivisions(): number;
  33097. /**
  33098. * X subdivisions
  33099. */
  33100. get subdivisionsX(): number;
  33101. /**
  33102. * Y subdivisions
  33103. */
  33104. get subdivisionsY(): number;
  33105. /**
  33106. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  33107. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  33108. * @param chunksCount the number of subdivisions for x and y
  33109. * @param octreeBlocksSize (Default: 32)
  33110. */
  33111. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  33112. /**
  33113. * Returns a height (y) value in the Worl system :
  33114. * the ground altitude at the coordinates (x, z) expressed in the World system.
  33115. * @param x x coordinate
  33116. * @param z z coordinate
  33117. * @returns the ground y position if (x, z) are outside the ground surface.
  33118. */
  33119. getHeightAtCoordinates(x: number, z: number): number;
  33120. /**
  33121. * Returns a normalized vector (Vector3) orthogonal to the ground
  33122. * at the ground coordinates (x, z) expressed in the World system.
  33123. * @param x x coordinate
  33124. * @param z z coordinate
  33125. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  33126. */
  33127. getNormalAtCoordinates(x: number, z: number): Vector3;
  33128. /**
  33129. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  33130. * at the ground coordinates (x, z) expressed in the World system.
  33131. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  33132. * @param x x coordinate
  33133. * @param z z coordinate
  33134. * @param ref vector to store the result
  33135. * @returns the GroundMesh.
  33136. */
  33137. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  33138. /**
  33139. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  33140. * if the ground has been updated.
  33141. * This can be used in the render loop.
  33142. * @returns the GroundMesh.
  33143. */
  33144. updateCoordinateHeights(): GroundMesh;
  33145. private _getFacetAt;
  33146. private _initHeightQuads;
  33147. private _computeHeightQuads;
  33148. /**
  33149. * Serializes this ground mesh
  33150. * @param serializationObject object to write serialization to
  33151. */
  33152. serialize(serializationObject: any): void;
  33153. /**
  33154. * Parses a serialized ground mesh
  33155. * @param parsedMesh the serialized mesh
  33156. * @param scene the scene to create the ground mesh in
  33157. * @returns the created ground mesh
  33158. */
  33159. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  33160. }
  33161. }
  33162. declare module "babylonjs/Physics/physicsJoint" {
  33163. import { Vector3 } from "babylonjs/Maths/math.vector";
  33164. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  33165. /**
  33166. * Interface for Physics-Joint data
  33167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33168. */
  33169. export interface PhysicsJointData {
  33170. /**
  33171. * The main pivot of the joint
  33172. */
  33173. mainPivot?: Vector3;
  33174. /**
  33175. * The connected pivot of the joint
  33176. */
  33177. connectedPivot?: Vector3;
  33178. /**
  33179. * The main axis of the joint
  33180. */
  33181. mainAxis?: Vector3;
  33182. /**
  33183. * The connected axis of the joint
  33184. */
  33185. connectedAxis?: Vector3;
  33186. /**
  33187. * The collision of the joint
  33188. */
  33189. collision?: boolean;
  33190. /**
  33191. * Native Oimo/Cannon/Energy data
  33192. */
  33193. nativeParams?: any;
  33194. }
  33195. /**
  33196. * This is a holder class for the physics joint created by the physics plugin
  33197. * It holds a set of functions to control the underlying joint
  33198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33199. */
  33200. export class PhysicsJoint {
  33201. /**
  33202. * The type of the physics joint
  33203. */
  33204. type: number;
  33205. /**
  33206. * The data for the physics joint
  33207. */
  33208. jointData: PhysicsJointData;
  33209. private _physicsJoint;
  33210. protected _physicsPlugin: IPhysicsEnginePlugin;
  33211. /**
  33212. * Initializes the physics joint
  33213. * @param type The type of the physics joint
  33214. * @param jointData The data for the physics joint
  33215. */
  33216. constructor(
  33217. /**
  33218. * The type of the physics joint
  33219. */
  33220. type: number,
  33221. /**
  33222. * The data for the physics joint
  33223. */
  33224. jointData: PhysicsJointData);
  33225. /**
  33226. * Gets the physics joint
  33227. */
  33228. get physicsJoint(): any;
  33229. /**
  33230. * Sets the physics joint
  33231. */
  33232. set physicsJoint(newJoint: any);
  33233. /**
  33234. * Sets the physics plugin
  33235. */
  33236. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  33237. /**
  33238. * Execute a function that is physics-plugin specific.
  33239. * @param {Function} func the function that will be executed.
  33240. * It accepts two parameters: the physics world and the physics joint
  33241. */
  33242. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33243. /**
  33244. * Distance-Joint type
  33245. */
  33246. static DistanceJoint: number;
  33247. /**
  33248. * Hinge-Joint type
  33249. */
  33250. static HingeJoint: number;
  33251. /**
  33252. * Ball-and-Socket joint type
  33253. */
  33254. static BallAndSocketJoint: number;
  33255. /**
  33256. * Wheel-Joint type
  33257. */
  33258. static WheelJoint: number;
  33259. /**
  33260. * Slider-Joint type
  33261. */
  33262. static SliderJoint: number;
  33263. /**
  33264. * Prismatic-Joint type
  33265. */
  33266. static PrismaticJoint: number;
  33267. /**
  33268. * Universal-Joint type
  33269. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33270. */
  33271. static UniversalJoint: number;
  33272. /**
  33273. * Hinge-Joint 2 type
  33274. */
  33275. static Hinge2Joint: number;
  33276. /**
  33277. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33278. */
  33279. static PointToPointJoint: number;
  33280. /**
  33281. * Spring-Joint type
  33282. */
  33283. static SpringJoint: number;
  33284. /**
  33285. * Lock-Joint type
  33286. */
  33287. static LockJoint: number;
  33288. }
  33289. /**
  33290. * A class representing a physics distance joint
  33291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33292. */
  33293. export class DistanceJoint extends PhysicsJoint {
  33294. /**
  33295. *
  33296. * @param jointData The data for the Distance-Joint
  33297. */
  33298. constructor(jointData: DistanceJointData);
  33299. /**
  33300. * Update the predefined distance.
  33301. * @param maxDistance The maximum preferred distance
  33302. * @param minDistance The minimum preferred distance
  33303. */
  33304. updateDistance(maxDistance: number, minDistance?: number): void;
  33305. }
  33306. /**
  33307. * Represents a Motor-Enabled Joint
  33308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33309. */
  33310. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33311. /**
  33312. * Initializes the Motor-Enabled Joint
  33313. * @param type The type of the joint
  33314. * @param jointData The physica joint data for the joint
  33315. */
  33316. constructor(type: number, jointData: PhysicsJointData);
  33317. /**
  33318. * Set the motor values.
  33319. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33320. * @param force the force to apply
  33321. * @param maxForce max force for this motor.
  33322. */
  33323. setMotor(force?: number, maxForce?: number): void;
  33324. /**
  33325. * Set the motor's limits.
  33326. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33327. * @param upperLimit The upper limit of the motor
  33328. * @param lowerLimit The lower limit of the motor
  33329. */
  33330. setLimit(upperLimit: number, lowerLimit?: number): void;
  33331. }
  33332. /**
  33333. * This class represents a single physics Hinge-Joint
  33334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33335. */
  33336. export class HingeJoint extends MotorEnabledJoint {
  33337. /**
  33338. * Initializes the Hinge-Joint
  33339. * @param jointData The joint data for the Hinge-Joint
  33340. */
  33341. constructor(jointData: PhysicsJointData);
  33342. /**
  33343. * Set the motor values.
  33344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33345. * @param {number} force the force to apply
  33346. * @param {number} maxForce max force for this motor.
  33347. */
  33348. setMotor(force?: number, maxForce?: number): void;
  33349. /**
  33350. * Set the motor's limits.
  33351. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33352. * @param upperLimit The upper limit of the motor
  33353. * @param lowerLimit The lower limit of the motor
  33354. */
  33355. setLimit(upperLimit: number, lowerLimit?: number): void;
  33356. }
  33357. /**
  33358. * This class represents a dual hinge physics joint (same as wheel joint)
  33359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33360. */
  33361. export class Hinge2Joint extends MotorEnabledJoint {
  33362. /**
  33363. * Initializes the Hinge2-Joint
  33364. * @param jointData The joint data for the Hinge2-Joint
  33365. */
  33366. constructor(jointData: PhysicsJointData);
  33367. /**
  33368. * Set the motor values.
  33369. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33370. * @param {number} targetSpeed the speed the motor is to reach
  33371. * @param {number} maxForce max force for this motor.
  33372. * @param {motorIndex} the motor's index, 0 or 1.
  33373. */
  33374. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  33375. /**
  33376. * Set the motor limits.
  33377. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33378. * @param {number} upperLimit the upper limit
  33379. * @param {number} lowerLimit lower limit
  33380. * @param {motorIndex} the motor's index, 0 or 1.
  33381. */
  33382. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33383. }
  33384. /**
  33385. * Interface for a motor enabled joint
  33386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33387. */
  33388. export interface IMotorEnabledJoint {
  33389. /**
  33390. * Physics joint
  33391. */
  33392. physicsJoint: any;
  33393. /**
  33394. * Sets the motor of the motor-enabled joint
  33395. * @param force The force of the motor
  33396. * @param maxForce The maximum force of the motor
  33397. * @param motorIndex The index of the motor
  33398. */
  33399. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33400. /**
  33401. * Sets the limit of the motor
  33402. * @param upperLimit The upper limit of the motor
  33403. * @param lowerLimit The lower limit of the motor
  33404. * @param motorIndex The index of the motor
  33405. */
  33406. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33407. }
  33408. /**
  33409. * Joint data for a Distance-Joint
  33410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33411. */
  33412. export interface DistanceJointData extends PhysicsJointData {
  33413. /**
  33414. * Max distance the 2 joint objects can be apart
  33415. */
  33416. maxDistance: number;
  33417. }
  33418. /**
  33419. * Joint data from a spring joint
  33420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33421. */
  33422. export interface SpringJointData extends PhysicsJointData {
  33423. /**
  33424. * Length of the spring
  33425. */
  33426. length: number;
  33427. /**
  33428. * Stiffness of the spring
  33429. */
  33430. stiffness: number;
  33431. /**
  33432. * Damping of the spring
  33433. */
  33434. damping: number;
  33435. /** this callback will be called when applying the force to the impostors. */
  33436. forceApplicationCallback: () => void;
  33437. }
  33438. }
  33439. declare module "babylonjs/Physics/physicsRaycastResult" {
  33440. import { Vector3 } from "babylonjs/Maths/math.vector";
  33441. /**
  33442. * Holds the data for the raycast result
  33443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33444. */
  33445. export class PhysicsRaycastResult {
  33446. private _hasHit;
  33447. private _hitDistance;
  33448. private _hitNormalWorld;
  33449. private _hitPointWorld;
  33450. private _rayFromWorld;
  33451. private _rayToWorld;
  33452. /**
  33453. * Gets if there was a hit
  33454. */
  33455. get hasHit(): boolean;
  33456. /**
  33457. * Gets the distance from the hit
  33458. */
  33459. get hitDistance(): number;
  33460. /**
  33461. * Gets the hit normal/direction in the world
  33462. */
  33463. get hitNormalWorld(): Vector3;
  33464. /**
  33465. * Gets the hit point in the world
  33466. */
  33467. get hitPointWorld(): Vector3;
  33468. /**
  33469. * Gets the ray "start point" of the ray in the world
  33470. */
  33471. get rayFromWorld(): Vector3;
  33472. /**
  33473. * Gets the ray "end point" of the ray in the world
  33474. */
  33475. get rayToWorld(): Vector3;
  33476. /**
  33477. * Sets the hit data (normal & point in world space)
  33478. * @param hitNormalWorld defines the normal in world space
  33479. * @param hitPointWorld defines the point in world space
  33480. */
  33481. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33482. /**
  33483. * Sets the distance from the start point to the hit point
  33484. * @param distance
  33485. */
  33486. setHitDistance(distance: number): void;
  33487. /**
  33488. * Calculates the distance manually
  33489. */
  33490. calculateHitDistance(): void;
  33491. /**
  33492. * Resets all the values to default
  33493. * @param from The from point on world space
  33494. * @param to The to point on world space
  33495. */
  33496. reset(from?: Vector3, to?: Vector3): void;
  33497. }
  33498. /**
  33499. * Interface for the size containing width and height
  33500. */
  33501. interface IXYZ {
  33502. /**
  33503. * X
  33504. */
  33505. x: number;
  33506. /**
  33507. * Y
  33508. */
  33509. y: number;
  33510. /**
  33511. * Z
  33512. */
  33513. z: number;
  33514. }
  33515. }
  33516. declare module "babylonjs/Physics/IPhysicsEngine" {
  33517. import { Nullable } from "babylonjs/types";
  33518. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33520. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33521. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33522. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33523. /**
  33524. * Interface used to describe a physics joint
  33525. */
  33526. export interface PhysicsImpostorJoint {
  33527. /** Defines the main impostor to which the joint is linked */
  33528. mainImpostor: PhysicsImpostor;
  33529. /** Defines the impostor that is connected to the main impostor using this joint */
  33530. connectedImpostor: PhysicsImpostor;
  33531. /** Defines the joint itself */
  33532. joint: PhysicsJoint;
  33533. }
  33534. /** @hidden */
  33535. export interface IPhysicsEnginePlugin {
  33536. world: any;
  33537. name: string;
  33538. setGravity(gravity: Vector3): void;
  33539. setTimeStep(timeStep: number): void;
  33540. getTimeStep(): number;
  33541. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33542. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33543. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33544. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33545. removePhysicsBody(impostor: PhysicsImpostor): void;
  33546. generateJoint(joint: PhysicsImpostorJoint): void;
  33547. removeJoint(joint: PhysicsImpostorJoint): void;
  33548. isSupported(): boolean;
  33549. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33550. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33551. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33552. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33553. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33554. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33555. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33556. getBodyMass(impostor: PhysicsImpostor): number;
  33557. getBodyFriction(impostor: PhysicsImpostor): number;
  33558. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33559. getBodyRestitution(impostor: PhysicsImpostor): number;
  33560. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33561. getBodyPressure?(impostor: PhysicsImpostor): number;
  33562. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33563. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33564. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33565. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33566. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33567. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33568. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33569. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33570. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33571. sleepBody(impostor: PhysicsImpostor): void;
  33572. wakeUpBody(impostor: PhysicsImpostor): void;
  33573. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33574. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33575. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33576. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33577. getRadius(impostor: PhysicsImpostor): number;
  33578. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33579. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33580. dispose(): void;
  33581. }
  33582. /**
  33583. * Interface used to define a physics engine
  33584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33585. */
  33586. export interface IPhysicsEngine {
  33587. /**
  33588. * Gets the gravity vector used by the simulation
  33589. */
  33590. gravity: Vector3;
  33591. /**
  33592. * Sets the gravity vector used by the simulation
  33593. * @param gravity defines the gravity vector to use
  33594. */
  33595. setGravity(gravity: Vector3): void;
  33596. /**
  33597. * Set the time step of the physics engine.
  33598. * Default is 1/60.
  33599. * To slow it down, enter 1/600 for example.
  33600. * To speed it up, 1/30
  33601. * @param newTimeStep the new timestep to apply to this world.
  33602. */
  33603. setTimeStep(newTimeStep: number): void;
  33604. /**
  33605. * Get the time step of the physics engine.
  33606. * @returns the current time step
  33607. */
  33608. getTimeStep(): number;
  33609. /**
  33610. * Set the sub time step of the physics engine.
  33611. * Default is 0 meaning there is no sub steps
  33612. * To increase physics resolution precision, set a small value (like 1 ms)
  33613. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33614. */
  33615. setSubTimeStep(subTimeStep: number): void;
  33616. /**
  33617. * Get the sub time step of the physics engine.
  33618. * @returns the current sub time step
  33619. */
  33620. getSubTimeStep(): number;
  33621. /**
  33622. * Release all resources
  33623. */
  33624. dispose(): void;
  33625. /**
  33626. * Gets the name of the current physics plugin
  33627. * @returns the name of the plugin
  33628. */
  33629. getPhysicsPluginName(): string;
  33630. /**
  33631. * Adding a new impostor for the impostor tracking.
  33632. * This will be done by the impostor itself.
  33633. * @param impostor the impostor to add
  33634. */
  33635. addImpostor(impostor: PhysicsImpostor): void;
  33636. /**
  33637. * Remove an impostor from the engine.
  33638. * This impostor and its mesh will not longer be updated by the physics engine.
  33639. * @param impostor the impostor to remove
  33640. */
  33641. removeImpostor(impostor: PhysicsImpostor): void;
  33642. /**
  33643. * Add a joint to the physics engine
  33644. * @param mainImpostor defines the main impostor to which the joint is added.
  33645. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33646. * @param joint defines the joint that will connect both impostors.
  33647. */
  33648. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33649. /**
  33650. * Removes a joint from the simulation
  33651. * @param mainImpostor defines the impostor used with the joint
  33652. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33653. * @param joint defines the joint to remove
  33654. */
  33655. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33656. /**
  33657. * Gets the current plugin used to run the simulation
  33658. * @returns current plugin
  33659. */
  33660. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33661. /**
  33662. * Gets the list of physic impostors
  33663. * @returns an array of PhysicsImpostor
  33664. */
  33665. getImpostors(): Array<PhysicsImpostor>;
  33666. /**
  33667. * Gets the impostor for a physics enabled object
  33668. * @param object defines the object impersonated by the impostor
  33669. * @returns the PhysicsImpostor or null if not found
  33670. */
  33671. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33672. /**
  33673. * Gets the impostor for a physics body object
  33674. * @param body defines physics body used by the impostor
  33675. * @returns the PhysicsImpostor or null if not found
  33676. */
  33677. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33678. /**
  33679. * Does a raycast in the physics world
  33680. * @param from when should the ray start?
  33681. * @param to when should the ray end?
  33682. * @returns PhysicsRaycastResult
  33683. */
  33684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33685. /**
  33686. * Called by the scene. No need to call it.
  33687. * @param delta defines the timespam between frames
  33688. */
  33689. _step(delta: number): void;
  33690. }
  33691. }
  33692. declare module "babylonjs/Physics/physicsImpostor" {
  33693. import { Nullable, IndicesArray } from "babylonjs/types";
  33694. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33695. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33697. import { Scene } from "babylonjs/scene";
  33698. import { Bone } from "babylonjs/Bones/bone";
  33699. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33700. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33701. import { Space } from "babylonjs/Maths/math.axis";
  33702. /**
  33703. * The interface for the physics imposter parameters
  33704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33705. */
  33706. export interface PhysicsImpostorParameters {
  33707. /**
  33708. * The mass of the physics imposter
  33709. */
  33710. mass: number;
  33711. /**
  33712. * The friction of the physics imposter
  33713. */
  33714. friction?: number;
  33715. /**
  33716. * The coefficient of restitution of the physics imposter
  33717. */
  33718. restitution?: number;
  33719. /**
  33720. * The native options of the physics imposter
  33721. */
  33722. nativeOptions?: any;
  33723. /**
  33724. * Specifies if the parent should be ignored
  33725. */
  33726. ignoreParent?: boolean;
  33727. /**
  33728. * Specifies if bi-directional transformations should be disabled
  33729. */
  33730. disableBidirectionalTransformation?: boolean;
  33731. /**
  33732. * The pressure inside the physics imposter, soft object only
  33733. */
  33734. pressure?: number;
  33735. /**
  33736. * The stiffness the physics imposter, soft object only
  33737. */
  33738. stiffness?: number;
  33739. /**
  33740. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33741. */
  33742. velocityIterations?: number;
  33743. /**
  33744. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33745. */
  33746. positionIterations?: number;
  33747. /**
  33748. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33749. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33750. * Add to fix multiple points
  33751. */
  33752. fixedPoints?: number;
  33753. /**
  33754. * The collision margin around a soft object
  33755. */
  33756. margin?: number;
  33757. /**
  33758. * The collision margin around a soft object
  33759. */
  33760. damping?: number;
  33761. /**
  33762. * The path for a rope based on an extrusion
  33763. */
  33764. path?: any;
  33765. /**
  33766. * The shape of an extrusion used for a rope based on an extrusion
  33767. */
  33768. shape?: any;
  33769. }
  33770. /**
  33771. * Interface for a physics-enabled object
  33772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33773. */
  33774. export interface IPhysicsEnabledObject {
  33775. /**
  33776. * The position of the physics-enabled object
  33777. */
  33778. position: Vector3;
  33779. /**
  33780. * The rotation of the physics-enabled object
  33781. */
  33782. rotationQuaternion: Nullable<Quaternion>;
  33783. /**
  33784. * The scale of the physics-enabled object
  33785. */
  33786. scaling: Vector3;
  33787. /**
  33788. * The rotation of the physics-enabled object
  33789. */
  33790. rotation?: Vector3;
  33791. /**
  33792. * The parent of the physics-enabled object
  33793. */
  33794. parent?: any;
  33795. /**
  33796. * The bounding info of the physics-enabled object
  33797. * @returns The bounding info of the physics-enabled object
  33798. */
  33799. getBoundingInfo(): BoundingInfo;
  33800. /**
  33801. * Computes the world matrix
  33802. * @param force Specifies if the world matrix should be computed by force
  33803. * @returns A world matrix
  33804. */
  33805. computeWorldMatrix(force: boolean): Matrix;
  33806. /**
  33807. * Gets the world matrix
  33808. * @returns A world matrix
  33809. */
  33810. getWorldMatrix?(): Matrix;
  33811. /**
  33812. * Gets the child meshes
  33813. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33814. * @returns An array of abstract meshes
  33815. */
  33816. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33817. /**
  33818. * Gets the vertex data
  33819. * @param kind The type of vertex data
  33820. * @returns A nullable array of numbers, or a float32 array
  33821. */
  33822. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33823. /**
  33824. * Gets the indices from the mesh
  33825. * @returns A nullable array of index arrays
  33826. */
  33827. getIndices?(): Nullable<IndicesArray>;
  33828. /**
  33829. * Gets the scene from the mesh
  33830. * @returns the indices array or null
  33831. */
  33832. getScene?(): Scene;
  33833. /**
  33834. * Gets the absolute position from the mesh
  33835. * @returns the absolute position
  33836. */
  33837. getAbsolutePosition(): Vector3;
  33838. /**
  33839. * Gets the absolute pivot point from the mesh
  33840. * @returns the absolute pivot point
  33841. */
  33842. getAbsolutePivotPoint(): Vector3;
  33843. /**
  33844. * Rotates the mesh
  33845. * @param axis The axis of rotation
  33846. * @param amount The amount of rotation
  33847. * @param space The space of the rotation
  33848. * @returns The rotation transform node
  33849. */
  33850. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33851. /**
  33852. * Translates the mesh
  33853. * @param axis The axis of translation
  33854. * @param distance The distance of translation
  33855. * @param space The space of the translation
  33856. * @returns The transform node
  33857. */
  33858. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33859. /**
  33860. * Sets the absolute position of the mesh
  33861. * @param absolutePosition The absolute position of the mesh
  33862. * @returns The transform node
  33863. */
  33864. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33865. /**
  33866. * Gets the class name of the mesh
  33867. * @returns The class name
  33868. */
  33869. getClassName(): string;
  33870. }
  33871. /**
  33872. * Represents a physics imposter
  33873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33874. */
  33875. export class PhysicsImpostor {
  33876. /**
  33877. * The physics-enabled object used as the physics imposter
  33878. */
  33879. object: IPhysicsEnabledObject;
  33880. /**
  33881. * The type of the physics imposter
  33882. */
  33883. type: number;
  33884. private _options;
  33885. private _scene?;
  33886. /**
  33887. * The default object size of the imposter
  33888. */
  33889. static DEFAULT_OBJECT_SIZE: Vector3;
  33890. /**
  33891. * The identity quaternion of the imposter
  33892. */
  33893. static IDENTITY_QUATERNION: Quaternion;
  33894. /** @hidden */
  33895. _pluginData: any;
  33896. private _physicsEngine;
  33897. private _physicsBody;
  33898. private _bodyUpdateRequired;
  33899. private _onBeforePhysicsStepCallbacks;
  33900. private _onAfterPhysicsStepCallbacks;
  33901. /** @hidden */
  33902. _onPhysicsCollideCallbacks: Array<{
  33903. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33904. otherImpostors: Array<PhysicsImpostor>;
  33905. }>;
  33906. private _deltaPosition;
  33907. private _deltaRotation;
  33908. private _deltaRotationConjugated;
  33909. /** @hidden */
  33910. _isFromLine: boolean;
  33911. private _parent;
  33912. private _isDisposed;
  33913. private static _tmpVecs;
  33914. private static _tmpQuat;
  33915. /**
  33916. * Specifies if the physics imposter is disposed
  33917. */
  33918. get isDisposed(): boolean;
  33919. /**
  33920. * Gets the mass of the physics imposter
  33921. */
  33922. get mass(): number;
  33923. set mass(value: number);
  33924. /**
  33925. * Gets the coefficient of friction
  33926. */
  33927. get friction(): number;
  33928. /**
  33929. * Sets the coefficient of friction
  33930. */
  33931. set friction(value: number);
  33932. /**
  33933. * Gets the coefficient of restitution
  33934. */
  33935. get restitution(): number;
  33936. /**
  33937. * Sets the coefficient of restitution
  33938. */
  33939. set restitution(value: number);
  33940. /**
  33941. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33942. */
  33943. get pressure(): number;
  33944. /**
  33945. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33946. */
  33947. set pressure(value: number);
  33948. /**
  33949. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33950. */
  33951. get stiffness(): number;
  33952. /**
  33953. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33954. */
  33955. set stiffness(value: number);
  33956. /**
  33957. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33958. */
  33959. get velocityIterations(): number;
  33960. /**
  33961. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33962. */
  33963. set velocityIterations(value: number);
  33964. /**
  33965. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33966. */
  33967. get positionIterations(): number;
  33968. /**
  33969. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33970. */
  33971. set positionIterations(value: number);
  33972. /**
  33973. * The unique id of the physics imposter
  33974. * set by the physics engine when adding this impostor to the array
  33975. */
  33976. uniqueId: number;
  33977. /**
  33978. * @hidden
  33979. */
  33980. soft: boolean;
  33981. /**
  33982. * @hidden
  33983. */
  33984. segments: number;
  33985. private _joints;
  33986. /**
  33987. * Initializes the physics imposter
  33988. * @param object The physics-enabled object used as the physics imposter
  33989. * @param type The type of the physics imposter
  33990. * @param _options The options for the physics imposter
  33991. * @param _scene The Babylon scene
  33992. */
  33993. constructor(
  33994. /**
  33995. * The physics-enabled object used as the physics imposter
  33996. */
  33997. object: IPhysicsEnabledObject,
  33998. /**
  33999. * The type of the physics imposter
  34000. */
  34001. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  34002. /**
  34003. * This function will completly initialize this impostor.
  34004. * It will create a new body - but only if this mesh has no parent.
  34005. * If it has, this impostor will not be used other than to define the impostor
  34006. * of the child mesh.
  34007. * @hidden
  34008. */
  34009. _init(): void;
  34010. private _getPhysicsParent;
  34011. /**
  34012. * Should a new body be generated.
  34013. * @returns boolean specifying if body initialization is required
  34014. */
  34015. isBodyInitRequired(): boolean;
  34016. /**
  34017. * Sets the updated scaling
  34018. * @param updated Specifies if the scaling is updated
  34019. */
  34020. setScalingUpdated(): void;
  34021. /**
  34022. * Force a regeneration of this or the parent's impostor's body.
  34023. * Use under cautious - This will remove all joints already implemented.
  34024. */
  34025. forceUpdate(): void;
  34026. /**
  34027. * Gets the body that holds this impostor. Either its own, or its parent.
  34028. */
  34029. get physicsBody(): any;
  34030. /**
  34031. * Get the parent of the physics imposter
  34032. * @returns Physics imposter or null
  34033. */
  34034. get parent(): Nullable<PhysicsImpostor>;
  34035. /**
  34036. * Sets the parent of the physics imposter
  34037. */
  34038. set parent(value: Nullable<PhysicsImpostor>);
  34039. /**
  34040. * Set the physics body. Used mainly by the physics engine/plugin
  34041. */
  34042. set physicsBody(physicsBody: any);
  34043. /**
  34044. * Resets the update flags
  34045. */
  34046. resetUpdateFlags(): void;
  34047. /**
  34048. * Gets the object extend size
  34049. * @returns the object extend size
  34050. */
  34051. getObjectExtendSize(): Vector3;
  34052. /**
  34053. * Gets the object center
  34054. * @returns The object center
  34055. */
  34056. getObjectCenter(): Vector3;
  34057. /**
  34058. * Get a specific parameter from the options parameters
  34059. * @param paramName The object parameter name
  34060. * @returns The object parameter
  34061. */
  34062. getParam(paramName: string): any;
  34063. /**
  34064. * Sets a specific parameter in the options given to the physics plugin
  34065. * @param paramName The parameter name
  34066. * @param value The value of the parameter
  34067. */
  34068. setParam(paramName: string, value: number): void;
  34069. /**
  34070. * Specifically change the body's mass option. Won't recreate the physics body object
  34071. * @param mass The mass of the physics imposter
  34072. */
  34073. setMass(mass: number): void;
  34074. /**
  34075. * Gets the linear velocity
  34076. * @returns linear velocity or null
  34077. */
  34078. getLinearVelocity(): Nullable<Vector3>;
  34079. /**
  34080. * Sets the linear velocity
  34081. * @param velocity linear velocity or null
  34082. */
  34083. setLinearVelocity(velocity: Nullable<Vector3>): void;
  34084. /**
  34085. * Gets the angular velocity
  34086. * @returns angular velocity or null
  34087. */
  34088. getAngularVelocity(): Nullable<Vector3>;
  34089. /**
  34090. * Sets the angular velocity
  34091. * @param velocity The velocity or null
  34092. */
  34093. setAngularVelocity(velocity: Nullable<Vector3>): void;
  34094. /**
  34095. * Execute a function with the physics plugin native code
  34096. * Provide a function the will have two variables - the world object and the physics body object
  34097. * @param func The function to execute with the physics plugin native code
  34098. */
  34099. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  34100. /**
  34101. * Register a function that will be executed before the physics world is stepping forward
  34102. * @param func The function to execute before the physics world is stepped forward
  34103. */
  34104. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34105. /**
  34106. * Unregister a function that will be executed before the physics world is stepping forward
  34107. * @param func The function to execute before the physics world is stepped forward
  34108. */
  34109. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34110. /**
  34111. * Register a function that will be executed after the physics step
  34112. * @param func The function to execute after physics step
  34113. */
  34114. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34115. /**
  34116. * Unregisters a function that will be executed after the physics step
  34117. * @param func The function to execute after physics step
  34118. */
  34119. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34120. /**
  34121. * register a function that will be executed when this impostor collides against a different body
  34122. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34123. * @param func Callback that is executed on collision
  34124. */
  34125. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34126. /**
  34127. * Unregisters the physics imposter on contact
  34128. * @param collideAgainst The physics object to collide against
  34129. * @param func Callback to execute on collision
  34130. */
  34131. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34132. private _tmpQuat;
  34133. private _tmpQuat2;
  34134. /**
  34135. * Get the parent rotation
  34136. * @returns The parent rotation
  34137. */
  34138. getParentsRotation(): Quaternion;
  34139. /**
  34140. * this function is executed by the physics engine.
  34141. */
  34142. beforeStep: () => void;
  34143. /**
  34144. * this function is executed by the physics engine
  34145. */
  34146. afterStep: () => void;
  34147. /**
  34148. * Legacy collision detection event support
  34149. */
  34150. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34151. /**
  34152. * event and body object due to cannon's event-based architecture.
  34153. */
  34154. onCollide: (e: {
  34155. body: any;
  34156. point: Nullable<Vector3>;
  34157. }) => void;
  34158. /**
  34159. * Apply a force
  34160. * @param force The force to apply
  34161. * @param contactPoint The contact point for the force
  34162. * @returns The physics imposter
  34163. */
  34164. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34165. /**
  34166. * Apply an impulse
  34167. * @param force The impulse force
  34168. * @param contactPoint The contact point for the impulse force
  34169. * @returns The physics imposter
  34170. */
  34171. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34172. /**
  34173. * A help function to create a joint
  34174. * @param otherImpostor A physics imposter used to create a joint
  34175. * @param jointType The type of joint
  34176. * @param jointData The data for the joint
  34177. * @returns The physics imposter
  34178. */
  34179. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34180. /**
  34181. * Add a joint to this impostor with a different impostor
  34182. * @param otherImpostor A physics imposter used to add a joint
  34183. * @param joint The joint to add
  34184. * @returns The physics imposter
  34185. */
  34186. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34187. /**
  34188. * Add an anchor to a cloth impostor
  34189. * @param otherImpostor rigid impostor to anchor to
  34190. * @param width ratio across width from 0 to 1
  34191. * @param height ratio up height from 0 to 1
  34192. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  34193. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  34194. * @returns impostor the soft imposter
  34195. */
  34196. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34197. /**
  34198. * Add a hook to a rope impostor
  34199. * @param otherImpostor rigid impostor to anchor to
  34200. * @param length ratio across rope from 0 to 1
  34201. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  34202. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  34203. * @returns impostor the rope imposter
  34204. */
  34205. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34206. /**
  34207. * Will keep this body still, in a sleep mode.
  34208. * @returns the physics imposter
  34209. */
  34210. sleep(): PhysicsImpostor;
  34211. /**
  34212. * Wake the body up.
  34213. * @returns The physics imposter
  34214. */
  34215. wakeUp(): PhysicsImpostor;
  34216. /**
  34217. * Clones the physics imposter
  34218. * @param newObject The physics imposter clones to this physics-enabled object
  34219. * @returns A nullable physics imposter
  34220. */
  34221. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34222. /**
  34223. * Disposes the physics imposter
  34224. */
  34225. dispose(): void;
  34226. /**
  34227. * Sets the delta position
  34228. * @param position The delta position amount
  34229. */
  34230. setDeltaPosition(position: Vector3): void;
  34231. /**
  34232. * Sets the delta rotation
  34233. * @param rotation The delta rotation amount
  34234. */
  34235. setDeltaRotation(rotation: Quaternion): void;
  34236. /**
  34237. * Gets the box size of the physics imposter and stores the result in the input parameter
  34238. * @param result Stores the box size
  34239. * @returns The physics imposter
  34240. */
  34241. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34242. /**
  34243. * Gets the radius of the physics imposter
  34244. * @returns Radius of the physics imposter
  34245. */
  34246. getRadius(): number;
  34247. /**
  34248. * Sync a bone with this impostor
  34249. * @param bone The bone to sync to the impostor.
  34250. * @param boneMesh The mesh that the bone is influencing.
  34251. * @param jointPivot The pivot of the joint / bone in local space.
  34252. * @param distToJoint Optional distance from the impostor to the joint.
  34253. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34254. */
  34255. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34256. /**
  34257. * Sync impostor to a bone
  34258. * @param bone The bone that the impostor will be synced to.
  34259. * @param boneMesh The mesh that the bone is influencing.
  34260. * @param jointPivot The pivot of the joint / bone in local space.
  34261. * @param distToJoint Optional distance from the impostor to the joint.
  34262. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34263. * @param boneAxis Optional vector3 axis the bone is aligned with
  34264. */
  34265. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34266. /**
  34267. * No-Imposter type
  34268. */
  34269. static NoImpostor: number;
  34270. /**
  34271. * Sphere-Imposter type
  34272. */
  34273. static SphereImpostor: number;
  34274. /**
  34275. * Box-Imposter type
  34276. */
  34277. static BoxImpostor: number;
  34278. /**
  34279. * Plane-Imposter type
  34280. */
  34281. static PlaneImpostor: number;
  34282. /**
  34283. * Mesh-imposter type
  34284. */
  34285. static MeshImpostor: number;
  34286. /**
  34287. * Capsule-Impostor type (Ammo.js plugin only)
  34288. */
  34289. static CapsuleImpostor: number;
  34290. /**
  34291. * Cylinder-Imposter type
  34292. */
  34293. static CylinderImpostor: number;
  34294. /**
  34295. * Particle-Imposter type
  34296. */
  34297. static ParticleImpostor: number;
  34298. /**
  34299. * Heightmap-Imposter type
  34300. */
  34301. static HeightmapImpostor: number;
  34302. /**
  34303. * ConvexHull-Impostor type (Ammo.js plugin only)
  34304. */
  34305. static ConvexHullImpostor: number;
  34306. /**
  34307. * Custom-Imposter type (Ammo.js plugin only)
  34308. */
  34309. static CustomImpostor: number;
  34310. /**
  34311. * Rope-Imposter type
  34312. */
  34313. static RopeImpostor: number;
  34314. /**
  34315. * Cloth-Imposter type
  34316. */
  34317. static ClothImpostor: number;
  34318. /**
  34319. * Softbody-Imposter type
  34320. */
  34321. static SoftbodyImpostor: number;
  34322. }
  34323. }
  34324. declare module "babylonjs/Meshes/mesh" {
  34325. import { Observable } from "babylonjs/Misc/observable";
  34326. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34327. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34328. import { Camera } from "babylonjs/Cameras/camera";
  34329. import { Scene } from "babylonjs/scene";
  34330. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34331. import { Color4 } from "babylonjs/Maths/math.color";
  34332. import { Engine } from "babylonjs/Engines/engine";
  34333. import { Node } from "babylonjs/node";
  34334. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  34335. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  34336. import { Buffer } from "babylonjs/Meshes/buffer";
  34337. import { Geometry } from "babylonjs/Meshes/geometry";
  34338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34339. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34340. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  34341. import { Effect } from "babylonjs/Materials/effect";
  34342. import { Material } from "babylonjs/Materials/material";
  34343. import { Skeleton } from "babylonjs/Bones/skeleton";
  34344. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34345. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  34346. import { Path3D } from "babylonjs/Maths/math.path";
  34347. import { Plane } from "babylonjs/Maths/math.plane";
  34348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34349. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34350. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  34351. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  34352. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  34353. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  34354. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  34355. /**
  34356. * @hidden
  34357. **/
  34358. export class _CreationDataStorage {
  34359. closePath?: boolean;
  34360. closeArray?: boolean;
  34361. idx: number[];
  34362. dashSize: number;
  34363. gapSize: number;
  34364. path3D: Path3D;
  34365. pathArray: Vector3[][];
  34366. arc: number;
  34367. radius: number;
  34368. cap: number;
  34369. tessellation: number;
  34370. }
  34371. /**
  34372. * @hidden
  34373. **/
  34374. class _InstanceDataStorage {
  34375. visibleInstances: any;
  34376. batchCache: _InstancesBatch;
  34377. instancesBufferSize: number;
  34378. instancesBuffer: Nullable<Buffer>;
  34379. instancesData: Float32Array;
  34380. overridenInstanceCount: number;
  34381. isFrozen: boolean;
  34382. previousBatch: Nullable<_InstancesBatch>;
  34383. hardwareInstancedRendering: boolean;
  34384. sideOrientation: number;
  34385. manualUpdate: boolean;
  34386. previousRenderId: number;
  34387. }
  34388. /**
  34389. * @hidden
  34390. **/
  34391. export class _InstancesBatch {
  34392. mustReturn: boolean;
  34393. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  34394. renderSelf: boolean[];
  34395. hardwareInstancedRendering: boolean[];
  34396. }
  34397. /**
  34398. * @hidden
  34399. **/
  34400. class _ThinInstanceDataStorage {
  34401. instancesCount: number;
  34402. matrixBuffer: Nullable<Buffer>;
  34403. matrixBufferSize: number;
  34404. matrixData: Nullable<Float32Array>;
  34405. boundingVectors: Array<Vector3>;
  34406. worldMatrices: Nullable<Matrix[]>;
  34407. }
  34408. /**
  34409. * Class used to represent renderable models
  34410. */
  34411. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34412. /**
  34413. * Mesh side orientation : usually the external or front surface
  34414. */
  34415. static readonly FRONTSIDE: number;
  34416. /**
  34417. * Mesh side orientation : usually the internal or back surface
  34418. */
  34419. static readonly BACKSIDE: number;
  34420. /**
  34421. * Mesh side orientation : both internal and external or front and back surfaces
  34422. */
  34423. static readonly DOUBLESIDE: number;
  34424. /**
  34425. * Mesh side orientation : by default, `FRONTSIDE`
  34426. */
  34427. static readonly DEFAULTSIDE: number;
  34428. /**
  34429. * Mesh cap setting : no cap
  34430. */
  34431. static readonly NO_CAP: number;
  34432. /**
  34433. * Mesh cap setting : one cap at the beginning of the mesh
  34434. */
  34435. static readonly CAP_START: number;
  34436. /**
  34437. * Mesh cap setting : one cap at the end of the mesh
  34438. */
  34439. static readonly CAP_END: number;
  34440. /**
  34441. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34442. */
  34443. static readonly CAP_ALL: number;
  34444. /**
  34445. * Mesh pattern setting : no flip or rotate
  34446. */
  34447. static readonly NO_FLIP: number;
  34448. /**
  34449. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34450. */
  34451. static readonly FLIP_TILE: number;
  34452. /**
  34453. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34454. */
  34455. static readonly ROTATE_TILE: number;
  34456. /**
  34457. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34458. */
  34459. static readonly FLIP_ROW: number;
  34460. /**
  34461. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34462. */
  34463. static readonly ROTATE_ROW: number;
  34464. /**
  34465. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34466. */
  34467. static readonly FLIP_N_ROTATE_TILE: number;
  34468. /**
  34469. * Mesh pattern setting : rotate pattern and rotate
  34470. */
  34471. static readonly FLIP_N_ROTATE_ROW: number;
  34472. /**
  34473. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34474. */
  34475. static readonly CENTER: number;
  34476. /**
  34477. * Mesh tile positioning : part tiles on left
  34478. */
  34479. static readonly LEFT: number;
  34480. /**
  34481. * Mesh tile positioning : part tiles on right
  34482. */
  34483. static readonly RIGHT: number;
  34484. /**
  34485. * Mesh tile positioning : part tiles on top
  34486. */
  34487. static readonly TOP: number;
  34488. /**
  34489. * Mesh tile positioning : part tiles on bottom
  34490. */
  34491. static readonly BOTTOM: number;
  34492. /**
  34493. * Gets the default side orientation.
  34494. * @param orientation the orientation to value to attempt to get
  34495. * @returns the default orientation
  34496. * @hidden
  34497. */
  34498. static _GetDefaultSideOrientation(orientation?: number): number;
  34499. private _internalMeshDataInfo;
  34500. get computeBonesUsingShaders(): boolean;
  34501. set computeBonesUsingShaders(value: boolean);
  34502. /**
  34503. * An event triggered before rendering the mesh
  34504. */
  34505. get onBeforeRenderObservable(): Observable<Mesh>;
  34506. /**
  34507. * An event triggered before binding the mesh
  34508. */
  34509. get onBeforeBindObservable(): Observable<Mesh>;
  34510. /**
  34511. * An event triggered after rendering the mesh
  34512. */
  34513. get onAfterRenderObservable(): Observable<Mesh>;
  34514. /**
  34515. * An event triggered before drawing the mesh
  34516. */
  34517. get onBeforeDrawObservable(): Observable<Mesh>;
  34518. private _onBeforeDrawObserver;
  34519. /**
  34520. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34521. */
  34522. set onBeforeDraw(callback: () => void);
  34523. get hasInstances(): boolean;
  34524. get hasThinInstances(): boolean;
  34525. /**
  34526. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34527. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34528. */
  34529. delayLoadState: number;
  34530. /**
  34531. * Gets the list of instances created from this mesh
  34532. * it is not supposed to be modified manually.
  34533. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34534. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34535. */
  34536. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34537. /**
  34538. * Gets the file containing delay loading data for this mesh
  34539. */
  34540. delayLoadingFile: string;
  34541. /** @hidden */
  34542. _binaryInfo: any;
  34543. /**
  34544. * User defined function used to change how LOD level selection is done
  34545. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34546. */
  34547. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34548. /**
  34549. * Gets or sets the morph target manager
  34550. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34551. */
  34552. get morphTargetManager(): Nullable<MorphTargetManager>;
  34553. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34554. /** @hidden */
  34555. _creationDataStorage: Nullable<_CreationDataStorage>;
  34556. /** @hidden */
  34557. _geometry: Nullable<Geometry>;
  34558. /** @hidden */
  34559. _delayInfo: Array<string>;
  34560. /** @hidden */
  34561. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34562. /** @hidden */
  34563. _instanceDataStorage: _InstanceDataStorage;
  34564. /** @hidden */
  34565. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34566. private _effectiveMaterial;
  34567. /** @hidden */
  34568. _shouldGenerateFlatShading: boolean;
  34569. /** @hidden */
  34570. _originalBuilderSideOrientation: number;
  34571. /**
  34572. * Use this property to change the original side orientation defined at construction time
  34573. */
  34574. overrideMaterialSideOrientation: Nullable<number>;
  34575. /**
  34576. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  34577. * Note this will reduce performance when set to true.
  34578. */
  34579. ignoreCameraMaxZ: boolean;
  34580. /**
  34581. * Gets the source mesh (the one used to clone this one from)
  34582. */
  34583. get source(): Nullable<Mesh>;
  34584. /**
  34585. * Gets the list of clones of this mesh
  34586. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34587. * Note that useClonedMeshMap=true is the default setting
  34588. */
  34589. get cloneMeshMap(): Nullable<{
  34590. [id: string]: Mesh | undefined;
  34591. }>;
  34592. /**
  34593. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34594. */
  34595. get isUnIndexed(): boolean;
  34596. set isUnIndexed(value: boolean);
  34597. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34598. get worldMatrixInstancedBuffer(): Float32Array;
  34599. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34600. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34601. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34602. /**
  34603. * @constructor
  34604. * @param name The value used by scene.getMeshByName() to do a lookup.
  34605. * @param scene The scene to add this mesh to.
  34606. * @param parent The parent of this mesh, if it has one
  34607. * @param source An optional Mesh from which geometry is shared, cloned.
  34608. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34609. * When false, achieved by calling a clone(), also passing False.
  34610. * This will make creation of children, recursive.
  34611. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34612. */
  34613. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34614. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34615. doNotInstantiate: boolean;
  34616. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34617. /**
  34618. * Gets the class name
  34619. * @returns the string "Mesh".
  34620. */
  34621. getClassName(): string;
  34622. /** @hidden */
  34623. get _isMesh(): boolean;
  34624. /**
  34625. * Returns a description of this mesh
  34626. * @param fullDetails define if full details about this mesh must be used
  34627. * @returns a descriptive string representing this mesh
  34628. */
  34629. toString(fullDetails?: boolean): string;
  34630. /** @hidden */
  34631. _unBindEffect(): void;
  34632. /**
  34633. * Gets a boolean indicating if this mesh has LOD
  34634. */
  34635. get hasLODLevels(): boolean;
  34636. /**
  34637. * Gets the list of MeshLODLevel associated with the current mesh
  34638. * @returns an array of MeshLODLevel
  34639. */
  34640. getLODLevels(): MeshLODLevel[];
  34641. private _sortLODLevels;
  34642. /**
  34643. * Add a mesh as LOD level triggered at the given distance.
  34644. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34645. * @param distance The distance from the center of the object to show this level
  34646. * @param mesh The mesh to be added as LOD level (can be null)
  34647. * @return This mesh (for chaining)
  34648. */
  34649. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34650. /**
  34651. * Returns the LOD level mesh at the passed distance or null if not found.
  34652. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34653. * @param distance The distance from the center of the object to show this level
  34654. * @returns a Mesh or `null`
  34655. */
  34656. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34657. /**
  34658. * Remove a mesh from the LOD array
  34659. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34660. * @param mesh defines the mesh to be removed
  34661. * @return This mesh (for chaining)
  34662. */
  34663. removeLODLevel(mesh: Mesh): Mesh;
  34664. /**
  34665. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34666. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34667. * @param camera defines the camera to use to compute distance
  34668. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34669. * @return This mesh (for chaining)
  34670. */
  34671. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34672. /**
  34673. * Gets the mesh internal Geometry object
  34674. */
  34675. get geometry(): Nullable<Geometry>;
  34676. /**
  34677. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34678. * @returns the total number of vertices
  34679. */
  34680. getTotalVertices(): number;
  34681. /**
  34682. * Returns the content of an associated vertex buffer
  34683. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34684. * - VertexBuffer.PositionKind
  34685. * - VertexBuffer.UVKind
  34686. * - VertexBuffer.UV2Kind
  34687. * - VertexBuffer.UV3Kind
  34688. * - VertexBuffer.UV4Kind
  34689. * - VertexBuffer.UV5Kind
  34690. * - VertexBuffer.UV6Kind
  34691. * - VertexBuffer.ColorKind
  34692. * - VertexBuffer.MatricesIndicesKind
  34693. * - VertexBuffer.MatricesIndicesExtraKind
  34694. * - VertexBuffer.MatricesWeightsKind
  34695. * - VertexBuffer.MatricesWeightsExtraKind
  34696. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  34697. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34698. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34699. */
  34700. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34701. /**
  34702. * Returns the mesh VertexBuffer object from the requested `kind`
  34703. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34704. * - VertexBuffer.PositionKind
  34705. * - VertexBuffer.NormalKind
  34706. * - VertexBuffer.UVKind
  34707. * - VertexBuffer.UV2Kind
  34708. * - VertexBuffer.UV3Kind
  34709. * - VertexBuffer.UV4Kind
  34710. * - VertexBuffer.UV5Kind
  34711. * - VertexBuffer.UV6Kind
  34712. * - VertexBuffer.ColorKind
  34713. * - VertexBuffer.MatricesIndicesKind
  34714. * - VertexBuffer.MatricesIndicesExtraKind
  34715. * - VertexBuffer.MatricesWeightsKind
  34716. * - VertexBuffer.MatricesWeightsExtraKind
  34717. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34718. */
  34719. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34720. /**
  34721. * Tests if a specific vertex buffer is associated with this mesh
  34722. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34723. * - VertexBuffer.PositionKind
  34724. * - VertexBuffer.NormalKind
  34725. * - VertexBuffer.UVKind
  34726. * - VertexBuffer.UV2Kind
  34727. * - VertexBuffer.UV3Kind
  34728. * - VertexBuffer.UV4Kind
  34729. * - VertexBuffer.UV5Kind
  34730. * - VertexBuffer.UV6Kind
  34731. * - VertexBuffer.ColorKind
  34732. * - VertexBuffer.MatricesIndicesKind
  34733. * - VertexBuffer.MatricesIndicesExtraKind
  34734. * - VertexBuffer.MatricesWeightsKind
  34735. * - VertexBuffer.MatricesWeightsExtraKind
  34736. * @returns a boolean
  34737. */
  34738. isVerticesDataPresent(kind: string): boolean;
  34739. /**
  34740. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34741. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34742. * - VertexBuffer.PositionKind
  34743. * - VertexBuffer.UVKind
  34744. * - VertexBuffer.UV2Kind
  34745. * - VertexBuffer.UV3Kind
  34746. * - VertexBuffer.UV4Kind
  34747. * - VertexBuffer.UV5Kind
  34748. * - VertexBuffer.UV6Kind
  34749. * - VertexBuffer.ColorKind
  34750. * - VertexBuffer.MatricesIndicesKind
  34751. * - VertexBuffer.MatricesIndicesExtraKind
  34752. * - VertexBuffer.MatricesWeightsKind
  34753. * - VertexBuffer.MatricesWeightsExtraKind
  34754. * @returns a boolean
  34755. */
  34756. isVertexBufferUpdatable(kind: string): boolean;
  34757. /**
  34758. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34759. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34760. * - VertexBuffer.PositionKind
  34761. * - VertexBuffer.NormalKind
  34762. * - VertexBuffer.UVKind
  34763. * - VertexBuffer.UV2Kind
  34764. * - VertexBuffer.UV3Kind
  34765. * - VertexBuffer.UV4Kind
  34766. * - VertexBuffer.UV5Kind
  34767. * - VertexBuffer.UV6Kind
  34768. * - VertexBuffer.ColorKind
  34769. * - VertexBuffer.MatricesIndicesKind
  34770. * - VertexBuffer.MatricesIndicesExtraKind
  34771. * - VertexBuffer.MatricesWeightsKind
  34772. * - VertexBuffer.MatricesWeightsExtraKind
  34773. * @returns an array of strings
  34774. */
  34775. getVerticesDataKinds(): string[];
  34776. /**
  34777. * Returns a positive integer : the total number of indices in this mesh geometry.
  34778. * @returns the numner of indices or zero if the mesh has no geometry.
  34779. */
  34780. getTotalIndices(): number;
  34781. /**
  34782. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34783. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  34784. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34785. * @returns the indices array or an empty array if the mesh has no geometry
  34786. */
  34787. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34788. get isBlocked(): boolean;
  34789. /**
  34790. * Determine if the current mesh is ready to be rendered
  34791. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34792. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34793. * @returns true if all associated assets are ready (material, textures, shaders)
  34794. */
  34795. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34796. /**
  34797. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  34798. */
  34799. get areNormalsFrozen(): boolean;
  34800. /**
  34801. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  34802. * @returns the current mesh
  34803. */
  34804. freezeNormals(): Mesh;
  34805. /**
  34806. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  34807. * @returns the current mesh
  34808. */
  34809. unfreezeNormals(): Mesh;
  34810. /**
  34811. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34812. */
  34813. set overridenInstanceCount(count: number);
  34814. /** @hidden */
  34815. _preActivate(): Mesh;
  34816. /** @hidden */
  34817. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34818. /** @hidden */
  34819. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34820. protected _afterComputeWorldMatrix(): void;
  34821. /** @hidden */
  34822. _postActivate(): void;
  34823. /**
  34824. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34825. * This means the mesh underlying bounding box and sphere are recomputed.
  34826. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34827. * @returns the current mesh
  34828. */
  34829. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34830. /** @hidden */
  34831. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34832. /**
  34833. * This function will subdivide the mesh into multiple submeshes
  34834. * @param count defines the expected number of submeshes
  34835. */
  34836. subdivide(count: number): void;
  34837. /**
  34838. * Copy a FloatArray into a specific associated vertex buffer
  34839. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34840. * - VertexBuffer.PositionKind
  34841. * - VertexBuffer.UVKind
  34842. * - VertexBuffer.UV2Kind
  34843. * - VertexBuffer.UV3Kind
  34844. * - VertexBuffer.UV4Kind
  34845. * - VertexBuffer.UV5Kind
  34846. * - VertexBuffer.UV6Kind
  34847. * - VertexBuffer.ColorKind
  34848. * - VertexBuffer.MatricesIndicesKind
  34849. * - VertexBuffer.MatricesIndicesExtraKind
  34850. * - VertexBuffer.MatricesWeightsKind
  34851. * - VertexBuffer.MatricesWeightsExtraKind
  34852. * @param data defines the data source
  34853. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34854. * @param stride defines the data stride size (can be null)
  34855. * @returns the current mesh
  34856. */
  34857. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34858. /**
  34859. * Delete a vertex buffer associated with this mesh
  34860. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34861. * - VertexBuffer.PositionKind
  34862. * - VertexBuffer.UVKind
  34863. * - VertexBuffer.UV2Kind
  34864. * - VertexBuffer.UV3Kind
  34865. * - VertexBuffer.UV4Kind
  34866. * - VertexBuffer.UV5Kind
  34867. * - VertexBuffer.UV6Kind
  34868. * - VertexBuffer.ColorKind
  34869. * - VertexBuffer.MatricesIndicesKind
  34870. * - VertexBuffer.MatricesIndicesExtraKind
  34871. * - VertexBuffer.MatricesWeightsKind
  34872. * - VertexBuffer.MatricesWeightsExtraKind
  34873. */
  34874. removeVerticesData(kind: string): void;
  34875. /**
  34876. * Flags an associated vertex buffer as updatable
  34877. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34878. * - VertexBuffer.PositionKind
  34879. * - VertexBuffer.UVKind
  34880. * - VertexBuffer.UV2Kind
  34881. * - VertexBuffer.UV3Kind
  34882. * - VertexBuffer.UV4Kind
  34883. * - VertexBuffer.UV5Kind
  34884. * - VertexBuffer.UV6Kind
  34885. * - VertexBuffer.ColorKind
  34886. * - VertexBuffer.MatricesIndicesKind
  34887. * - VertexBuffer.MatricesIndicesExtraKind
  34888. * - VertexBuffer.MatricesWeightsKind
  34889. * - VertexBuffer.MatricesWeightsExtraKind
  34890. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34891. */
  34892. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34893. /**
  34894. * Sets the mesh global Vertex Buffer
  34895. * @param buffer defines the buffer to use
  34896. * @returns the current mesh
  34897. */
  34898. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34899. /**
  34900. * Update a specific associated vertex buffer
  34901. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34902. * - VertexBuffer.PositionKind
  34903. * - VertexBuffer.UVKind
  34904. * - VertexBuffer.UV2Kind
  34905. * - VertexBuffer.UV3Kind
  34906. * - VertexBuffer.UV4Kind
  34907. * - VertexBuffer.UV5Kind
  34908. * - VertexBuffer.UV6Kind
  34909. * - VertexBuffer.ColorKind
  34910. * - VertexBuffer.MatricesIndicesKind
  34911. * - VertexBuffer.MatricesIndicesExtraKind
  34912. * - VertexBuffer.MatricesWeightsKind
  34913. * - VertexBuffer.MatricesWeightsExtraKind
  34914. * @param data defines the data source
  34915. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34916. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  34917. * @returns the current mesh
  34918. */
  34919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34920. /**
  34921. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34922. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34923. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34924. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34925. * @returns the current mesh
  34926. */
  34927. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34928. /**
  34929. * Creates a un-shared specific occurence of the geometry for the mesh.
  34930. * @returns the current mesh
  34931. */
  34932. makeGeometryUnique(): Mesh;
  34933. /**
  34934. * Set the index buffer of this mesh
  34935. * @param indices defines the source data
  34936. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34937. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34938. * @returns the current mesh
  34939. */
  34940. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34941. /**
  34942. * Update the current index buffer
  34943. * @param indices defines the source data
  34944. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34945. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  34946. * @returns the current mesh
  34947. */
  34948. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34949. /**
  34950. * Invert the geometry to move from a right handed system to a left handed one.
  34951. * @returns the current mesh
  34952. */
  34953. toLeftHanded(): Mesh;
  34954. /** @hidden */
  34955. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34956. /** @hidden */
  34957. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34958. /**
  34959. * Registers for this mesh a javascript function called just before the rendering process
  34960. * @param func defines the function to call before rendering this mesh
  34961. * @returns the current mesh
  34962. */
  34963. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34964. /**
  34965. * Disposes a previously registered javascript function called before the rendering
  34966. * @param func defines the function to remove
  34967. * @returns the current mesh
  34968. */
  34969. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34970. /**
  34971. * Registers for this mesh a javascript function called just after the rendering is complete
  34972. * @param func defines the function to call after rendering this mesh
  34973. * @returns the current mesh
  34974. */
  34975. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34976. /**
  34977. * Disposes a previously registered javascript function called after the rendering.
  34978. * @param func defines the function to remove
  34979. * @returns the current mesh
  34980. */
  34981. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34982. /** @hidden */
  34983. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34984. /** @hidden */
  34985. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34986. /** @hidden */
  34987. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34988. /** @hidden */
  34989. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34990. /** @hidden */
  34991. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34992. /** @hidden */
  34993. _rebuild(): void;
  34994. /** @hidden */
  34995. _freeze(): void;
  34996. /** @hidden */
  34997. _unFreeze(): void;
  34998. /**
  34999. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  35000. * @param subMesh defines the subMesh to render
  35001. * @param enableAlphaMode defines if alpha mode can be changed
  35002. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  35003. * @returns the current mesh
  35004. */
  35005. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  35006. private _onBeforeDraw;
  35007. /**
  35008. * Renormalize the mesh and patch it up if there are no weights
  35009. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  35010. * However in the case of zero weights then we set just a single influence to 1.
  35011. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  35012. */
  35013. cleanMatrixWeights(): void;
  35014. private normalizeSkinFourWeights;
  35015. private normalizeSkinWeightsAndExtra;
  35016. /**
  35017. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  35018. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  35019. * the user know there was an issue with importing the mesh
  35020. * @returns a validation object with skinned, valid and report string
  35021. */
  35022. validateSkinning(): {
  35023. skinned: boolean;
  35024. valid: boolean;
  35025. report: string;
  35026. };
  35027. /** @hidden */
  35028. _checkDelayState(): Mesh;
  35029. private _queueLoad;
  35030. /**
  35031. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35032. * A mesh is in the frustum if its bounding box intersects the frustum
  35033. * @param frustumPlanes defines the frustum to test
  35034. * @returns true if the mesh is in the frustum planes
  35035. */
  35036. isInFrustum(frustumPlanes: Plane[]): boolean;
  35037. /**
  35038. * Sets the mesh material by the material or multiMaterial `id` property
  35039. * @param id is a string identifying the material or the multiMaterial
  35040. * @returns the current mesh
  35041. */
  35042. setMaterialByID(id: string): Mesh;
  35043. /**
  35044. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  35045. * @returns an array of IAnimatable
  35046. */
  35047. getAnimatables(): IAnimatable[];
  35048. /**
  35049. * Modifies the mesh geometry according to the passed transformation matrix.
  35050. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  35051. * The mesh normals are modified using the same transformation.
  35052. * Note that, under the hood, this method sets a new VertexBuffer each call.
  35053. * @param transform defines the transform matrix to use
  35054. * @see https://doc.babylonjs.com/resources/baking_transformations
  35055. * @returns the current mesh
  35056. */
  35057. bakeTransformIntoVertices(transform: Matrix): Mesh;
  35058. /**
  35059. * Modifies the mesh geometry according to its own current World Matrix.
  35060. * The mesh World Matrix is then reset.
  35061. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  35062. * Note that, under the hood, this method sets a new VertexBuffer each call.
  35063. * @see https://doc.babylonjs.com/resources/baking_transformations
  35064. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  35065. * @returns the current mesh
  35066. */
  35067. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  35068. /** @hidden */
  35069. get _positions(): Nullable<Vector3[]>;
  35070. /** @hidden */
  35071. _resetPointsArrayCache(): Mesh;
  35072. /** @hidden */
  35073. _generatePointsArray(): boolean;
  35074. /**
  35075. * Returns a new Mesh object generated from the current mesh properties.
  35076. * This method must not get confused with createInstance()
  35077. * @param name is a string, the name given to the new mesh
  35078. * @param newParent can be any Node object (default `null`)
  35079. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  35080. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  35081. * @returns a new mesh
  35082. */
  35083. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  35084. /**
  35085. * Releases resources associated with this mesh.
  35086. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35087. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35088. */
  35089. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35090. /** @hidden */
  35091. _disposeInstanceSpecificData(): void;
  35092. /** @hidden */
  35093. _disposeThinInstanceSpecificData(): void;
  35094. /**
  35095. * Modifies the mesh geometry according to a displacement map.
  35096. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  35097. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  35098. * @param url is a string, the URL from the image file is to be downloaded.
  35099. * @param minHeight is the lower limit of the displacement.
  35100. * @param maxHeight is the upper limit of the displacement.
  35101. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  35102. * @param uvOffset is an optional vector2 used to offset UV.
  35103. * @param uvScale is an optional vector2 used to scale UV.
  35104. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  35105. * @returns the Mesh.
  35106. */
  35107. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  35108. /**
  35109. * Modifies the mesh geometry according to a displacementMap buffer.
  35110. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  35111. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  35112. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  35113. * @param heightMapWidth is the width of the buffer image.
  35114. * @param heightMapHeight is the height of the buffer image.
  35115. * @param minHeight is the lower limit of the displacement.
  35116. * @param maxHeight is the upper limit of the displacement.
  35117. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  35118. * @param uvOffset is an optional vector2 used to offset UV.
  35119. * @param uvScale is an optional vector2 used to scale UV.
  35120. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  35121. * @returns the Mesh.
  35122. */
  35123. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  35124. /**
  35125. * Modify the mesh to get a flat shading rendering.
  35126. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  35127. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  35128. * @returns current mesh
  35129. */
  35130. convertToFlatShadedMesh(): Mesh;
  35131. /**
  35132. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  35133. * In other words, more vertices, no more indices and a single bigger VBO.
  35134. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  35135. * @returns current mesh
  35136. */
  35137. convertToUnIndexedMesh(): Mesh;
  35138. /**
  35139. * Inverses facet orientations.
  35140. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35141. * @param flipNormals will also inverts the normals
  35142. * @returns current mesh
  35143. */
  35144. flipFaces(flipNormals?: boolean): Mesh;
  35145. /**
  35146. * Increase the number of facets and hence vertices in a mesh
  35147. * Vertex normals are interpolated from existing vertex normals
  35148. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35149. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  35150. */
  35151. increaseVertices(numberPerEdge: number): void;
  35152. /**
  35153. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  35154. * This will undo any application of covertToFlatShadedMesh
  35155. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35156. */
  35157. forceSharedVertices(): void;
  35158. /** @hidden */
  35159. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  35160. /** @hidden */
  35161. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  35162. /**
  35163. * Creates a new InstancedMesh object from the mesh model.
  35164. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  35165. * @param name defines the name of the new instance
  35166. * @returns a new InstancedMesh
  35167. */
  35168. createInstance(name: string): InstancedMesh;
  35169. /**
  35170. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  35171. * After this call, all the mesh instances have the same submeshes than the current mesh.
  35172. * @returns the current mesh
  35173. */
  35174. synchronizeInstances(): Mesh;
  35175. /**
  35176. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  35177. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  35178. * This should be used together with the simplification to avoid disappearing triangles.
  35179. * @param successCallback an optional success callback to be called after the optimization finished.
  35180. * @returns the current mesh
  35181. */
  35182. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  35183. /**
  35184. * Serialize current mesh
  35185. * @param serializationObject defines the object which will receive the serialization data
  35186. */
  35187. serialize(serializationObject: any): void;
  35188. /** @hidden */
  35189. _syncGeometryWithMorphTargetManager(): void;
  35190. /** @hidden */
  35191. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  35192. /**
  35193. * Returns a new Mesh object parsed from the source provided.
  35194. * @param parsedMesh is the source
  35195. * @param scene defines the hosting scene
  35196. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  35197. * @returns a new Mesh
  35198. */
  35199. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  35200. /**
  35201. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  35202. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35203. * @param name defines the name of the mesh to create
  35204. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  35205. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  35206. * @param closePath creates a seam between the first and the last points of each path of the path array
  35207. * @param offset is taken in account only if the `pathArray` is containing a single path
  35208. * @param scene defines the hosting scene
  35209. * @param updatable defines if the mesh must be flagged as updatable
  35210. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35211. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  35212. * @returns a new Mesh
  35213. */
  35214. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35215. /**
  35216. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  35217. * @param name defines the name of the mesh to create
  35218. * @param radius sets the radius size (float) of the polygon (default 0.5)
  35219. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  35220. * @param scene defines the hosting scene
  35221. * @param updatable defines if the mesh must be flagged as updatable
  35222. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35223. * @returns a new Mesh
  35224. */
  35225. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35226. /**
  35227. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  35228. * @param name defines the name of the mesh to create
  35229. * @param size sets the size (float) of each box side (default 1)
  35230. * @param scene defines the hosting scene
  35231. * @param updatable defines if the mesh must be flagged as updatable
  35232. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35233. * @returns a new Mesh
  35234. */
  35235. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35236. /**
  35237. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  35238. * @param name defines the name of the mesh to create
  35239. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35240. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35241. * @param scene defines the hosting scene
  35242. * @param updatable defines if the mesh must be flagged as updatable
  35243. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35244. * @returns a new Mesh
  35245. */
  35246. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35247. /**
  35248. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  35249. * @param name defines the name of the mesh to create
  35250. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35251. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35252. * @param scene defines the hosting scene
  35253. * @returns a new Mesh
  35254. */
  35255. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  35256. /**
  35257. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  35258. * @param name defines the name of the mesh to create
  35259. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  35260. * @param diameterTop set the top cap diameter (floats, default 1)
  35261. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  35262. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  35263. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  35264. * @param scene defines the hosting scene
  35265. * @param updatable defines if the mesh must be flagged as updatable
  35266. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35267. * @returns a new Mesh
  35268. */
  35269. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  35270. /**
  35271. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  35272. * @param name defines the name of the mesh to create
  35273. * @param diameter sets the diameter size (float) of the torus (default 1)
  35274. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  35275. * @param tessellation sets the number of torus sides (postive integer, default 16)
  35276. * @param scene defines the hosting scene
  35277. * @param updatable defines if the mesh must be flagged as updatable
  35278. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35279. * @returns a new Mesh
  35280. */
  35281. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35282. /**
  35283. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  35284. * @param name defines the name of the mesh to create
  35285. * @param radius sets the global radius size (float) of the torus knot (default 2)
  35286. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  35287. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  35288. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  35289. * @param p the number of windings on X axis (positive integers, default 2)
  35290. * @param q the number of windings on Y axis (positive integers, default 3)
  35291. * @param scene defines the hosting scene
  35292. * @param updatable defines if the mesh must be flagged as updatable
  35293. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35294. * @returns a new Mesh
  35295. */
  35296. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35297. /**
  35298. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  35299. * @param name defines the name of the mesh to create
  35300. * @param points is an array successive Vector3
  35301. * @param scene defines the hosting scene
  35302. * @param updatable defines if the mesh must be flagged as updatable
  35303. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  35304. * @returns a new Mesh
  35305. */
  35306. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  35307. /**
  35308. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  35309. * @param name defines the name of the mesh to create
  35310. * @param points is an array successive Vector3
  35311. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  35312. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  35313. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  35314. * @param scene defines the hosting scene
  35315. * @param updatable defines if the mesh must be flagged as updatable
  35316. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  35317. * @returns a new Mesh
  35318. */
  35319. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  35320. /**
  35321. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  35322. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  35323. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  35324. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35325. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  35326. * Remember you can only change the shape positions, not their number when updating a polygon.
  35327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  35328. * @param name defines the name of the mesh to create
  35329. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  35330. * @param scene defines the hosting scene
  35331. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35332. * @param updatable defines if the mesh must be flagged as updatable
  35333. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35334. * @param earcutInjection can be used to inject your own earcut reference
  35335. * @returns a new Mesh
  35336. */
  35337. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35338. /**
  35339. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  35340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  35341. * @param name defines the name of the mesh to create
  35342. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  35343. * @param depth defines the height of extrusion
  35344. * @param scene defines the hosting scene
  35345. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35346. * @param updatable defines if the mesh must be flagged as updatable
  35347. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35348. * @param earcutInjection can be used to inject your own earcut reference
  35349. * @returns a new Mesh
  35350. */
  35351. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35352. /**
  35353. * Creates an extruded shape mesh.
  35354. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  35355. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35356. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35357. * @param name defines the name of the mesh to create
  35358. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  35359. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35360. * @param scale is the value to scale the shape
  35361. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  35362. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  35363. * @param scene defines the hosting scene
  35364. * @param updatable defines if the mesh must be flagged as updatable
  35365. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35366. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  35367. * @returns a new Mesh
  35368. */
  35369. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35370. /**
  35371. * Creates an custom extruded shape mesh.
  35372. * The custom extrusion is a parametric shape.
  35373. * It has no predefined shape. Its final shape will depend on the input parameters.
  35374. * Please consider using the same method from the MeshBuilder class instead
  35375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35376. * @param name defines the name of the mesh to create
  35377. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  35378. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35379. * @param scaleFunction is a custom Javascript function called on each path point
  35380. * @param rotationFunction is a custom Javascript function called on each path point
  35381. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  35382. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  35383. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  35384. * @param scene defines the hosting scene
  35385. * @param updatable defines if the mesh must be flagged as updatable
  35386. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35387. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  35388. * @returns a new Mesh
  35389. */
  35390. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35391. /**
  35392. * Creates lathe mesh.
  35393. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  35394. * Please consider using the same method from the MeshBuilder class instead
  35395. * @param name defines the name of the mesh to create
  35396. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  35397. * @param radius is the radius value of the lathe
  35398. * @param tessellation is the side number of the lathe.
  35399. * @param scene defines the hosting scene
  35400. * @param updatable defines if the mesh must be flagged as updatable
  35401. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35402. * @returns a new Mesh
  35403. */
  35404. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35405. /**
  35406. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35407. * @param name defines the name of the mesh to create
  35408. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35409. * @param scene defines the hosting scene
  35410. * @param updatable defines if the mesh must be flagged as updatable
  35411. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35412. * @returns a new Mesh
  35413. */
  35414. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35415. /**
  35416. * Creates a ground mesh.
  35417. * Please consider using the same method from the MeshBuilder class instead
  35418. * @param name defines the name of the mesh to create
  35419. * @param width set the width of the ground
  35420. * @param height set the height of the ground
  35421. * @param subdivisions sets the number of subdivisions per side
  35422. * @param scene defines the hosting scene
  35423. * @param updatable defines if the mesh must be flagged as updatable
  35424. * @returns a new Mesh
  35425. */
  35426. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35427. /**
  35428. * Creates a tiled ground mesh.
  35429. * Please consider using the same method from the MeshBuilder class instead
  35430. * @param name defines the name of the mesh to create
  35431. * @param xmin set the ground minimum X coordinate
  35432. * @param zmin set the ground minimum Y coordinate
  35433. * @param xmax set the ground maximum X coordinate
  35434. * @param zmax set the ground maximum Z coordinate
  35435. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  35436. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  35437. * @param scene defines the hosting scene
  35438. * @param updatable defines if the mesh must be flagged as updatable
  35439. * @returns a new Mesh
  35440. */
  35441. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35442. w: number;
  35443. h: number;
  35444. }, precision: {
  35445. w: number;
  35446. h: number;
  35447. }, scene: Scene, updatable?: boolean): Mesh;
  35448. /**
  35449. * Creates a ground mesh from a height map.
  35450. * Please consider using the same method from the MeshBuilder class instead
  35451. * @see https://doc.babylonjs.com/babylon101/height_map
  35452. * @param name defines the name of the mesh to create
  35453. * @param url sets the URL of the height map image resource
  35454. * @param width set the ground width size
  35455. * @param height set the ground height size
  35456. * @param subdivisions sets the number of subdivision per side
  35457. * @param minHeight is the minimum altitude on the ground
  35458. * @param maxHeight is the maximum altitude on the ground
  35459. * @param scene defines the hosting scene
  35460. * @param updatable defines if the mesh must be flagged as updatable
  35461. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35462. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35463. * @returns a new Mesh
  35464. */
  35465. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  35466. /**
  35467. * Creates a tube mesh.
  35468. * The tube is a parametric shape.
  35469. * It has no predefined shape. Its final shape will depend on the input parameters.
  35470. * Please consider using the same method from the MeshBuilder class instead
  35471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35472. * @param name defines the name of the mesh to create
  35473. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35474. * @param radius sets the tube radius size
  35475. * @param tessellation is the number of sides on the tubular surface
  35476. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  35477. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  35478. * @param scene defines the hosting scene
  35479. * @param updatable defines if the mesh must be flagged as updatable
  35480. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35481. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  35482. * @returns a new Mesh
  35483. */
  35484. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35485. (i: number, distance: number): number;
  35486. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35487. /**
  35488. * Creates a polyhedron mesh.
  35489. * Please consider using the same method from the MeshBuilder class instead.
  35490. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  35491. * * The parameter `size` (positive float, default 1) sets the polygon size
  35492. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35493. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  35494. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  35495. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  35496. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  35497. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  35498. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35501. * @param name defines the name of the mesh to create
  35502. * @param options defines the options used to create the mesh
  35503. * @param scene defines the hosting scene
  35504. * @returns a new Mesh
  35505. */
  35506. static CreatePolyhedron(name: string, options: {
  35507. type?: number;
  35508. size?: number;
  35509. sizeX?: number;
  35510. sizeY?: number;
  35511. sizeZ?: number;
  35512. custom?: any;
  35513. faceUV?: Vector4[];
  35514. faceColors?: Color4[];
  35515. updatable?: boolean;
  35516. sideOrientation?: number;
  35517. }, scene: Scene): Mesh;
  35518. /**
  35519. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35520. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35521. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  35522. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35523. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  35524. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35527. * @param name defines the name of the mesh
  35528. * @param options defines the options used to create the mesh
  35529. * @param scene defines the hosting scene
  35530. * @returns a new Mesh
  35531. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35532. */
  35533. static CreateIcoSphere(name: string, options: {
  35534. radius?: number;
  35535. flat?: boolean;
  35536. subdivisions?: number;
  35537. sideOrientation?: number;
  35538. updatable?: boolean;
  35539. }, scene: Scene): Mesh;
  35540. /**
  35541. * Creates a decal mesh.
  35542. * Please consider using the same method from the MeshBuilder class instead.
  35543. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35544. * @param name defines the name of the mesh
  35545. * @param sourceMesh defines the mesh receiving the decal
  35546. * @param position sets the position of the decal in world coordinates
  35547. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35548. * @param size sets the decal scaling
  35549. * @param angle sets the angle to rotate the decal
  35550. * @returns a new Mesh
  35551. */
  35552. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35553. /** Creates a Capsule Mesh
  35554. * @param name defines the name of the mesh.
  35555. * @param options the constructors options used to shape the mesh.
  35556. * @param scene defines the scene the mesh is scoped to.
  35557. * @returns the capsule mesh
  35558. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35559. */
  35560. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35561. /**
  35562. * Prepare internal position array for software CPU skinning
  35563. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35564. */
  35565. setPositionsForCPUSkinning(): Float32Array;
  35566. /**
  35567. * Prepare internal normal array for software CPU skinning
  35568. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35569. */
  35570. setNormalsForCPUSkinning(): Float32Array;
  35571. /**
  35572. * Updates the vertex buffer by applying transformation from the bones
  35573. * @param skeleton defines the skeleton to apply to current mesh
  35574. * @returns the current mesh
  35575. */
  35576. applySkeleton(skeleton: Skeleton): Mesh;
  35577. /**
  35578. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  35579. * @param meshes defines the list of meshes to scan
  35580. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35581. */
  35582. static MinMax(meshes: AbstractMesh[]): {
  35583. min: Vector3;
  35584. max: Vector3;
  35585. };
  35586. /**
  35587. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35588. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35589. * @returns a vector3
  35590. */
  35591. static Center(meshesOrMinMaxVector: {
  35592. min: Vector3;
  35593. max: Vector3;
  35594. } | AbstractMesh[]): Vector3;
  35595. /**
  35596. * Merge the array of meshes into a single mesh for performance reasons.
  35597. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35598. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35599. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35600. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35601. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35602. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35603. * @returns a new mesh
  35604. */
  35605. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35606. /** @hidden */
  35607. addInstance(instance: InstancedMesh): void;
  35608. /** @hidden */
  35609. removeInstance(instance: InstancedMesh): void;
  35610. }
  35611. }
  35612. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  35613. import { Vector3 } from "babylonjs/Maths/math.vector";
  35614. import { Mesh } from "babylonjs/Meshes/mesh";
  35615. /**
  35616. * The options Interface for creating a Capsule Mesh
  35617. */
  35618. export interface ICreateCapsuleOptions {
  35619. /** The Orientation of the capsule. Default : Vector3.Up() */
  35620. orientation?: Vector3;
  35621. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  35622. subdivisions: number;
  35623. /** Number of cylindrical segments on the capsule. */
  35624. tessellation: number;
  35625. /** Height or Length of the capsule. */
  35626. height: number;
  35627. /** Radius of the capsule. */
  35628. radius: number;
  35629. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  35630. capSubdivisions: number;
  35631. /** Overwrite for the top radius. */
  35632. radiusTop?: number;
  35633. /** Overwrite for the bottom radius. */
  35634. radiusBottom?: number;
  35635. /** Overwrite for the top capSubdivisions. */
  35636. topCapSubdivisions?: number;
  35637. /** Overwrite for the bottom capSubdivisions. */
  35638. bottomCapSubdivisions?: number;
  35639. }
  35640. /**
  35641. * Class containing static functions to help procedurally build meshes
  35642. */
  35643. export class CapsuleBuilder {
  35644. /**
  35645. * Creates a capsule or a pill mesh
  35646. * @param name defines the name of the mesh
  35647. * @param options The constructors options.
  35648. * @param scene The scene the mesh is scoped to.
  35649. * @returns Capsule Mesh
  35650. */
  35651. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  35652. }
  35653. }
  35654. declare module "babylonjs/Meshes/mesh.vertexData" {
  35655. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  35656. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  35657. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35658. import { Geometry } from "babylonjs/Meshes/geometry";
  35659. import { Mesh } from "babylonjs/Meshes/mesh";
  35660. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  35661. /**
  35662. * Define an interface for all classes that will get and set the data on vertices
  35663. */
  35664. export interface IGetSetVerticesData {
  35665. /**
  35666. * Gets a boolean indicating if specific vertex data is present
  35667. * @param kind defines the vertex data kind to use
  35668. * @returns true is data kind is present
  35669. */
  35670. isVerticesDataPresent(kind: string): boolean;
  35671. /**
  35672. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  35673. * @param kind defines the data kind (Position, normal, etc...)
  35674. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  35675. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35676. * @returns a float array containing vertex data
  35677. */
  35678. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  35679. /**
  35680. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  35681. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  35682. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35683. * @returns the indices array or an empty array if the mesh has no geometry
  35684. */
  35685. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  35686. /**
  35687. * Set specific vertex data
  35688. * @param kind defines the data kind (Position, normal, etc...)
  35689. * @param data defines the vertex data to use
  35690. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  35691. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  35692. */
  35693. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  35694. /**
  35695. * Update a specific associated vertex buffer
  35696. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  35697. * - VertexBuffer.PositionKind
  35698. * - VertexBuffer.UVKind
  35699. * - VertexBuffer.UV2Kind
  35700. * - VertexBuffer.UV3Kind
  35701. * - VertexBuffer.UV4Kind
  35702. * - VertexBuffer.UV5Kind
  35703. * - VertexBuffer.UV6Kind
  35704. * - VertexBuffer.ColorKind
  35705. * - VertexBuffer.MatricesIndicesKind
  35706. * - VertexBuffer.MatricesIndicesExtraKind
  35707. * - VertexBuffer.MatricesWeightsKind
  35708. * - VertexBuffer.MatricesWeightsExtraKind
  35709. * @param data defines the data source
  35710. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  35711. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  35712. */
  35713. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  35714. /**
  35715. * Creates a new index buffer
  35716. * @param indices defines the indices to store in the index buffer
  35717. * @param totalVertices defines the total number of vertices (could be null)
  35718. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  35719. */
  35720. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  35721. }
  35722. /**
  35723. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  35724. */
  35725. export class VertexData {
  35726. /**
  35727. * Mesh side orientation : usually the external or front surface
  35728. */
  35729. static readonly FRONTSIDE: number;
  35730. /**
  35731. * Mesh side orientation : usually the internal or back surface
  35732. */
  35733. static readonly BACKSIDE: number;
  35734. /**
  35735. * Mesh side orientation : both internal and external or front and back surfaces
  35736. */
  35737. static readonly DOUBLESIDE: number;
  35738. /**
  35739. * Mesh side orientation : by default, `FRONTSIDE`
  35740. */
  35741. static readonly DEFAULTSIDE: number;
  35742. /**
  35743. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  35744. */
  35745. positions: Nullable<FloatArray>;
  35746. /**
  35747. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  35748. */
  35749. normals: Nullable<FloatArray>;
  35750. /**
  35751. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  35752. */
  35753. tangents: Nullable<FloatArray>;
  35754. /**
  35755. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35756. */
  35757. uvs: Nullable<FloatArray>;
  35758. /**
  35759. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35760. */
  35761. uvs2: Nullable<FloatArray>;
  35762. /**
  35763. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35764. */
  35765. uvs3: Nullable<FloatArray>;
  35766. /**
  35767. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35768. */
  35769. uvs4: Nullable<FloatArray>;
  35770. /**
  35771. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35772. */
  35773. uvs5: Nullable<FloatArray>;
  35774. /**
  35775. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35776. */
  35777. uvs6: Nullable<FloatArray>;
  35778. /**
  35779. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  35780. */
  35781. colors: Nullable<FloatArray>;
  35782. /**
  35783. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  35784. */
  35785. matricesIndices: Nullable<FloatArray>;
  35786. /**
  35787. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  35788. */
  35789. matricesWeights: Nullable<FloatArray>;
  35790. /**
  35791. * An array extending the number of possible indices
  35792. */
  35793. matricesIndicesExtra: Nullable<FloatArray>;
  35794. /**
  35795. * An array extending the number of possible weights when the number of indices is extended
  35796. */
  35797. matricesWeightsExtra: Nullable<FloatArray>;
  35798. /**
  35799. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  35800. */
  35801. indices: Nullable<IndicesArray>;
  35802. /**
  35803. * Uses the passed data array to set the set the values for the specified kind of data
  35804. * @param data a linear array of floating numbers
  35805. * @param kind the type of data that is being set, eg positions, colors etc
  35806. */
  35807. set(data: FloatArray, kind: string): void;
  35808. /**
  35809. * Associates the vertexData to the passed Mesh.
  35810. * Sets it as updatable or not (default `false`)
  35811. * @param mesh the mesh the vertexData is applied to
  35812. * @param updatable when used and having the value true allows new data to update the vertexData
  35813. * @returns the VertexData
  35814. */
  35815. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  35816. /**
  35817. * Associates the vertexData to the passed Geometry.
  35818. * Sets it as updatable or not (default `false`)
  35819. * @param geometry the geometry the vertexData is applied to
  35820. * @param updatable when used and having the value true allows new data to update the vertexData
  35821. * @returns VertexData
  35822. */
  35823. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  35824. /**
  35825. * Updates the associated mesh
  35826. * @param mesh the mesh to be updated
  35827. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35828. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  35829. * @returns VertexData
  35830. */
  35831. updateMesh(mesh: Mesh): VertexData;
  35832. /**
  35833. * Updates the associated geometry
  35834. * @param geometry the geometry to be updated
  35835. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35836. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  35837. * @returns VertexData.
  35838. */
  35839. updateGeometry(geometry: Geometry): VertexData;
  35840. private _applyTo;
  35841. private _update;
  35842. /**
  35843. * Transforms each position and each normal of the vertexData according to the passed Matrix
  35844. * @param matrix the transforming matrix
  35845. * @returns the VertexData
  35846. */
  35847. transform(matrix: Matrix): VertexData;
  35848. /**
  35849. * Merges the passed VertexData into the current one
  35850. * @param other the VertexData to be merged into the current one
  35851. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  35852. * @returns the modified VertexData
  35853. */
  35854. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  35855. private _mergeElement;
  35856. private _validate;
  35857. /**
  35858. * Serializes the VertexData
  35859. * @returns a serialized object
  35860. */
  35861. serialize(): any;
  35862. /**
  35863. * Extracts the vertexData from a mesh
  35864. * @param mesh the mesh from which to extract the VertexData
  35865. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  35866. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35867. * @returns the object VertexData associated to the passed mesh
  35868. */
  35869. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35870. /**
  35871. * Extracts the vertexData from the geometry
  35872. * @param geometry the geometry from which to extract the VertexData
  35873. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  35874. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35875. * @returns the object VertexData associated to the passed mesh
  35876. */
  35877. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35878. private static _ExtractFrom;
  35879. /**
  35880. * Creates the VertexData for a Ribbon
  35881. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35882. * * pathArray array of paths, each of which an array of successive Vector3
  35883. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35884. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35885. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  35886. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35887. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35888. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35889. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35890. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35891. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35892. * @returns the VertexData of the ribbon
  35893. */
  35894. static CreateRibbon(options: {
  35895. pathArray: Vector3[][];
  35896. closeArray?: boolean;
  35897. closePath?: boolean;
  35898. offset?: number;
  35899. sideOrientation?: number;
  35900. frontUVs?: Vector4;
  35901. backUVs?: Vector4;
  35902. invertUV?: boolean;
  35903. uvs?: Vector2[];
  35904. colors?: Color4[];
  35905. }): VertexData;
  35906. /**
  35907. * Creates the VertexData for a box
  35908. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35909. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35910. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35911. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35912. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35913. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35914. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35916. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35917. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35918. * @returns the VertexData of the box
  35919. */
  35920. static CreateBox(options: {
  35921. size?: number;
  35922. width?: number;
  35923. height?: number;
  35924. depth?: number;
  35925. faceUV?: Vector4[];
  35926. faceColors?: Color4[];
  35927. sideOrientation?: number;
  35928. frontUVs?: Vector4;
  35929. backUVs?: Vector4;
  35930. }): VertexData;
  35931. /**
  35932. * Creates the VertexData for a tiled box
  35933. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35934. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35935. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35936. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35938. * @returns the VertexData of the box
  35939. */
  35940. static CreateTiledBox(options: {
  35941. pattern?: number;
  35942. width?: number;
  35943. height?: number;
  35944. depth?: number;
  35945. tileSize?: number;
  35946. tileWidth?: number;
  35947. tileHeight?: number;
  35948. alignHorizontal?: number;
  35949. alignVertical?: number;
  35950. faceUV?: Vector4[];
  35951. faceColors?: Color4[];
  35952. sideOrientation?: number;
  35953. }): VertexData;
  35954. /**
  35955. * Creates the VertexData for a tiled plane
  35956. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35957. * * pattern a limited pattern arrangement depending on the number
  35958. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35959. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35960. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35962. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35963. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35964. * @returns the VertexData of the tiled plane
  35965. */
  35966. static CreateTiledPlane(options: {
  35967. pattern?: number;
  35968. tileSize?: number;
  35969. tileWidth?: number;
  35970. tileHeight?: number;
  35971. size?: number;
  35972. width?: number;
  35973. height?: number;
  35974. alignHorizontal?: number;
  35975. alignVertical?: number;
  35976. sideOrientation?: number;
  35977. frontUVs?: Vector4;
  35978. backUVs?: Vector4;
  35979. }): VertexData;
  35980. /**
  35981. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35982. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35983. * * segments sets the number of horizontal strips optional, default 32
  35984. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35985. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35986. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35987. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35988. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  35989. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  35990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35991. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35992. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35993. * @returns the VertexData of the ellipsoid
  35994. */
  35995. static CreateSphere(options: {
  35996. segments?: number;
  35997. diameter?: number;
  35998. diameterX?: number;
  35999. diameterY?: number;
  36000. diameterZ?: number;
  36001. arc?: number;
  36002. slice?: number;
  36003. sideOrientation?: number;
  36004. frontUVs?: Vector4;
  36005. backUVs?: Vector4;
  36006. }): VertexData;
  36007. /**
  36008. * Creates the VertexData for a cylinder, cone or prism
  36009. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36010. * * height sets the height (y direction) of the cylinder, optional, default 2
  36011. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  36012. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  36013. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  36014. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  36015. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  36016. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  36017. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36018. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36019. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  36020. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  36021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36022. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36023. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36024. * @returns the VertexData of the cylinder, cone or prism
  36025. */
  36026. static CreateCylinder(options: {
  36027. height?: number;
  36028. diameterTop?: number;
  36029. diameterBottom?: number;
  36030. diameter?: number;
  36031. tessellation?: number;
  36032. subdivisions?: number;
  36033. arc?: number;
  36034. faceColors?: Color4[];
  36035. faceUV?: Vector4[];
  36036. hasRings?: boolean;
  36037. enclose?: boolean;
  36038. sideOrientation?: number;
  36039. frontUVs?: Vector4;
  36040. backUVs?: Vector4;
  36041. }): VertexData;
  36042. /**
  36043. * Creates the VertexData for a torus
  36044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36045. * * diameter the diameter of the torus, optional default 1
  36046. * * thickness the diameter of the tube forming the torus, optional default 0.5
  36047. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  36048. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36049. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36050. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36051. * @returns the VertexData of the torus
  36052. */
  36053. static CreateTorus(options: {
  36054. diameter?: number;
  36055. thickness?: number;
  36056. tessellation?: number;
  36057. sideOrientation?: number;
  36058. frontUVs?: Vector4;
  36059. backUVs?: Vector4;
  36060. }): VertexData;
  36061. /**
  36062. * Creates the VertexData of the LineSystem
  36063. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  36064. * - lines an array of lines, each line being an array of successive Vector3
  36065. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  36066. * @returns the VertexData of the LineSystem
  36067. */
  36068. static CreateLineSystem(options: {
  36069. lines: Vector3[][];
  36070. colors?: Nullable<Color4[][]>;
  36071. }): VertexData;
  36072. /**
  36073. * Create the VertexData for a DashedLines
  36074. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  36075. * - points an array successive Vector3
  36076. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  36077. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  36078. * - dashNb the intended total number of dashes, optional, default 200
  36079. * @returns the VertexData for the DashedLines
  36080. */
  36081. static CreateDashedLines(options: {
  36082. points: Vector3[];
  36083. dashSize?: number;
  36084. gapSize?: number;
  36085. dashNb?: number;
  36086. }): VertexData;
  36087. /**
  36088. * Creates the VertexData for a Ground
  36089. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  36090. * - width the width (x direction) of the ground, optional, default 1
  36091. * - height the height (z direction) of the ground, optional, default 1
  36092. * - subdivisions the number of subdivisions per side, optional, default 1
  36093. * @returns the VertexData of the Ground
  36094. */
  36095. static CreateGround(options: {
  36096. width?: number;
  36097. height?: number;
  36098. subdivisions?: number;
  36099. subdivisionsX?: number;
  36100. subdivisionsY?: number;
  36101. }): VertexData;
  36102. /**
  36103. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  36104. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  36105. * * xmin the ground minimum X coordinate, optional, default -1
  36106. * * zmin the ground minimum Z coordinate, optional, default -1
  36107. * * xmax the ground maximum X coordinate, optional, default 1
  36108. * * zmax the ground maximum Z coordinate, optional, default 1
  36109. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  36110. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  36111. * @returns the VertexData of the TiledGround
  36112. */
  36113. static CreateTiledGround(options: {
  36114. xmin: number;
  36115. zmin: number;
  36116. xmax: number;
  36117. zmax: number;
  36118. subdivisions?: {
  36119. w: number;
  36120. h: number;
  36121. };
  36122. precision?: {
  36123. w: number;
  36124. h: number;
  36125. };
  36126. }): VertexData;
  36127. /**
  36128. * Creates the VertexData of the Ground designed from a heightmap
  36129. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  36130. * * width the width (x direction) of the ground
  36131. * * height the height (z direction) of the ground
  36132. * * subdivisions the number of subdivisions per side
  36133. * * minHeight the minimum altitude on the ground, optional, default 0
  36134. * * maxHeight the maximum altitude on the ground, optional default 1
  36135. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  36136. * * buffer the array holding the image color data
  36137. * * bufferWidth the width of image
  36138. * * bufferHeight the height of image
  36139. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  36140. * @returns the VertexData of the Ground designed from a heightmap
  36141. */
  36142. static CreateGroundFromHeightMap(options: {
  36143. width: number;
  36144. height: number;
  36145. subdivisions: number;
  36146. minHeight: number;
  36147. maxHeight: number;
  36148. colorFilter: Color3;
  36149. buffer: Uint8Array;
  36150. bufferWidth: number;
  36151. bufferHeight: number;
  36152. alphaFilter: number;
  36153. }): VertexData;
  36154. /**
  36155. * Creates the VertexData for a Plane
  36156. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  36157. * * size sets the width and height of the plane to the value of size, optional default 1
  36158. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  36159. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  36160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36161. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36162. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36163. * @returns the VertexData of the box
  36164. */
  36165. static CreatePlane(options: {
  36166. size?: number;
  36167. width?: number;
  36168. height?: number;
  36169. sideOrientation?: number;
  36170. frontUVs?: Vector4;
  36171. backUVs?: Vector4;
  36172. }): VertexData;
  36173. /**
  36174. * Creates the VertexData of the Disc or regular Polygon
  36175. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  36176. * * radius the radius of the disc, optional default 0.5
  36177. * * tessellation the number of polygon sides, optional, default 64
  36178. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  36179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36180. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36181. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36182. * @returns the VertexData of the box
  36183. */
  36184. static CreateDisc(options: {
  36185. radius?: number;
  36186. tessellation?: number;
  36187. arc?: number;
  36188. sideOrientation?: number;
  36189. frontUVs?: Vector4;
  36190. backUVs?: Vector4;
  36191. }): VertexData;
  36192. /**
  36193. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  36194. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  36195. * @param polygon a mesh built from polygonTriangulation.build()
  36196. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36197. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36198. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36199. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36200. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36201. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  36202. * @returns the VertexData of the Polygon
  36203. */
  36204. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  36205. /**
  36206. * Creates the VertexData of the IcoSphere
  36207. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  36208. * * radius the radius of the IcoSphere, optional default 1
  36209. * * radiusX allows stretching in the x direction, optional, default radius
  36210. * * radiusY allows stretching in the y direction, optional, default radius
  36211. * * radiusZ allows stretching in the z direction, optional, default radius
  36212. * * flat when true creates a flat shaded mesh, optional, default true
  36213. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36215. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36216. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36217. * @returns the VertexData of the IcoSphere
  36218. */
  36219. static CreateIcoSphere(options: {
  36220. radius?: number;
  36221. radiusX?: number;
  36222. radiusY?: number;
  36223. radiusZ?: number;
  36224. flat?: boolean;
  36225. subdivisions?: number;
  36226. sideOrientation?: number;
  36227. frontUVs?: Vector4;
  36228. backUVs?: Vector4;
  36229. }): VertexData;
  36230. /**
  36231. * Creates the VertexData for a Polyhedron
  36232. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  36233. * * type provided types are:
  36234. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  36235. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  36236. * * size the size of the IcoSphere, optional default 1
  36237. * * sizeX allows stretching in the x direction, optional, default size
  36238. * * sizeY allows stretching in the y direction, optional, default size
  36239. * * sizeZ allows stretching in the z direction, optional, default size
  36240. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  36241. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36242. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36243. * * flat when true creates a flat shaded mesh, optional, default true
  36244. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36246. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36247. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36248. * @returns the VertexData of the Polyhedron
  36249. */
  36250. static CreatePolyhedron(options: {
  36251. type?: number;
  36252. size?: number;
  36253. sizeX?: number;
  36254. sizeY?: number;
  36255. sizeZ?: number;
  36256. custom?: any;
  36257. faceUV?: Vector4[];
  36258. faceColors?: Color4[];
  36259. flat?: boolean;
  36260. sideOrientation?: number;
  36261. frontUVs?: Vector4;
  36262. backUVs?: Vector4;
  36263. }): VertexData;
  36264. /**
  36265. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  36266. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  36267. * @returns the VertexData of the Capsule
  36268. */
  36269. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  36270. /**
  36271. * Creates the VertexData for a TorusKnot
  36272. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  36273. * * radius the radius of the torus knot, optional, default 2
  36274. * * tube the thickness of the tube, optional, default 0.5
  36275. * * radialSegments the number of sides on each tube segments, optional, default 32
  36276. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  36277. * * p the number of windings around the z axis, optional, default 2
  36278. * * q the number of windings around the x axis, optional, default 3
  36279. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36280. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  36281. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  36282. * @returns the VertexData of the Torus Knot
  36283. */
  36284. static CreateTorusKnot(options: {
  36285. radius?: number;
  36286. tube?: number;
  36287. radialSegments?: number;
  36288. tubularSegments?: number;
  36289. p?: number;
  36290. q?: number;
  36291. sideOrientation?: number;
  36292. frontUVs?: Vector4;
  36293. backUVs?: Vector4;
  36294. }): VertexData;
  36295. /**
  36296. * Compute normals for given positions and indices
  36297. * @param positions an array of vertex positions, [...., x, y, z, ......]
  36298. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  36299. * @param normals an array of vertex normals, [...., x, y, z, ......]
  36300. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  36301. * * facetNormals : optional array of facet normals (vector3)
  36302. * * facetPositions : optional array of facet positions (vector3)
  36303. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  36304. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  36305. * * bInfo : optional bounding info, required for facetPartitioning computation
  36306. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  36307. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  36308. * * useRightHandedSystem: optional boolean to for right handed system computation
  36309. * * depthSort : optional boolean to enable the facet depth sort computation
  36310. * * distanceTo : optional Vector3 to compute the facet depth from this location
  36311. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  36312. */
  36313. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  36314. facetNormals?: any;
  36315. facetPositions?: any;
  36316. facetPartitioning?: any;
  36317. ratio?: number;
  36318. bInfo?: any;
  36319. bbSize?: Vector3;
  36320. subDiv?: any;
  36321. useRightHandedSystem?: boolean;
  36322. depthSort?: boolean;
  36323. distanceTo?: Vector3;
  36324. depthSortedFacets?: any;
  36325. }): void;
  36326. /** @hidden */
  36327. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  36328. /**
  36329. * Applies VertexData created from the imported parameters to the geometry
  36330. * @param parsedVertexData the parsed data from an imported file
  36331. * @param geometry the geometry to apply the VertexData to
  36332. */
  36333. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  36334. }
  36335. }
  36336. declare module "babylonjs/Meshes/Builders/discBuilder" {
  36337. import { Nullable } from "babylonjs/types";
  36338. import { Scene } from "babylonjs/scene";
  36339. import { Vector4 } from "babylonjs/Maths/math.vector";
  36340. import { Mesh } from "babylonjs/Meshes/mesh";
  36341. /**
  36342. * Class containing static functions to help procedurally build meshes
  36343. */
  36344. export class DiscBuilder {
  36345. /**
  36346. * Creates a plane polygonal mesh. By default, this is a disc
  36347. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  36348. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  36349. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  36350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36353. * @param name defines the name of the mesh
  36354. * @param options defines the options used to create the mesh
  36355. * @param scene defines the hosting scene
  36356. * @returns the plane polygonal mesh
  36357. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  36358. */
  36359. static CreateDisc(name: string, options: {
  36360. radius?: number;
  36361. tessellation?: number;
  36362. arc?: number;
  36363. updatable?: boolean;
  36364. sideOrientation?: number;
  36365. frontUVs?: Vector4;
  36366. backUVs?: Vector4;
  36367. }, scene?: Nullable<Scene>): Mesh;
  36368. }
  36369. }
  36370. declare module "babylonjs/Particles/solidParticleSystem" {
  36371. import { Nullable } from "babylonjs/types";
  36372. import { Mesh } from "babylonjs/Meshes/mesh";
  36373. import { Scene, IDisposable } from "babylonjs/scene";
  36374. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  36375. import { Material } from "babylonjs/Materials/material";
  36376. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36377. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36378. /**
  36379. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  36380. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  36381. * The SPS is also a particle system. It provides some methods to manage the particles.
  36382. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  36383. *
  36384. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  36385. */
  36386. export class SolidParticleSystem implements IDisposable {
  36387. /**
  36388. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  36389. * Example : var p = SPS.particles[i];
  36390. */
  36391. particles: SolidParticle[];
  36392. /**
  36393. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  36394. */
  36395. nbParticles: number;
  36396. /**
  36397. * If the particles must ever face the camera (default false). Useful for planar particles.
  36398. */
  36399. billboard: boolean;
  36400. /**
  36401. * Recompute normals when adding a shape
  36402. */
  36403. recomputeNormals: boolean;
  36404. /**
  36405. * This a counter ofr your own usage. It's not set by any SPS functions.
  36406. */
  36407. counter: number;
  36408. /**
  36409. * The SPS name. This name is also given to the underlying mesh.
  36410. */
  36411. name: string;
  36412. /**
  36413. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  36414. */
  36415. mesh: Mesh;
  36416. /**
  36417. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  36418. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  36419. */
  36420. vars: any;
  36421. /**
  36422. * This array is populated when the SPS is set as 'pickable'.
  36423. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  36424. * Each element of this array is an object `{idx: int, faceId: int}`.
  36425. * `idx` is the picked particle index in the `SPS.particles` array
  36426. * `faceId` is the picked face index counted within this particle.
  36427. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  36428. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  36429. * Use the method SPS.pickedParticle(pickingInfo) instead.
  36430. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36431. */
  36432. pickedParticles: {
  36433. idx: number;
  36434. faceId: number;
  36435. }[];
  36436. /**
  36437. * This array is populated when the SPS is set as 'pickable'
  36438. * Each key of this array is a submesh index.
  36439. * Each element of this array is a second array defined like this :
  36440. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  36441. * Each element of this second array is an object `{idx: int, faceId: int}`.
  36442. * `idx` is the picked particle index in the `SPS.particles` array
  36443. * `faceId` is the picked face index counted within this particle.
  36444. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  36445. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36446. */
  36447. pickedBySubMesh: {
  36448. idx: number;
  36449. faceId: number;
  36450. }[][];
  36451. /**
  36452. * This array is populated when `enableDepthSort` is set to true.
  36453. * Each element of this array is an instance of the class DepthSortedParticle.
  36454. */
  36455. depthSortedParticles: DepthSortedParticle[];
  36456. /**
  36457. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  36458. * @hidden
  36459. */
  36460. _bSphereOnly: boolean;
  36461. /**
  36462. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  36463. * @hidden
  36464. */
  36465. _bSphereRadiusFactor: number;
  36466. private _scene;
  36467. private _positions;
  36468. private _indices;
  36469. private _normals;
  36470. private _colors;
  36471. private _uvs;
  36472. private _indices32;
  36473. private _positions32;
  36474. private _normals32;
  36475. private _fixedNormal32;
  36476. private _colors32;
  36477. private _uvs32;
  36478. private _index;
  36479. private _updatable;
  36480. private _pickable;
  36481. private _isVisibilityBoxLocked;
  36482. private _alwaysVisible;
  36483. private _depthSort;
  36484. private _expandable;
  36485. private _shapeCounter;
  36486. private _copy;
  36487. private _color;
  36488. private _computeParticleColor;
  36489. private _computeParticleTexture;
  36490. private _computeParticleRotation;
  36491. private _computeParticleVertex;
  36492. private _computeBoundingBox;
  36493. private _depthSortParticles;
  36494. private _camera;
  36495. private _mustUnrotateFixedNormals;
  36496. private _particlesIntersect;
  36497. private _needs32Bits;
  36498. private _isNotBuilt;
  36499. private _lastParticleId;
  36500. private _idxOfId;
  36501. private _multimaterialEnabled;
  36502. private _useModelMaterial;
  36503. private _indicesByMaterial;
  36504. private _materialIndexes;
  36505. private _depthSortFunction;
  36506. private _materialSortFunction;
  36507. private _materials;
  36508. private _multimaterial;
  36509. private _materialIndexesById;
  36510. private _defaultMaterial;
  36511. private _autoUpdateSubMeshes;
  36512. private _tmpVertex;
  36513. /**
  36514. * Creates a SPS (Solid Particle System) object.
  36515. * @param name (String) is the SPS name, this will be the underlying mesh name.
  36516. * @param scene (Scene) is the scene in which the SPS is added.
  36517. * @param options defines the options of the sps e.g.
  36518. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  36519. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  36520. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  36521. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  36522. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  36523. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  36524. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  36525. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  36526. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  36527. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  36528. */
  36529. constructor(name: string, scene: Scene, options?: {
  36530. updatable?: boolean;
  36531. isPickable?: boolean;
  36532. enableDepthSort?: boolean;
  36533. particleIntersection?: boolean;
  36534. boundingSphereOnly?: boolean;
  36535. bSphereRadiusFactor?: number;
  36536. expandable?: boolean;
  36537. useModelMaterial?: boolean;
  36538. enableMultiMaterial?: boolean;
  36539. });
  36540. /**
  36541. * Builds the SPS underlying mesh. Returns a standard Mesh.
  36542. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  36543. * @returns the created mesh
  36544. */
  36545. buildMesh(): Mesh;
  36546. /**
  36547. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  36548. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  36549. * Thus the particles generated from `digest()` have their property `position` set yet.
  36550. * @param mesh ( Mesh ) is the mesh to be digested
  36551. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  36552. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  36553. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  36554. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36555. * @returns the current SPS
  36556. */
  36557. digest(mesh: Mesh, options?: {
  36558. facetNb?: number;
  36559. number?: number;
  36560. delta?: number;
  36561. storage?: [];
  36562. }): SolidParticleSystem;
  36563. /**
  36564. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  36565. * @hidden
  36566. */
  36567. private _unrotateFixedNormals;
  36568. /**
  36569. * Resets the temporary working copy particle
  36570. * @hidden
  36571. */
  36572. private _resetCopy;
  36573. /**
  36574. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36575. * @param p the current index in the positions array to be updated
  36576. * @param ind the current index in the indices array
  36577. * @param shape a Vector3 array, the shape geometry
  36578. * @param positions the positions array to be updated
  36579. * @param meshInd the shape indices array
  36580. * @param indices the indices array to be updated
  36581. * @param meshUV the shape uv array
  36582. * @param uvs the uv array to be updated
  36583. * @param meshCol the shape color array
  36584. * @param colors the color array to be updated
  36585. * @param meshNor the shape normals array
  36586. * @param normals the normals array to be updated
  36587. * @param idx the particle index
  36588. * @param idxInShape the particle index in its shape
  36589. * @param options the addShape() method passed options
  36590. * @model the particle model
  36591. * @hidden
  36592. */
  36593. private _meshBuilder;
  36594. /**
  36595. * Returns a shape Vector3 array from positions float array
  36596. * @param positions float array
  36597. * @returns a vector3 array
  36598. * @hidden
  36599. */
  36600. private _posToShape;
  36601. /**
  36602. * Returns a shapeUV array from a float uvs (array deep copy)
  36603. * @param uvs as a float array
  36604. * @returns a shapeUV array
  36605. * @hidden
  36606. */
  36607. private _uvsToShapeUV;
  36608. /**
  36609. * Adds a new particle object in the particles array
  36610. * @param idx particle index in particles array
  36611. * @param id particle id
  36612. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36613. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36614. * @param model particle ModelShape object
  36615. * @param shapeId model shape identifier
  36616. * @param idxInShape index of the particle in the current model
  36617. * @param bInfo model bounding info object
  36618. * @param storage target storage array, if any
  36619. * @hidden
  36620. */
  36621. private _addParticle;
  36622. /**
  36623. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36624. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36625. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36626. * @param nb (positive integer) the number of particles to be created from this model
  36627. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36628. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36629. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36630. * @returns the number of shapes in the system
  36631. */
  36632. addShape(mesh: Mesh, nb: number, options?: {
  36633. positionFunction?: any;
  36634. vertexFunction?: any;
  36635. storage?: [];
  36636. }): number;
  36637. /**
  36638. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36639. * @hidden
  36640. */
  36641. private _rebuildParticle;
  36642. /**
  36643. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36644. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  36645. * @returns the SPS.
  36646. */
  36647. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36648. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36649. * Returns an array with the removed particles.
  36650. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  36651. * The SPS can't be empty so at least one particle needs to remain in place.
  36652. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36653. * @param start index of the first particle to remove
  36654. * @param end index of the last particle to remove (included)
  36655. * @returns an array populated with the removed particles
  36656. */
  36657. removeParticles(start: number, end: number): SolidParticle[];
  36658. /**
  36659. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36660. * @param solidParticleArray an array populated with Solid Particles objects
  36661. * @returns the SPS
  36662. */
  36663. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36664. /**
  36665. * Creates a new particle and modifies the SPS mesh geometry :
  36666. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36667. * - calls _addParticle() to populate the particle array
  36668. * factorized code from addShape() and insertParticlesFromArray()
  36669. * @param idx particle index in the particles array
  36670. * @param i particle index in its shape
  36671. * @param modelShape particle ModelShape object
  36672. * @param shape shape vertex array
  36673. * @param meshInd shape indices array
  36674. * @param meshUV shape uv array
  36675. * @param meshCol shape color array
  36676. * @param meshNor shape normals array
  36677. * @param bbInfo shape bounding info
  36678. * @param storage target particle storage
  36679. * @options addShape() passed options
  36680. * @hidden
  36681. */
  36682. private _insertNewParticle;
  36683. /**
  36684. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36685. * This method calls `updateParticle()` for each particle of the SPS.
  36686. * For an animated SPS, it is usually called within the render loop.
  36687. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  36688. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36689. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36690. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36691. * @returns the SPS.
  36692. */
  36693. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36694. /**
  36695. * Disposes the SPS.
  36696. */
  36697. dispose(): void;
  36698. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36699. * idx is the particle index in the SPS
  36700. * faceId is the picked face index counted within this particle.
  36701. * Returns null if the pickInfo can't identify a picked particle.
  36702. * @param pickingInfo (PickingInfo object)
  36703. * @returns {idx: number, faceId: number} or null
  36704. */
  36705. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36706. idx: number;
  36707. faceId: number;
  36708. }>;
  36709. /**
  36710. * Returns a SolidParticle object from its identifier : particle.id
  36711. * @param id (integer) the particle Id
  36712. * @returns the searched particle or null if not found in the SPS.
  36713. */
  36714. getParticleById(id: number): Nullable<SolidParticle>;
  36715. /**
  36716. * Returns a new array populated with the particles having the passed shapeId.
  36717. * @param shapeId (integer) the shape identifier
  36718. * @returns a new solid particle array
  36719. */
  36720. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36721. /**
  36722. * Populates the passed array "ref" with the particles having the passed shapeId.
  36723. * @param shapeId the shape identifier
  36724. * @returns the SPS
  36725. * @param ref
  36726. */
  36727. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36728. /**
  36729. * Computes the required SubMeshes according the materials assigned to the particles.
  36730. * @returns the solid particle system.
  36731. * Does nothing if called before the SPS mesh is built.
  36732. */
  36733. computeSubMeshes(): SolidParticleSystem;
  36734. /**
  36735. * Sorts the solid particles by material when MultiMaterial is enabled.
  36736. * Updates the indices32 array.
  36737. * Updates the indicesByMaterial array.
  36738. * Updates the mesh indices array.
  36739. * @returns the SPS
  36740. * @hidden
  36741. */
  36742. private _sortParticlesByMaterial;
  36743. /**
  36744. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36745. * @hidden
  36746. */
  36747. private _setMaterialIndexesById;
  36748. /**
  36749. * Returns an array with unique values of Materials from the passed array
  36750. * @param array the material array to be checked and filtered
  36751. * @hidden
  36752. */
  36753. private _filterUniqueMaterialId;
  36754. /**
  36755. * Sets a new Standard Material as _defaultMaterial if not already set.
  36756. * @hidden
  36757. */
  36758. private _setDefaultMaterial;
  36759. /**
  36760. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36761. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36762. * @returns the SPS.
  36763. */
  36764. refreshVisibleSize(): SolidParticleSystem;
  36765. /**
  36766. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36767. * @param size the size (float) of the visibility box
  36768. * note : this doesn't lock the SPS mesh bounding box.
  36769. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36770. */
  36771. setVisibilityBox(size: number): void;
  36772. /**
  36773. * Gets whether the SPS as always visible or not
  36774. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36775. */
  36776. get isAlwaysVisible(): boolean;
  36777. /**
  36778. * Sets the SPS as always visible or not
  36779. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36780. */
  36781. set isAlwaysVisible(val: boolean);
  36782. /**
  36783. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36784. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36785. */
  36786. set isVisibilityBoxLocked(val: boolean);
  36787. /**
  36788. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36789. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36790. */
  36791. get isVisibilityBoxLocked(): boolean;
  36792. /**
  36793. * Tells to `setParticles()` to compute the particle rotations or not.
  36794. * Default value : true. The SPS is faster when it's set to false.
  36795. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36796. */
  36797. set computeParticleRotation(val: boolean);
  36798. /**
  36799. * Tells to `setParticles()` to compute the particle colors or not.
  36800. * Default value : true. The SPS is faster when it's set to false.
  36801. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36802. */
  36803. set computeParticleColor(val: boolean);
  36804. set computeParticleTexture(val: boolean);
  36805. /**
  36806. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36807. * Default value : false. The SPS is faster when it's set to false.
  36808. * Note : the particle custom vertex positions aren't stored values.
  36809. */
  36810. set computeParticleVertex(val: boolean);
  36811. /**
  36812. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36813. */
  36814. set computeBoundingBox(val: boolean);
  36815. /**
  36816. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36817. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36818. * Default : `true`
  36819. */
  36820. set depthSortParticles(val: boolean);
  36821. /**
  36822. * Gets if `setParticles()` computes the particle rotations or not.
  36823. * Default value : true. The SPS is faster when it's set to false.
  36824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36825. */
  36826. get computeParticleRotation(): boolean;
  36827. /**
  36828. * Gets if `setParticles()` computes the particle colors or not.
  36829. * Default value : true. The SPS is faster when it's set to false.
  36830. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36831. */
  36832. get computeParticleColor(): boolean;
  36833. /**
  36834. * Gets if `setParticles()` computes the particle textures or not.
  36835. * Default value : true. The SPS is faster when it's set to false.
  36836. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36837. */
  36838. get computeParticleTexture(): boolean;
  36839. /**
  36840. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36841. * Default value : false. The SPS is faster when it's set to false.
  36842. * Note : the particle custom vertex positions aren't stored values.
  36843. */
  36844. get computeParticleVertex(): boolean;
  36845. /**
  36846. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36847. */
  36848. get computeBoundingBox(): boolean;
  36849. /**
  36850. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36851. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36852. * Default : `true`
  36853. */
  36854. get depthSortParticles(): boolean;
  36855. /**
  36856. * Gets if the SPS is created as expandable at construction time.
  36857. * Default : `false`
  36858. */
  36859. get expandable(): boolean;
  36860. /**
  36861. * Gets if the SPS supports the Multi Materials
  36862. */
  36863. get multimaterialEnabled(): boolean;
  36864. /**
  36865. * Gets if the SPS uses the model materials for its own multimaterial.
  36866. */
  36867. get useModelMaterial(): boolean;
  36868. /**
  36869. * The SPS used material array.
  36870. */
  36871. get materials(): Material[];
  36872. /**
  36873. * Sets the SPS MultiMaterial from the passed materials.
  36874. * Note : the passed array is internally copied and not used then by reference.
  36875. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36876. */
  36877. setMultiMaterial(materials: Material[]): void;
  36878. /**
  36879. * The SPS computed multimaterial object
  36880. */
  36881. get multimaterial(): MultiMaterial;
  36882. set multimaterial(mm: MultiMaterial);
  36883. /**
  36884. * If the subMeshes must be updated on the next call to setParticles()
  36885. */
  36886. get autoUpdateSubMeshes(): boolean;
  36887. set autoUpdateSubMeshes(val: boolean);
  36888. /**
  36889. * This function does nothing. It may be overwritten to set all the particle first values.
  36890. * The SPS doesn't call this function, you may have to call it by your own.
  36891. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36892. */
  36893. initParticles(): void;
  36894. /**
  36895. * This function does nothing. It may be overwritten to recycle a particle.
  36896. * The SPS doesn't call this function, you may have to call it by your own.
  36897. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36898. * @param particle The particle to recycle
  36899. * @returns the recycled particle
  36900. */
  36901. recycleParticle(particle: SolidParticle): SolidParticle;
  36902. /**
  36903. * Updates a particle : this function should be overwritten by the user.
  36904. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36905. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36906. * @example : just set a particle position or velocity and recycle conditions
  36907. * @param particle The particle to update
  36908. * @returns the updated particle
  36909. */
  36910. updateParticle(particle: SolidParticle): SolidParticle;
  36911. /**
  36912. * Updates a vertex of a particle : it can be overwritten by the user.
  36913. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36914. * @param particle the current particle
  36915. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36916. * @param pt the index of the current vertex in the particle shape
  36917. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36918. * @example : just set a vertex particle position or color
  36919. * @returns the sps
  36920. */
  36921. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36922. /**
  36923. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36924. * This does nothing and may be overwritten by the user.
  36925. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36926. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36927. * @param update the boolean update value actually passed to setParticles()
  36928. */
  36929. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36930. /**
  36931. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36932. * This will be passed three parameters.
  36933. * This does nothing and may be overwritten by the user.
  36934. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36935. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36936. * @param update the boolean update value actually passed to setParticles()
  36937. */
  36938. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36939. }
  36940. }
  36941. declare module "babylonjs/Particles/solidParticle" {
  36942. import { Nullable } from "babylonjs/types";
  36943. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36944. import { Color4 } from "babylonjs/Maths/math.color";
  36945. import { Mesh } from "babylonjs/Meshes/mesh";
  36946. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36947. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36948. import { Plane } from "babylonjs/Maths/math.plane";
  36949. import { Material } from "babylonjs/Materials/material";
  36950. /**
  36951. * Represents one particle of a solid particle system.
  36952. */
  36953. export class SolidParticle {
  36954. /**
  36955. * particle global index
  36956. */
  36957. idx: number;
  36958. /**
  36959. * particle identifier
  36960. */
  36961. id: number;
  36962. /**
  36963. * The color of the particle
  36964. */
  36965. color: Nullable<Color4>;
  36966. /**
  36967. * The world space position of the particle.
  36968. */
  36969. position: Vector3;
  36970. /**
  36971. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36972. */
  36973. rotation: Vector3;
  36974. /**
  36975. * The world space rotation quaternion of the particle.
  36976. */
  36977. rotationQuaternion: Nullable<Quaternion>;
  36978. /**
  36979. * The scaling of the particle.
  36980. */
  36981. scaling: Vector3;
  36982. /**
  36983. * The uvs of the particle.
  36984. */
  36985. uvs: Vector4;
  36986. /**
  36987. * The current speed of the particle.
  36988. */
  36989. velocity: Vector3;
  36990. /**
  36991. * The pivot point in the particle local space.
  36992. */
  36993. pivot: Vector3;
  36994. /**
  36995. * Must the particle be translated from its pivot point in its local space ?
  36996. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36997. * Default : false
  36998. */
  36999. translateFromPivot: boolean;
  37000. /**
  37001. * Is the particle active or not ?
  37002. */
  37003. alive: boolean;
  37004. /**
  37005. * Is the particle visible or not ?
  37006. */
  37007. isVisible: boolean;
  37008. /**
  37009. * Index of this particle in the global "positions" array (Internal use)
  37010. * @hidden
  37011. */
  37012. _pos: number;
  37013. /**
  37014. * @hidden Index of this particle in the global "indices" array (Internal use)
  37015. */
  37016. _ind: number;
  37017. /**
  37018. * @hidden ModelShape of this particle (Internal use)
  37019. */
  37020. _model: ModelShape;
  37021. /**
  37022. * ModelShape id of this particle
  37023. */
  37024. shapeId: number;
  37025. /**
  37026. * Index of the particle in its shape id
  37027. */
  37028. idxInShape: number;
  37029. /**
  37030. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  37031. */
  37032. _modelBoundingInfo: BoundingInfo;
  37033. /**
  37034. * @hidden Particle BoundingInfo object (Internal use)
  37035. */
  37036. _boundingInfo: BoundingInfo;
  37037. /**
  37038. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  37039. */
  37040. _sps: SolidParticleSystem;
  37041. /**
  37042. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  37043. */
  37044. _stillInvisible: boolean;
  37045. /**
  37046. * @hidden Last computed particle rotation matrix
  37047. */
  37048. _rotationMatrix: number[];
  37049. /**
  37050. * Parent particle Id, if any.
  37051. * Default null.
  37052. */
  37053. parentId: Nullable<number>;
  37054. /**
  37055. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  37056. */
  37057. materialIndex: Nullable<number>;
  37058. /**
  37059. * Custom object or properties.
  37060. */
  37061. props: Nullable<any>;
  37062. /**
  37063. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  37064. * The possible values are :
  37065. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  37066. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37067. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  37068. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  37069. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37070. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  37071. * */
  37072. cullingStrategy: number;
  37073. /**
  37074. * @hidden Internal global position in the SPS.
  37075. */
  37076. _globalPosition: Vector3;
  37077. /**
  37078. * Creates a Solid Particle object.
  37079. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  37080. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  37081. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  37082. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  37083. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  37084. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  37085. * @param shapeId (integer) is the model shape identifier in the SPS.
  37086. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  37087. * @param sps defines the sps it is associated to
  37088. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  37089. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  37090. */
  37091. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  37092. /**
  37093. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  37094. * @param target the particle target
  37095. * @returns the current particle
  37096. */
  37097. copyToRef(target: SolidParticle): SolidParticle;
  37098. /**
  37099. * Legacy support, changed scale to scaling
  37100. */
  37101. get scale(): Vector3;
  37102. /**
  37103. * Legacy support, changed scale to scaling
  37104. */
  37105. set scale(scale: Vector3);
  37106. /**
  37107. * Legacy support, changed quaternion to rotationQuaternion
  37108. */
  37109. get quaternion(): Nullable<Quaternion>;
  37110. /**
  37111. * Legacy support, changed quaternion to rotationQuaternion
  37112. */
  37113. set quaternion(q: Nullable<Quaternion>);
  37114. /**
  37115. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  37116. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  37117. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  37118. * @returns true if it intersects
  37119. */
  37120. intersectsMesh(target: Mesh | SolidParticle): boolean;
  37121. /**
  37122. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  37123. * A particle is in the frustum if its bounding box intersects the frustum
  37124. * @param frustumPlanes defines the frustum to test
  37125. * @returns true if the particle is in the frustum planes
  37126. */
  37127. isInFrustum(frustumPlanes: Plane[]): boolean;
  37128. /**
  37129. * get the rotation matrix of the particle
  37130. * @hidden
  37131. */
  37132. getRotationMatrix(m: Matrix): void;
  37133. }
  37134. /**
  37135. * Represents the shape of the model used by one particle of a solid particle system.
  37136. * SPS internal tool, don't use it manually.
  37137. */
  37138. export class ModelShape {
  37139. /**
  37140. * The shape id
  37141. * @hidden
  37142. */
  37143. shapeID: number;
  37144. /**
  37145. * flat array of model positions (internal use)
  37146. * @hidden
  37147. */
  37148. _shape: Vector3[];
  37149. /**
  37150. * flat array of model UVs (internal use)
  37151. * @hidden
  37152. */
  37153. _shapeUV: number[];
  37154. /**
  37155. * color array of the model
  37156. * @hidden
  37157. */
  37158. _shapeColors: number[];
  37159. /**
  37160. * indices array of the model
  37161. * @hidden
  37162. */
  37163. _indices: number[];
  37164. /**
  37165. * normals array of the model
  37166. * @hidden
  37167. */
  37168. _normals: number[];
  37169. /**
  37170. * length of the shape in the model indices array (internal use)
  37171. * @hidden
  37172. */
  37173. _indicesLength: number;
  37174. /**
  37175. * Custom position function (internal use)
  37176. * @hidden
  37177. */
  37178. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  37179. /**
  37180. * Custom vertex function (internal use)
  37181. * @hidden
  37182. */
  37183. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  37184. /**
  37185. * Model material (internal use)
  37186. * @hidden
  37187. */
  37188. _material: Nullable<Material>;
  37189. /**
  37190. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  37191. * SPS internal tool, don't use it manually.
  37192. * @hidden
  37193. */
  37194. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  37195. }
  37196. /**
  37197. * Represents a Depth Sorted Particle in the solid particle system.
  37198. * @hidden
  37199. */
  37200. export class DepthSortedParticle {
  37201. /**
  37202. * Particle index
  37203. */
  37204. idx: number;
  37205. /**
  37206. * Index of the particle in the "indices" array
  37207. */
  37208. ind: number;
  37209. /**
  37210. * Length of the particle shape in the "indices" array
  37211. */
  37212. indicesLength: number;
  37213. /**
  37214. * Squared distance from the particle to the camera
  37215. */
  37216. sqDistance: number;
  37217. /**
  37218. * Material index when used with MultiMaterials
  37219. */
  37220. materialIndex: number;
  37221. /**
  37222. * Creates a new sorted particle
  37223. * @param materialIndex
  37224. */
  37225. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  37226. }
  37227. /**
  37228. * Represents a solid particle vertex
  37229. */
  37230. export class SolidParticleVertex {
  37231. /**
  37232. * Vertex position
  37233. */
  37234. position: Vector3;
  37235. /**
  37236. * Vertex color
  37237. */
  37238. color: Color4;
  37239. /**
  37240. * Vertex UV
  37241. */
  37242. uv: Vector2;
  37243. /**
  37244. * Creates a new solid particle vertex
  37245. */
  37246. constructor();
  37247. /** Vertex x coordinate */
  37248. get x(): number;
  37249. set x(val: number);
  37250. /** Vertex y coordinate */
  37251. get y(): number;
  37252. set y(val: number);
  37253. /** Vertex z coordinate */
  37254. get z(): number;
  37255. set z(val: number);
  37256. }
  37257. }
  37258. declare module "babylonjs/Collisions/meshCollisionData" {
  37259. import { Collider } from "babylonjs/Collisions/collider";
  37260. import { Vector3 } from "babylonjs/Maths/math.vector";
  37261. import { Nullable } from "babylonjs/types";
  37262. import { Observer } from "babylonjs/Misc/observable";
  37263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37264. /**
  37265. * @hidden
  37266. */
  37267. export class _MeshCollisionData {
  37268. _checkCollisions: boolean;
  37269. _collisionMask: number;
  37270. _collisionGroup: number;
  37271. _surroundingMeshes: Nullable<AbstractMesh[]>;
  37272. _collider: Nullable<Collider>;
  37273. _oldPositionForCollisions: Vector3;
  37274. _diffPositionForCollisions: Vector3;
  37275. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  37276. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  37277. _collisionResponse: boolean;
  37278. }
  37279. }
  37280. declare module "babylonjs/Meshes/abstractMesh" {
  37281. import { Observable } from "babylonjs/Misc/observable";
  37282. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  37283. import { Camera } from "babylonjs/Cameras/camera";
  37284. import { Scene, IDisposable } from "babylonjs/scene";
  37285. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37286. import { Node } from "babylonjs/node";
  37287. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  37288. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37289. import { SubMesh } from "babylonjs/Meshes/subMesh";
  37290. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  37291. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  37292. import { Material } from "babylonjs/Materials/material";
  37293. import { Light } from "babylonjs/Lights/light";
  37294. import { Skeleton } from "babylonjs/Bones/skeleton";
  37295. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  37296. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  37297. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37298. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  37299. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  37300. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37301. import { Plane } from "babylonjs/Maths/math.plane";
  37302. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37303. import { Ray } from "babylonjs/Culling/ray";
  37304. import { Collider } from "babylonjs/Collisions/collider";
  37305. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  37306. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  37307. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  37308. /** @hidden */
  37309. class _FacetDataStorage {
  37310. facetPositions: Vector3[];
  37311. facetNormals: Vector3[];
  37312. facetPartitioning: number[][];
  37313. facetNb: number;
  37314. partitioningSubdivisions: number;
  37315. partitioningBBoxRatio: number;
  37316. facetDataEnabled: boolean;
  37317. facetParameters: any;
  37318. bbSize: Vector3;
  37319. subDiv: {
  37320. max: number;
  37321. X: number;
  37322. Y: number;
  37323. Z: number;
  37324. };
  37325. facetDepthSort: boolean;
  37326. facetDepthSortEnabled: boolean;
  37327. depthSortedIndices: IndicesArray;
  37328. depthSortedFacets: {
  37329. ind: number;
  37330. sqDistance: number;
  37331. }[];
  37332. facetDepthSortFunction: (f1: {
  37333. ind: number;
  37334. sqDistance: number;
  37335. }, f2: {
  37336. ind: number;
  37337. sqDistance: number;
  37338. }) => number;
  37339. facetDepthSortFrom: Vector3;
  37340. facetDepthSortOrigin: Vector3;
  37341. invertedMatrix: Matrix;
  37342. }
  37343. /**
  37344. * @hidden
  37345. **/
  37346. class _InternalAbstractMeshDataInfo {
  37347. _hasVertexAlpha: boolean;
  37348. _useVertexColors: boolean;
  37349. _numBoneInfluencers: number;
  37350. _applyFog: boolean;
  37351. _receiveShadows: boolean;
  37352. _facetData: _FacetDataStorage;
  37353. _visibility: number;
  37354. _skeleton: Nullable<Skeleton>;
  37355. _layerMask: number;
  37356. _computeBonesUsingShaders: boolean;
  37357. _isActive: boolean;
  37358. _onlyForInstances: boolean;
  37359. _isActiveIntermediate: boolean;
  37360. _onlyForInstancesIntermediate: boolean;
  37361. _actAsRegularMesh: boolean;
  37362. _currentLOD: Nullable<AbstractMesh>;
  37363. _currentLODIsUpToDate: boolean;
  37364. }
  37365. /**
  37366. * Class used to store all common mesh properties
  37367. */
  37368. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  37369. /** No occlusion */
  37370. static OCCLUSION_TYPE_NONE: number;
  37371. /** Occlusion set to optimisitic */
  37372. static OCCLUSION_TYPE_OPTIMISTIC: number;
  37373. /** Occlusion set to strict */
  37374. static OCCLUSION_TYPE_STRICT: number;
  37375. /** Use an accurante occlusion algorithm */
  37376. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  37377. /** Use a conservative occlusion algorithm */
  37378. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  37379. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  37380. * Test order :
  37381. * Is the bounding sphere outside the frustum ?
  37382. * If not, are the bounding box vertices outside the frustum ?
  37383. * It not, then the cullable object is in the frustum.
  37384. */
  37385. static readonly CULLINGSTRATEGY_STANDARD: number;
  37386. /** Culling strategy : Bounding Sphere Only.
  37387. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  37388. * It's also less accurate than the standard because some not visible objects can still be selected.
  37389. * Test : is the bounding sphere outside the frustum ?
  37390. * If not, then the cullable object is in the frustum.
  37391. */
  37392. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  37393. /** Culling strategy : Optimistic Inclusion.
  37394. * This in an inclusion test first, then the standard exclusion test.
  37395. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  37396. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  37397. * Anyway, it's as accurate as the standard strategy.
  37398. * Test :
  37399. * Is the cullable object bounding sphere center in the frustum ?
  37400. * If not, apply the default culling strategy.
  37401. */
  37402. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  37403. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  37404. * This in an inclusion test first, then the bounding sphere only exclusion test.
  37405. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  37406. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  37407. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  37408. * Test :
  37409. * Is the cullable object bounding sphere center in the frustum ?
  37410. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  37411. */
  37412. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  37413. /**
  37414. * No billboard
  37415. */
  37416. static get BILLBOARDMODE_NONE(): number;
  37417. /** Billboard on X axis */
  37418. static get BILLBOARDMODE_X(): number;
  37419. /** Billboard on Y axis */
  37420. static get BILLBOARDMODE_Y(): number;
  37421. /** Billboard on Z axis */
  37422. static get BILLBOARDMODE_Z(): number;
  37423. /** Billboard on all axes */
  37424. static get BILLBOARDMODE_ALL(): number;
  37425. /** Billboard on using position instead of orientation */
  37426. static get BILLBOARDMODE_USE_POSITION(): number;
  37427. /** @hidden */
  37428. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  37429. /**
  37430. * The culling strategy to use to check whether the mesh must be rendered or not.
  37431. * This value can be changed at any time and will be used on the next render mesh selection.
  37432. * The possible values are :
  37433. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  37434. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37435. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  37436. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  37437. * Please read each static variable documentation to get details about the culling process.
  37438. * */
  37439. cullingStrategy: number;
  37440. /**
  37441. * Gets the number of facets in the mesh
  37442. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37443. */
  37444. get facetNb(): number;
  37445. /**
  37446. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  37447. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37448. */
  37449. get partitioningSubdivisions(): number;
  37450. set partitioningSubdivisions(nb: number);
  37451. /**
  37452. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  37453. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  37454. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37455. */
  37456. get partitioningBBoxRatio(): number;
  37457. set partitioningBBoxRatio(ratio: number);
  37458. /**
  37459. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  37460. * Works only for updatable meshes.
  37461. * Doesn't work with multi-materials
  37462. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37463. */
  37464. get mustDepthSortFacets(): boolean;
  37465. set mustDepthSortFacets(sort: boolean);
  37466. /**
  37467. * The location (Vector3) where the facet depth sort must be computed from.
  37468. * By default, the active camera position.
  37469. * Used only when facet depth sort is enabled
  37470. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37471. */
  37472. get facetDepthSortFrom(): Vector3;
  37473. set facetDepthSortFrom(location: Vector3);
  37474. /**
  37475. * gets a boolean indicating if facetData is enabled
  37476. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37477. */
  37478. get isFacetDataEnabled(): boolean;
  37479. /** @hidden */
  37480. _updateNonUniformScalingState(value: boolean): boolean;
  37481. /**
  37482. * An event triggered when this mesh collides with another one
  37483. */
  37484. onCollideObservable: Observable<AbstractMesh>;
  37485. /** Set a function to call when this mesh collides with another one */
  37486. set onCollide(callback: () => void);
  37487. /**
  37488. * An event triggered when the collision's position changes
  37489. */
  37490. onCollisionPositionChangeObservable: Observable<Vector3>;
  37491. /** Set a function to call when the collision's position changes */
  37492. set onCollisionPositionChange(callback: () => void);
  37493. /**
  37494. * An event triggered when material is changed
  37495. */
  37496. onMaterialChangedObservable: Observable<AbstractMesh>;
  37497. /**
  37498. * Gets or sets the orientation for POV movement & rotation
  37499. */
  37500. definedFacingForward: boolean;
  37501. /** @hidden */
  37502. _occlusionQuery: Nullable<WebGLQuery>;
  37503. /** @hidden */
  37504. _renderingGroup: Nullable<RenderingGroup>;
  37505. /**
  37506. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37507. */
  37508. get visibility(): number;
  37509. /**
  37510. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37511. */
  37512. set visibility(value: number);
  37513. /** Gets or sets the alpha index used to sort transparent meshes
  37514. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  37515. */
  37516. alphaIndex: number;
  37517. /**
  37518. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  37519. */
  37520. isVisible: boolean;
  37521. /**
  37522. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37523. */
  37524. isPickable: boolean;
  37525. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  37526. showSubMeshesBoundingBox: boolean;
  37527. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  37528. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  37529. */
  37530. isBlocker: boolean;
  37531. /**
  37532. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  37533. */
  37534. enablePointerMoveEvents: boolean;
  37535. private _renderingGroupId;
  37536. /**
  37537. * Specifies the rendering group id for this mesh (0 by default)
  37538. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37539. */
  37540. get renderingGroupId(): number;
  37541. set renderingGroupId(value: number);
  37542. private _material;
  37543. /** Gets or sets current material */
  37544. get material(): Nullable<Material>;
  37545. set material(value: Nullable<Material>);
  37546. /**
  37547. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  37548. * @see https://doc.babylonjs.com/babylon101/shadows
  37549. */
  37550. get receiveShadows(): boolean;
  37551. set receiveShadows(value: boolean);
  37552. /** Defines color to use when rendering outline */
  37553. outlineColor: Color3;
  37554. /** Define width to use when rendering outline */
  37555. outlineWidth: number;
  37556. /** Defines color to use when rendering overlay */
  37557. overlayColor: Color3;
  37558. /** Defines alpha to use when rendering overlay */
  37559. overlayAlpha: number;
  37560. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  37561. get hasVertexAlpha(): boolean;
  37562. set hasVertexAlpha(value: boolean);
  37563. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  37564. get useVertexColors(): boolean;
  37565. set useVertexColors(value: boolean);
  37566. /**
  37567. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  37568. */
  37569. get computeBonesUsingShaders(): boolean;
  37570. set computeBonesUsingShaders(value: boolean);
  37571. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  37572. get numBoneInfluencers(): number;
  37573. set numBoneInfluencers(value: number);
  37574. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  37575. get applyFog(): boolean;
  37576. set applyFog(value: boolean);
  37577. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37578. useOctreeForRenderingSelection: boolean;
  37579. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37580. useOctreeForPicking: boolean;
  37581. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37582. useOctreeForCollisions: boolean;
  37583. /**
  37584. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37585. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37586. */
  37587. get layerMask(): number;
  37588. set layerMask(value: number);
  37589. /**
  37590. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37591. */
  37592. alwaysSelectAsActiveMesh: boolean;
  37593. /**
  37594. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37595. */
  37596. doNotSyncBoundingInfo: boolean;
  37597. /**
  37598. * Gets or sets the current action manager
  37599. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37600. */
  37601. actionManager: Nullable<AbstractActionManager>;
  37602. private _meshCollisionData;
  37603. /**
  37604. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37605. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37606. */
  37607. ellipsoid: Vector3;
  37608. /**
  37609. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37610. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37611. */
  37612. ellipsoidOffset: Vector3;
  37613. /**
  37614. * Gets or sets a collision mask used to mask collisions (default is -1).
  37615. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37616. */
  37617. get collisionMask(): number;
  37618. set collisionMask(mask: number);
  37619. /**
  37620. * Gets or sets a collision response flag (default is true).
  37621. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37622. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37623. * to respond to the collision.
  37624. */
  37625. get collisionResponse(): boolean;
  37626. set collisionResponse(response: boolean);
  37627. /**
  37628. * Gets or sets the current collision group mask (-1 by default).
  37629. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37630. */
  37631. get collisionGroup(): number;
  37632. set collisionGroup(mask: number);
  37633. /**
  37634. * Gets or sets current surrounding meshes (null by default).
  37635. *
  37636. * By default collision detection is tested against every mesh in the scene.
  37637. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37638. * meshes will be tested for the collision.
  37639. *
  37640. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37641. */
  37642. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37643. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37644. /**
  37645. * Defines edge width used when edgesRenderer is enabled
  37646. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37647. */
  37648. edgesWidth: number;
  37649. /**
  37650. * Defines edge color used when edgesRenderer is enabled
  37651. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37652. */
  37653. edgesColor: Color4;
  37654. /** @hidden */
  37655. _edgesRenderer: Nullable<IEdgesRenderer>;
  37656. /** @hidden */
  37657. _masterMesh: Nullable<AbstractMesh>;
  37658. /** @hidden */
  37659. _boundingInfo: Nullable<BoundingInfo>;
  37660. /** @hidden */
  37661. _renderId: number;
  37662. /**
  37663. * Gets or sets the list of subMeshes
  37664. * @see https://doc.babylonjs.com/how_to/multi_materials
  37665. */
  37666. subMeshes: SubMesh[];
  37667. /** @hidden */
  37668. _intersectionsInProgress: AbstractMesh[];
  37669. /** @hidden */
  37670. _unIndexed: boolean;
  37671. /** @hidden */
  37672. _lightSources: Light[];
  37673. /** Gets the list of lights affecting that mesh */
  37674. get lightSources(): Light[];
  37675. /** @hidden */
  37676. get _positions(): Nullable<Vector3[]>;
  37677. /** @hidden */
  37678. _waitingData: {
  37679. lods: Nullable<any>;
  37680. actions: Nullable<any>;
  37681. freezeWorldMatrix: Nullable<boolean>;
  37682. };
  37683. /** @hidden */
  37684. _bonesTransformMatrices: Nullable<Float32Array>;
  37685. /** @hidden */
  37686. _transformMatrixTexture: Nullable<RawTexture>;
  37687. /**
  37688. * Gets or sets a skeleton to apply skining transformations
  37689. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37690. */
  37691. set skeleton(value: Nullable<Skeleton>);
  37692. get skeleton(): Nullable<Skeleton>;
  37693. /**
  37694. * An event triggered when the mesh is rebuilt.
  37695. */
  37696. onRebuildObservable: Observable<AbstractMesh>;
  37697. /**
  37698. * The current mesh unifom buffer.
  37699. * @hidden Internal use only.
  37700. */
  37701. _uniformBuffer: UniformBuffer;
  37702. /**
  37703. * Creates a new AbstractMesh
  37704. * @param name defines the name of the mesh
  37705. * @param scene defines the hosting scene
  37706. */
  37707. constructor(name: string, scene?: Nullable<Scene>);
  37708. protected _buildUniformLayout(): void;
  37709. /**
  37710. * Transfer the mesh values to its UBO.
  37711. * @param world The world matrix associated with the mesh
  37712. */
  37713. transferToEffect(world: Matrix): void;
  37714. /**
  37715. * Gets the mesh uniform buffer.
  37716. * @return the uniform buffer of the mesh.
  37717. */
  37718. getMeshUniformBuffer(): UniformBuffer;
  37719. /**
  37720. * Returns the string "AbstractMesh"
  37721. * @returns "AbstractMesh"
  37722. */
  37723. getClassName(): string;
  37724. /**
  37725. * Gets a string representation of the current mesh
  37726. * @param fullDetails defines a boolean indicating if full details must be included
  37727. * @returns a string representation of the current mesh
  37728. */
  37729. toString(fullDetails?: boolean): string;
  37730. /**
  37731. * @hidden
  37732. */
  37733. protected _getEffectiveParent(): Nullable<Node>;
  37734. /** @hidden */
  37735. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37736. /** @hidden */
  37737. _rebuild(): void;
  37738. /** @hidden */
  37739. _resyncLightSources(): void;
  37740. /** @hidden */
  37741. _resyncLightSource(light: Light): void;
  37742. /** @hidden */
  37743. _unBindEffect(): void;
  37744. /** @hidden */
  37745. _removeLightSource(light: Light, dispose: boolean): void;
  37746. private _markSubMeshesAsDirty;
  37747. /** @hidden */
  37748. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37749. /** @hidden */
  37750. _markSubMeshesAsAttributesDirty(): void;
  37751. /** @hidden */
  37752. _markSubMeshesAsMiscDirty(): void;
  37753. /**
  37754. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37755. */
  37756. get scaling(): Vector3;
  37757. set scaling(newScaling: Vector3);
  37758. /**
  37759. * Returns true if the mesh is blocked. Implemented by child classes
  37760. */
  37761. get isBlocked(): boolean;
  37762. /**
  37763. * Returns the mesh itself by default. Implemented by child classes
  37764. * @param camera defines the camera to use to pick the right LOD level
  37765. * @returns the currentAbstractMesh
  37766. */
  37767. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37768. /**
  37769. * Returns 0 by default. Implemented by child classes
  37770. * @returns an integer
  37771. */
  37772. getTotalVertices(): number;
  37773. /**
  37774. * Returns a positive integer : the total number of indices in this mesh geometry.
  37775. * @returns the numner of indices or zero if the mesh has no geometry.
  37776. */
  37777. getTotalIndices(): number;
  37778. /**
  37779. * Returns null by default. Implemented by child classes
  37780. * @returns null
  37781. */
  37782. getIndices(): Nullable<IndicesArray>;
  37783. /**
  37784. * Returns the array of the requested vertex data kind. Implemented by child classes
  37785. * @param kind defines the vertex data kind to use
  37786. * @returns null
  37787. */
  37788. getVerticesData(kind: string): Nullable<FloatArray>;
  37789. /**
  37790. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37791. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37792. * Note that a new underlying VertexBuffer object is created each call.
  37793. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37794. * @param kind defines vertex data kind:
  37795. * * VertexBuffer.PositionKind
  37796. * * VertexBuffer.UVKind
  37797. * * VertexBuffer.UV2Kind
  37798. * * VertexBuffer.UV3Kind
  37799. * * VertexBuffer.UV4Kind
  37800. * * VertexBuffer.UV5Kind
  37801. * * VertexBuffer.UV6Kind
  37802. * * VertexBuffer.ColorKind
  37803. * * VertexBuffer.MatricesIndicesKind
  37804. * * VertexBuffer.MatricesIndicesExtraKind
  37805. * * VertexBuffer.MatricesWeightsKind
  37806. * * VertexBuffer.MatricesWeightsExtraKind
  37807. * @param data defines the data source
  37808. * @param updatable defines if the data must be flagged as updatable (or static)
  37809. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  37810. * @returns the current mesh
  37811. */
  37812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37813. /**
  37814. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37815. * If the mesh has no geometry, it is simply returned as it is.
  37816. * @param kind defines vertex data kind:
  37817. * * VertexBuffer.PositionKind
  37818. * * VertexBuffer.UVKind
  37819. * * VertexBuffer.UV2Kind
  37820. * * VertexBuffer.UV3Kind
  37821. * * VertexBuffer.UV4Kind
  37822. * * VertexBuffer.UV5Kind
  37823. * * VertexBuffer.UV6Kind
  37824. * * VertexBuffer.ColorKind
  37825. * * VertexBuffer.MatricesIndicesKind
  37826. * * VertexBuffer.MatricesIndicesExtraKind
  37827. * * VertexBuffer.MatricesWeightsKind
  37828. * * VertexBuffer.MatricesWeightsExtraKind
  37829. * @param data defines the data source
  37830. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  37831. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37832. * @returns the current mesh
  37833. */
  37834. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37835. /**
  37836. * Sets the mesh indices,
  37837. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37838. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37839. * @param totalVertices Defines the total number of vertices
  37840. * @returns the current mesh
  37841. */
  37842. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37843. /**
  37844. * Gets a boolean indicating if specific vertex data is present
  37845. * @param kind defines the vertex data kind to use
  37846. * @returns true is data kind is present
  37847. */
  37848. isVerticesDataPresent(kind: string): boolean;
  37849. /**
  37850. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37851. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37852. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37853. * @returns a BoundingInfo
  37854. */
  37855. getBoundingInfo(): BoundingInfo;
  37856. /**
  37857. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37858. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37859. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37860. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37861. * @returns the current mesh
  37862. */
  37863. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37864. /**
  37865. * Overwrite the current bounding info
  37866. * @param boundingInfo defines the new bounding info
  37867. * @returns the current mesh
  37868. */
  37869. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37870. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37871. get useBones(): boolean;
  37872. /** @hidden */
  37873. _preActivate(): void;
  37874. /** @hidden */
  37875. _preActivateForIntermediateRendering(renderId: number): void;
  37876. /** @hidden */
  37877. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37878. /** @hidden */
  37879. _postActivate(): void;
  37880. /** @hidden */
  37881. _freeze(): void;
  37882. /** @hidden */
  37883. _unFreeze(): void;
  37884. /**
  37885. * Gets the current world matrix
  37886. * @returns a Matrix
  37887. */
  37888. getWorldMatrix(): Matrix;
  37889. /** @hidden */
  37890. _getWorldMatrixDeterminant(): number;
  37891. /**
  37892. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37893. */
  37894. get isAnInstance(): boolean;
  37895. /**
  37896. * Gets a boolean indicating if this mesh has instances
  37897. */
  37898. get hasInstances(): boolean;
  37899. /**
  37900. * Gets a boolean indicating if this mesh has thin instances
  37901. */
  37902. get hasThinInstances(): boolean;
  37903. /**
  37904. * Perform relative position change from the point of view of behind the front of the mesh.
  37905. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37906. * Supports definition of mesh facing forward or backward
  37907. * @param amountRight defines the distance on the right axis
  37908. * @param amountUp defines the distance on the up axis
  37909. * @param amountForward defines the distance on the forward axis
  37910. * @returns the current mesh
  37911. */
  37912. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37913. /**
  37914. * Calculate relative position change from the point of view of behind the front of the mesh.
  37915. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37916. * Supports definition of mesh facing forward or backward
  37917. * @param amountRight defines the distance on the right axis
  37918. * @param amountUp defines the distance on the up axis
  37919. * @param amountForward defines the distance on the forward axis
  37920. * @returns the new displacement vector
  37921. */
  37922. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37923. /**
  37924. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37925. * Supports definition of mesh facing forward or backward
  37926. * @param flipBack defines the flip
  37927. * @param twirlClockwise defines the twirl
  37928. * @param tiltRight defines the tilt
  37929. * @returns the current mesh
  37930. */
  37931. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37932. /**
  37933. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37934. * Supports definition of mesh facing forward or backward.
  37935. * @param flipBack defines the flip
  37936. * @param twirlClockwise defines the twirl
  37937. * @param tiltRight defines the tilt
  37938. * @returns the new rotation vector
  37939. */
  37940. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37941. /**
  37942. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37943. * This means the mesh underlying bounding box and sphere are recomputed.
  37944. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37945. * @returns the current mesh
  37946. */
  37947. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37948. /** @hidden */
  37949. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37950. /** @hidden */
  37951. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37952. /** @hidden */
  37953. _updateBoundingInfo(): AbstractMesh;
  37954. /** @hidden */
  37955. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37956. /** @hidden */
  37957. protected _afterComputeWorldMatrix(): void;
  37958. /** @hidden */
  37959. get _effectiveMesh(): AbstractMesh;
  37960. /**
  37961. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37962. * A mesh is in the frustum if its bounding box intersects the frustum
  37963. * @param frustumPlanes defines the frustum to test
  37964. * @returns true if the mesh is in the frustum planes
  37965. */
  37966. isInFrustum(frustumPlanes: Plane[]): boolean;
  37967. /**
  37968. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37969. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37970. * @param frustumPlanes defines the frustum to test
  37971. * @returns true if the mesh is completely in the frustum planes
  37972. */
  37973. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37974. /**
  37975. * True if the mesh intersects another mesh or a SolidParticle object
  37976. * @param mesh defines a target mesh or SolidParticle to test
  37977. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  37978. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37979. * @returns true if there is an intersection
  37980. */
  37981. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37982. /**
  37983. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37984. * @param point defines the point to test
  37985. * @returns true if there is an intersection
  37986. */
  37987. intersectsPoint(point: Vector3): boolean;
  37988. /**
  37989. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37990. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37991. */
  37992. get checkCollisions(): boolean;
  37993. set checkCollisions(collisionEnabled: boolean);
  37994. /**
  37995. * Gets Collider object used to compute collisions (not physics)
  37996. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37997. */
  37998. get collider(): Nullable<Collider>;
  37999. /**
  38000. * Move the mesh using collision engine
  38001. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38002. * @param displacement defines the requested displacement vector
  38003. * @returns the current mesh
  38004. */
  38005. moveWithCollisions(displacement: Vector3): AbstractMesh;
  38006. private _onCollisionPositionChange;
  38007. /** @hidden */
  38008. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  38009. /** @hidden */
  38010. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  38011. /** @hidden */
  38012. _checkCollision(collider: Collider): AbstractMesh;
  38013. /** @hidden */
  38014. _generatePointsArray(): boolean;
  38015. /**
  38016. * Checks if the passed Ray intersects with the mesh
  38017. * @param ray defines the ray to use
  38018. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  38019. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38020. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  38021. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  38022. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  38023. * @returns the picking info
  38024. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  38025. */
  38026. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  38027. /**
  38028. * Clones the current mesh
  38029. * @param name defines the mesh name
  38030. * @param newParent defines the new mesh parent
  38031. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  38032. * @returns the new mesh
  38033. */
  38034. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  38035. /**
  38036. * Disposes all the submeshes of the current meshnp
  38037. * @returns the current mesh
  38038. */
  38039. releaseSubMeshes(): AbstractMesh;
  38040. /**
  38041. * Releases resources associated with this abstract mesh.
  38042. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38043. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38044. */
  38045. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38046. /**
  38047. * Adds the passed mesh as a child to the current mesh
  38048. * @param mesh defines the child mesh
  38049. * @returns the current mesh
  38050. */
  38051. addChild(mesh: AbstractMesh): AbstractMesh;
  38052. /**
  38053. * Removes the passed mesh from the current mesh children list
  38054. * @param mesh defines the child mesh
  38055. * @returns the current mesh
  38056. */
  38057. removeChild(mesh: AbstractMesh): AbstractMesh;
  38058. /** @hidden */
  38059. private _initFacetData;
  38060. /**
  38061. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  38062. * This method can be called within the render loop.
  38063. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  38064. * @returns the current mesh
  38065. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38066. */
  38067. updateFacetData(): AbstractMesh;
  38068. /**
  38069. * Returns the facetLocalNormals array.
  38070. * The normals are expressed in the mesh local spac
  38071. * @returns an array of Vector3
  38072. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38073. */
  38074. getFacetLocalNormals(): Vector3[];
  38075. /**
  38076. * Returns the facetLocalPositions array.
  38077. * The facet positions are expressed in the mesh local space
  38078. * @returns an array of Vector3
  38079. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38080. */
  38081. getFacetLocalPositions(): Vector3[];
  38082. /**
  38083. * Returns the facetLocalPartioning array
  38084. * @returns an array of array of numbers
  38085. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38086. */
  38087. getFacetLocalPartitioning(): number[][];
  38088. /**
  38089. * Returns the i-th facet position in the world system.
  38090. * This method allocates a new Vector3 per call
  38091. * @param i defines the facet index
  38092. * @returns a new Vector3
  38093. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38094. */
  38095. getFacetPosition(i: number): Vector3;
  38096. /**
  38097. * Sets the reference Vector3 with the i-th facet position in the world system
  38098. * @param i defines the facet index
  38099. * @param ref defines the target vector
  38100. * @returns the current mesh
  38101. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38102. */
  38103. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  38104. /**
  38105. * Returns the i-th facet normal in the world system.
  38106. * This method allocates a new Vector3 per call
  38107. * @param i defines the facet index
  38108. * @returns a new Vector3
  38109. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38110. */
  38111. getFacetNormal(i: number): Vector3;
  38112. /**
  38113. * Sets the reference Vector3 with the i-th facet normal in the world system
  38114. * @param i defines the facet index
  38115. * @param ref defines the target vector
  38116. * @returns the current mesh
  38117. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38118. */
  38119. getFacetNormalToRef(i: number, ref: Vector3): this;
  38120. /**
  38121. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  38122. * @param x defines x coordinate
  38123. * @param y defines y coordinate
  38124. * @param z defines z coordinate
  38125. * @returns the array of facet indexes
  38126. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38127. */
  38128. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  38129. /**
  38130. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  38131. * @param projected sets as the (x,y,z) world projection on the facet
  38132. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  38133. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  38134. * @param x defines x coordinate
  38135. * @param y defines y coordinate
  38136. * @param z defines z coordinate
  38137. * @returns the face index if found (or null instead)
  38138. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38139. */
  38140. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38141. /**
  38142. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  38143. * @param projected sets as the (x,y,z) local projection on the facet
  38144. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  38145. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  38146. * @param x defines x coordinate
  38147. * @param y defines y coordinate
  38148. * @param z defines z coordinate
  38149. * @returns the face index if found (or null instead)
  38150. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38151. */
  38152. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38153. /**
  38154. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  38155. * @returns the parameters
  38156. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38157. */
  38158. getFacetDataParameters(): any;
  38159. /**
  38160. * Disables the feature FacetData and frees the related memory
  38161. * @returns the current mesh
  38162. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38163. */
  38164. disableFacetData(): AbstractMesh;
  38165. /**
  38166. * Updates the AbstractMesh indices array
  38167. * @param indices defines the data source
  38168. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  38169. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  38170. * @returns the current mesh
  38171. */
  38172. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  38173. /**
  38174. * Creates new normals data for the mesh
  38175. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  38176. * @returns the current mesh
  38177. */
  38178. createNormals(updatable: boolean): AbstractMesh;
  38179. /**
  38180. * Align the mesh with a normal
  38181. * @param normal defines the normal to use
  38182. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  38183. * @returns the current mesh
  38184. */
  38185. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  38186. /** @hidden */
  38187. _checkOcclusionQuery(): boolean;
  38188. /**
  38189. * Disables the mesh edge rendering mode
  38190. * @returns the currentAbstractMesh
  38191. */
  38192. disableEdgesRendering(): AbstractMesh;
  38193. /**
  38194. * Enables the edge rendering mode on the mesh.
  38195. * This mode makes the mesh edges visible
  38196. * @param epsilon defines the maximal distance between two angles to detect a face
  38197. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  38198. * @param options options to the edge renderer
  38199. * @returns the currentAbstractMesh
  38200. * @see https://www.babylonjs-playground.com/#19O9TU#0
  38201. */
  38202. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  38203. /**
  38204. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  38205. * @returns an array of particle systems in the scene that use the mesh as an emitter
  38206. */
  38207. getConnectedParticleSystems(): IParticleSystem[];
  38208. }
  38209. }
  38210. declare module "babylonjs/Actions/actionEvent" {
  38211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38212. import { Nullable } from "babylonjs/types";
  38213. import { Sprite } from "babylonjs/Sprites/sprite";
  38214. import { Scene } from "babylonjs/scene";
  38215. import { Vector2 } from "babylonjs/Maths/math.vector";
  38216. /**
  38217. * Interface used to define ActionEvent
  38218. */
  38219. export interface IActionEvent {
  38220. /** The mesh or sprite that triggered the action */
  38221. source: any;
  38222. /** The X mouse cursor position at the time of the event */
  38223. pointerX: number;
  38224. /** The Y mouse cursor position at the time of the event */
  38225. pointerY: number;
  38226. /** The mesh that is currently pointed at (can be null) */
  38227. meshUnderPointer: Nullable<AbstractMesh>;
  38228. /** the original (browser) event that triggered the ActionEvent */
  38229. sourceEvent?: any;
  38230. /** additional data for the event */
  38231. additionalData?: any;
  38232. }
  38233. /**
  38234. * ActionEvent is the event being sent when an action is triggered.
  38235. */
  38236. export class ActionEvent implements IActionEvent {
  38237. /** The mesh or sprite that triggered the action */
  38238. source: any;
  38239. /** The X mouse cursor position at the time of the event */
  38240. pointerX: number;
  38241. /** The Y mouse cursor position at the time of the event */
  38242. pointerY: number;
  38243. /** The mesh that is currently pointed at (can be null) */
  38244. meshUnderPointer: Nullable<AbstractMesh>;
  38245. /** the original (browser) event that triggered the ActionEvent */
  38246. sourceEvent?: any;
  38247. /** additional data for the event */
  38248. additionalData?: any;
  38249. /**
  38250. * Creates a new ActionEvent
  38251. * @param source The mesh or sprite that triggered the action
  38252. * @param pointerX The X mouse cursor position at the time of the event
  38253. * @param pointerY The Y mouse cursor position at the time of the event
  38254. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  38255. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  38256. * @param additionalData additional data for the event
  38257. */
  38258. constructor(
  38259. /** The mesh or sprite that triggered the action */
  38260. source: any,
  38261. /** The X mouse cursor position at the time of the event */
  38262. pointerX: number,
  38263. /** The Y mouse cursor position at the time of the event */
  38264. pointerY: number,
  38265. /** The mesh that is currently pointed at (can be null) */
  38266. meshUnderPointer: Nullable<AbstractMesh>,
  38267. /** the original (browser) event that triggered the ActionEvent */
  38268. sourceEvent?: any,
  38269. /** additional data for the event */
  38270. additionalData?: any);
  38271. /**
  38272. * Helper function to auto-create an ActionEvent from a source mesh.
  38273. * @param source The source mesh that triggered the event
  38274. * @param evt The original (browser) event
  38275. * @param additionalData additional data for the event
  38276. * @returns the new ActionEvent
  38277. */
  38278. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  38279. /**
  38280. * Helper function to auto-create an ActionEvent from a source sprite
  38281. * @param source The source sprite that triggered the event
  38282. * @param scene Scene associated with the sprite
  38283. * @param evt The original (browser) event
  38284. * @param additionalData additional data for the event
  38285. * @returns the new ActionEvent
  38286. */
  38287. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  38288. /**
  38289. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  38290. * @param scene the scene where the event occurred
  38291. * @param evt The original (browser) event
  38292. * @returns the new ActionEvent
  38293. */
  38294. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  38295. /**
  38296. * Helper function to auto-create an ActionEvent from a primitive
  38297. * @param prim defines the target primitive
  38298. * @param pointerPos defines the pointer position
  38299. * @param evt The original (browser) event
  38300. * @param additionalData additional data for the event
  38301. * @returns the new ActionEvent
  38302. */
  38303. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  38304. }
  38305. }
  38306. declare module "babylonjs/Actions/abstractActionManager" {
  38307. import { IDisposable } from "babylonjs/scene";
  38308. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  38309. import { IAction } from "babylonjs/Actions/action";
  38310. import { Nullable } from "babylonjs/types";
  38311. /**
  38312. * Abstract class used to decouple action Manager from scene and meshes.
  38313. * Do not instantiate.
  38314. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  38315. */
  38316. export abstract class AbstractActionManager implements IDisposable {
  38317. /** Gets the list of active triggers */
  38318. static Triggers: {
  38319. [key: string]: number;
  38320. };
  38321. /** Gets the cursor to use when hovering items */
  38322. hoverCursor: string;
  38323. /** Gets the list of actions */
  38324. actions: IAction[];
  38325. /**
  38326. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  38327. */
  38328. isRecursive: boolean;
  38329. /**
  38330. * Releases all associated resources
  38331. */
  38332. abstract dispose(): void;
  38333. /**
  38334. * Does this action manager has pointer triggers
  38335. */
  38336. abstract get hasPointerTriggers(): boolean;
  38337. /**
  38338. * Does this action manager has pick triggers
  38339. */
  38340. abstract get hasPickTriggers(): boolean;
  38341. /**
  38342. * Process a specific trigger
  38343. * @param trigger defines the trigger to process
  38344. * @param evt defines the event details to be processed
  38345. */
  38346. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  38347. /**
  38348. * Does this action manager handles actions of any of the given triggers
  38349. * @param triggers defines the triggers to be tested
  38350. * @return a boolean indicating whether one (or more) of the triggers is handled
  38351. */
  38352. abstract hasSpecificTriggers(triggers: number[]): boolean;
  38353. /**
  38354. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  38355. * speed.
  38356. * @param triggerA defines the trigger to be tested
  38357. * @param triggerB defines the trigger to be tested
  38358. * @return a boolean indicating whether one (or more) of the triggers is handled
  38359. */
  38360. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  38361. /**
  38362. * Does this action manager handles actions of a given trigger
  38363. * @param trigger defines the trigger to be tested
  38364. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  38365. * @return whether the trigger is handled
  38366. */
  38367. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  38368. /**
  38369. * Serialize this manager to a JSON object
  38370. * @param name defines the property name to store this manager
  38371. * @returns a JSON representation of this manager
  38372. */
  38373. abstract serialize(name: string): any;
  38374. /**
  38375. * Registers an action to this action manager
  38376. * @param action defines the action to be registered
  38377. * @return the action amended (prepared) after registration
  38378. */
  38379. abstract registerAction(action: IAction): Nullable<IAction>;
  38380. /**
  38381. * Unregisters an action to this action manager
  38382. * @param action defines the action to be unregistered
  38383. * @return a boolean indicating whether the action has been unregistered
  38384. */
  38385. abstract unregisterAction(action: IAction): Boolean;
  38386. /**
  38387. * Does exist one action manager with at least one trigger
  38388. **/
  38389. static get HasTriggers(): boolean;
  38390. /**
  38391. * Does exist one action manager with at least one pick trigger
  38392. **/
  38393. static get HasPickTriggers(): boolean;
  38394. /**
  38395. * Does exist one action manager that handles actions of a given trigger
  38396. * @param trigger defines the trigger to be tested
  38397. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  38398. **/
  38399. static HasSpecificTrigger(trigger: number): boolean;
  38400. }
  38401. }
  38402. declare module "babylonjs/node" {
  38403. import { Scene } from "babylonjs/scene";
  38404. import { Nullable } from "babylonjs/types";
  38405. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38406. import { Engine } from "babylonjs/Engines/engine";
  38407. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  38408. import { Observable } from "babylonjs/Misc/observable";
  38409. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38410. import { IInspectable } from "babylonjs/Misc/iInspectable";
  38411. import { Animatable } from "babylonjs/Animations/animatable";
  38412. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  38413. import { Animation } from "babylonjs/Animations/animation";
  38414. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38416. /**
  38417. * Defines how a node can be built from a string name.
  38418. */
  38419. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  38420. /**
  38421. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  38422. */
  38423. export class Node implements IBehaviorAware<Node> {
  38424. /** @hidden */
  38425. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  38426. private static _NodeConstructors;
  38427. /**
  38428. * Add a new node constructor
  38429. * @param type defines the type name of the node to construct
  38430. * @param constructorFunc defines the constructor function
  38431. */
  38432. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  38433. /**
  38434. * Returns a node constructor based on type name
  38435. * @param type defines the type name
  38436. * @param name defines the new node name
  38437. * @param scene defines the hosting scene
  38438. * @param options defines optional options to transmit to constructors
  38439. * @returns the new constructor or null
  38440. */
  38441. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  38442. /**
  38443. * Gets or sets the name of the node
  38444. */
  38445. name: string;
  38446. /**
  38447. * Gets or sets the id of the node
  38448. */
  38449. id: string;
  38450. /**
  38451. * Gets or sets the unique id of the node
  38452. */
  38453. uniqueId: number;
  38454. /**
  38455. * Gets or sets a string used to store user defined state for the node
  38456. */
  38457. state: string;
  38458. /**
  38459. * Gets or sets an object used to store user defined information for the node
  38460. */
  38461. metadata: any;
  38462. /**
  38463. * For internal use only. Please do not use.
  38464. */
  38465. reservedDataStore: any;
  38466. /**
  38467. * List of inspectable custom properties (used by the Inspector)
  38468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  38469. */
  38470. inspectableCustomProperties: IInspectable[];
  38471. private _doNotSerialize;
  38472. /**
  38473. * Gets or sets a boolean used to define if the node must be serialized
  38474. */
  38475. get doNotSerialize(): boolean;
  38476. set doNotSerialize(value: boolean);
  38477. /** @hidden */
  38478. _isDisposed: boolean;
  38479. /**
  38480. * Gets a list of Animations associated with the node
  38481. */
  38482. animations: import("babylonjs/Animations/animation").Animation[];
  38483. protected _ranges: {
  38484. [name: string]: Nullable<AnimationRange>;
  38485. };
  38486. /**
  38487. * Callback raised when the node is ready to be used
  38488. */
  38489. onReady: Nullable<(node: Node) => void>;
  38490. private _isEnabled;
  38491. private _isParentEnabled;
  38492. private _isReady;
  38493. /** @hidden */
  38494. _currentRenderId: number;
  38495. private _parentUpdateId;
  38496. /** @hidden */
  38497. _childUpdateId: number;
  38498. /** @hidden */
  38499. _waitingParentId: Nullable<string>;
  38500. /** @hidden */
  38501. _scene: Scene;
  38502. /** @hidden */
  38503. _cache: any;
  38504. private _parentNode;
  38505. private _children;
  38506. /** @hidden */
  38507. _worldMatrix: Matrix;
  38508. /** @hidden */
  38509. _worldMatrixDeterminant: number;
  38510. /** @hidden */
  38511. _worldMatrixDeterminantIsDirty: boolean;
  38512. /** @hidden */
  38513. private _sceneRootNodesIndex;
  38514. /**
  38515. * Gets a boolean indicating if the node has been disposed
  38516. * @returns true if the node was disposed
  38517. */
  38518. isDisposed(): boolean;
  38519. /**
  38520. * Gets or sets the parent of the node (without keeping the current position in the scene)
  38521. * @see https://doc.babylonjs.com/how_to/parenting
  38522. */
  38523. set parent(parent: Nullable<Node>);
  38524. get parent(): Nullable<Node>;
  38525. /** @hidden */
  38526. _addToSceneRootNodes(): void;
  38527. /** @hidden */
  38528. _removeFromSceneRootNodes(): void;
  38529. private _animationPropertiesOverride;
  38530. /**
  38531. * Gets or sets the animation properties override
  38532. */
  38533. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38534. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38535. /**
  38536. * Gets a string identifying the name of the class
  38537. * @returns "Node" string
  38538. */
  38539. getClassName(): string;
  38540. /** @hidden */
  38541. readonly _isNode: boolean;
  38542. /**
  38543. * An event triggered when the mesh is disposed
  38544. */
  38545. onDisposeObservable: Observable<Node>;
  38546. private _onDisposeObserver;
  38547. /**
  38548. * Sets a callback that will be raised when the node will be disposed
  38549. */
  38550. set onDispose(callback: () => void);
  38551. /**
  38552. * Creates a new Node
  38553. * @param name the name and id to be given to this node
  38554. * @param scene the scene this node will be added to
  38555. */
  38556. constructor(name: string, scene?: Nullable<Scene>);
  38557. /**
  38558. * Gets the scene of the node
  38559. * @returns a scene
  38560. */
  38561. getScene(): Scene;
  38562. /**
  38563. * Gets the engine of the node
  38564. * @returns a Engine
  38565. */
  38566. getEngine(): Engine;
  38567. private _behaviors;
  38568. /**
  38569. * Attach a behavior to the node
  38570. * @see https://doc.babylonjs.com/features/behaviour
  38571. * @param behavior defines the behavior to attach
  38572. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  38573. * @returns the current Node
  38574. */
  38575. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  38576. /**
  38577. * Remove an attached behavior
  38578. * @see https://doc.babylonjs.com/features/behaviour
  38579. * @param behavior defines the behavior to attach
  38580. * @returns the current Node
  38581. */
  38582. removeBehavior(behavior: Behavior<Node>): Node;
  38583. /**
  38584. * Gets the list of attached behaviors
  38585. * @see https://doc.babylonjs.com/features/behaviour
  38586. */
  38587. get behaviors(): Behavior<Node>[];
  38588. /**
  38589. * Gets an attached behavior by name
  38590. * @param name defines the name of the behavior to look for
  38591. * @see https://doc.babylonjs.com/features/behaviour
  38592. * @returns null if behavior was not found else the requested behavior
  38593. */
  38594. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38595. /**
  38596. * Returns the latest update of the World matrix
  38597. * @returns a Matrix
  38598. */
  38599. getWorldMatrix(): Matrix;
  38600. /** @hidden */
  38601. _getWorldMatrixDeterminant(): number;
  38602. /**
  38603. * Returns directly the latest state of the mesh World matrix.
  38604. * A Matrix is returned.
  38605. */
  38606. get worldMatrixFromCache(): Matrix;
  38607. /** @hidden */
  38608. _initCache(): void;
  38609. /** @hidden */
  38610. updateCache(force?: boolean): void;
  38611. /** @hidden */
  38612. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38613. /** @hidden */
  38614. _updateCache(ignoreParentClass?: boolean): void;
  38615. /** @hidden */
  38616. _isSynchronized(): boolean;
  38617. /** @hidden */
  38618. _markSyncedWithParent(): void;
  38619. /** @hidden */
  38620. isSynchronizedWithParent(): boolean;
  38621. /** @hidden */
  38622. isSynchronized(): boolean;
  38623. /**
  38624. * Is this node ready to be used/rendered
  38625. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38626. * @return true if the node is ready
  38627. */
  38628. isReady(completeCheck?: boolean): boolean;
  38629. /**
  38630. * Is this node enabled?
  38631. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  38632. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  38633. * @return whether this node (and its parent) is enabled
  38634. */
  38635. isEnabled(checkAncestors?: boolean): boolean;
  38636. /** @hidden */
  38637. protected _syncParentEnabledState(): void;
  38638. /**
  38639. * Set the enabled state of this node
  38640. * @param value defines the new enabled state
  38641. */
  38642. setEnabled(value: boolean): void;
  38643. /**
  38644. * Is this node a descendant of the given node?
  38645. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38646. * @param ancestor defines the parent node to inspect
  38647. * @returns a boolean indicating if this node is a descendant of the given node
  38648. */
  38649. isDescendantOf(ancestor: Node): boolean;
  38650. /** @hidden */
  38651. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38652. /**
  38653. * Will return all nodes that have this node as ascendant
  38654. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  38655. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  38656. * @return all children nodes of all types
  38657. */
  38658. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38659. /**
  38660. * Get all child-meshes of this node
  38661. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  38662. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  38663. * @returns an array of AbstractMesh
  38664. */
  38665. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38666. /**
  38667. * Get all direct children of this node
  38668. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  38669. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  38670. * @returns an array of Node
  38671. */
  38672. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38673. /** @hidden */
  38674. _setReady(state: boolean): void;
  38675. /**
  38676. * Get an animation by name
  38677. * @param name defines the name of the animation to look for
  38678. * @returns null if not found else the requested animation
  38679. */
  38680. getAnimationByName(name: string): Nullable<Animation>;
  38681. /**
  38682. * Creates an animation range for this node
  38683. * @param name defines the name of the range
  38684. * @param from defines the starting key
  38685. * @param to defines the end key
  38686. */
  38687. createAnimationRange(name: string, from: number, to: number): void;
  38688. /**
  38689. * Delete a specific animation range
  38690. * @param name defines the name of the range to delete
  38691. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38692. */
  38693. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38694. /**
  38695. * Get an animation range by name
  38696. * @param name defines the name of the animation range to look for
  38697. * @returns null if not found else the requested animation range
  38698. */
  38699. getAnimationRange(name: string): Nullable<AnimationRange>;
  38700. /**
  38701. * Gets the list of all animation ranges defined on this node
  38702. * @returns an array
  38703. */
  38704. getAnimationRanges(): Nullable<AnimationRange>[];
  38705. /**
  38706. * Will start the animation sequence
  38707. * @param name defines the range frames for animation sequence
  38708. * @param loop defines if the animation should loop (false by default)
  38709. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38710. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38711. * @returns the object created for this animation. If range does not exist, it will return null
  38712. */
  38713. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38714. /**
  38715. * Serialize animation ranges into a JSON compatible object
  38716. * @returns serialization object
  38717. */
  38718. serializeAnimationRanges(): any;
  38719. /**
  38720. * Computes the world matrix of the node
  38721. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38722. * @returns the world matrix
  38723. */
  38724. computeWorldMatrix(force?: boolean): Matrix;
  38725. /**
  38726. * Releases resources associated with this node.
  38727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38729. */
  38730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38731. /**
  38732. * Parse animation range data from a serialization object and store them into a given node
  38733. * @param node defines where to store the animation ranges
  38734. * @param parsedNode defines the serialization object to read data from
  38735. * @param scene defines the hosting scene
  38736. */
  38737. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38738. /**
  38739. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38740. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38741. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  38742. * @returns the new bounding vectors
  38743. */
  38744. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38745. min: Vector3;
  38746. max: Vector3;
  38747. };
  38748. }
  38749. }
  38750. declare module "babylonjs/Animations/animation" {
  38751. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38752. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38753. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38754. import { Nullable } from "babylonjs/types";
  38755. import { Scene } from "babylonjs/scene";
  38756. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38757. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38758. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38759. import { Node } from "babylonjs/node";
  38760. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38761. import { Size } from "babylonjs/Maths/math.size";
  38762. import { Animatable } from "babylonjs/Animations/animatable";
  38763. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38764. /**
  38765. * @hidden
  38766. */
  38767. export class _IAnimationState {
  38768. key: number;
  38769. repeatCount: number;
  38770. workValue?: any;
  38771. loopMode?: number;
  38772. offsetValue?: any;
  38773. highLimitValue?: any;
  38774. }
  38775. /**
  38776. * Class used to store any kind of animation
  38777. */
  38778. export class Animation {
  38779. /**Name of the animation */
  38780. name: string;
  38781. /**Property to animate */
  38782. targetProperty: string;
  38783. /**The frames per second of the animation */
  38784. framePerSecond: number;
  38785. /**The data type of the animation */
  38786. dataType: number;
  38787. /**The loop mode of the animation */
  38788. loopMode?: number | undefined;
  38789. /**Specifies if blending should be enabled */
  38790. enableBlending?: boolean | undefined;
  38791. /**
  38792. * Use matrix interpolation instead of using direct key value when animating matrices
  38793. */
  38794. static AllowMatricesInterpolation: boolean;
  38795. /**
  38796. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38797. */
  38798. static AllowMatrixDecomposeForInterpolation: boolean;
  38799. /** Define the Url to load snippets */
  38800. static SnippetUrl: string;
  38801. /** Snippet ID if the animation was created from the snippet server */
  38802. snippetId: string;
  38803. /**
  38804. * Stores the key frames of the animation
  38805. */
  38806. private _keys;
  38807. /**
  38808. * Stores the easing function of the animation
  38809. */
  38810. private _easingFunction;
  38811. /**
  38812. * @hidden Internal use only
  38813. */
  38814. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38815. /**
  38816. * The set of event that will be linked to this animation
  38817. */
  38818. private _events;
  38819. /**
  38820. * Stores an array of target property paths
  38821. */
  38822. targetPropertyPath: string[];
  38823. /**
  38824. * Stores the blending speed of the animation
  38825. */
  38826. blendingSpeed: number;
  38827. /**
  38828. * Stores the animation ranges for the animation
  38829. */
  38830. private _ranges;
  38831. /**
  38832. * @hidden Internal use
  38833. */
  38834. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38835. /**
  38836. * Sets up an animation
  38837. * @param property The property to animate
  38838. * @param animationType The animation type to apply
  38839. * @param framePerSecond The frames per second of the animation
  38840. * @param easingFunction The easing function used in the animation
  38841. * @returns The created animation
  38842. */
  38843. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38844. /**
  38845. * Create and start an animation on a node
  38846. * @param name defines the name of the global animation that will be run on all nodes
  38847. * @param node defines the root node where the animation will take place
  38848. * @param targetProperty defines property to animate
  38849. * @param framePerSecond defines the number of frame per second yo use
  38850. * @param totalFrame defines the number of frames in total
  38851. * @param from defines the initial value
  38852. * @param to defines the final value
  38853. * @param loopMode defines which loop mode you want to use (off by default)
  38854. * @param easingFunction defines the easing function to use (linear by default)
  38855. * @param onAnimationEnd defines the callback to call when animation end
  38856. * @returns the animatable created for this animation
  38857. */
  38858. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38859. /**
  38860. * Create and start an animation on a node and its descendants
  38861. * @param name defines the name of the global animation that will be run on all nodes
  38862. * @param node defines the root node where the animation will take place
  38863. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  38864. * @param targetProperty defines property to animate
  38865. * @param framePerSecond defines the number of frame per second to use
  38866. * @param totalFrame defines the number of frames in total
  38867. * @param from defines the initial value
  38868. * @param to defines the final value
  38869. * @param loopMode defines which loop mode you want to use (off by default)
  38870. * @param easingFunction defines the easing function to use (linear by default)
  38871. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38872. * @returns the list of animatables created for all nodes
  38873. * @example https://www.babylonjs-playground.com/#MH0VLI
  38874. */
  38875. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  38876. /**
  38877. * Creates a new animation, merges it with the existing animations and starts it
  38878. * @param name Name of the animation
  38879. * @param node Node which contains the scene that begins the animations
  38880. * @param targetProperty Specifies which property to animate
  38881. * @param framePerSecond The frames per second of the animation
  38882. * @param totalFrame The total number of frames
  38883. * @param from The frame at the beginning of the animation
  38884. * @param to The frame at the end of the animation
  38885. * @param loopMode Specifies the loop mode of the animation
  38886. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38887. * @param onAnimationEnd Callback to run once the animation is complete
  38888. * @returns Nullable animation
  38889. */
  38890. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38891. /**
  38892. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38893. * @param sourceAnimation defines the Animation containing keyframes to convert
  38894. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38895. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38896. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38897. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38898. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38899. */
  38900. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38901. /**
  38902. * Transition property of an host to the target Value
  38903. * @param property The property to transition
  38904. * @param targetValue The target Value of the property
  38905. * @param host The object where the property to animate belongs
  38906. * @param scene Scene used to run the animation
  38907. * @param frameRate Framerate (in frame/s) to use
  38908. * @param transition The transition type we want to use
  38909. * @param duration The duration of the animation, in milliseconds
  38910. * @param onAnimationEnd Callback trigger at the end of the animation
  38911. * @returns Nullable animation
  38912. */
  38913. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38914. /**
  38915. * Return the array of runtime animations currently using this animation
  38916. */
  38917. get runtimeAnimations(): RuntimeAnimation[];
  38918. /**
  38919. * Specifies if any of the runtime animations are currently running
  38920. */
  38921. get hasRunningRuntimeAnimations(): boolean;
  38922. /**
  38923. * Initializes the animation
  38924. * @param name Name of the animation
  38925. * @param targetProperty Property to animate
  38926. * @param framePerSecond The frames per second of the animation
  38927. * @param dataType The data type of the animation
  38928. * @param loopMode The loop mode of the animation
  38929. * @param enableBlending Specifies if blending should be enabled
  38930. */
  38931. constructor(
  38932. /**Name of the animation */
  38933. name: string,
  38934. /**Property to animate */
  38935. targetProperty: string,
  38936. /**The frames per second of the animation */
  38937. framePerSecond: number,
  38938. /**The data type of the animation */
  38939. dataType: number,
  38940. /**The loop mode of the animation */
  38941. loopMode?: number | undefined,
  38942. /**Specifies if blending should be enabled */
  38943. enableBlending?: boolean | undefined);
  38944. /**
  38945. * Converts the animation to a string
  38946. * @param fullDetails support for multiple levels of logging within scene loading
  38947. * @returns String form of the animation
  38948. */
  38949. toString(fullDetails?: boolean): string;
  38950. /**
  38951. * Add an event to this animation
  38952. * @param event Event to add
  38953. */
  38954. addEvent(event: AnimationEvent): void;
  38955. /**
  38956. * Remove all events found at the given frame
  38957. * @param frame The frame to remove events from
  38958. */
  38959. removeEvents(frame: number): void;
  38960. /**
  38961. * Retrieves all the events from the animation
  38962. * @returns Events from the animation
  38963. */
  38964. getEvents(): AnimationEvent[];
  38965. /**
  38966. * Creates an animation range
  38967. * @param name Name of the animation range
  38968. * @param from Starting frame of the animation range
  38969. * @param to Ending frame of the animation
  38970. */
  38971. createRange(name: string, from: number, to: number): void;
  38972. /**
  38973. * Deletes an animation range by name
  38974. * @param name Name of the animation range to delete
  38975. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38976. */
  38977. deleteRange(name: string, deleteFrames?: boolean): void;
  38978. /**
  38979. * Gets the animation range by name, or null if not defined
  38980. * @param name Name of the animation range
  38981. * @returns Nullable animation range
  38982. */
  38983. getRange(name: string): Nullable<AnimationRange>;
  38984. /**
  38985. * Gets the key frames from the animation
  38986. * @returns The key frames of the animation
  38987. */
  38988. getKeys(): Array<IAnimationKey>;
  38989. /**
  38990. * Gets the highest frame rate of the animation
  38991. * @returns Highest frame rate of the animation
  38992. */
  38993. getHighestFrame(): number;
  38994. /**
  38995. * Gets the easing function of the animation
  38996. * @returns Easing function of the animation
  38997. */
  38998. getEasingFunction(): IEasingFunction;
  38999. /**
  39000. * Sets the easing function of the animation
  39001. * @param easingFunction A custom mathematical formula for animation
  39002. */
  39003. setEasingFunction(easingFunction: EasingFunction): void;
  39004. /**
  39005. * Interpolates a scalar linearly
  39006. * @param startValue Start value of the animation curve
  39007. * @param endValue End value of the animation curve
  39008. * @param gradient Scalar amount to interpolate
  39009. * @returns Interpolated scalar value
  39010. */
  39011. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  39012. /**
  39013. * Interpolates a scalar cubically
  39014. * @param startValue Start value of the animation curve
  39015. * @param outTangent End tangent of the animation
  39016. * @param endValue End value of the animation curve
  39017. * @param inTangent Start tangent of the animation curve
  39018. * @param gradient Scalar amount to interpolate
  39019. * @returns Interpolated scalar value
  39020. */
  39021. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  39022. /**
  39023. * Interpolates a quaternion using a spherical linear interpolation
  39024. * @param startValue Start value of the animation curve
  39025. * @param endValue End value of the animation curve
  39026. * @param gradient Scalar amount to interpolate
  39027. * @returns Interpolated quaternion value
  39028. */
  39029. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  39030. /**
  39031. * Interpolates a quaternion cubically
  39032. * @param startValue Start value of the animation curve
  39033. * @param outTangent End tangent of the animation curve
  39034. * @param endValue End value of the animation curve
  39035. * @param inTangent Start tangent of the animation curve
  39036. * @param gradient Scalar amount to interpolate
  39037. * @returns Interpolated quaternion value
  39038. */
  39039. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  39040. /**
  39041. * Interpolates a Vector3 linearl
  39042. * @param startValue Start value of the animation curve
  39043. * @param endValue End value of the animation curve
  39044. * @param gradient Scalar amount to interpolate
  39045. * @returns Interpolated scalar value
  39046. */
  39047. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  39048. /**
  39049. * Interpolates a Vector3 cubically
  39050. * @param startValue Start value of the animation curve
  39051. * @param outTangent End tangent of the animation
  39052. * @param endValue End value of the animation curve
  39053. * @param inTangent Start tangent of the animation curve
  39054. * @param gradient Scalar amount to interpolate
  39055. * @returns InterpolatedVector3 value
  39056. */
  39057. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  39058. /**
  39059. * Interpolates a Vector2 linearly
  39060. * @param startValue Start value of the animation curve
  39061. * @param endValue End value of the animation curve
  39062. * @param gradient Scalar amount to interpolate
  39063. * @returns Interpolated Vector2 value
  39064. */
  39065. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  39066. /**
  39067. * Interpolates a Vector2 cubically
  39068. * @param startValue Start value of the animation curve
  39069. * @param outTangent End tangent of the animation
  39070. * @param endValue End value of the animation curve
  39071. * @param inTangent Start tangent of the animation curve
  39072. * @param gradient Scalar amount to interpolate
  39073. * @returns Interpolated Vector2 value
  39074. */
  39075. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  39076. /**
  39077. * Interpolates a size linearly
  39078. * @param startValue Start value of the animation curve
  39079. * @param endValue End value of the animation curve
  39080. * @param gradient Scalar amount to interpolate
  39081. * @returns Interpolated Size value
  39082. */
  39083. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  39084. /**
  39085. * Interpolates a Color3 linearly
  39086. * @param startValue Start value of the animation curve
  39087. * @param endValue End value of the animation curve
  39088. * @param gradient Scalar amount to interpolate
  39089. * @returns Interpolated Color3 value
  39090. */
  39091. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  39092. /**
  39093. * Interpolates a Color4 linearly
  39094. * @param startValue Start value of the animation curve
  39095. * @param endValue End value of the animation curve
  39096. * @param gradient Scalar amount to interpolate
  39097. * @returns Interpolated Color3 value
  39098. */
  39099. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  39100. /**
  39101. * @hidden Internal use only
  39102. */
  39103. _getKeyValue(value: any): any;
  39104. /**
  39105. * @hidden Internal use only
  39106. */
  39107. _interpolate(currentFrame: number, state: _IAnimationState): any;
  39108. /**
  39109. * Defines the function to use to interpolate matrices
  39110. * @param startValue defines the start matrix
  39111. * @param endValue defines the end matrix
  39112. * @param gradient defines the gradient between both matrices
  39113. * @param result defines an optional target matrix where to store the interpolation
  39114. * @returns the interpolated matrix
  39115. */
  39116. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  39117. /**
  39118. * Makes a copy of the animation
  39119. * @returns Cloned animation
  39120. */
  39121. clone(): Animation;
  39122. /**
  39123. * Sets the key frames of the animation
  39124. * @param values The animation key frames to set
  39125. */
  39126. setKeys(values: Array<IAnimationKey>): void;
  39127. /**
  39128. * Serializes the animation to an object
  39129. * @returns Serialized object
  39130. */
  39131. serialize(): any;
  39132. /**
  39133. * Float animation type
  39134. */
  39135. static readonly ANIMATIONTYPE_FLOAT: number;
  39136. /**
  39137. * Vector3 animation type
  39138. */
  39139. static readonly ANIMATIONTYPE_VECTOR3: number;
  39140. /**
  39141. * Quaternion animation type
  39142. */
  39143. static readonly ANIMATIONTYPE_QUATERNION: number;
  39144. /**
  39145. * Matrix animation type
  39146. */
  39147. static readonly ANIMATIONTYPE_MATRIX: number;
  39148. /**
  39149. * Color3 animation type
  39150. */
  39151. static readonly ANIMATIONTYPE_COLOR3: number;
  39152. /**
  39153. * Color3 animation type
  39154. */
  39155. static readonly ANIMATIONTYPE_COLOR4: number;
  39156. /**
  39157. * Vector2 animation type
  39158. */
  39159. static readonly ANIMATIONTYPE_VECTOR2: number;
  39160. /**
  39161. * Size animation type
  39162. */
  39163. static readonly ANIMATIONTYPE_SIZE: number;
  39164. /**
  39165. * Relative Loop Mode
  39166. */
  39167. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  39168. /**
  39169. * Cycle Loop Mode
  39170. */
  39171. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  39172. /**
  39173. * Constant Loop Mode
  39174. */
  39175. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  39176. /** @hidden */
  39177. static _UniversalLerp(left: any, right: any, amount: number): any;
  39178. /**
  39179. * Parses an animation object and creates an animation
  39180. * @param parsedAnimation Parsed animation object
  39181. * @returns Animation object
  39182. */
  39183. static Parse(parsedAnimation: any): Animation;
  39184. /**
  39185. * Appends the serialized animations from the source animations
  39186. * @param source Source containing the animations
  39187. * @param destination Target to store the animations
  39188. */
  39189. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39190. /**
  39191. * Creates a new animation or an array of animations from a snippet saved in a remote file
  39192. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  39193. * @param url defines the url to load from
  39194. * @returns a promise that will resolve to the new animation or an array of animations
  39195. */
  39196. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  39197. /**
  39198. * Creates an animation or an array of animations from a snippet saved by the Inspector
  39199. * @param snippetId defines the snippet to load
  39200. * @returns a promise that will resolve to the new animation or a new array of animations
  39201. */
  39202. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  39203. }
  39204. }
  39205. declare module "babylonjs/Animations/animatable.interface" {
  39206. import { Nullable } from "babylonjs/types";
  39207. import { Animation } from "babylonjs/Animations/animation";
  39208. /**
  39209. * Interface containing an array of animations
  39210. */
  39211. export interface IAnimatable {
  39212. /**
  39213. * Array of animations
  39214. */
  39215. animations: Nullable<Array<Animation>>;
  39216. }
  39217. }
  39218. declare module "babylonjs/Misc/decorators" {
  39219. import { Nullable } from "babylonjs/types";
  39220. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39221. import { Scene } from "babylonjs/scene";
  39222. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39223. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39224. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39226. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  39227. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39228. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39229. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39230. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39231. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39232. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39233. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39234. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39235. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39236. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39237. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39238. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39239. /**
  39240. * Decorator used to define property that can be serialized as reference to a camera
  39241. * @param sourceName defines the name of the property to decorate
  39242. */
  39243. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39244. /**
  39245. * Class used to help serialization objects
  39246. */
  39247. export class SerializationHelper {
  39248. /** @hidden */
  39249. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  39250. /** @hidden */
  39251. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  39252. /** @hidden */
  39253. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  39254. /** @hidden */
  39255. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  39256. /**
  39257. * Appends the serialized animations from the source animations
  39258. * @param source Source containing the animations
  39259. * @param destination Target to store the animations
  39260. */
  39261. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39262. /**
  39263. * Static function used to serialized a specific entity
  39264. * @param entity defines the entity to serialize
  39265. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  39266. * @returns a JSON compatible object representing the serialization of the entity
  39267. */
  39268. static Serialize<T>(entity: T, serializationObject?: any): any;
  39269. /**
  39270. * Creates a new entity from a serialization data object
  39271. * @param creationFunction defines a function used to instanciated the new entity
  39272. * @param source defines the source serialization data
  39273. * @param scene defines the hosting scene
  39274. * @param rootUrl defines the root url for resources
  39275. * @returns a new entity
  39276. */
  39277. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  39278. /**
  39279. * Clones an object
  39280. * @param creationFunction defines the function used to instanciate the new object
  39281. * @param source defines the source object
  39282. * @returns the cloned object
  39283. */
  39284. static Clone<T>(creationFunction: () => T, source: T): T;
  39285. /**
  39286. * Instanciates a new object based on a source one (some data will be shared between both object)
  39287. * @param creationFunction defines the function used to instanciate the new object
  39288. * @param source defines the source object
  39289. * @returns the new object
  39290. */
  39291. static Instanciate<T>(creationFunction: () => T, source: T): T;
  39292. }
  39293. }
  39294. declare module "babylonjs/Cameras/camera" {
  39295. import { SmartArray } from "babylonjs/Misc/smartArray";
  39296. import { Observable } from "babylonjs/Misc/observable";
  39297. import { Nullable } from "babylonjs/types";
  39298. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39299. import { Scene } from "babylonjs/scene";
  39300. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39301. import { Node } from "babylonjs/node";
  39302. import { Mesh } from "babylonjs/Meshes/mesh";
  39303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39304. import { ICullable } from "babylonjs/Culling/boundingInfo";
  39305. import { Viewport } from "babylonjs/Maths/math.viewport";
  39306. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39307. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39308. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39309. import { Ray } from "babylonjs/Culling/ray";
  39310. /**
  39311. * This is the base class of all the camera used in the application.
  39312. * @see https://doc.babylonjs.com/features/cameras
  39313. */
  39314. export class Camera extends Node {
  39315. /** @hidden */
  39316. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  39317. /**
  39318. * This is the default projection mode used by the cameras.
  39319. * It helps recreating a feeling of perspective and better appreciate depth.
  39320. * This is the best way to simulate real life cameras.
  39321. */
  39322. static readonly PERSPECTIVE_CAMERA: number;
  39323. /**
  39324. * This helps creating camera with an orthographic mode.
  39325. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  39326. */
  39327. static readonly ORTHOGRAPHIC_CAMERA: number;
  39328. /**
  39329. * This is the default FOV mode for perspective cameras.
  39330. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  39331. */
  39332. static readonly FOVMODE_VERTICAL_FIXED: number;
  39333. /**
  39334. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  39335. */
  39336. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  39337. /**
  39338. * This specifies ther is no need for a camera rig.
  39339. * Basically only one eye is rendered corresponding to the camera.
  39340. */
  39341. static readonly RIG_MODE_NONE: number;
  39342. /**
  39343. * Simulates a camera Rig with one blue eye and one red eye.
  39344. * This can be use with 3d blue and red glasses.
  39345. */
  39346. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  39347. /**
  39348. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  39349. */
  39350. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  39351. /**
  39352. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  39353. */
  39354. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  39355. /**
  39356. * Defines that both eyes of the camera will be rendered over under each other.
  39357. */
  39358. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  39359. /**
  39360. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  39361. */
  39362. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  39363. /**
  39364. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  39365. */
  39366. static readonly RIG_MODE_VR: number;
  39367. /**
  39368. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  39369. */
  39370. static readonly RIG_MODE_WEBVR: number;
  39371. /**
  39372. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  39373. */
  39374. static readonly RIG_MODE_CUSTOM: number;
  39375. /**
  39376. * Defines if by default attaching controls should prevent the default javascript event to continue.
  39377. */
  39378. static ForceAttachControlToAlwaysPreventDefault: boolean;
  39379. /**
  39380. * Define the input manager associated with the camera.
  39381. */
  39382. inputs: CameraInputsManager<Camera>;
  39383. /** @hidden */
  39384. _position: Vector3;
  39385. /**
  39386. * Define the current local position of the camera in the scene
  39387. */
  39388. get position(): Vector3;
  39389. set position(newPosition: Vector3);
  39390. protected _upVector: Vector3;
  39391. /**
  39392. * The vector the camera should consider as up.
  39393. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  39394. */
  39395. set upVector(vec: Vector3);
  39396. get upVector(): Vector3;
  39397. /**
  39398. * Define the current limit on the left side for an orthographic camera
  39399. * In scene unit
  39400. */
  39401. orthoLeft: Nullable<number>;
  39402. /**
  39403. * Define the current limit on the right side for an orthographic camera
  39404. * In scene unit
  39405. */
  39406. orthoRight: Nullable<number>;
  39407. /**
  39408. * Define the current limit on the bottom side for an orthographic camera
  39409. * In scene unit
  39410. */
  39411. orthoBottom: Nullable<number>;
  39412. /**
  39413. * Define the current limit on the top side for an orthographic camera
  39414. * In scene unit
  39415. */
  39416. orthoTop: Nullable<number>;
  39417. /**
  39418. * Field Of View is set in Radians. (default is 0.8)
  39419. */
  39420. fov: number;
  39421. /**
  39422. * Define the minimum distance the camera can see from.
  39423. * This is important to note that the depth buffer are not infinite and the closer it starts
  39424. * the more your scene might encounter depth fighting issue.
  39425. */
  39426. minZ: number;
  39427. /**
  39428. * Define the maximum distance the camera can see to.
  39429. * This is important to note that the depth buffer are not infinite and the further it end
  39430. * the more your scene might encounter depth fighting issue.
  39431. */
  39432. maxZ: number;
  39433. /**
  39434. * Define the default inertia of the camera.
  39435. * This helps giving a smooth feeling to the camera movement.
  39436. */
  39437. inertia: number;
  39438. /**
  39439. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  39440. */
  39441. mode: number;
  39442. /**
  39443. * Define whether the camera is intermediate.
  39444. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  39445. */
  39446. isIntermediate: boolean;
  39447. /**
  39448. * Define the viewport of the camera.
  39449. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  39450. */
  39451. viewport: Viewport;
  39452. /**
  39453. * Restricts the camera to viewing objects with the same layerMask.
  39454. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  39455. */
  39456. layerMask: number;
  39457. /**
  39458. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  39459. */
  39460. fovMode: number;
  39461. /**
  39462. * Rig mode of the camera.
  39463. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  39464. * This is normally controlled byt the camera themselves as internal use.
  39465. */
  39466. cameraRigMode: number;
  39467. /**
  39468. * Defines the distance between both "eyes" in case of a RIG
  39469. */
  39470. interaxialDistance: number;
  39471. /**
  39472. * Defines if stereoscopic rendering is done side by side or over under.
  39473. */
  39474. isStereoscopicSideBySide: boolean;
  39475. /**
  39476. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  39477. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  39478. * else in the scene. (Eg. security camera)
  39479. *
  39480. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  39481. */
  39482. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  39483. /**
  39484. * When set, the camera will render to this render target instead of the default canvas
  39485. *
  39486. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  39487. */
  39488. outputRenderTarget: Nullable<RenderTargetTexture>;
  39489. /**
  39490. * Observable triggered when the camera view matrix has changed.
  39491. */
  39492. onViewMatrixChangedObservable: Observable<Camera>;
  39493. /**
  39494. * Observable triggered when the camera Projection matrix has changed.
  39495. */
  39496. onProjectionMatrixChangedObservable: Observable<Camera>;
  39497. /**
  39498. * Observable triggered when the inputs have been processed.
  39499. */
  39500. onAfterCheckInputsObservable: Observable<Camera>;
  39501. /**
  39502. * Observable triggered when reset has been called and applied to the camera.
  39503. */
  39504. onRestoreStateObservable: Observable<Camera>;
  39505. /**
  39506. * Is this camera a part of a rig system?
  39507. */
  39508. isRigCamera: boolean;
  39509. /**
  39510. * If isRigCamera set to true this will be set with the parent camera.
  39511. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  39512. */
  39513. rigParent?: Camera;
  39514. /** @hidden */
  39515. _cameraRigParams: any;
  39516. /** @hidden */
  39517. _rigCameras: Camera[];
  39518. /** @hidden */
  39519. _rigPostProcess: Nullable<PostProcess>;
  39520. protected _webvrViewMatrix: Matrix;
  39521. /** @hidden */
  39522. _skipRendering: boolean;
  39523. /** @hidden */
  39524. _projectionMatrix: Matrix;
  39525. /** @hidden */
  39526. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  39527. /** @hidden */
  39528. _activeMeshes: SmartArray<AbstractMesh>;
  39529. protected _globalPosition: Vector3;
  39530. /** @hidden */
  39531. _computedViewMatrix: Matrix;
  39532. private _doNotComputeProjectionMatrix;
  39533. private _transformMatrix;
  39534. private _frustumPlanes;
  39535. private _refreshFrustumPlanes;
  39536. private _storedFov;
  39537. private _stateStored;
  39538. /**
  39539. * Instantiates a new camera object.
  39540. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  39541. * @see https://doc.babylonjs.com/features/cameras
  39542. * @param name Defines the name of the camera in the scene
  39543. * @param position Defines the position of the camera
  39544. * @param scene Defines the scene the camera belongs too
  39545. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  39546. */
  39547. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39548. /**
  39549. * Store current camera state (fov, position, etc..)
  39550. * @returns the camera
  39551. */
  39552. storeState(): Camera;
  39553. /**
  39554. * Restores the camera state values if it has been stored. You must call storeState() first
  39555. */
  39556. protected _restoreStateValues(): boolean;
  39557. /**
  39558. * Restored camera state. You must call storeState() first.
  39559. * @returns true if restored and false otherwise
  39560. */
  39561. restoreState(): boolean;
  39562. /**
  39563. * Gets the class name of the camera.
  39564. * @returns the class name
  39565. */
  39566. getClassName(): string;
  39567. /** @hidden */
  39568. readonly _isCamera: boolean;
  39569. /**
  39570. * Gets a string representation of the camera useful for debug purpose.
  39571. * @param fullDetails Defines that a more verboe level of logging is required
  39572. * @returns the string representation
  39573. */
  39574. toString(fullDetails?: boolean): string;
  39575. /**
  39576. * Gets the current world space position of the camera.
  39577. */
  39578. get globalPosition(): Vector3;
  39579. /**
  39580. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  39581. * @returns the active meshe list
  39582. */
  39583. getActiveMeshes(): SmartArray<AbstractMesh>;
  39584. /**
  39585. * Check whether a mesh is part of the current active mesh list of the camera
  39586. * @param mesh Defines the mesh to check
  39587. * @returns true if active, false otherwise
  39588. */
  39589. isActiveMesh(mesh: Mesh): boolean;
  39590. /**
  39591. * Is this camera ready to be used/rendered
  39592. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  39593. * @return true if the camera is ready
  39594. */
  39595. isReady(completeCheck?: boolean): boolean;
  39596. /** @hidden */
  39597. _initCache(): void;
  39598. /** @hidden */
  39599. _updateCache(ignoreParentClass?: boolean): void;
  39600. /** @hidden */
  39601. _isSynchronized(): boolean;
  39602. /** @hidden */
  39603. _isSynchronizedViewMatrix(): boolean;
  39604. /** @hidden */
  39605. _isSynchronizedProjectionMatrix(): boolean;
  39606. /**
  39607. * Attach the input controls to a specific dom element to get the input from.
  39608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39609. */
  39610. attachControl(noPreventDefault?: boolean): void;
  39611. /**
  39612. * Attach the input controls to a specific dom element to get the input from.
  39613. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  39614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39615. * BACK COMPAT SIGNATURE ONLY.
  39616. */
  39617. attachControl(ignored: any, noPreventDefault?: boolean): void;
  39618. /**
  39619. * Detach the current controls from the specified dom element.
  39620. */
  39621. detachControl(): void;
  39622. /**
  39623. * Detach the current controls from the specified dom element.
  39624. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  39625. */
  39626. detachControl(ignored: any): void;
  39627. /**
  39628. * Update the camera state according to the different inputs gathered during the frame.
  39629. */
  39630. update(): void;
  39631. /** @hidden */
  39632. _checkInputs(): void;
  39633. /** @hidden */
  39634. get rigCameras(): Camera[];
  39635. /**
  39636. * Gets the post process used by the rig cameras
  39637. */
  39638. get rigPostProcess(): Nullable<PostProcess>;
  39639. /**
  39640. * Internal, gets the first post proces.
  39641. * @returns the first post process to be run on this camera.
  39642. */
  39643. _getFirstPostProcess(): Nullable<PostProcess>;
  39644. private _cascadePostProcessesToRigCams;
  39645. /**
  39646. * Attach a post process to the camera.
  39647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39648. * @param postProcess The post process to attach to the camera
  39649. * @param insertAt The position of the post process in case several of them are in use in the scene
  39650. * @returns the position the post process has been inserted at
  39651. */
  39652. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  39653. /**
  39654. * Detach a post process to the camera.
  39655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39656. * @param postProcess The post process to detach from the camera
  39657. */
  39658. detachPostProcess(postProcess: PostProcess): void;
  39659. /**
  39660. * Gets the current world matrix of the camera
  39661. */
  39662. getWorldMatrix(): Matrix;
  39663. /** @hidden */
  39664. _getViewMatrix(): Matrix;
  39665. /**
  39666. * Gets the current view matrix of the camera.
  39667. * @param force forces the camera to recompute the matrix without looking at the cached state
  39668. * @returns the view matrix
  39669. */
  39670. getViewMatrix(force?: boolean): Matrix;
  39671. /**
  39672. * Freeze the projection matrix.
  39673. * It will prevent the cache check of the camera projection compute and can speed up perf
  39674. * if no parameter of the camera are meant to change
  39675. * @param projection Defines manually a projection if necessary
  39676. */
  39677. freezeProjectionMatrix(projection?: Matrix): void;
  39678. /**
  39679. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  39680. */
  39681. unfreezeProjectionMatrix(): void;
  39682. /**
  39683. * Gets the current projection matrix of the camera.
  39684. * @param force forces the camera to recompute the matrix without looking at the cached state
  39685. * @returns the projection matrix
  39686. */
  39687. getProjectionMatrix(force?: boolean): Matrix;
  39688. /**
  39689. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  39690. * @returns a Matrix
  39691. */
  39692. getTransformationMatrix(): Matrix;
  39693. private _updateFrustumPlanes;
  39694. /**
  39695. * Checks if a cullable object (mesh...) is in the camera frustum
  39696. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  39697. * @param target The object to check
  39698. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  39699. * @returns true if the object is in frustum otherwise false
  39700. */
  39701. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  39702. /**
  39703. * Checks if a cullable object (mesh...) is in the camera frustum
  39704. * Unlike isInFrustum this cheks the full bounding box
  39705. * @param target The object to check
  39706. * @returns true if the object is in frustum otherwise false
  39707. */
  39708. isCompletelyInFrustum(target: ICullable): boolean;
  39709. /**
  39710. * Gets a ray in the forward direction from the camera.
  39711. * @param length Defines the length of the ray to create
  39712. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  39713. * @param origin Defines the start point of the ray which defaults to the camera position
  39714. * @returns the forward ray
  39715. */
  39716. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39717. /**
  39718. * Gets a ray in the forward direction from the camera.
  39719. * @param refRay the ray to (re)use when setting the values
  39720. * @param length Defines the length of the ray to create
  39721. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  39722. * @param origin Defines the start point of the ray which defaults to the camera position
  39723. * @returns the forward ray
  39724. */
  39725. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39726. /**
  39727. * Releases resources associated with this node.
  39728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39730. */
  39731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  39732. /** @hidden */
  39733. _isLeftCamera: boolean;
  39734. /**
  39735. * Gets the left camera of a rig setup in case of Rigged Camera
  39736. */
  39737. get isLeftCamera(): boolean;
  39738. /** @hidden */
  39739. _isRightCamera: boolean;
  39740. /**
  39741. * Gets the right camera of a rig setup in case of Rigged Camera
  39742. */
  39743. get isRightCamera(): boolean;
  39744. /**
  39745. * Gets the left camera of a rig setup in case of Rigged Camera
  39746. */
  39747. get leftCamera(): Nullable<FreeCamera>;
  39748. /**
  39749. * Gets the right camera of a rig setup in case of Rigged Camera
  39750. */
  39751. get rightCamera(): Nullable<FreeCamera>;
  39752. /**
  39753. * Gets the left camera target of a rig setup in case of Rigged Camera
  39754. * @returns the target position
  39755. */
  39756. getLeftTarget(): Nullable<Vector3>;
  39757. /**
  39758. * Gets the right camera target of a rig setup in case of Rigged Camera
  39759. * @returns the target position
  39760. */
  39761. getRightTarget(): Nullable<Vector3>;
  39762. /**
  39763. * @hidden
  39764. */
  39765. setCameraRigMode(mode: number, rigParams: any): void;
  39766. /** @hidden */
  39767. static _setStereoscopicRigMode(camera: Camera): void;
  39768. /** @hidden */
  39769. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  39770. /** @hidden */
  39771. static _setVRRigMode(camera: Camera, rigParams: any): void;
  39772. /** @hidden */
  39773. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  39774. /** @hidden */
  39775. _getVRProjectionMatrix(): Matrix;
  39776. protected _updateCameraRotationMatrix(): void;
  39777. protected _updateWebVRCameraRotationMatrix(): void;
  39778. /**
  39779. * This function MUST be overwritten by the different WebVR cameras available.
  39780. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39781. * @hidden
  39782. */
  39783. _getWebVRProjectionMatrix(): Matrix;
  39784. /**
  39785. * This function MUST be overwritten by the different WebVR cameras available.
  39786. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39787. * @hidden
  39788. */
  39789. _getWebVRViewMatrix(): Matrix;
  39790. /** @hidden */
  39791. setCameraRigParameter(name: string, value: any): void;
  39792. /**
  39793. * needs to be overridden by children so sub has required properties to be copied
  39794. * @hidden
  39795. */
  39796. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  39797. /**
  39798. * May need to be overridden by children
  39799. * @hidden
  39800. */
  39801. _updateRigCameras(): void;
  39802. /** @hidden */
  39803. _setupInputs(): void;
  39804. /**
  39805. * Serialiaze the camera setup to a json represention
  39806. * @returns the JSON representation
  39807. */
  39808. serialize(): any;
  39809. /**
  39810. * Clones the current camera.
  39811. * @param name The cloned camera name
  39812. * @returns the cloned camera
  39813. */
  39814. clone(name: string): Camera;
  39815. /**
  39816. * Gets the direction of the camera relative to a given local axis.
  39817. * @param localAxis Defines the reference axis to provide a relative direction.
  39818. * @return the direction
  39819. */
  39820. getDirection(localAxis: Vector3): Vector3;
  39821. /**
  39822. * Returns the current camera absolute rotation
  39823. */
  39824. get absoluteRotation(): Quaternion;
  39825. /**
  39826. * Gets the direction of the camera relative to a given local axis into a passed vector.
  39827. * @param localAxis Defines the reference axis to provide a relative direction.
  39828. * @param result Defines the vector to store the result in
  39829. */
  39830. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  39831. /**
  39832. * Gets a camera constructor for a given camera type
  39833. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  39834. * @param name The name of the camera the result will be able to instantiate
  39835. * @param scene The scene the result will construct the camera in
  39836. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  39837. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  39838. * @returns a factory method to construc the camera
  39839. */
  39840. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  39841. /**
  39842. * Compute the world matrix of the camera.
  39843. * @returns the camera world matrix
  39844. */
  39845. computeWorldMatrix(): Matrix;
  39846. /**
  39847. * Parse a JSON and creates the camera from the parsed information
  39848. * @param parsedCamera The JSON to parse
  39849. * @param scene The scene to instantiate the camera in
  39850. * @returns the newly constructed camera
  39851. */
  39852. static Parse(parsedCamera: any, scene: Scene): Camera;
  39853. }
  39854. }
  39855. declare module "babylonjs/PostProcesses/postProcessManager" {
  39856. import { Nullable } from "babylonjs/types";
  39857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39858. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39859. import { Scene } from "babylonjs/scene";
  39860. /**
  39861. * PostProcessManager is used to manage one or more post processes or post process pipelines
  39862. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  39863. */
  39864. export class PostProcessManager {
  39865. private _scene;
  39866. private _indexBuffer;
  39867. private _vertexBuffers;
  39868. /**
  39869. * Creates a new instance PostProcess
  39870. * @param scene The scene that the post process is associated with.
  39871. */
  39872. constructor(scene: Scene);
  39873. private _prepareBuffers;
  39874. private _buildIndexBuffer;
  39875. /**
  39876. * Rebuilds the vertex buffers of the manager.
  39877. * @hidden
  39878. */
  39879. _rebuild(): void;
  39880. /**
  39881. * Prepares a frame to be run through a post process.
  39882. * @param sourceTexture The input texture to the post procesess. (default: null)
  39883. * @param postProcesses An array of post processes to be run. (default: null)
  39884. * @returns True if the post processes were able to be run.
  39885. * @hidden
  39886. */
  39887. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  39888. /**
  39889. * Manually render a set of post processes to a texture.
  39890. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39891. * @param postProcesses An array of post processes to be run.
  39892. * @param targetTexture The target texture to render to.
  39893. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39894. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39895. * @param lodLevel defines which lod of the texture to render to
  39896. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39897. */
  39898. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39899. /**
  39900. * Finalize the result of the output of the postprocesses.
  39901. * @param doNotPresent If true the result will not be displayed to the screen.
  39902. * @param targetTexture The target texture to render to.
  39903. * @param faceIndex The index of the face to bind the target texture to.
  39904. * @param postProcesses The array of post processes to render.
  39905. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39906. * @hidden
  39907. */
  39908. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39909. /**
  39910. * Disposes of the post process manager.
  39911. */
  39912. dispose(): void;
  39913. }
  39914. }
  39915. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  39916. import { Observable } from "babylonjs/Misc/observable";
  39917. import { SmartArray } from "babylonjs/Misc/smartArray";
  39918. import { Nullable, Immutable } from "babylonjs/types";
  39919. import { Camera } from "babylonjs/Cameras/camera";
  39920. import { Scene } from "babylonjs/scene";
  39921. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  39922. import { Color4 } from "babylonjs/Maths/math.color";
  39923. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  39924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39925. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39926. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39927. import { Texture } from "babylonjs/Materials/Textures/texture";
  39928. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39929. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39930. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39931. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39932. import { Engine } from "babylonjs/Engines/engine";
  39933. /**
  39934. * This Helps creating a texture that will be created from a camera in your scene.
  39935. * It is basically a dynamic texture that could be used to create special effects for instance.
  39936. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39937. */
  39938. export class RenderTargetTexture extends Texture {
  39939. /**
  39940. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39941. */
  39942. static readonly REFRESHRATE_RENDER_ONCE: number;
  39943. /**
  39944. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39945. */
  39946. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39947. /**
  39948. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39949. * the central point of your effect and can save a lot of performances.
  39950. */
  39951. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39952. /**
  39953. * Use this predicate to dynamically define the list of mesh you want to render.
  39954. * If set, the renderList property will be overwritten.
  39955. */
  39956. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39957. private _renderList;
  39958. /**
  39959. * Use this list to define the list of mesh you want to render.
  39960. */
  39961. get renderList(): Nullable<Array<AbstractMesh>>;
  39962. set renderList(value: Nullable<Array<AbstractMesh>>);
  39963. /**
  39964. * Use this function to overload the renderList array at rendering time.
  39965. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39966. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39967. * the cube (if the RTT is a cube, else layerOrFace=0).
  39968. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39969. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39970. * hold dummy elements!
  39971. */
  39972. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39973. private _hookArray;
  39974. /**
  39975. * Define if particles should be rendered in your texture.
  39976. */
  39977. renderParticles: boolean;
  39978. /**
  39979. * Define if sprites should be rendered in your texture.
  39980. */
  39981. renderSprites: boolean;
  39982. /**
  39983. * Define the camera used to render the texture.
  39984. */
  39985. activeCamera: Nullable<Camera>;
  39986. /**
  39987. * Override the mesh isReady function with your own one.
  39988. */
  39989. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39990. /**
  39991. * Override the render function of the texture with your own one.
  39992. */
  39993. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39994. /**
  39995. * Define if camera post processes should be use while rendering the texture.
  39996. */
  39997. useCameraPostProcesses: boolean;
  39998. /**
  39999. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  40000. */
  40001. ignoreCameraViewport: boolean;
  40002. private _postProcessManager;
  40003. private _postProcesses;
  40004. private _resizeObserver;
  40005. /**
  40006. * An event triggered when the texture is unbind.
  40007. */
  40008. onBeforeBindObservable: Observable<RenderTargetTexture>;
  40009. /**
  40010. * An event triggered when the texture is unbind.
  40011. */
  40012. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  40013. private _onAfterUnbindObserver;
  40014. /**
  40015. * Set a after unbind callback in the texture.
  40016. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  40017. */
  40018. set onAfterUnbind(callback: () => void);
  40019. /**
  40020. * An event triggered before rendering the texture
  40021. */
  40022. onBeforeRenderObservable: Observable<number>;
  40023. private _onBeforeRenderObserver;
  40024. /**
  40025. * Set a before render callback in the texture.
  40026. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  40027. */
  40028. set onBeforeRender(callback: (faceIndex: number) => void);
  40029. /**
  40030. * An event triggered after rendering the texture
  40031. */
  40032. onAfterRenderObservable: Observable<number>;
  40033. private _onAfterRenderObserver;
  40034. /**
  40035. * Set a after render callback in the texture.
  40036. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  40037. */
  40038. set onAfterRender(callback: (faceIndex: number) => void);
  40039. /**
  40040. * An event triggered after the texture clear
  40041. */
  40042. onClearObservable: Observable<Engine>;
  40043. private _onClearObserver;
  40044. /**
  40045. * Set a clear callback in the texture.
  40046. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  40047. */
  40048. set onClear(callback: (Engine: Engine) => void);
  40049. /**
  40050. * An event triggered when the texture is resized.
  40051. */
  40052. onResizeObservable: Observable<RenderTargetTexture>;
  40053. /**
  40054. * Define the clear color of the Render Target if it should be different from the scene.
  40055. */
  40056. clearColor: Color4;
  40057. protected _size: number | {
  40058. width: number;
  40059. height: number;
  40060. layers?: number;
  40061. };
  40062. protected _initialSizeParameter: number | {
  40063. width: number;
  40064. height: number;
  40065. } | {
  40066. ratio: number;
  40067. };
  40068. protected _sizeRatio: Nullable<number>;
  40069. /** @hidden */
  40070. _generateMipMaps: boolean;
  40071. protected _renderingManager: RenderingManager;
  40072. /** @hidden */
  40073. _waitingRenderList?: string[];
  40074. protected _doNotChangeAspectRatio: boolean;
  40075. protected _currentRefreshId: number;
  40076. protected _refreshRate: number;
  40077. protected _textureMatrix: Matrix;
  40078. protected _samples: number;
  40079. protected _renderTargetOptions: RenderTargetCreationOptions;
  40080. /**
  40081. * Gets render target creation options that were used.
  40082. */
  40083. get renderTargetOptions(): RenderTargetCreationOptions;
  40084. protected _onRatioRescale(): void;
  40085. /**
  40086. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  40087. * It must define where the camera used to render the texture is set
  40088. */
  40089. boundingBoxPosition: Vector3;
  40090. private _boundingBoxSize;
  40091. /**
  40092. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  40093. * When defined, the cubemap will switch to local mode
  40094. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  40095. * @example https://www.babylonjs-playground.com/#RNASML
  40096. */
  40097. set boundingBoxSize(value: Vector3);
  40098. get boundingBoxSize(): Vector3;
  40099. /**
  40100. * In case the RTT has been created with a depth texture, get the associated
  40101. * depth texture.
  40102. * Otherwise, return null.
  40103. */
  40104. get depthStencilTexture(): Nullable<InternalTexture>;
  40105. /**
  40106. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  40107. * or used a shadow, depth texture...
  40108. * @param name The friendly name of the texture
  40109. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  40110. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  40111. * @param generateMipMaps True if mip maps need to be generated after render.
  40112. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  40113. * @param type The type of the buffer in the RTT (int, half float, float...)
  40114. * @param isCube True if a cube texture needs to be created
  40115. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  40116. * @param generateDepthBuffer True to generate a depth buffer
  40117. * @param generateStencilBuffer True to generate a stencil buffer
  40118. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  40119. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  40120. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40121. * @param samples sample count to use when creating the RTT
  40122. */
  40123. constructor(name: string, size: number | {
  40124. width: number;
  40125. height: number;
  40126. layers?: number;
  40127. } | {
  40128. ratio: number;
  40129. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  40130. /**
  40131. * Creates a depth stencil texture.
  40132. * This is only available in WebGL 2 or with the depth texture extension available.
  40133. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  40134. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  40135. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  40136. * @param samples sample count of the depth/stencil texture
  40137. */
  40138. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  40139. private _processSizeParameter;
  40140. /**
  40141. * Define the number of samples to use in case of MSAA.
  40142. * It defaults to one meaning no MSAA has been enabled.
  40143. */
  40144. get samples(): number;
  40145. set samples(value: number);
  40146. /**
  40147. * Resets the refresh counter of the texture and start bak from scratch.
  40148. * Could be useful to regenerate the texture if it is setup to render only once.
  40149. */
  40150. resetRefreshCounter(): void;
  40151. /**
  40152. * Define the refresh rate of the texture or the rendering frequency.
  40153. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  40154. */
  40155. get refreshRate(): number;
  40156. set refreshRate(value: number);
  40157. /**
  40158. * Adds a post process to the render target rendering passes.
  40159. * @param postProcess define the post process to add
  40160. */
  40161. addPostProcess(postProcess: PostProcess): void;
  40162. /**
  40163. * Clear all the post processes attached to the render target
  40164. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  40165. */
  40166. clearPostProcesses(dispose?: boolean): void;
  40167. /**
  40168. * Remove one of the post process from the list of attached post processes to the texture
  40169. * @param postProcess define the post process to remove from the list
  40170. */
  40171. removePostProcess(postProcess: PostProcess): void;
  40172. /** @hidden */
  40173. _shouldRender(): boolean;
  40174. /**
  40175. * Gets the actual render size of the texture.
  40176. * @returns the width of the render size
  40177. */
  40178. getRenderSize(): number;
  40179. /**
  40180. * Gets the actual render width of the texture.
  40181. * @returns the width of the render size
  40182. */
  40183. getRenderWidth(): number;
  40184. /**
  40185. * Gets the actual render height of the texture.
  40186. * @returns the height of the render size
  40187. */
  40188. getRenderHeight(): number;
  40189. /**
  40190. * Gets the actual number of layers of the texture.
  40191. * @returns the number of layers
  40192. */
  40193. getRenderLayers(): number;
  40194. /**
  40195. * Get if the texture can be rescaled or not.
  40196. */
  40197. get canRescale(): boolean;
  40198. /**
  40199. * Resize the texture using a ratio.
  40200. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  40201. */
  40202. scale(ratio: number): void;
  40203. /**
  40204. * Get the texture reflection matrix used to rotate/transform the reflection.
  40205. * @returns the reflection matrix
  40206. */
  40207. getReflectionTextureMatrix(): Matrix;
  40208. /**
  40209. * Resize the texture to a new desired size.
  40210. * Be carrefull as it will recreate all the data in the new texture.
  40211. * @param size Define the new size. It can be:
  40212. * - a number for squared texture,
  40213. * - an object containing { width: number, height: number }
  40214. * - or an object containing a ratio { ratio: number }
  40215. */
  40216. resize(size: number | {
  40217. width: number;
  40218. height: number;
  40219. } | {
  40220. ratio: number;
  40221. }): void;
  40222. private _defaultRenderListPrepared;
  40223. /**
  40224. * Renders all the objects from the render list into the texture.
  40225. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  40226. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  40227. */
  40228. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  40229. private _bestReflectionRenderTargetDimension;
  40230. private _prepareRenderingManager;
  40231. /**
  40232. * @hidden
  40233. * @param faceIndex face index to bind to if this is a cubetexture
  40234. * @param layer defines the index of the texture to bind in the array
  40235. */
  40236. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  40237. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40238. private renderToTarget;
  40239. /**
  40240. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40241. * This allowed control for front to back rendering or reversly depending of the special needs.
  40242. *
  40243. * @param renderingGroupId The rendering group id corresponding to its index
  40244. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40245. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40246. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40247. */
  40248. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  40249. /**
  40250. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40251. *
  40252. * @param renderingGroupId The rendering group id corresponding to its index
  40253. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40254. */
  40255. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  40256. /**
  40257. * Clones the texture.
  40258. * @returns the cloned texture
  40259. */
  40260. clone(): RenderTargetTexture;
  40261. /**
  40262. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  40263. * @returns The JSON representation of the texture
  40264. */
  40265. serialize(): any;
  40266. /**
  40267. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  40268. */
  40269. disposeFramebufferObjects(): void;
  40270. /**
  40271. * Dispose the texture and release its associated resources.
  40272. */
  40273. dispose(): void;
  40274. /** @hidden */
  40275. _rebuild(): void;
  40276. /**
  40277. * Clear the info related to rendering groups preventing retention point in material dispose.
  40278. */
  40279. freeRenderingGroups(): void;
  40280. /**
  40281. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  40282. * @returns the view count
  40283. */
  40284. getViewCount(): number;
  40285. }
  40286. }
  40287. declare module "babylonjs/Materials/effect" {
  40288. import { Observable } from "babylonjs/Misc/observable";
  40289. import { FloatArray, Nullable } from "babylonjs/types";
  40290. import { IDisposable } from "babylonjs/scene";
  40291. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40292. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40293. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  40294. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40295. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40296. import { Engine } from "babylonjs/Engines/engine";
  40297. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40298. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40299. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40300. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40301. /**
  40302. * Options to be used when creating an effect.
  40303. */
  40304. export interface IEffectCreationOptions {
  40305. /**
  40306. * Atrributes that will be used in the shader.
  40307. */
  40308. attributes: string[];
  40309. /**
  40310. * Uniform varible names that will be set in the shader.
  40311. */
  40312. uniformsNames: string[];
  40313. /**
  40314. * Uniform buffer variable names that will be set in the shader.
  40315. */
  40316. uniformBuffersNames: string[];
  40317. /**
  40318. * Sampler texture variable names that will be set in the shader.
  40319. */
  40320. samplers: string[];
  40321. /**
  40322. * Define statements that will be set in the shader.
  40323. */
  40324. defines: any;
  40325. /**
  40326. * Possible fallbacks for this effect to improve performance when needed.
  40327. */
  40328. fallbacks: Nullable<IEffectFallbacks>;
  40329. /**
  40330. * Callback that will be called when the shader is compiled.
  40331. */
  40332. onCompiled: Nullable<(effect: Effect) => void>;
  40333. /**
  40334. * Callback that will be called if an error occurs during shader compilation.
  40335. */
  40336. onError: Nullable<(effect: Effect, errors: string) => void>;
  40337. /**
  40338. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40339. */
  40340. indexParameters?: any;
  40341. /**
  40342. * Max number of lights that can be used in the shader.
  40343. */
  40344. maxSimultaneousLights?: number;
  40345. /**
  40346. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  40347. */
  40348. transformFeedbackVaryings?: Nullable<string[]>;
  40349. /**
  40350. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  40351. */
  40352. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  40353. /**
  40354. * Is this effect rendering to several color attachments ?
  40355. */
  40356. multiTarget?: boolean;
  40357. }
  40358. /**
  40359. * Effect containing vertex and fragment shader that can be executed on an object.
  40360. */
  40361. export class Effect implements IDisposable {
  40362. /**
  40363. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40364. */
  40365. static ShadersRepository: string;
  40366. /**
  40367. * Enable logging of the shader code when a compilation error occurs
  40368. */
  40369. static LogShaderCodeOnCompilationError: boolean;
  40370. /**
  40371. * Name of the effect.
  40372. */
  40373. name: any;
  40374. /**
  40375. * String container all the define statements that should be set on the shader.
  40376. */
  40377. defines: string;
  40378. /**
  40379. * Callback that will be called when the shader is compiled.
  40380. */
  40381. onCompiled: Nullable<(effect: Effect) => void>;
  40382. /**
  40383. * Callback that will be called if an error occurs during shader compilation.
  40384. */
  40385. onError: Nullable<(effect: Effect, errors: string) => void>;
  40386. /**
  40387. * Callback that will be called when effect is bound.
  40388. */
  40389. onBind: Nullable<(effect: Effect) => void>;
  40390. /**
  40391. * Unique ID of the effect.
  40392. */
  40393. uniqueId: number;
  40394. /**
  40395. * Observable that will be called when the shader is compiled.
  40396. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  40397. */
  40398. onCompileObservable: Observable<Effect>;
  40399. /**
  40400. * Observable that will be called if an error occurs during shader compilation.
  40401. */
  40402. onErrorObservable: Observable<Effect>;
  40403. /** @hidden */
  40404. _onBindObservable: Nullable<Observable<Effect>>;
  40405. /**
  40406. * @hidden
  40407. * Specifies if the effect was previously ready
  40408. */
  40409. _wasPreviouslyReady: boolean;
  40410. /**
  40411. * Observable that will be called when effect is bound.
  40412. */
  40413. get onBindObservable(): Observable<Effect>;
  40414. /** @hidden */
  40415. _bonesComputationForcedToCPU: boolean;
  40416. /** @hidden */
  40417. _uniformBuffersNames: {
  40418. [key: string]: number;
  40419. };
  40420. /** @hidden */
  40421. _samplerList: string[];
  40422. /** @hidden */
  40423. _multiTarget: boolean;
  40424. private static _uniqueIdSeed;
  40425. private _engine;
  40426. private _uniformBuffersNamesList;
  40427. private _uniformsNames;
  40428. private _samplers;
  40429. private _isReady;
  40430. private _compilationError;
  40431. private _allFallbacksProcessed;
  40432. private _attributesNames;
  40433. private _attributes;
  40434. private _attributeLocationByName;
  40435. private _uniforms;
  40436. /**
  40437. * Key for the effect.
  40438. * @hidden
  40439. */
  40440. _key: string;
  40441. private _indexParameters;
  40442. private _fallbacks;
  40443. private _vertexSourceCodeOverride;
  40444. private _fragmentSourceCodeOverride;
  40445. private _transformFeedbackVaryings;
  40446. /**
  40447. * Compiled shader to webGL program.
  40448. * @hidden
  40449. */
  40450. _pipelineContext: Nullable<IPipelineContext>;
  40451. /** @hidden */
  40452. _vertexSourceCode: string;
  40453. /** @hidden */
  40454. _fragmentSourceCode: string;
  40455. /** @hidden */
  40456. private _rawVertexSourceCode;
  40457. /** @hidden */
  40458. private _rawFragmentSourceCode;
  40459. private static _baseCache;
  40460. private _processingContext;
  40461. /**
  40462. * Instantiates an effect.
  40463. * An effect can be used to create/manage/execute vertex and fragment shaders.
  40464. * @param baseName Name of the effect.
  40465. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  40466. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  40467. * @param samplers List of sampler variables that will be passed to the shader.
  40468. * @param engine Engine to be used to render the effect
  40469. * @param defines Define statements to be added to the shader.
  40470. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  40471. * @param onCompiled Callback that will be called when the shader is compiled.
  40472. * @param onError Callback that will be called if an error occurs during shader compilation.
  40473. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40474. * @param key Effect Key identifying uniquely compiled shader variants
  40475. */
  40476. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, key?: string);
  40477. private _useFinalCode;
  40478. /**
  40479. * Unique key for this effect
  40480. */
  40481. get key(): string;
  40482. /**
  40483. * If the effect has been compiled and prepared.
  40484. * @returns if the effect is compiled and prepared.
  40485. */
  40486. isReady(): boolean;
  40487. private _isReadyInternal;
  40488. /**
  40489. * The engine the effect was initialized with.
  40490. * @returns the engine.
  40491. */
  40492. getEngine(): Engine;
  40493. /**
  40494. * The pipeline context for this effect
  40495. * @returns the associated pipeline context
  40496. */
  40497. getPipelineContext(): Nullable<IPipelineContext>;
  40498. /**
  40499. * The set of names of attribute variables for the shader.
  40500. * @returns An array of attribute names.
  40501. */
  40502. getAttributesNames(): string[];
  40503. /**
  40504. * Returns the attribute at the given index.
  40505. * @param index The index of the attribute.
  40506. * @returns The location of the attribute.
  40507. */
  40508. getAttributeLocation(index: number): number;
  40509. /**
  40510. * Returns the attribute based on the name of the variable.
  40511. * @param name of the attribute to look up.
  40512. * @returns the attribute location.
  40513. */
  40514. getAttributeLocationByName(name: string): number;
  40515. /**
  40516. * The number of attributes.
  40517. * @returns the numnber of attributes.
  40518. */
  40519. getAttributesCount(): number;
  40520. /**
  40521. * Gets the index of a uniform variable.
  40522. * @param uniformName of the uniform to look up.
  40523. * @returns the index.
  40524. */
  40525. getUniformIndex(uniformName: string): number;
  40526. /**
  40527. * Returns the attribute based on the name of the variable.
  40528. * @param uniformName of the uniform to look up.
  40529. * @returns the location of the uniform.
  40530. */
  40531. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  40532. /**
  40533. * Returns an array of sampler variable names
  40534. * @returns The array of sampler variable names.
  40535. */
  40536. getSamplers(): string[];
  40537. /**
  40538. * Returns an array of uniform variable names
  40539. * @returns The array of uniform variable names.
  40540. */
  40541. getUniformNames(): string[];
  40542. /**
  40543. * Returns an array of uniform buffer variable names
  40544. * @returns The array of uniform buffer variable names.
  40545. */
  40546. getUniformBuffersNames(): string[];
  40547. /**
  40548. * Returns the index parameters used to create the effect
  40549. * @returns The index parameters object
  40550. */
  40551. getIndexParameters(): any;
  40552. /**
  40553. * The error from the last compilation.
  40554. * @returns the error string.
  40555. */
  40556. getCompilationError(): string;
  40557. /**
  40558. * Gets a boolean indicating that all fallbacks were used during compilation
  40559. * @returns true if all fallbacks were used
  40560. */
  40561. allFallbacksProcessed(): boolean;
  40562. /**
  40563. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  40564. * @param func The callback to be used.
  40565. */
  40566. executeWhenCompiled(func: (effect: Effect) => void): void;
  40567. private _checkIsReady;
  40568. private _loadShader;
  40569. /**
  40570. * Gets the vertex shader source code of this effect
  40571. */
  40572. get vertexSourceCode(): string;
  40573. /**
  40574. * Gets the fragment shader source code of this effect
  40575. */
  40576. get fragmentSourceCode(): string;
  40577. /**
  40578. * Gets the vertex shader source code before it has been processed by the preprocessor
  40579. */
  40580. get rawVertexSourceCode(): string;
  40581. /**
  40582. * Gets the fragment shader source code before it has been processed by the preprocessor
  40583. */
  40584. get rawFragmentSourceCode(): string;
  40585. /**
  40586. * Recompiles the webGL program
  40587. * @param vertexSourceCode The source code for the vertex shader.
  40588. * @param fragmentSourceCode The source code for the fragment shader.
  40589. * @param onCompiled Callback called when completed.
  40590. * @param onError Callback called on error.
  40591. * @hidden
  40592. */
  40593. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  40594. /**
  40595. * Prepares the effect
  40596. * @hidden
  40597. */
  40598. _prepareEffect(): void;
  40599. private _getShaderCodeAndErrorLine;
  40600. private _processCompilationErrors;
  40601. /**
  40602. * Checks if the effect is supported. (Must be called after compilation)
  40603. */
  40604. get isSupported(): boolean;
  40605. /**
  40606. * Binds a texture to the engine to be used as output of the shader.
  40607. * @param channel Name of the output variable.
  40608. * @param texture Texture to bind.
  40609. * @hidden
  40610. */
  40611. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  40612. /**
  40613. * Sets a texture on the engine to be used in the shader.
  40614. * @param channel Name of the sampler variable.
  40615. * @param texture Texture to set.
  40616. */
  40617. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  40618. /**
  40619. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  40620. * @param channel Name of the sampler variable.
  40621. * @param texture Texture to set.
  40622. */
  40623. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  40624. /**
  40625. * Sets an array of textures on the engine to be used in the shader.
  40626. * @param channel Name of the variable.
  40627. * @param textures Textures to set.
  40628. */
  40629. setTextureArray(channel: string, textures: ThinTexture[]): void;
  40630. /**
  40631. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  40632. * @param channel Name of the sampler variable.
  40633. * @param postProcess Post process to get the input texture from.
  40634. */
  40635. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  40636. /**
  40637. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  40638. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  40639. * @param channel Name of the sampler variable.
  40640. * @param postProcess Post process to get the output texture from.
  40641. */
  40642. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  40643. /**
  40644. * Binds a buffer to a uniform.
  40645. * @param buffer Buffer to bind.
  40646. * @param name Name of the uniform variable to bind to.
  40647. */
  40648. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  40649. /**
  40650. * Binds block to a uniform.
  40651. * @param blockName Name of the block to bind.
  40652. * @param index Index to bind.
  40653. */
  40654. bindUniformBlock(blockName: string, index: number): void;
  40655. /**
  40656. * Sets an interger value on a uniform variable.
  40657. * @param uniformName Name of the variable.
  40658. * @param value Value to be set.
  40659. * @returns this effect.
  40660. */
  40661. setInt(uniformName: string, value: number): Effect;
  40662. /**
  40663. * Sets an int2 value on a uniform variable.
  40664. * @param uniformName Name of the variable.
  40665. * @param x First int in int2.
  40666. * @param y Second int in int2.
  40667. * @returns this effect.
  40668. */
  40669. setInt2(uniformName: string, x: number, y: number): Effect;
  40670. /**
  40671. * Sets an int3 value on a uniform variable.
  40672. * @param uniformName Name of the variable.
  40673. * @param x First int in int3.
  40674. * @param y Second int in int3.
  40675. * @param z Third int in int3.
  40676. * @returns this effect.
  40677. */
  40678. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  40679. /**
  40680. * Sets an int4 value on a uniform variable.
  40681. * @param uniformName Name of the variable.
  40682. * @param x First int in int4.
  40683. * @param y Second int in int4.
  40684. * @param z Third int in int4.
  40685. * @param w Fourth int in int4.
  40686. * @returns this effect.
  40687. */
  40688. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40689. /**
  40690. * Sets an int array on a uniform variable.
  40691. * @param uniformName Name of the variable.
  40692. * @param array array to be set.
  40693. * @returns this effect.
  40694. */
  40695. setIntArray(uniformName: string, array: Int32Array): Effect;
  40696. /**
  40697. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  40698. * @param uniformName Name of the variable.
  40699. * @param array array to be set.
  40700. * @returns this effect.
  40701. */
  40702. setIntArray2(uniformName: string, array: Int32Array): Effect;
  40703. /**
  40704. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  40705. * @param uniformName Name of the variable.
  40706. * @param array array to be set.
  40707. * @returns this effect.
  40708. */
  40709. setIntArray3(uniformName: string, array: Int32Array): Effect;
  40710. /**
  40711. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  40712. * @param uniformName Name of the variable.
  40713. * @param array array to be set.
  40714. * @returns this effect.
  40715. */
  40716. setIntArray4(uniformName: string, array: Int32Array): Effect;
  40717. /**
  40718. * Sets an float array on a uniform variable.
  40719. * @param uniformName Name of the variable.
  40720. * @param array array to be set.
  40721. * @returns this effect.
  40722. */
  40723. setFloatArray(uniformName: string, array: FloatArray): Effect;
  40724. /**
  40725. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  40726. * @param uniformName Name of the variable.
  40727. * @param array array to be set.
  40728. * @returns this effect.
  40729. */
  40730. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  40731. /**
  40732. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  40733. * @param uniformName Name of the variable.
  40734. * @param array array to be set.
  40735. * @returns this effect.
  40736. */
  40737. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  40738. /**
  40739. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  40740. * @param uniformName Name of the variable.
  40741. * @param array array to be set.
  40742. * @returns this effect.
  40743. */
  40744. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  40745. /**
  40746. * Sets an array on a uniform variable.
  40747. * @param uniformName Name of the variable.
  40748. * @param array array to be set.
  40749. * @returns this effect.
  40750. */
  40751. setArray(uniformName: string, array: number[]): Effect;
  40752. /**
  40753. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  40754. * @param uniformName Name of the variable.
  40755. * @param array array to be set.
  40756. * @returns this effect.
  40757. */
  40758. setArray2(uniformName: string, array: number[]): Effect;
  40759. /**
  40760. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  40761. * @param uniformName Name of the variable.
  40762. * @param array array to be set.
  40763. * @returns this effect.
  40764. */
  40765. setArray3(uniformName: string, array: number[]): Effect;
  40766. /**
  40767. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  40768. * @param uniformName Name of the variable.
  40769. * @param array array to be set.
  40770. * @returns this effect.
  40771. */
  40772. setArray4(uniformName: string, array: number[]): Effect;
  40773. /**
  40774. * Sets matrices on a uniform variable.
  40775. * @param uniformName Name of the variable.
  40776. * @param matrices matrices to be set.
  40777. * @returns this effect.
  40778. */
  40779. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  40780. /**
  40781. * Sets matrix on a uniform variable.
  40782. * @param uniformName Name of the variable.
  40783. * @param matrix matrix to be set.
  40784. * @returns this effect.
  40785. */
  40786. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  40787. /**
  40788. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  40789. * @param uniformName Name of the variable.
  40790. * @param matrix matrix to be set.
  40791. * @returns this effect.
  40792. */
  40793. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40794. /**
  40795. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  40796. * @param uniformName Name of the variable.
  40797. * @param matrix matrix to be set.
  40798. * @returns this effect.
  40799. */
  40800. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40801. /**
  40802. * Sets a float on a uniform variable.
  40803. * @param uniformName Name of the variable.
  40804. * @param value value to be set.
  40805. * @returns this effect.
  40806. */
  40807. setFloat(uniformName: string, value: number): Effect;
  40808. /**
  40809. * Sets a boolean on a uniform variable.
  40810. * @param uniformName Name of the variable.
  40811. * @param bool value to be set.
  40812. * @returns this effect.
  40813. */
  40814. setBool(uniformName: string, bool: boolean): Effect;
  40815. /**
  40816. * Sets a Vector2 on a uniform variable.
  40817. * @param uniformName Name of the variable.
  40818. * @param vector2 vector2 to be set.
  40819. * @returns this effect.
  40820. */
  40821. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  40822. /**
  40823. * Sets a float2 on a uniform variable.
  40824. * @param uniformName Name of the variable.
  40825. * @param x First float in float2.
  40826. * @param y Second float in float2.
  40827. * @returns this effect.
  40828. */
  40829. setFloat2(uniformName: string, x: number, y: number): Effect;
  40830. /**
  40831. * Sets a Vector3 on a uniform variable.
  40832. * @param uniformName Name of the variable.
  40833. * @param vector3 Value to be set.
  40834. * @returns this effect.
  40835. */
  40836. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  40837. /**
  40838. * Sets a float3 on a uniform variable.
  40839. * @param uniformName Name of the variable.
  40840. * @param x First float in float3.
  40841. * @param y Second float in float3.
  40842. * @param z Third float in float3.
  40843. * @returns this effect.
  40844. */
  40845. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  40846. /**
  40847. * Sets a Vector4 on a uniform variable.
  40848. * @param uniformName Name of the variable.
  40849. * @param vector4 Value to be set.
  40850. * @returns this effect.
  40851. */
  40852. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  40853. /**
  40854. * Sets a float4 on a uniform variable.
  40855. * @param uniformName Name of the variable.
  40856. * @param x First float in float4.
  40857. * @param y Second float in float4.
  40858. * @param z Third float in float4.
  40859. * @param w Fourth float in float4.
  40860. * @returns this effect.
  40861. */
  40862. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40863. /**
  40864. * Sets a Color3 on a uniform variable.
  40865. * @param uniformName Name of the variable.
  40866. * @param color3 Value to be set.
  40867. * @returns this effect.
  40868. */
  40869. setColor3(uniformName: string, color3: IColor3Like): Effect;
  40870. /**
  40871. * Sets a Color4 on a uniform variable.
  40872. * @param uniformName Name of the variable.
  40873. * @param color3 Value to be set.
  40874. * @param alpha Alpha value to be set.
  40875. * @returns this effect.
  40876. */
  40877. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  40878. /**
  40879. * Sets a Color4 on a uniform variable
  40880. * @param uniformName defines the name of the variable
  40881. * @param color4 defines the value to be set
  40882. * @returns this effect.
  40883. */
  40884. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  40885. /**
  40886. * Release all associated resources.
  40887. **/
  40888. dispose(): void;
  40889. /**
  40890. * This function will add a new shader to the shader store
  40891. * @param name the name of the shader
  40892. * @param pixelShader optional pixel shader content
  40893. * @param vertexShader optional vertex shader content
  40894. */
  40895. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  40896. /**
  40897. * Store of each shader (The can be looked up using effect.key)
  40898. */
  40899. static ShadersStore: {
  40900. [key: string]: string;
  40901. };
  40902. /**
  40903. * Store of each included file for a shader (The can be looked up using effect.key)
  40904. */
  40905. static IncludesShadersStore: {
  40906. [key: string]: string;
  40907. };
  40908. /**
  40909. * Resets the cache of effects.
  40910. */
  40911. static ResetCache(): void;
  40912. }
  40913. }
  40914. declare module "babylonjs/Engines/engineCapabilities" {
  40915. /**
  40916. * Interface used to describe the capabilities of the engine relatively to the current browser
  40917. */
  40918. export interface EngineCapabilities {
  40919. /** Maximum textures units per fragment shader */
  40920. maxTexturesImageUnits: number;
  40921. /** Maximum texture units per vertex shader */
  40922. maxVertexTextureImageUnits: number;
  40923. /** Maximum textures units in the entire pipeline */
  40924. maxCombinedTexturesImageUnits: number;
  40925. /** Maximum texture size */
  40926. maxTextureSize: number;
  40927. /** Maximum texture samples */
  40928. maxSamples?: number;
  40929. /** Maximum cube texture size */
  40930. maxCubemapTextureSize: number;
  40931. /** Maximum render texture size */
  40932. maxRenderTextureSize: number;
  40933. /** Maximum number of vertex attributes */
  40934. maxVertexAttribs: number;
  40935. /** Maximum number of varyings */
  40936. maxVaryingVectors: number;
  40937. /** Maximum number of uniforms per vertex shader */
  40938. maxVertexUniformVectors: number;
  40939. /** Maximum number of uniforms per fragment shader */
  40940. maxFragmentUniformVectors: number;
  40941. /** Defines if standard derivates (dx/dy) are supported */
  40942. standardDerivatives: boolean;
  40943. /** Defines if s3tc texture compression is supported */
  40944. s3tc?: WEBGL_compressed_texture_s3tc;
  40945. /** Defines if pvrtc texture compression is supported */
  40946. pvrtc: any;
  40947. /** Defines if etc1 texture compression is supported */
  40948. etc1: any;
  40949. /** Defines if etc2 texture compression is supported */
  40950. etc2: any;
  40951. /** Defines if astc texture compression is supported */
  40952. astc: any;
  40953. /** Defines if bptc texture compression is supported */
  40954. bptc: any;
  40955. /** Defines if float textures are supported */
  40956. textureFloat: boolean;
  40957. /** Defines if vertex array objects are supported */
  40958. vertexArrayObject: boolean;
  40959. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40960. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40961. /** Gets the maximum level of anisotropy supported */
  40962. maxAnisotropy: number;
  40963. /** Defines if instancing is supported */
  40964. instancedArrays: boolean;
  40965. /** Defines if 32 bits indices are supported */
  40966. uintIndices: boolean;
  40967. /** Defines if high precision shaders are supported */
  40968. highPrecisionShaderSupported: boolean;
  40969. /** Defines if depth reading in the fragment shader is supported */
  40970. fragmentDepthSupported: boolean;
  40971. /** Defines if float texture linear filtering is supported*/
  40972. textureFloatLinearFiltering: boolean;
  40973. /** Defines if rendering to float textures is supported */
  40974. textureFloatRender: boolean;
  40975. /** Defines if half float textures are supported*/
  40976. textureHalfFloat: boolean;
  40977. /** Defines if half float texture linear filtering is supported*/
  40978. textureHalfFloatLinearFiltering: boolean;
  40979. /** Defines if rendering to half float textures is supported */
  40980. textureHalfFloatRender: boolean;
  40981. /** Defines if textureLOD shader command is supported */
  40982. textureLOD: boolean;
  40983. /** Defines if draw buffers extension is supported */
  40984. drawBuffersExtension: boolean;
  40985. /** Defines if depth textures are supported */
  40986. depthTextureExtension: boolean;
  40987. /** Defines if float color buffer are supported */
  40988. colorBufferFloat: boolean;
  40989. /** Gets disjoint timer query extension (null if not supported) */
  40990. timerQuery?: EXT_disjoint_timer_query;
  40991. /** Defines if timestamp can be used with timer query */
  40992. canUseTimestampForTimerQuery: boolean;
  40993. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40994. multiview?: any;
  40995. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40996. oculusMultiview?: any;
  40997. /** Function used to let the system compiles shaders in background */
  40998. parallelShaderCompile?: {
  40999. COMPLETION_STATUS_KHR: number;
  41000. };
  41001. /** Max number of texture samples for MSAA */
  41002. maxMSAASamples: number;
  41003. /** Defines if the blend min max extension is supported */
  41004. blendMinMax: boolean;
  41005. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  41006. canUseGLInstanceID: boolean;
  41007. }
  41008. }
  41009. declare module "babylonjs/States/depthCullingState" {
  41010. import { Nullable } from "babylonjs/types";
  41011. /**
  41012. * @hidden
  41013. **/
  41014. export class DepthCullingState {
  41015. private _isDepthTestDirty;
  41016. private _isDepthMaskDirty;
  41017. private _isDepthFuncDirty;
  41018. private _isCullFaceDirty;
  41019. private _isCullDirty;
  41020. private _isZOffsetDirty;
  41021. private _isFrontFaceDirty;
  41022. private _depthTest;
  41023. private _depthMask;
  41024. private _depthFunc;
  41025. private _cull;
  41026. private _cullFace;
  41027. private _zOffset;
  41028. private _frontFace;
  41029. /**
  41030. * Initializes the state.
  41031. */
  41032. constructor();
  41033. get isDirty(): boolean;
  41034. get zOffset(): number;
  41035. set zOffset(value: number);
  41036. get cullFace(): Nullable<number>;
  41037. set cullFace(value: Nullable<number>);
  41038. get cull(): Nullable<boolean>;
  41039. set cull(value: Nullable<boolean>);
  41040. get depthFunc(): Nullable<number>;
  41041. set depthFunc(value: Nullable<number>);
  41042. get depthMask(): boolean;
  41043. set depthMask(value: boolean);
  41044. get depthTest(): boolean;
  41045. set depthTest(value: boolean);
  41046. get frontFace(): Nullable<number>;
  41047. set frontFace(value: Nullable<number>);
  41048. reset(): void;
  41049. apply(gl: WebGLRenderingContext): void;
  41050. }
  41051. }
  41052. declare module "babylonjs/States/stencilState" {
  41053. /**
  41054. * @hidden
  41055. **/
  41056. export class StencilState {
  41057. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  41058. static readonly ALWAYS: number;
  41059. /** Passed to stencilOperation to specify that stencil value must be kept */
  41060. static readonly KEEP: number;
  41061. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41062. static readonly REPLACE: number;
  41063. private _isStencilTestDirty;
  41064. private _isStencilMaskDirty;
  41065. private _isStencilFuncDirty;
  41066. private _isStencilOpDirty;
  41067. private _stencilTest;
  41068. private _stencilMask;
  41069. private _stencilFunc;
  41070. private _stencilFuncRef;
  41071. private _stencilFuncMask;
  41072. private _stencilOpStencilFail;
  41073. private _stencilOpDepthFail;
  41074. private _stencilOpStencilDepthPass;
  41075. get isDirty(): boolean;
  41076. get stencilFunc(): number;
  41077. set stencilFunc(value: number);
  41078. get stencilFuncRef(): number;
  41079. set stencilFuncRef(value: number);
  41080. get stencilFuncMask(): number;
  41081. set stencilFuncMask(value: number);
  41082. get stencilOpStencilFail(): number;
  41083. set stencilOpStencilFail(value: number);
  41084. get stencilOpDepthFail(): number;
  41085. set stencilOpDepthFail(value: number);
  41086. get stencilOpStencilDepthPass(): number;
  41087. set stencilOpStencilDepthPass(value: number);
  41088. get stencilMask(): number;
  41089. set stencilMask(value: number);
  41090. get stencilTest(): boolean;
  41091. set stencilTest(value: boolean);
  41092. constructor();
  41093. reset(): void;
  41094. apply(gl: WebGLRenderingContext): void;
  41095. }
  41096. }
  41097. declare module "babylonjs/States/alphaCullingState" {
  41098. import { Nullable } from "babylonjs/types";
  41099. /**
  41100. * @hidden
  41101. **/
  41102. export class AlphaState {
  41103. _blendFunctionParameters: Nullable<number>[];
  41104. _blendEquationParameters: Nullable<number>[];
  41105. _blendConstants: Nullable<number>[];
  41106. _isBlendConstantsDirty: boolean;
  41107. private _alphaBlend;
  41108. private _isAlphaBlendDirty;
  41109. private _isBlendFunctionParametersDirty;
  41110. private _isBlendEquationParametersDirty;
  41111. /**
  41112. * Initializes the state.
  41113. */
  41114. constructor();
  41115. get isDirty(): boolean;
  41116. get alphaBlend(): boolean;
  41117. set alphaBlend(value: boolean);
  41118. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  41119. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  41120. setAlphaEquationParameters(rgb: number, alpha: number): void;
  41121. reset(): void;
  41122. apply(gl: WebGLRenderingContext): void;
  41123. }
  41124. }
  41125. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  41126. import { Nullable } from "babylonjs/types";
  41127. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41128. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41129. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41130. /** @hidden */
  41131. export class WebGLShaderProcessor implements IShaderProcessor {
  41132. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41133. }
  41134. }
  41135. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  41136. import { Nullable } from "babylonjs/types";
  41137. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41138. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41139. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41140. /** @hidden */
  41141. export class WebGL2ShaderProcessor implements IShaderProcessor {
  41142. attributeProcessor(attribute: string): string;
  41143. varyingProcessor(varying: string, isFragment: boolean): string;
  41144. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41145. }
  41146. }
  41147. declare module "babylonjs/Engines/instancingAttributeInfo" {
  41148. /**
  41149. * Interface for attribute information associated with buffer instanciation
  41150. */
  41151. export interface InstancingAttributeInfo {
  41152. /**
  41153. * Name of the GLSL attribute
  41154. * if attribute index is not specified, this is used to retrieve the index from the effect
  41155. */
  41156. attributeName: string;
  41157. /**
  41158. * Index/offset of the attribute in the vertex shader
  41159. * if not specified, this will be computes from the name.
  41160. */
  41161. index?: number;
  41162. /**
  41163. * size of the attribute, 1, 2, 3 or 4
  41164. */
  41165. attributeSize: number;
  41166. /**
  41167. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  41168. */
  41169. offset: number;
  41170. /**
  41171. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  41172. * default to 1
  41173. */
  41174. divisor?: number;
  41175. /**
  41176. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  41177. * default is FLOAT
  41178. */
  41179. attributeType?: number;
  41180. /**
  41181. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  41182. */
  41183. normalized?: boolean;
  41184. }
  41185. }
  41186. declare module "babylonjs/Engines/engineFeatures" {
  41187. /** @hidden */
  41188. export interface EngineFeatures {
  41189. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  41190. forceBitmapOverHTMLImageElement: boolean;
  41191. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  41192. supportRenderAndCopyToLodForFloatTextures: boolean;
  41193. /** Indicates that the engine support handling depth/stencil textures */
  41194. supportDepthStencilTexture: boolean;
  41195. /** Indicates that the engine support shadow samplers */
  41196. supportShadowSamplers: boolean;
  41197. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  41198. uniformBufferHardCheckMatrix: boolean;
  41199. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  41200. allowTexturePrefiltering: boolean;
  41201. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  41202. trackUbosInFrame: boolean;
  41203. /** Indicates that the Cascaded Shadow Map technic is supported */
  41204. supportCSM: boolean;
  41205. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  41206. basisNeedsPOT: boolean;
  41207. /** Indicates that the engine supports 3D textures */
  41208. support3DTextures: boolean;
  41209. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  41210. needTypeSuffixInShaderConstants: boolean;
  41211. /** Indicates that MSAA is supported */
  41212. supportMSAA: boolean;
  41213. /** Indicates that SSAO2 is supported */
  41214. supportSSAO2: boolean;
  41215. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  41216. supportExtendedTextureFormats: boolean;
  41217. /** Indicates that the switch/case construct is supported in shaders */
  41218. supportSwitchCaseInShader: boolean;
  41219. /** Indicates that synchronous texture reading is supported */
  41220. supportSyncTextureRead: boolean;
  41221. /** @hidden */
  41222. _collectUbosUpdatedInFrame: boolean;
  41223. }
  41224. }
  41225. declare module "babylonjs/Engines/WebGL/webGLHardwareTexture" {
  41226. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41227. import { Nullable } from "babylonjs/types";
  41228. /** @hidden */
  41229. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  41230. private _webGLTexture;
  41231. private _context;
  41232. get underlyingResource(): Nullable<WebGLTexture>;
  41233. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  41234. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  41235. set(hardwareTexture: WebGLTexture): void;
  41236. reset(): void;
  41237. release(): void;
  41238. }
  41239. }
  41240. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  41241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41242. import { Nullable } from "babylonjs/types";
  41243. module "babylonjs/Engines/thinEngine" {
  41244. interface ThinEngine {
  41245. /**
  41246. * Update a video texture
  41247. * @param texture defines the texture to update
  41248. * @param video defines the video element to use
  41249. * @param invertY defines if data must be stored with Y axis inverted
  41250. */
  41251. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  41252. }
  41253. }
  41254. }
  41255. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  41256. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41257. import { Nullable } from "babylonjs/types";
  41258. module "babylonjs/Engines/thinEngine" {
  41259. interface ThinEngine {
  41260. /**
  41261. * Creates a dynamic texture
  41262. * @param width defines the width of the texture
  41263. * @param height defines the height of the texture
  41264. * @param generateMipMaps defines if the engine should generate the mip levels
  41265. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  41266. * @returns the dynamic texture inside an InternalTexture
  41267. */
  41268. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  41269. /**
  41270. * Update the content of a dynamic texture
  41271. * @param texture defines the texture to update
  41272. * @param source defines the source containing the data
  41273. * @param invertY defines if data must be stored with Y axis inverted
  41274. * @param premulAlpha defines if alpha is stored as premultiplied
  41275. * @param format defines the format of the data
  41276. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  41277. */
  41278. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  41279. }
  41280. }
  41281. }
  41282. declare module "babylonjs/Materials/Textures/videoTexture" {
  41283. import { Observable } from "babylonjs/Misc/observable";
  41284. import { Nullable } from "babylonjs/types";
  41285. import { Scene } from "babylonjs/scene";
  41286. import { Texture } from "babylonjs/Materials/Textures/texture";
  41287. import "babylonjs/Engines/Extensions/engine.videoTexture";
  41288. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  41289. /**
  41290. * Settings for finer control over video usage
  41291. */
  41292. export interface VideoTextureSettings {
  41293. /**
  41294. * Applies `autoplay` to video, if specified
  41295. */
  41296. autoPlay?: boolean;
  41297. /**
  41298. * Applies `muted` to video, if specified
  41299. */
  41300. muted?: boolean;
  41301. /**
  41302. * Applies `loop` to video, if specified
  41303. */
  41304. loop?: boolean;
  41305. /**
  41306. * Automatically updates internal texture from video at every frame in the render loop
  41307. */
  41308. autoUpdateTexture: boolean;
  41309. /**
  41310. * Image src displayed during the video loading or until the user interacts with the video.
  41311. */
  41312. poster?: string;
  41313. }
  41314. /**
  41315. * If you want to display a video in your scene, this is the special texture for that.
  41316. * This special texture works similar to other textures, with the exception of a few parameters.
  41317. * @see https://doc.babylonjs.com/how_to/video_texture
  41318. */
  41319. export class VideoTexture extends Texture {
  41320. /**
  41321. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  41322. */
  41323. readonly autoUpdateTexture: boolean;
  41324. /**
  41325. * The video instance used by the texture internally
  41326. */
  41327. readonly video: HTMLVideoElement;
  41328. private _onUserActionRequestedObservable;
  41329. /**
  41330. * Event triggerd when a dom action is required by the user to play the video.
  41331. * This happens due to recent changes in browser policies preventing video to auto start.
  41332. */
  41333. get onUserActionRequestedObservable(): Observable<Texture>;
  41334. private _generateMipMaps;
  41335. private _stillImageCaptured;
  41336. private _displayingPosterTexture;
  41337. private _settings;
  41338. private _createInternalTextureOnEvent;
  41339. private _frameId;
  41340. private _currentSrc;
  41341. /**
  41342. * Creates a video texture.
  41343. * If you want to display a video in your scene, this is the special texture for that.
  41344. * This special texture works similar to other textures, with the exception of a few parameters.
  41345. * @see https://doc.babylonjs.com/how_to/video_texture
  41346. * @param name optional name, will detect from video source, if not defined
  41347. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  41348. * @param scene is obviously the current scene.
  41349. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  41350. * @param invertY is false by default but can be used to invert video on Y axis
  41351. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  41352. * @param settings allows finer control over video usage
  41353. */
  41354. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  41355. private _getName;
  41356. private _getVideo;
  41357. private _createInternalTexture;
  41358. private reset;
  41359. /**
  41360. * @hidden Internal method to initiate `update`.
  41361. */
  41362. _rebuild(): void;
  41363. /**
  41364. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  41365. */
  41366. update(): void;
  41367. /**
  41368. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  41369. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  41370. */
  41371. updateTexture(isVisible: boolean): void;
  41372. protected _updateInternalTexture: () => void;
  41373. /**
  41374. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  41375. * @param url New url.
  41376. */
  41377. updateURL(url: string): void;
  41378. /**
  41379. * Clones the texture.
  41380. * @returns the cloned texture
  41381. */
  41382. clone(): VideoTexture;
  41383. /**
  41384. * Dispose the texture and release its associated resources.
  41385. */
  41386. dispose(): void;
  41387. /**
  41388. * Creates a video texture straight from a stream.
  41389. * @param scene Define the scene the texture should be created in
  41390. * @param stream Define the stream the texture should be created from
  41391. * @returns The created video texture as a promise
  41392. */
  41393. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  41394. /**
  41395. * Creates a video texture straight from your WebCam video feed.
  41396. * @param scene Define the scene the texture should be created in
  41397. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41398. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41399. * @returns The created video texture as a promise
  41400. */
  41401. static CreateFromWebCamAsync(scene: Scene, constraints: {
  41402. minWidth: number;
  41403. maxWidth: number;
  41404. minHeight: number;
  41405. maxHeight: number;
  41406. deviceId: string;
  41407. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  41408. /**
  41409. * Creates a video texture straight from your WebCam video feed.
  41410. * @param scene Define the scene the texture should be created in
  41411. * @param onReady Define a callback to triggered once the texture will be ready
  41412. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41413. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41414. */
  41415. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  41416. minWidth: number;
  41417. maxWidth: number;
  41418. minHeight: number;
  41419. maxHeight: number;
  41420. deviceId: string;
  41421. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  41422. }
  41423. }
  41424. declare module "babylonjs/Engines/thinEngine" {
  41425. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  41426. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  41427. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41428. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  41430. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  41431. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  41432. import { Observable } from "babylonjs/Misc/observable";
  41433. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  41434. import { StencilState } from "babylonjs/States/stencilState";
  41435. import { AlphaState } from "babylonjs/States/alphaCullingState";
  41436. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41437. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41438. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41439. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  41440. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41441. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41442. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41443. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  41444. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  41445. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41446. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  41447. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  41448. import { EngineFeatures } from "babylonjs/Engines/engineFeatures";
  41449. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41450. import { WebRequest } from "babylonjs/Misc/webRequest";
  41451. import { LoadFileError } from "babylonjs/Misc/fileTools";
  41452. /**
  41453. * Defines the interface used by objects working like Scene
  41454. * @hidden
  41455. */
  41456. export interface ISceneLike {
  41457. _addPendingData(data: any): void;
  41458. _removePendingData(data: any): void;
  41459. offlineProvider: IOfflineProvider;
  41460. }
  41461. /**
  41462. * Information about the current host
  41463. */
  41464. export interface HostInformation {
  41465. /**
  41466. * Defines if the current host is a mobile
  41467. */
  41468. isMobile: boolean;
  41469. }
  41470. /** Interface defining initialization parameters for Engine class */
  41471. export interface EngineOptions extends WebGLContextAttributes {
  41472. /**
  41473. * Defines if the engine should no exceed a specified device ratio
  41474. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  41475. */
  41476. limitDeviceRatio?: number;
  41477. /**
  41478. * Defines if webvr should be enabled automatically
  41479. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41480. */
  41481. autoEnableWebVR?: boolean;
  41482. /**
  41483. * Defines if webgl2 should be turned off even if supported
  41484. * @see https://doc.babylonjs.com/features/webgl2
  41485. */
  41486. disableWebGL2Support?: boolean;
  41487. /**
  41488. * Defines if webaudio should be initialized as well
  41489. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41490. */
  41491. audioEngine?: boolean;
  41492. /**
  41493. * Defines if animations should run using a deterministic lock step
  41494. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41495. */
  41496. deterministicLockstep?: boolean;
  41497. /** Defines the maximum steps to use with deterministic lock step mode */
  41498. lockstepMaxSteps?: number;
  41499. /** Defines the seconds between each deterministic lock step */
  41500. timeStep?: number;
  41501. /**
  41502. * Defines that engine should ignore context lost events
  41503. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  41504. */
  41505. doNotHandleContextLost?: boolean;
  41506. /**
  41507. * Defines that engine should ignore modifying touch action attribute and style
  41508. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  41509. */
  41510. doNotHandleTouchAction?: boolean;
  41511. /**
  41512. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  41513. */
  41514. useHighPrecisionFloats?: boolean;
  41515. /**
  41516. * Make the canvas XR Compatible for XR sessions
  41517. */
  41518. xrCompatible?: boolean;
  41519. /**
  41520. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  41521. */
  41522. useHighPrecisionMatrix?: boolean;
  41523. /**
  41524. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  41525. */
  41526. failIfMajorPerformanceCaveat?: boolean;
  41527. /**
  41528. * Defines whether to adapt to the device's viewport characteristics (default: false)
  41529. */
  41530. adaptToDeviceRatio?: boolean;
  41531. }
  41532. /**
  41533. * The base engine class (root of all engines)
  41534. */
  41535. export class ThinEngine {
  41536. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  41537. static ExceptionList: ({
  41538. key: string;
  41539. capture: string;
  41540. captureConstraint: number;
  41541. targets: string[];
  41542. } | {
  41543. key: string;
  41544. capture: null;
  41545. captureConstraint: null;
  41546. targets: string[];
  41547. })[];
  41548. /** @hidden */
  41549. static _TextureLoaders: IInternalTextureLoader[];
  41550. /**
  41551. * Returns the current npm package of the sdk
  41552. */
  41553. static get NpmPackage(): string;
  41554. /**
  41555. * Returns the current version of the framework
  41556. */
  41557. static get Version(): string;
  41558. /**
  41559. * Returns a string describing the current engine
  41560. */
  41561. get description(): string;
  41562. /**
  41563. * Returns the name of the engine
  41564. */
  41565. get name(): string;
  41566. /**
  41567. * Returns the version of the engine
  41568. */
  41569. get version(): number;
  41570. /**
  41571. * Gets or sets the epsilon value used by collision engine
  41572. */
  41573. static CollisionsEpsilon: number;
  41574. /**
  41575. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  41576. */
  41577. static get ShadersRepository(): string;
  41578. static set ShadersRepository(value: string);
  41579. /** @hidden */
  41580. _shaderProcessor: Nullable<IShaderProcessor>;
  41581. /**
  41582. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  41583. */
  41584. forcePOTTextures: boolean;
  41585. /**
  41586. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  41587. */
  41588. isFullscreen: boolean;
  41589. /**
  41590. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  41591. */
  41592. cullBackFaces: boolean;
  41593. /**
  41594. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  41595. */
  41596. renderEvenInBackground: boolean;
  41597. /**
  41598. * Gets or sets a boolean indicating that cache can be kept between frames
  41599. */
  41600. preventCacheWipeBetweenFrames: boolean;
  41601. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  41602. validateShaderPrograms: boolean;
  41603. /**
  41604. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  41605. * This can provide greater z depth for distant objects.
  41606. */
  41607. useReverseDepthBuffer: boolean;
  41608. /**
  41609. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  41610. */
  41611. disableUniformBuffers: boolean;
  41612. private _frameId;
  41613. /**
  41614. * Gets the current frame id
  41615. */
  41616. get frameId(): number;
  41617. /** @hidden */
  41618. _uniformBuffers: UniformBuffer[];
  41619. /**
  41620. * Gets a boolean indicating that the engine supports uniform buffers
  41621. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  41622. */
  41623. get supportsUniformBuffers(): boolean;
  41624. /** @hidden */
  41625. _gl: WebGLRenderingContext;
  41626. /** @hidden */
  41627. _webGLVersion: number;
  41628. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  41629. protected _windowIsBackground: boolean;
  41630. protected _creationOptions: EngineOptions;
  41631. protected _highPrecisionShadersAllowed: boolean;
  41632. /** @hidden */
  41633. get _shouldUseHighPrecisionShader(): boolean;
  41634. /**
  41635. * Gets a boolean indicating that only power of 2 textures are supported
  41636. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  41637. */
  41638. get needPOTTextures(): boolean;
  41639. /** @hidden */
  41640. _badOS: boolean;
  41641. /** @hidden */
  41642. _badDesktopOS: boolean;
  41643. protected _hardwareScalingLevel: number;
  41644. /** @hidden */
  41645. _caps: EngineCapabilities;
  41646. /** @hidden */
  41647. _features: EngineFeatures;
  41648. protected _isStencilEnable: boolean;
  41649. private _glVersion;
  41650. private _glRenderer;
  41651. private _glVendor;
  41652. /** @hidden */
  41653. _videoTextureSupported: boolean;
  41654. protected _renderingQueueLaunched: boolean;
  41655. protected _activeRenderLoops: (() => void)[];
  41656. /**
  41657. * Observable signaled when a context lost event is raised
  41658. */
  41659. onContextLostObservable: Observable<ThinEngine>;
  41660. /**
  41661. * Observable signaled when a context restored event is raised
  41662. */
  41663. onContextRestoredObservable: Observable<ThinEngine>;
  41664. private _onContextLost;
  41665. private _onContextRestored;
  41666. protected _contextWasLost: boolean;
  41667. /** @hidden */
  41668. _doNotHandleContextLost: boolean;
  41669. /**
  41670. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  41671. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  41672. */
  41673. get doNotHandleContextLost(): boolean;
  41674. set doNotHandleContextLost(value: boolean);
  41675. /**
  41676. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  41677. */
  41678. disableVertexArrayObjects: boolean;
  41679. /** @hidden */
  41680. protected _colorWrite: boolean;
  41681. /** @hidden */
  41682. protected _colorWriteChanged: boolean;
  41683. /** @hidden */
  41684. protected _depthCullingState: DepthCullingState;
  41685. /** @hidden */
  41686. protected _stencilState: StencilState;
  41687. /** @hidden */
  41688. _alphaState: AlphaState;
  41689. /** @hidden */
  41690. _alphaMode: number;
  41691. /** @hidden */
  41692. _alphaEquation: number;
  41693. /** @hidden */
  41694. _internalTexturesCache: InternalTexture[];
  41695. /** @hidden */
  41696. protected _activeChannel: number;
  41697. private _currentTextureChannel;
  41698. /** @hidden */
  41699. protected _boundTexturesCache: {
  41700. [key: string]: Nullable<InternalTexture>;
  41701. };
  41702. /** @hidden */
  41703. protected _currentEffect: Nullable<Effect>;
  41704. /** @hidden */
  41705. protected _currentProgram: Nullable<WebGLProgram>;
  41706. protected _compiledEffects: {
  41707. [key: string]: Effect;
  41708. };
  41709. private _vertexAttribArraysEnabled;
  41710. /** @hidden */
  41711. protected _cachedViewport: Nullable<IViewportLike>;
  41712. private _cachedVertexArrayObject;
  41713. /** @hidden */
  41714. protected _cachedVertexBuffers: any;
  41715. /** @hidden */
  41716. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  41717. /** @hidden */
  41718. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  41719. /** @hidden */
  41720. _currentRenderTarget: Nullable<InternalTexture>;
  41721. private _uintIndicesCurrentlySet;
  41722. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  41723. /** @hidden */
  41724. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  41725. /** @hidden */
  41726. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  41727. private _currentBufferPointers;
  41728. private _currentInstanceLocations;
  41729. private _currentInstanceBuffers;
  41730. private _textureUnits;
  41731. /** @hidden */
  41732. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41733. /** @hidden */
  41734. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41735. /** @hidden */
  41736. _boundRenderFunction: any;
  41737. private _vaoRecordInProgress;
  41738. private _mustWipeVertexAttributes;
  41739. private _emptyTexture;
  41740. private _emptyCubeTexture;
  41741. private _emptyTexture3D;
  41742. private _emptyTexture2DArray;
  41743. /** @hidden */
  41744. _frameHandler: number;
  41745. private _nextFreeTextureSlots;
  41746. private _maxSimultaneousTextures;
  41747. private _activeRequests;
  41748. /** @hidden */
  41749. _transformTextureUrl: Nullable<(url: string) => string>;
  41750. /**
  41751. * Gets information about the current host
  41752. */
  41753. hostInformation: HostInformation;
  41754. protected get _supportsHardwareTextureRescaling(): boolean;
  41755. private _framebufferDimensionsObject;
  41756. /**
  41757. * sets the object from which width and height will be taken from when getting render width and height
  41758. * Will fallback to the gl object
  41759. * @param dimensions the framebuffer width and height that will be used.
  41760. */
  41761. set framebufferDimensionsObject(dimensions: Nullable<{
  41762. framebufferWidth: number;
  41763. framebufferHeight: number;
  41764. }>);
  41765. /**
  41766. * Gets the current viewport
  41767. */
  41768. get currentViewport(): Nullable<IViewportLike>;
  41769. /**
  41770. * Gets the default empty texture
  41771. */
  41772. get emptyTexture(): InternalTexture;
  41773. /**
  41774. * Gets the default empty 3D texture
  41775. */
  41776. get emptyTexture3D(): InternalTexture;
  41777. /**
  41778. * Gets the default empty 2D array texture
  41779. */
  41780. get emptyTexture2DArray(): InternalTexture;
  41781. /**
  41782. * Gets the default empty cube texture
  41783. */
  41784. get emptyCubeTexture(): InternalTexture;
  41785. /**
  41786. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  41787. */
  41788. premultipliedAlpha: boolean;
  41789. /**
  41790. * Observable event triggered before each texture is initialized
  41791. */
  41792. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  41793. /** @hidden */
  41794. protected _isWebGPU: boolean;
  41795. /**
  41796. * Gets a boolean indicating if the engine runs in WebGPU or not.
  41797. */
  41798. get isWebGPU(): boolean;
  41799. /** @hidden */
  41800. protected _shaderPlatformName: string;
  41801. /**
  41802. * Gets the shader platfrom name used by the effects.
  41803. */
  41804. get shaderPlatformName(): string;
  41805. /**
  41806. * Creates a new engine
  41807. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  41808. * @param antialias defines enable antialiasing (default: false)
  41809. * @param options defines further options to be sent to the getContext() function
  41810. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41811. */
  41812. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41813. /**
  41814. * @hidden
  41815. */
  41816. _debugPushGroup(groupName: string, targetObject?: number): void;
  41817. /**
  41818. * @hidden
  41819. */
  41820. _debugPopGroup(targetObject?: number): void;
  41821. /**
  41822. * @hidden
  41823. */
  41824. _debugInsertMarker(text: string, targetObject?: number): void;
  41825. /**
  41826. * Shared initialization across engines types.
  41827. * @param canvas The canvas associated with this instance of the engine.
  41828. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  41829. * @param audioEngine Defines if an audio engine should be created by default
  41830. */
  41831. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  41832. /**
  41833. * Gets a shader processor implementation fitting with the current engine type.
  41834. * @returns The shader processor implementation.
  41835. */
  41836. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  41837. /** @hidden */
  41838. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  41839. private _rebuildInternalTextures;
  41840. private _rebuildEffects;
  41841. /**
  41842. * Gets a boolean indicating if all created effects are ready
  41843. * @returns true if all effects are ready
  41844. */
  41845. areAllEffectsReady(): boolean;
  41846. protected _rebuildBuffers(): void;
  41847. protected _initGLContext(): void;
  41848. protected _initFeatures(): void;
  41849. /**
  41850. * Gets version of the current webGL context
  41851. * Keep it for back compat - use version instead
  41852. */
  41853. get webGLVersion(): number;
  41854. /**
  41855. * Gets a string identifying the name of the class
  41856. * @returns "Engine" string
  41857. */
  41858. getClassName(): string;
  41859. /**
  41860. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  41861. */
  41862. get isStencilEnable(): boolean;
  41863. /** @hidden */
  41864. _prepareWorkingCanvas(): void;
  41865. /**
  41866. * Reset the texture cache to empty state
  41867. */
  41868. resetTextureCache(): void;
  41869. /**
  41870. * Gets an object containing information about the current webGL context
  41871. * @returns an object containing the vender, the renderer and the version of the current webGL context
  41872. */
  41873. getGlInfo(): {
  41874. vendor: string;
  41875. renderer: string;
  41876. version: string;
  41877. };
  41878. /**
  41879. * Defines the hardware scaling level.
  41880. * By default the hardware scaling level is computed from the window device ratio.
  41881. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  41882. * @param level defines the level to use
  41883. */
  41884. setHardwareScalingLevel(level: number): void;
  41885. /**
  41886. * Gets the current hardware scaling level.
  41887. * By default the hardware scaling level is computed from the window device ratio.
  41888. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  41889. * @returns a number indicating the current hardware scaling level
  41890. */
  41891. getHardwareScalingLevel(): number;
  41892. /**
  41893. * Gets the list of loaded textures
  41894. * @returns an array containing all loaded textures
  41895. */
  41896. getLoadedTexturesCache(): InternalTexture[];
  41897. /**
  41898. * Gets the object containing all engine capabilities
  41899. * @returns the EngineCapabilities object
  41900. */
  41901. getCaps(): EngineCapabilities;
  41902. /**
  41903. * stop executing a render loop function and remove it from the execution array
  41904. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  41905. */
  41906. stopRenderLoop(renderFunction?: () => void): void;
  41907. /** @hidden */
  41908. _renderLoop(): void;
  41909. /**
  41910. * Gets the HTML canvas attached with the current webGL context
  41911. * @returns a HTML canvas
  41912. */
  41913. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  41914. /**
  41915. * Gets host window
  41916. * @returns the host window object
  41917. */
  41918. getHostWindow(): Nullable<Window>;
  41919. /**
  41920. * Gets the current render width
  41921. * @param useScreen defines if screen size must be used (or the current render target if any)
  41922. * @returns a number defining the current render width
  41923. */
  41924. getRenderWidth(useScreen?: boolean): number;
  41925. /**
  41926. * Gets the current render height
  41927. * @param useScreen defines if screen size must be used (or the current render target if any)
  41928. * @returns a number defining the current render height
  41929. */
  41930. getRenderHeight(useScreen?: boolean): number;
  41931. /**
  41932. * Can be used to override the current requestAnimationFrame requester.
  41933. * @hidden
  41934. */
  41935. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  41936. /**
  41937. * Register and execute a render loop. The engine can have more than one render function
  41938. * @param renderFunction defines the function to continuously execute
  41939. */
  41940. runRenderLoop(renderFunction: () => void): void;
  41941. /**
  41942. * Clear the current render buffer or the current render target (if any is set up)
  41943. * @param color defines the color to use
  41944. * @param backBuffer defines if the back buffer must be cleared
  41945. * @param depth defines if the depth buffer must be cleared
  41946. * @param stencil defines if the stencil buffer must be cleared
  41947. */
  41948. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41949. protected _viewportCached: {
  41950. x: number;
  41951. y: number;
  41952. z: number;
  41953. w: number;
  41954. };
  41955. /** @hidden */
  41956. _viewport(x: number, y: number, width: number, height: number): void;
  41957. /**
  41958. * Set the WebGL's viewport
  41959. * @param viewport defines the viewport element to be used
  41960. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  41961. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  41962. */
  41963. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  41964. /**
  41965. * Begin a new frame
  41966. */
  41967. beginFrame(): void;
  41968. /**
  41969. * Enf the current frame
  41970. */
  41971. endFrame(): void;
  41972. /**
  41973. * Resize the view according to the canvas' size
  41974. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41975. */
  41976. resize(forceSetSize?: boolean): void;
  41977. /**
  41978. * Force a specific size of the canvas
  41979. * @param width defines the new canvas' width
  41980. * @param height defines the new canvas' height
  41981. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41982. * @returns true if the size was changed
  41983. */
  41984. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  41985. /**
  41986. * Binds the frame buffer to the specified texture.
  41987. * @param texture The texture to render to or null for the default canvas
  41988. * @param faceIndex The face of the texture to render to in case of cube texture
  41989. * @param requiredWidth The width of the target to render to
  41990. * @param requiredHeight The height of the target to render to
  41991. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  41992. * @param lodLevel defines the lod level to bind to the frame buffer
  41993. * @param layer defines the 2d array index to bind to frame buffer to
  41994. */
  41995. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  41996. /** @hidden */
  41997. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  41998. /**
  41999. * Unbind the current render target texture from the webGL context
  42000. * @param texture defines the render target texture to unbind
  42001. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42002. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42003. */
  42004. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42005. /**
  42006. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  42007. */
  42008. flushFramebuffer(): void;
  42009. /**
  42010. * Unbind the current render target and bind the default framebuffer
  42011. */
  42012. restoreDefaultFramebuffer(): void;
  42013. /** @hidden */
  42014. protected _resetVertexBufferBinding(): void;
  42015. /**
  42016. * Creates a vertex buffer
  42017. * @param data the data for the vertex buffer
  42018. * @returns the new WebGL static buffer
  42019. */
  42020. createVertexBuffer(data: DataArray): DataBuffer;
  42021. private _createVertexBuffer;
  42022. /**
  42023. * Creates a dynamic vertex buffer
  42024. * @param data the data for the dynamic vertex buffer
  42025. * @returns the new WebGL dynamic buffer
  42026. */
  42027. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  42028. protected _resetIndexBufferBinding(): void;
  42029. /**
  42030. * Creates a new index buffer
  42031. * @param indices defines the content of the index buffer
  42032. * @param updatable defines if the index buffer must be updatable
  42033. * @returns a new webGL buffer
  42034. */
  42035. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  42036. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  42037. /**
  42038. * Bind a webGL buffer to the webGL context
  42039. * @param buffer defines the buffer to bind
  42040. */
  42041. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  42042. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  42043. private bindBuffer;
  42044. /**
  42045. * update the bound buffer with the given data
  42046. * @param data defines the data to update
  42047. */
  42048. updateArrayBuffer(data: Float32Array): void;
  42049. private _vertexAttribPointer;
  42050. /** @hidden */
  42051. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  42052. private _bindVertexBuffersAttributes;
  42053. /**
  42054. * Records a vertex array object
  42055. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  42056. * @param vertexBuffers defines the list of vertex buffers to store
  42057. * @param indexBuffer defines the index buffer to store
  42058. * @param effect defines the effect to store
  42059. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  42060. * @returns the new vertex array object
  42061. */
  42062. recordVertexArrayObject(vertexBuffers: {
  42063. [key: string]: VertexBuffer;
  42064. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  42065. [kind: string]: Nullable<VertexBuffer>;
  42066. }): WebGLVertexArrayObject;
  42067. /**
  42068. * Bind a specific vertex array object
  42069. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  42070. * @param vertexArrayObject defines the vertex array object to bind
  42071. * @param indexBuffer defines the index buffer to bind
  42072. */
  42073. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  42074. /**
  42075. * Bind webGl buffers directly to the webGL context
  42076. * @param vertexBuffer defines the vertex buffer to bind
  42077. * @param indexBuffer defines the index buffer to bind
  42078. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  42079. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  42080. * @param effect defines the effect associated with the vertex buffer
  42081. */
  42082. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  42083. private _unbindVertexArrayObject;
  42084. /**
  42085. * Bind a list of vertex buffers to the webGL context
  42086. * @param vertexBuffers defines the list of vertex buffers to bind
  42087. * @param indexBuffer defines the index buffer to bind
  42088. * @param effect defines the effect associated with the vertex buffers
  42089. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  42090. */
  42091. bindBuffers(vertexBuffers: {
  42092. [key: string]: Nullable<VertexBuffer>;
  42093. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  42094. [kind: string]: Nullable<VertexBuffer>;
  42095. }): void;
  42096. /**
  42097. * Unbind all instance attributes
  42098. */
  42099. unbindInstanceAttributes(): void;
  42100. /**
  42101. * Release and free the memory of a vertex array object
  42102. * @param vao defines the vertex array object to delete
  42103. */
  42104. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  42105. /** @hidden */
  42106. _releaseBuffer(buffer: DataBuffer): boolean;
  42107. protected _deleteBuffer(buffer: DataBuffer): void;
  42108. /**
  42109. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  42110. * @param instancesBuffer defines the webGL buffer to update and bind
  42111. * @param data defines the data to store in the buffer
  42112. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  42113. */
  42114. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  42115. /**
  42116. * Bind the content of a webGL buffer used with instantiation
  42117. * @param instancesBuffer defines the webGL buffer to bind
  42118. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  42119. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  42120. */
  42121. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  42122. /**
  42123. * Disable the instance attribute corresponding to the name in parameter
  42124. * @param name defines the name of the attribute to disable
  42125. */
  42126. disableInstanceAttributeByName(name: string): void;
  42127. /**
  42128. * Disable the instance attribute corresponding to the location in parameter
  42129. * @param attributeLocation defines the attribute location of the attribute to disable
  42130. */
  42131. disableInstanceAttribute(attributeLocation: number): void;
  42132. /**
  42133. * Disable the attribute corresponding to the location in parameter
  42134. * @param attributeLocation defines the attribute location of the attribute to disable
  42135. */
  42136. disableAttributeByIndex(attributeLocation: number): void;
  42137. /**
  42138. * Send a draw order
  42139. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42140. * @param indexStart defines the starting index
  42141. * @param indexCount defines the number of index to draw
  42142. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42143. */
  42144. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42145. /**
  42146. * Draw a list of points
  42147. * @param verticesStart defines the index of first vertex to draw
  42148. * @param verticesCount defines the count of vertices to draw
  42149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42150. */
  42151. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42152. /**
  42153. * Draw a list of unindexed primitives
  42154. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42155. * @param verticesStart defines the index of first vertex to draw
  42156. * @param verticesCount defines the count of vertices to draw
  42157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42158. */
  42159. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42160. /**
  42161. * Draw a list of indexed primitives
  42162. * @param fillMode defines the primitive to use
  42163. * @param indexStart defines the starting index
  42164. * @param indexCount defines the number of index to draw
  42165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42166. */
  42167. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42168. /**
  42169. * Draw a list of unindexed primitives
  42170. * @param fillMode defines the primitive to use
  42171. * @param verticesStart defines the index of first vertex to draw
  42172. * @param verticesCount defines the count of vertices to draw
  42173. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42174. */
  42175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42176. private _drawMode;
  42177. /** @hidden */
  42178. protected _reportDrawCall(): void;
  42179. /** @hidden */
  42180. _releaseEffect(effect: Effect): void;
  42181. /** @hidden */
  42182. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42183. /**
  42184. * Create a new effect (used to store vertex/fragment shaders)
  42185. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  42186. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  42187. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  42188. * @param samplers defines an array of string used to represent textures
  42189. * @param defines defines the string containing the defines to use to compile the shaders
  42190. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  42191. * @param onCompiled defines a function to call when the effect creation is successful
  42192. * @param onError defines a function to call when the effect creation has failed
  42193. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  42194. * @returns the new Effect
  42195. */
  42196. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  42197. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  42198. private _compileShader;
  42199. private _compileRawShader;
  42200. /** @hidden */
  42201. _getShaderSource(shader: WebGLShader): Nullable<string>;
  42202. /**
  42203. * Directly creates a webGL program
  42204. * @param pipelineContext defines the pipeline context to attach to
  42205. * @param vertexCode defines the vertex shader code to use
  42206. * @param fragmentCode defines the fragment shader code to use
  42207. * @param context defines the webGL context to use (if not set, the current one will be used)
  42208. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42209. * @returns the new webGL program
  42210. */
  42211. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42212. /**
  42213. * Creates a webGL program
  42214. * @param pipelineContext defines the pipeline context to attach to
  42215. * @param vertexCode defines the vertex shader code to use
  42216. * @param fragmentCode defines the fragment shader code to use
  42217. * @param defines defines the string containing the defines to use to compile the shaders
  42218. * @param context defines the webGL context to use (if not set, the current one will be used)
  42219. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42220. * @returns the new webGL program
  42221. */
  42222. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42223. /**
  42224. * Creates a new pipeline context
  42225. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  42226. * @returns the new pipeline
  42227. */
  42228. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  42229. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42230. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  42231. /** @hidden */
  42232. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  42233. /** @hidden */
  42234. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  42235. /** @hidden */
  42236. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  42237. /**
  42238. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42239. * @param pipelineContext defines the pipeline context to use
  42240. * @param uniformsNames defines the list of uniform names
  42241. * @returns an array of webGL uniform locations
  42242. */
  42243. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42244. /**
  42245. * Gets the list of active attributes for a given webGL program
  42246. * @param pipelineContext defines the pipeline context to use
  42247. * @param attributesNames defines the list of attribute names to get
  42248. * @returns an array of indices indicating the offset of each attribute
  42249. */
  42250. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42251. /**
  42252. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  42253. * @param effect defines the effect to activate
  42254. */
  42255. enableEffect(effect: Nullable<Effect>): void;
  42256. /**
  42257. * Set the value of an uniform to a number (int)
  42258. * @param uniform defines the webGL uniform location where to store the value
  42259. * @param value defines the int number to store
  42260. * @returns true if the value was set
  42261. */
  42262. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42263. /**
  42264. * Set the value of an uniform to a int2
  42265. * @param uniform defines the webGL uniform location where to store the value
  42266. * @param x defines the 1st component of the value
  42267. * @param y defines the 2nd component of the value
  42268. * @returns true if the value was set
  42269. */
  42270. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42271. /**
  42272. * Set the value of an uniform to a int3
  42273. * @param uniform defines the webGL uniform location where to store the value
  42274. * @param x defines the 1st component of the value
  42275. * @param y defines the 2nd component of the value
  42276. * @param z defines the 3rd component of the value
  42277. * @returns true if the value was set
  42278. */
  42279. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42280. /**
  42281. * Set the value of an uniform to a int4
  42282. * @param uniform defines the webGL uniform location where to store the value
  42283. * @param x defines the 1st component of the value
  42284. * @param y defines the 2nd component of the value
  42285. * @param z defines the 3rd component of the value
  42286. * @param w defines the 4th component of the value
  42287. * @returns true if the value was set
  42288. */
  42289. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42290. /**
  42291. * Set the value of an uniform to an array of int32
  42292. * @param uniform defines the webGL uniform location where to store the value
  42293. * @param array defines the array of int32 to store
  42294. * @returns true if the value was set
  42295. */
  42296. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42297. /**
  42298. * Set the value of an uniform to an array of int32 (stored as vec2)
  42299. * @param uniform defines the webGL uniform location where to store the value
  42300. * @param array defines the array of int32 to store
  42301. * @returns true if the value was set
  42302. */
  42303. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42304. /**
  42305. * Set the value of an uniform to an array of int32 (stored as vec3)
  42306. * @param uniform defines the webGL uniform location where to store the value
  42307. * @param array defines the array of int32 to store
  42308. * @returns true if the value was set
  42309. */
  42310. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42311. /**
  42312. * Set the value of an uniform to an array of int32 (stored as vec4)
  42313. * @param uniform defines the webGL uniform location where to store the value
  42314. * @param array defines the array of int32 to store
  42315. * @returns true if the value was set
  42316. */
  42317. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42318. /**
  42319. * Set the value of an uniform to an array of number
  42320. * @param uniform defines the webGL uniform location where to store the value
  42321. * @param array defines the array of number to store
  42322. * @returns true if the value was set
  42323. */
  42324. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42325. /**
  42326. * Set the value of an uniform to an array of number (stored as vec2)
  42327. * @param uniform defines the webGL uniform location where to store the value
  42328. * @param array defines the array of number to store
  42329. * @returns true if the value was set
  42330. */
  42331. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42332. /**
  42333. * Set the value of an uniform to an array of number (stored as vec3)
  42334. * @param uniform defines the webGL uniform location where to store the value
  42335. * @param array defines the array of number to store
  42336. * @returns true if the value was set
  42337. */
  42338. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42339. /**
  42340. * Set the value of an uniform to an array of number (stored as vec4)
  42341. * @param uniform defines the webGL uniform location where to store the value
  42342. * @param array defines the array of number to store
  42343. * @returns true if the value was set
  42344. */
  42345. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42346. /**
  42347. * Set the value of an uniform to an array of float32 (stored as matrices)
  42348. * @param uniform defines the webGL uniform location where to store the value
  42349. * @param matrices defines the array of float32 to store
  42350. * @returns true if the value was set
  42351. */
  42352. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  42353. /**
  42354. * Set the value of an uniform to a matrix (3x3)
  42355. * @param uniform defines the webGL uniform location where to store the value
  42356. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  42357. * @returns true if the value was set
  42358. */
  42359. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42360. /**
  42361. * Set the value of an uniform to a matrix (2x2)
  42362. * @param uniform defines the webGL uniform location where to store the value
  42363. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  42364. * @returns true if the value was set
  42365. */
  42366. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42367. /**
  42368. * Set the value of an uniform to a number (float)
  42369. * @param uniform defines the webGL uniform location where to store the value
  42370. * @param value defines the float number to store
  42371. * @returns true if the value was transfered
  42372. */
  42373. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42374. /**
  42375. * Set the value of an uniform to a vec2
  42376. * @param uniform defines the webGL uniform location where to store the value
  42377. * @param x defines the 1st component of the value
  42378. * @param y defines the 2nd component of the value
  42379. * @returns true if the value was set
  42380. */
  42381. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42382. /**
  42383. * Set the value of an uniform to a vec3
  42384. * @param uniform defines the webGL uniform location where to store the value
  42385. * @param x defines the 1st component of the value
  42386. * @param y defines the 2nd component of the value
  42387. * @param z defines the 3rd component of the value
  42388. * @returns true if the value was set
  42389. */
  42390. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42391. /**
  42392. * Set the value of an uniform to a vec4
  42393. * @param uniform defines the webGL uniform location where to store the value
  42394. * @param x defines the 1st component of the value
  42395. * @param y defines the 2nd component of the value
  42396. * @param z defines the 3rd component of the value
  42397. * @param w defines the 4th component of the value
  42398. * @returns true if the value was set
  42399. */
  42400. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42401. /**
  42402. * Apply all cached states (depth, culling, stencil and alpha)
  42403. */
  42404. applyStates(): void;
  42405. /**
  42406. * Enable or disable color writing
  42407. * @param enable defines the state to set
  42408. */
  42409. setColorWrite(enable: boolean): void;
  42410. /**
  42411. * Gets a boolean indicating if color writing is enabled
  42412. * @returns the current color writing state
  42413. */
  42414. getColorWrite(): boolean;
  42415. /**
  42416. * Gets the depth culling state manager
  42417. */
  42418. get depthCullingState(): DepthCullingState;
  42419. /**
  42420. * Gets the alpha state manager
  42421. */
  42422. get alphaState(): AlphaState;
  42423. /**
  42424. * Gets the stencil state manager
  42425. */
  42426. get stencilState(): StencilState;
  42427. /**
  42428. * Clears the list of texture accessible through engine.
  42429. * This can help preventing texture load conflict due to name collision.
  42430. */
  42431. clearInternalTexturesCache(): void;
  42432. /**
  42433. * Force the entire cache to be cleared
  42434. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  42435. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  42436. */
  42437. wipeCaches(bruteForce?: boolean): void;
  42438. /** @hidden */
  42439. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  42440. min: number;
  42441. mag: number;
  42442. };
  42443. /** @hidden */
  42444. protected _createTexture(): WebGLTexture;
  42445. /** @hidden */
  42446. _createHardwareTexture(): HardwareTextureWrapper;
  42447. protected _createTextureBase(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode: number | undefined, onLoad: (() => void) | null | undefined, onError: ((message: string, exception: any) => void) | null | undefined, prepareTexture: (texture: InternalTexture, extension: string, scene: Nullable<ISceneLike>, img: HTMLImageElement | ImageBitmap | {
  42448. width: number;
  42449. height: number;
  42450. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42451. width: number;
  42452. height: number;
  42453. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42454. width: number;
  42455. height: number;
  42456. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  42457. /**
  42458. * Usually called from Texture.ts.
  42459. * Passed information to create a WebGLTexture
  42460. * @param url defines a value which contains one of the following:
  42461. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  42462. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  42463. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  42464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  42465. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  42466. * @param scene needed for loading to the correct scene
  42467. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  42468. * @param onLoad optional callback to be called upon successful completion
  42469. * @param onError optional callback to be called upon failure
  42470. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  42471. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  42472. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  42473. * @param forcedExtension defines the extension to use to pick the right loader
  42474. * @param mimeType defines an optional mime type
  42475. * @param loaderOptions options to be passed to the loader
  42476. * @returns a InternalTexture for assignment back into BABYLON.Texture
  42477. */
  42478. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  42479. /**
  42480. * Loads an image as an HTMLImageElement.
  42481. * @param input url string, ArrayBuffer, or Blob to load
  42482. * @param onLoad callback called when the image successfully loads
  42483. * @param onError callback called when the image fails to load
  42484. * @param offlineProvider offline provider for caching
  42485. * @param mimeType optional mime type
  42486. * @returns the HTMLImageElement of the loaded image
  42487. * @hidden
  42488. */
  42489. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42490. /**
  42491. * @hidden
  42492. */
  42493. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42494. private _unpackFlipYCached;
  42495. /**
  42496. * In case you are sharing the context with other applications, it might
  42497. * be interested to not cache the unpack flip y state to ensure a consistent
  42498. * value would be set.
  42499. */
  42500. enableUnpackFlipYCached: boolean;
  42501. /** @hidden */
  42502. _unpackFlipY(value: boolean): void;
  42503. /** @hidden */
  42504. _getUnpackAlignement(): number;
  42505. private _getTextureTarget;
  42506. /**
  42507. * Update the sampling mode of a given texture
  42508. * @param samplingMode defines the required sampling mode
  42509. * @param texture defines the texture to update
  42510. * @param generateMipMaps defines whether to generate mipmaps for the texture
  42511. */
  42512. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  42513. /**
  42514. * Update the dimensions of a texture
  42515. * @param texture texture to update
  42516. * @param width new width of the texture
  42517. * @param height new height of the texture
  42518. * @param depth new depth of the texture
  42519. */
  42520. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  42521. /**
  42522. * Update the sampling mode of a given texture
  42523. * @param texture defines the texture to update
  42524. * @param wrapU defines the texture wrap mode of the u coordinates
  42525. * @param wrapV defines the texture wrap mode of the v coordinates
  42526. * @param wrapR defines the texture wrap mode of the r coordinates
  42527. */
  42528. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  42529. /** @hidden */
  42530. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  42531. width: number;
  42532. height: number;
  42533. layers?: number;
  42534. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  42535. /** @hidden */
  42536. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42537. /** @hidden */
  42538. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  42539. /**
  42540. * Update a portion of an internal texture
  42541. * @param texture defines the texture to update
  42542. * @param imageData defines the data to store into the texture
  42543. * @param xOffset defines the x coordinates of the update rectangle
  42544. * @param yOffset defines the y coordinates of the update rectangle
  42545. * @param width defines the width of the update rectangle
  42546. * @param height defines the height of the update rectangle
  42547. * @param faceIndex defines the face index if texture is a cube (0 by default)
  42548. * @param lod defines the lod level to update (0 by default)
  42549. */
  42550. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  42551. /** @hidden */
  42552. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42553. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  42554. private _prepareWebGLTexture;
  42555. /** @hidden */
  42556. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  42557. private _getDepthStencilBuffer;
  42558. /** @hidden */
  42559. _releaseFramebufferObjects(texture: InternalTexture): void;
  42560. /** @hidden */
  42561. _releaseTexture(texture: InternalTexture): void;
  42562. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  42563. protected _setProgram(program: WebGLProgram): void;
  42564. protected _boundUniforms: {
  42565. [key: number]: WebGLUniformLocation;
  42566. };
  42567. /**
  42568. * Binds an effect to the webGL context
  42569. * @param effect defines the effect to bind
  42570. */
  42571. bindSamplers(effect: Effect): void;
  42572. private _activateCurrentTexture;
  42573. /** @hidden */
  42574. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  42575. /** @hidden */
  42576. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  42577. /**
  42578. * Unbind all textures from the webGL context
  42579. */
  42580. unbindAllTextures(): void;
  42581. /**
  42582. * Sets a texture to the according uniform.
  42583. * @param channel The texture channel
  42584. * @param uniform The uniform to set
  42585. * @param texture The texture to apply
  42586. * @param name The name of the uniform in the effect
  42587. */
  42588. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  42589. private _bindSamplerUniformToChannel;
  42590. private _getTextureWrapMode;
  42591. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  42592. /**
  42593. * Sets an array of texture to the webGL context
  42594. * @param channel defines the channel where the texture array must be set
  42595. * @param uniform defines the associated uniform location
  42596. * @param textures defines the array of textures to bind
  42597. * @param name name of the channel
  42598. */
  42599. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  42600. /** @hidden */
  42601. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  42602. private _setTextureParameterFloat;
  42603. private _setTextureParameterInteger;
  42604. /**
  42605. * Unbind all vertex attributes from the webGL context
  42606. */
  42607. unbindAllAttributes(): void;
  42608. /**
  42609. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  42610. */
  42611. releaseEffects(): void;
  42612. /**
  42613. * Dispose and release all associated resources
  42614. */
  42615. dispose(): void;
  42616. /**
  42617. * Attach a new callback raised when context lost event is fired
  42618. * @param callback defines the callback to call
  42619. */
  42620. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42621. /**
  42622. * Attach a new callback raised when context restored event is fired
  42623. * @param callback defines the callback to call
  42624. */
  42625. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42626. /**
  42627. * Get the current error code of the webGL context
  42628. * @returns the error code
  42629. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42630. */
  42631. getError(): number;
  42632. private _canRenderToFloatFramebuffer;
  42633. private _canRenderToHalfFloatFramebuffer;
  42634. private _canRenderToFramebuffer;
  42635. /** @hidden */
  42636. _getWebGLTextureType(type: number): number;
  42637. /** @hidden */
  42638. _getInternalFormat(format: number): number;
  42639. /** @hidden */
  42640. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  42641. /** @hidden */
  42642. _getRGBAMultiSampleBufferFormat(type: number): number;
  42643. /** @hidden */
  42644. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  42645. /**
  42646. * Loads a file from a url
  42647. * @param url url to load
  42648. * @param onSuccess callback called when the file successfully loads
  42649. * @param onProgress callback called while file is loading (if the server supports this mode)
  42650. * @param offlineProvider defines the offline provider for caching
  42651. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42652. * @param onError callback called when the file fails to load
  42653. * @returns a file request object
  42654. * @hidden
  42655. */
  42656. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  42657. /**
  42658. * Reads pixels from the current frame buffer. Please note that this function can be slow
  42659. * @param x defines the x coordinate of the rectangle where pixels must be read
  42660. * @param y defines the y coordinate of the rectangle where pixels must be read
  42661. * @param width defines the width of the rectangle where pixels must be read
  42662. * @param height defines the height of the rectangle where pixels must be read
  42663. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  42664. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  42665. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  42666. */
  42667. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42668. private static _IsSupported;
  42669. private static _HasMajorPerformanceCaveat;
  42670. /**
  42671. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42672. */
  42673. static get IsSupported(): boolean;
  42674. /**
  42675. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42676. * @returns true if the engine can be created
  42677. * @ignorenaming
  42678. */
  42679. static isSupported(): boolean;
  42680. /**
  42681. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  42682. */
  42683. static get HasMajorPerformanceCaveat(): boolean;
  42684. /**
  42685. * Find the next highest power of two.
  42686. * @param x Number to start search from.
  42687. * @return Next highest power of two.
  42688. */
  42689. static CeilingPOT(x: number): number;
  42690. /**
  42691. * Find the next lowest power of two.
  42692. * @param x Number to start search from.
  42693. * @return Next lowest power of two.
  42694. */
  42695. static FloorPOT(x: number): number;
  42696. /**
  42697. * Find the nearest power of two.
  42698. * @param x Number to start search from.
  42699. * @return Next nearest power of two.
  42700. */
  42701. static NearestPOT(x: number): number;
  42702. /**
  42703. * Get the closest exponent of two
  42704. * @param value defines the value to approximate
  42705. * @param max defines the maximum value to return
  42706. * @param mode defines how to define the closest value
  42707. * @returns closest exponent of two of the given value
  42708. */
  42709. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  42710. /**
  42711. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  42712. * @param func - the function to be called
  42713. * @param requester - the object that will request the next frame. Falls back to window.
  42714. * @returns frame number
  42715. */
  42716. static QueueNewFrame(func: () => void, requester?: any): number;
  42717. /**
  42718. * Gets host document
  42719. * @returns the host document object
  42720. */
  42721. getHostDocument(): Nullable<Document>;
  42722. }
  42723. }
  42724. declare module "babylonjs/Materials/Textures/internalTexture" {
  42725. import { Observable } from "babylonjs/Misc/observable";
  42726. import { Nullable, int } from "babylonjs/types";
  42727. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  42728. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  42729. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42730. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  42731. /**
  42732. * Defines the source of the internal texture
  42733. */
  42734. export enum InternalTextureSource {
  42735. /**
  42736. * The source of the texture data is unknown
  42737. */
  42738. Unknown = 0,
  42739. /**
  42740. * Texture data comes from an URL
  42741. */
  42742. Url = 1,
  42743. /**
  42744. * Texture data is only used for temporary storage
  42745. */
  42746. Temp = 2,
  42747. /**
  42748. * Texture data comes from raw data (ArrayBuffer)
  42749. */
  42750. Raw = 3,
  42751. /**
  42752. * Texture content is dynamic (video or dynamic texture)
  42753. */
  42754. Dynamic = 4,
  42755. /**
  42756. * Texture content is generated by rendering to it
  42757. */
  42758. RenderTarget = 5,
  42759. /**
  42760. * Texture content is part of a multi render target process
  42761. */
  42762. MultiRenderTarget = 6,
  42763. /**
  42764. * Texture data comes from a cube data file
  42765. */
  42766. Cube = 7,
  42767. /**
  42768. * Texture data comes from a raw cube data
  42769. */
  42770. CubeRaw = 8,
  42771. /**
  42772. * Texture data come from a prefiltered cube data file
  42773. */
  42774. CubePrefiltered = 9,
  42775. /**
  42776. * Texture content is raw 3D data
  42777. */
  42778. Raw3D = 10,
  42779. /**
  42780. * Texture content is raw 2D array data
  42781. */
  42782. Raw2DArray = 11,
  42783. /**
  42784. * Texture content is a depth texture
  42785. */
  42786. Depth = 12,
  42787. /**
  42788. * Texture data comes from a raw cube data encoded with RGBD
  42789. */
  42790. CubeRawRGBD = 13
  42791. }
  42792. /**
  42793. * Class used to store data associated with WebGL texture data for the engine
  42794. * This class should not be used directly
  42795. */
  42796. export class InternalTexture {
  42797. /** @hidden */
  42798. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  42799. /**
  42800. * Defines if the texture is ready
  42801. */
  42802. isReady: boolean;
  42803. /**
  42804. * Defines if the texture is a cube texture
  42805. */
  42806. isCube: boolean;
  42807. /**
  42808. * Defines if the texture contains 3D data
  42809. */
  42810. is3D: boolean;
  42811. /**
  42812. * Defines if the texture contains 2D array data
  42813. */
  42814. is2DArray: boolean;
  42815. /**
  42816. * Defines if the texture contains multiview data
  42817. */
  42818. isMultiview: boolean;
  42819. /**
  42820. * Gets the URL used to load this texture
  42821. */
  42822. url: string;
  42823. /** @hidden */
  42824. _originalUrl: string;
  42825. /**
  42826. * Gets the sampling mode of the texture
  42827. */
  42828. samplingMode: number;
  42829. /**
  42830. * Gets a boolean indicating if the texture needs mipmaps generation
  42831. */
  42832. generateMipMaps: boolean;
  42833. /**
  42834. * Gets the number of samples used by the texture (WebGL2+ only)
  42835. */
  42836. samples: number;
  42837. /**
  42838. * Gets the type of the texture (int, float...)
  42839. */
  42840. type: number;
  42841. /**
  42842. * Gets the format of the texture (RGB, RGBA...)
  42843. */
  42844. format: number;
  42845. /**
  42846. * Observable called when the texture is loaded
  42847. */
  42848. onLoadedObservable: Observable<InternalTexture>;
  42849. /**
  42850. * Gets the width of the texture
  42851. */
  42852. width: number;
  42853. /**
  42854. * Gets the height of the texture
  42855. */
  42856. height: number;
  42857. /**
  42858. * Gets the depth of the texture
  42859. */
  42860. depth: number;
  42861. /**
  42862. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  42863. */
  42864. baseWidth: number;
  42865. /**
  42866. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  42867. */
  42868. baseHeight: number;
  42869. /**
  42870. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  42871. */
  42872. baseDepth: number;
  42873. /**
  42874. * Gets a boolean indicating if the texture is inverted on Y axis
  42875. */
  42876. invertY: boolean;
  42877. /** @hidden */
  42878. _invertVScale: boolean;
  42879. /** @hidden */
  42880. _associatedChannel: number;
  42881. /** @hidden */
  42882. _source: InternalTextureSource;
  42883. /** @hidden */
  42884. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  42885. /** @hidden */
  42886. _bufferView: Nullable<ArrayBufferView>;
  42887. /** @hidden */
  42888. _bufferViewArray: Nullable<ArrayBufferView[]>;
  42889. /** @hidden */
  42890. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  42891. /** @hidden */
  42892. _size: number;
  42893. /** @hidden */
  42894. _extension: string;
  42895. /** @hidden */
  42896. _files: Nullable<string[]>;
  42897. /** @hidden */
  42898. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  42899. /** @hidden */
  42900. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  42901. /** @hidden */
  42902. _framebuffer: Nullable<WebGLFramebuffer>;
  42903. /** @hidden */
  42904. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  42905. /** @hidden */
  42906. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  42907. /** @hidden */
  42908. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  42909. /** @hidden */
  42910. _attachments: Nullable<number[]>;
  42911. /** @hidden */
  42912. _textureArray: Nullable<InternalTexture[]>;
  42913. /** @hidden */
  42914. _cachedCoordinatesMode: Nullable<number>;
  42915. /** @hidden */
  42916. _cachedWrapU: Nullable<number>;
  42917. /** @hidden */
  42918. _cachedWrapV: Nullable<number>;
  42919. /** @hidden */
  42920. _cachedWrapR: Nullable<number>;
  42921. /** @hidden */
  42922. _cachedAnisotropicFilteringLevel: Nullable<number>;
  42923. /** @hidden */
  42924. _isDisabled: boolean;
  42925. /** @hidden */
  42926. _compression: Nullable<string>;
  42927. /** @hidden */
  42928. _generateStencilBuffer: boolean;
  42929. /** @hidden */
  42930. _generateDepthBuffer: boolean;
  42931. /** @hidden */
  42932. _comparisonFunction: number;
  42933. /** @hidden */
  42934. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  42935. /** @hidden */
  42936. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  42937. /** @hidden */
  42938. _sphericalPolynomialComputed: boolean;
  42939. /** @hidden */
  42940. _lodGenerationScale: number;
  42941. /** @hidden */
  42942. _lodGenerationOffset: number;
  42943. /** @hidden */
  42944. _depthStencilTexture: Nullable<InternalTexture>;
  42945. /** @hidden */
  42946. _colorTextureArray: Nullable<WebGLTexture>;
  42947. /** @hidden */
  42948. _depthStencilTextureArray: Nullable<WebGLTexture>;
  42949. /** @hidden */
  42950. _lodTextureHigh: Nullable<BaseTexture>;
  42951. /** @hidden */
  42952. _lodTextureMid: Nullable<BaseTexture>;
  42953. /** @hidden */
  42954. _lodTextureLow: Nullable<BaseTexture>;
  42955. /** @hidden */
  42956. _isRGBD: boolean;
  42957. /** @hidden */
  42958. _linearSpecularLOD: boolean;
  42959. /** @hidden */
  42960. _irradianceTexture: Nullable<BaseTexture>;
  42961. /** @hidden */
  42962. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  42963. /** @hidden */
  42964. _references: number;
  42965. /** @hidden */
  42966. _gammaSpace: Nullable<boolean>;
  42967. private _engine;
  42968. private _uniqueId;
  42969. private static _Counter;
  42970. /** Gets the unique id of the internal texture */
  42971. get uniqueId(): number;
  42972. /**
  42973. * Gets the Engine the texture belongs to.
  42974. * @returns The babylon engine
  42975. */
  42976. getEngine(): ThinEngine;
  42977. /**
  42978. * Gets the data source type of the texture
  42979. */
  42980. get source(): InternalTextureSource;
  42981. /**
  42982. * Creates a new InternalTexture
  42983. * @param engine defines the engine to use
  42984. * @param source defines the type of data that will be used
  42985. * @param delayAllocation if the texture allocation should be delayed (default: false)
  42986. */
  42987. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  42988. /**
  42989. * Increments the number of references (ie. the number of Texture that point to it)
  42990. */
  42991. incrementReferences(): void;
  42992. /**
  42993. * Change the size of the texture (not the size of the content)
  42994. * @param width defines the new width
  42995. * @param height defines the new height
  42996. * @param depth defines the new depth (1 by default)
  42997. */
  42998. updateSize(width: int, height: int, depth?: int): void;
  42999. /** @hidden */
  43000. _rebuild(): void;
  43001. /** @hidden */
  43002. _swapAndDie(target: InternalTexture): void;
  43003. /**
  43004. * Dispose the current allocated resources
  43005. */
  43006. dispose(): void;
  43007. }
  43008. }
  43009. declare module "babylonjs/Loading/loadingScreen" {
  43010. /**
  43011. * Interface used to present a loading screen while loading a scene
  43012. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43013. */
  43014. export interface ILoadingScreen {
  43015. /**
  43016. * Function called to display the loading screen
  43017. */
  43018. displayLoadingUI: () => void;
  43019. /**
  43020. * Function called to hide the loading screen
  43021. */
  43022. hideLoadingUI: () => void;
  43023. /**
  43024. * Gets or sets the color to use for the background
  43025. */
  43026. loadingUIBackgroundColor: string;
  43027. /**
  43028. * Gets or sets the text to display while loading
  43029. */
  43030. loadingUIText: string;
  43031. }
  43032. /**
  43033. * Class used for the default loading screen
  43034. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43035. */
  43036. export class DefaultLoadingScreen implements ILoadingScreen {
  43037. private _renderingCanvas;
  43038. private _loadingText;
  43039. private _loadingDivBackgroundColor;
  43040. private _loadingDiv;
  43041. private _loadingTextDiv;
  43042. /** Gets or sets the logo url to use for the default loading screen */
  43043. static DefaultLogoUrl: string;
  43044. /** Gets or sets the spinner url to use for the default loading screen */
  43045. static DefaultSpinnerUrl: string;
  43046. /**
  43047. * Creates a new default loading screen
  43048. * @param _renderingCanvas defines the canvas used to render the scene
  43049. * @param _loadingText defines the default text to display
  43050. * @param _loadingDivBackgroundColor defines the default background color
  43051. */
  43052. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  43053. /**
  43054. * Function called to display the loading screen
  43055. */
  43056. displayLoadingUI(): void;
  43057. /**
  43058. * Function called to hide the loading screen
  43059. */
  43060. hideLoadingUI(): void;
  43061. /**
  43062. * Gets or sets the text to display while loading
  43063. */
  43064. set loadingUIText(text: string);
  43065. get loadingUIText(): string;
  43066. /**
  43067. * Gets or sets the color to use for the background
  43068. */
  43069. get loadingUIBackgroundColor(): string;
  43070. set loadingUIBackgroundColor(color: string);
  43071. private _resizeLoadingUI;
  43072. }
  43073. }
  43074. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  43075. /**
  43076. * Interface for any object that can request an animation frame
  43077. */
  43078. export interface ICustomAnimationFrameRequester {
  43079. /**
  43080. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  43081. */
  43082. renderFunction?: Function;
  43083. /**
  43084. * Called to request the next frame to render to
  43085. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  43086. */
  43087. requestAnimationFrame: Function;
  43088. /**
  43089. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  43090. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  43091. */
  43092. requestID?: number;
  43093. }
  43094. }
  43095. declare module "babylonjs/Misc/performanceMonitor" {
  43096. /**
  43097. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  43098. */
  43099. export class PerformanceMonitor {
  43100. private _enabled;
  43101. private _rollingFrameTime;
  43102. private _lastFrameTimeMs;
  43103. /**
  43104. * constructor
  43105. * @param frameSampleSize The number of samples required to saturate the sliding window
  43106. */
  43107. constructor(frameSampleSize?: number);
  43108. /**
  43109. * Samples current frame
  43110. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  43111. */
  43112. sampleFrame(timeMs?: number): void;
  43113. /**
  43114. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  43115. */
  43116. get averageFrameTime(): number;
  43117. /**
  43118. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  43119. */
  43120. get averageFrameTimeVariance(): number;
  43121. /**
  43122. * Returns the frame time of the most recent frame
  43123. */
  43124. get instantaneousFrameTime(): number;
  43125. /**
  43126. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  43127. */
  43128. get averageFPS(): number;
  43129. /**
  43130. * Returns the average framerate in frames per second using the most recent frame time
  43131. */
  43132. get instantaneousFPS(): number;
  43133. /**
  43134. * Returns true if enough samples have been taken to completely fill the sliding window
  43135. */
  43136. get isSaturated(): boolean;
  43137. /**
  43138. * Enables contributions to the sliding window sample set
  43139. */
  43140. enable(): void;
  43141. /**
  43142. * Disables contributions to the sliding window sample set
  43143. * Samples will not be interpolated over the disabled period
  43144. */
  43145. disable(): void;
  43146. /**
  43147. * Returns true if sampling is enabled
  43148. */
  43149. get isEnabled(): boolean;
  43150. /**
  43151. * Resets performance monitor
  43152. */
  43153. reset(): void;
  43154. }
  43155. /**
  43156. * RollingAverage
  43157. *
  43158. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  43159. */
  43160. export class RollingAverage {
  43161. /**
  43162. * Current average
  43163. */
  43164. average: number;
  43165. /**
  43166. * Current variance
  43167. */
  43168. variance: number;
  43169. protected _samples: Array<number>;
  43170. protected _sampleCount: number;
  43171. protected _pos: number;
  43172. protected _m2: number;
  43173. /**
  43174. * constructor
  43175. * @param length The number of samples required to saturate the sliding window
  43176. */
  43177. constructor(length: number);
  43178. /**
  43179. * Adds a sample to the sample set
  43180. * @param v The sample value
  43181. */
  43182. add(v: number): void;
  43183. /**
  43184. * Returns previously added values or null if outside of history or outside the sliding window domain
  43185. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  43186. * @return Value previously recorded with add() or null if outside of range
  43187. */
  43188. history(i: number): number;
  43189. /**
  43190. * Returns true if enough samples have been taken to completely fill the sliding window
  43191. * @return true if sample-set saturated
  43192. */
  43193. isSaturated(): boolean;
  43194. /**
  43195. * Resets the rolling average (equivalent to 0 samples taken so far)
  43196. */
  43197. reset(): void;
  43198. /**
  43199. * Wraps a value around the sample range boundaries
  43200. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  43201. * @return Wrapped position in sample range
  43202. */
  43203. protected _wrapPosition(i: number): number;
  43204. }
  43205. }
  43206. declare module "babylonjs/Misc/perfCounter" {
  43207. /**
  43208. * This class is used to track a performance counter which is number based.
  43209. * The user has access to many properties which give statistics of different nature.
  43210. *
  43211. * The implementer can track two kinds of Performance Counter: time and count.
  43212. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  43213. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  43214. */
  43215. export class PerfCounter {
  43216. /**
  43217. * Gets or sets a global boolean to turn on and off all the counters
  43218. */
  43219. static Enabled: boolean;
  43220. /**
  43221. * Returns the smallest value ever
  43222. */
  43223. get min(): number;
  43224. /**
  43225. * Returns the biggest value ever
  43226. */
  43227. get max(): number;
  43228. /**
  43229. * Returns the average value since the performance counter is running
  43230. */
  43231. get average(): number;
  43232. /**
  43233. * Returns the average value of the last second the counter was monitored
  43234. */
  43235. get lastSecAverage(): number;
  43236. /**
  43237. * Returns the current value
  43238. */
  43239. get current(): number;
  43240. /**
  43241. * Gets the accumulated total
  43242. */
  43243. get total(): number;
  43244. /**
  43245. * Gets the total value count
  43246. */
  43247. get count(): number;
  43248. /**
  43249. * Creates a new counter
  43250. */
  43251. constructor();
  43252. /**
  43253. * Call this method to start monitoring a new frame.
  43254. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  43255. */
  43256. fetchNewFrame(): void;
  43257. /**
  43258. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  43259. * @param newCount the count value to add to the monitored count
  43260. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  43261. */
  43262. addCount(newCount: number, fetchResult: boolean): void;
  43263. /**
  43264. * Start monitoring this performance counter
  43265. */
  43266. beginMonitoring(): void;
  43267. /**
  43268. * Compute the time lapsed since the previous beginMonitoring() call.
  43269. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  43270. */
  43271. endMonitoring(newFrame?: boolean): void;
  43272. private _fetchResult;
  43273. private _startMonitoringTime;
  43274. private _min;
  43275. private _max;
  43276. private _average;
  43277. private _current;
  43278. private _totalValueCount;
  43279. private _totalAccumulated;
  43280. private _lastSecAverage;
  43281. private _lastSecAccumulated;
  43282. private _lastSecTime;
  43283. private _lastSecValueCount;
  43284. }
  43285. }
  43286. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  43287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43288. import { Nullable } from "babylonjs/types";
  43289. module "babylonjs/Engines/thinEngine" {
  43290. interface ThinEngine {
  43291. /** @hidden */
  43292. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  43293. /** @hidden */
  43294. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  43295. }
  43296. }
  43297. }
  43298. declare module "babylonjs/Audio/analyser" {
  43299. import { Scene } from "babylonjs/scene";
  43300. /**
  43301. * Class used to work with sound analyzer using fast fourier transform (FFT)
  43302. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43303. */
  43304. export class Analyser {
  43305. /**
  43306. * Gets or sets the smoothing
  43307. * @ignorenaming
  43308. */
  43309. SMOOTHING: number;
  43310. /**
  43311. * Gets or sets the FFT table size
  43312. * @ignorenaming
  43313. */
  43314. FFT_SIZE: number;
  43315. /**
  43316. * Gets or sets the bar graph amplitude
  43317. * @ignorenaming
  43318. */
  43319. BARGRAPHAMPLITUDE: number;
  43320. /**
  43321. * Gets or sets the position of the debug canvas
  43322. * @ignorenaming
  43323. */
  43324. DEBUGCANVASPOS: {
  43325. x: number;
  43326. y: number;
  43327. };
  43328. /**
  43329. * Gets or sets the debug canvas size
  43330. * @ignorenaming
  43331. */
  43332. DEBUGCANVASSIZE: {
  43333. width: number;
  43334. height: number;
  43335. };
  43336. private _byteFreqs;
  43337. private _byteTime;
  43338. private _floatFreqs;
  43339. private _webAudioAnalyser;
  43340. private _debugCanvas;
  43341. private _debugCanvasContext;
  43342. private _scene;
  43343. private _registerFunc;
  43344. private _audioEngine;
  43345. /**
  43346. * Creates a new analyser
  43347. * @param scene defines hosting scene
  43348. */
  43349. constructor(scene: Scene);
  43350. /**
  43351. * Get the number of data values you will have to play with for the visualization
  43352. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  43353. * @returns a number
  43354. */
  43355. getFrequencyBinCount(): number;
  43356. /**
  43357. * Gets the current frequency data as a byte array
  43358. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43359. * @returns a Uint8Array
  43360. */
  43361. getByteFrequencyData(): Uint8Array;
  43362. /**
  43363. * Gets the current waveform as a byte array
  43364. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  43365. * @returns a Uint8Array
  43366. */
  43367. getByteTimeDomainData(): Uint8Array;
  43368. /**
  43369. * Gets the current frequency data as a float array
  43370. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43371. * @returns a Float32Array
  43372. */
  43373. getFloatFrequencyData(): Float32Array;
  43374. /**
  43375. * Renders the debug canvas
  43376. */
  43377. drawDebugCanvas(): void;
  43378. /**
  43379. * Stops rendering the debug canvas and removes it
  43380. */
  43381. stopDebugCanvas(): void;
  43382. /**
  43383. * Connects two audio nodes
  43384. * @param inputAudioNode defines first node to connect
  43385. * @param outputAudioNode defines second node to connect
  43386. */
  43387. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  43388. /**
  43389. * Releases all associated resources
  43390. */
  43391. dispose(): void;
  43392. }
  43393. }
  43394. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  43395. import { Observable } from "babylonjs/Misc/observable";
  43396. import { IDisposable } from "babylonjs/scene";
  43397. import { Nullable } from "babylonjs/types";
  43398. import { Analyser } from "babylonjs/Audio/analyser";
  43399. /**
  43400. * This represents an audio engine and it is responsible
  43401. * to play, synchronize and analyse sounds throughout the application.
  43402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43403. */
  43404. export interface IAudioEngine extends IDisposable {
  43405. /**
  43406. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  43407. */
  43408. readonly canUseWebAudio: boolean;
  43409. /**
  43410. * Gets the current AudioContext if available.
  43411. */
  43412. readonly audioContext: Nullable<AudioContext>;
  43413. /**
  43414. * The master gain node defines the global audio volume of your audio engine.
  43415. */
  43416. readonly masterGain: GainNode;
  43417. /**
  43418. * Gets whether or not mp3 are supported by your browser.
  43419. */
  43420. readonly isMP3supported: boolean;
  43421. /**
  43422. * Gets whether or not ogg are supported by your browser.
  43423. */
  43424. readonly isOGGsupported: boolean;
  43425. /**
  43426. * Defines if Babylon should emit a warning if WebAudio is not supported.
  43427. * @ignoreNaming
  43428. */
  43429. WarnedWebAudioUnsupported: boolean;
  43430. /**
  43431. * Defines if the audio engine relies on a custom unlocked button.
  43432. * In this case, the embedded button will not be displayed.
  43433. */
  43434. useCustomUnlockedButton: boolean;
  43435. /**
  43436. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  43437. */
  43438. readonly unlocked: boolean;
  43439. /**
  43440. * Event raised when audio has been unlocked on the browser.
  43441. */
  43442. onAudioUnlockedObservable: Observable<IAudioEngine>;
  43443. /**
  43444. * Event raised when audio has been locked on the browser.
  43445. */
  43446. onAudioLockedObservable: Observable<IAudioEngine>;
  43447. /**
  43448. * Flags the audio engine in Locked state.
  43449. * This happens due to new browser policies preventing audio to autoplay.
  43450. */
  43451. lock(): void;
  43452. /**
  43453. * Unlocks the audio engine once a user action has been done on the dom.
  43454. * This is helpful to resume play once browser policies have been satisfied.
  43455. */
  43456. unlock(): void;
  43457. /**
  43458. * Gets the global volume sets on the master gain.
  43459. * @returns the global volume if set or -1 otherwise
  43460. */
  43461. getGlobalVolume(): number;
  43462. /**
  43463. * Sets the global volume of your experience (sets on the master gain).
  43464. * @param newVolume Defines the new global volume of the application
  43465. */
  43466. setGlobalVolume(newVolume: number): void;
  43467. /**
  43468. * Connect the audio engine to an audio analyser allowing some amazing
  43469. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43470. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43471. * @param analyser The analyser to connect to the engine
  43472. */
  43473. connectToAnalyser(analyser: Analyser): void;
  43474. }
  43475. }
  43476. declare module "babylonjs/Engines/engine" {
  43477. import { Observable } from "babylonjs/Misc/observable";
  43478. import { Nullable } from "babylonjs/types";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43481. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43482. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  43483. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43484. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43485. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  43486. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  43487. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  43488. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43489. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  43490. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43491. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43492. import "babylonjs/Engines/Extensions/engine.alpha";
  43493. import "babylonjs/Engines/Extensions/engine.readTexture";
  43494. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  43495. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  43496. import { Material } from "babylonjs/Materials/material";
  43497. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43498. /**
  43499. * Defines the interface used by display changed events
  43500. */
  43501. export interface IDisplayChangedEventArgs {
  43502. /** Gets the vrDisplay object (if any) */
  43503. vrDisplay: Nullable<any>;
  43504. /** Gets a boolean indicating if webVR is supported */
  43505. vrSupported: boolean;
  43506. }
  43507. /**
  43508. * Defines the interface used by objects containing a viewport (like a camera)
  43509. */
  43510. interface IViewportOwnerLike {
  43511. /**
  43512. * Gets or sets the viewport
  43513. */
  43514. viewport: IViewportLike;
  43515. }
  43516. /**
  43517. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  43518. */
  43519. export class Engine extends ThinEngine {
  43520. /** Defines that alpha blending is disabled */
  43521. static readonly ALPHA_DISABLE: number;
  43522. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  43523. static readonly ALPHA_ADD: number;
  43524. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  43525. static readonly ALPHA_COMBINE: number;
  43526. /** Defines that alpha blending to DEST - SRC * DEST */
  43527. static readonly ALPHA_SUBTRACT: number;
  43528. /** Defines that alpha blending to SRC * DEST */
  43529. static readonly ALPHA_MULTIPLY: number;
  43530. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  43531. static readonly ALPHA_MAXIMIZED: number;
  43532. /** Defines that alpha blending to SRC + DEST */
  43533. static readonly ALPHA_ONEONE: number;
  43534. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  43535. static readonly ALPHA_PREMULTIPLIED: number;
  43536. /**
  43537. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  43538. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  43539. */
  43540. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  43541. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  43542. static readonly ALPHA_INTERPOLATE: number;
  43543. /**
  43544. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  43545. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  43546. */
  43547. static readonly ALPHA_SCREENMODE: number;
  43548. /** Defines that the ressource is not delayed*/
  43549. static readonly DELAYLOADSTATE_NONE: number;
  43550. /** Defines that the ressource was successfully delay loaded */
  43551. static readonly DELAYLOADSTATE_LOADED: number;
  43552. /** Defines that the ressource is currently delay loading */
  43553. static readonly DELAYLOADSTATE_LOADING: number;
  43554. /** Defines that the ressource is delayed and has not started loading */
  43555. static readonly DELAYLOADSTATE_NOTLOADED: number;
  43556. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  43557. static readonly NEVER: number;
  43558. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  43559. static readonly ALWAYS: number;
  43560. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  43561. static readonly LESS: number;
  43562. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  43563. static readonly EQUAL: number;
  43564. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  43565. static readonly LEQUAL: number;
  43566. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  43567. static readonly GREATER: number;
  43568. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  43569. static readonly GEQUAL: number;
  43570. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  43571. static readonly NOTEQUAL: number;
  43572. /** Passed to stencilOperation to specify that stencil value must be kept */
  43573. static readonly KEEP: number;
  43574. /** Passed to stencilOperation to specify that stencil value must be replaced */
  43575. static readonly REPLACE: number;
  43576. /** Passed to stencilOperation to specify that stencil value must be incremented */
  43577. static readonly INCR: number;
  43578. /** Passed to stencilOperation to specify that stencil value must be decremented */
  43579. static readonly DECR: number;
  43580. /** Passed to stencilOperation to specify that stencil value must be inverted */
  43581. static readonly INVERT: number;
  43582. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  43583. static readonly INCR_WRAP: number;
  43584. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  43585. static readonly DECR_WRAP: number;
  43586. /** Texture is not repeating outside of 0..1 UVs */
  43587. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  43588. /** Texture is repeating outside of 0..1 UVs */
  43589. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  43590. /** Texture is repeating and mirrored */
  43591. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  43592. /** ALPHA */
  43593. static readonly TEXTUREFORMAT_ALPHA: number;
  43594. /** LUMINANCE */
  43595. static readonly TEXTUREFORMAT_LUMINANCE: number;
  43596. /** LUMINANCE_ALPHA */
  43597. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  43598. /** RGB */
  43599. static readonly TEXTUREFORMAT_RGB: number;
  43600. /** RGBA */
  43601. static readonly TEXTUREFORMAT_RGBA: number;
  43602. /** RED */
  43603. static readonly TEXTUREFORMAT_RED: number;
  43604. /** RED (2nd reference) */
  43605. static readonly TEXTUREFORMAT_R: number;
  43606. /** RG */
  43607. static readonly TEXTUREFORMAT_RG: number;
  43608. /** RED_INTEGER */
  43609. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  43610. /** RED_INTEGER (2nd reference) */
  43611. static readonly TEXTUREFORMAT_R_INTEGER: number;
  43612. /** RG_INTEGER */
  43613. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  43614. /** RGB_INTEGER */
  43615. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  43616. /** RGBA_INTEGER */
  43617. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  43618. /** UNSIGNED_BYTE */
  43619. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  43620. /** UNSIGNED_BYTE (2nd reference) */
  43621. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  43622. /** FLOAT */
  43623. static readonly TEXTURETYPE_FLOAT: number;
  43624. /** HALF_FLOAT */
  43625. static readonly TEXTURETYPE_HALF_FLOAT: number;
  43626. /** BYTE */
  43627. static readonly TEXTURETYPE_BYTE: number;
  43628. /** SHORT */
  43629. static readonly TEXTURETYPE_SHORT: number;
  43630. /** UNSIGNED_SHORT */
  43631. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  43632. /** INT */
  43633. static readonly TEXTURETYPE_INT: number;
  43634. /** UNSIGNED_INT */
  43635. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  43636. /** UNSIGNED_SHORT_4_4_4_4 */
  43637. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  43638. /** UNSIGNED_SHORT_5_5_5_1 */
  43639. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  43640. /** UNSIGNED_SHORT_5_6_5 */
  43641. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  43642. /** UNSIGNED_INT_2_10_10_10_REV */
  43643. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  43644. /** UNSIGNED_INT_24_8 */
  43645. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  43646. /** UNSIGNED_INT_10F_11F_11F_REV */
  43647. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  43648. /** UNSIGNED_INT_5_9_9_9_REV */
  43649. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  43650. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  43651. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  43652. /** nearest is mag = nearest and min = nearest and mip = none */
  43653. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  43654. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43655. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  43656. /** Trilinear is mag = linear and min = linear and mip = linear */
  43657. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  43658. /** nearest is mag = nearest and min = nearest and mip = linear */
  43659. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  43660. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43661. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  43662. /** Trilinear is mag = linear and min = linear and mip = linear */
  43663. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  43664. /** mag = nearest and min = nearest and mip = nearest */
  43665. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  43666. /** mag = nearest and min = linear and mip = nearest */
  43667. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  43668. /** mag = nearest and min = linear and mip = linear */
  43669. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  43670. /** mag = nearest and min = linear and mip = none */
  43671. static readonly TEXTURE_NEAREST_LINEAR: number;
  43672. /** mag = nearest and min = nearest and mip = none */
  43673. static readonly TEXTURE_NEAREST_NEAREST: number;
  43674. /** mag = linear and min = nearest and mip = nearest */
  43675. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  43676. /** mag = linear and min = nearest and mip = linear */
  43677. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  43678. /** mag = linear and min = linear and mip = none */
  43679. static readonly TEXTURE_LINEAR_LINEAR: number;
  43680. /** mag = linear and min = nearest and mip = none */
  43681. static readonly TEXTURE_LINEAR_NEAREST: number;
  43682. /** Explicit coordinates mode */
  43683. static readonly TEXTURE_EXPLICIT_MODE: number;
  43684. /** Spherical coordinates mode */
  43685. static readonly TEXTURE_SPHERICAL_MODE: number;
  43686. /** Planar coordinates mode */
  43687. static readonly TEXTURE_PLANAR_MODE: number;
  43688. /** Cubic coordinates mode */
  43689. static readonly TEXTURE_CUBIC_MODE: number;
  43690. /** Projection coordinates mode */
  43691. static readonly TEXTURE_PROJECTION_MODE: number;
  43692. /** Skybox coordinates mode */
  43693. static readonly TEXTURE_SKYBOX_MODE: number;
  43694. /** Inverse Cubic coordinates mode */
  43695. static readonly TEXTURE_INVCUBIC_MODE: number;
  43696. /** Equirectangular coordinates mode */
  43697. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  43698. /** Equirectangular Fixed coordinates mode */
  43699. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  43700. /** Equirectangular Fixed Mirrored coordinates mode */
  43701. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  43702. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  43703. static readonly SCALEMODE_FLOOR: number;
  43704. /** Defines that texture rescaling will look for the nearest power of 2 size */
  43705. static readonly SCALEMODE_NEAREST: number;
  43706. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  43707. static readonly SCALEMODE_CEILING: number;
  43708. /**
  43709. * Returns the current npm package of the sdk
  43710. */
  43711. static get NpmPackage(): string;
  43712. /**
  43713. * Returns the current version of the framework
  43714. */
  43715. static get Version(): string;
  43716. /** Gets the list of created engines */
  43717. static get Instances(): Engine[];
  43718. /**
  43719. * Gets the latest created engine
  43720. */
  43721. static get LastCreatedEngine(): Nullable<Engine>;
  43722. /**
  43723. * Gets the latest created scene
  43724. */
  43725. static get LastCreatedScene(): Nullable<Scene>;
  43726. /**
  43727. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  43728. * @param flag defines which part of the materials must be marked as dirty
  43729. * @param predicate defines a predicate used to filter which materials should be affected
  43730. */
  43731. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  43732. /**
  43733. * Method called to create the default loading screen.
  43734. * This can be overriden in your own app.
  43735. * @param canvas The rendering canvas element
  43736. * @returns The loading screen
  43737. */
  43738. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  43739. /**
  43740. * Method called to create the default rescale post process on each engine.
  43741. */
  43742. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  43743. /**
  43744. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  43745. **/
  43746. enableOfflineSupport: boolean;
  43747. /**
  43748. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  43749. **/
  43750. disableManifestCheck: boolean;
  43751. /**
  43752. * Gets the list of created scenes
  43753. */
  43754. scenes: Scene[];
  43755. /**
  43756. * Event raised when a new scene is created
  43757. */
  43758. onNewSceneAddedObservable: Observable<Scene>;
  43759. /**
  43760. * Gets the list of created postprocesses
  43761. */
  43762. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43763. /**
  43764. * Gets a boolean indicating if the pointer is currently locked
  43765. */
  43766. isPointerLock: boolean;
  43767. /**
  43768. * Observable event triggered each time the rendering canvas is resized
  43769. */
  43770. onResizeObservable: Observable<Engine>;
  43771. /**
  43772. * Observable event triggered each time the canvas loses focus
  43773. */
  43774. onCanvasBlurObservable: Observable<Engine>;
  43775. /**
  43776. * Observable event triggered each time the canvas gains focus
  43777. */
  43778. onCanvasFocusObservable: Observable<Engine>;
  43779. /**
  43780. * Observable event triggered each time the canvas receives pointerout event
  43781. */
  43782. onCanvasPointerOutObservable: Observable<PointerEvent>;
  43783. /**
  43784. * Observable raised when the engine begins a new frame
  43785. */
  43786. onBeginFrameObservable: Observable<Engine>;
  43787. /**
  43788. * If set, will be used to request the next animation frame for the render loop
  43789. */
  43790. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  43791. /**
  43792. * Observable raised when the engine ends the current frame
  43793. */
  43794. onEndFrameObservable: Observable<Engine>;
  43795. /**
  43796. * Observable raised when the engine is about to compile a shader
  43797. */
  43798. onBeforeShaderCompilationObservable: Observable<Engine>;
  43799. /**
  43800. * Observable raised when the engine has jsut compiled a shader
  43801. */
  43802. onAfterShaderCompilationObservable: Observable<Engine>;
  43803. /**
  43804. * Gets the audio engine
  43805. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43806. * @ignorenaming
  43807. */
  43808. static audioEngine: IAudioEngine;
  43809. /**
  43810. * Default AudioEngine factory responsible of creating the Audio Engine.
  43811. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  43812. */
  43813. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  43814. /**
  43815. * Default offline support factory responsible of creating a tool used to store data locally.
  43816. * By default, this will create a Database object if the workload has been embedded.
  43817. */
  43818. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  43819. private _loadingScreen;
  43820. private _pointerLockRequested;
  43821. private _rescalePostProcess;
  43822. protected _deterministicLockstep: boolean;
  43823. protected _lockstepMaxSteps: number;
  43824. protected _timeStep: number;
  43825. protected get _supportsHardwareTextureRescaling(): boolean;
  43826. private _fps;
  43827. private _deltaTime;
  43828. /** @hidden */
  43829. _drawCalls: PerfCounter;
  43830. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  43831. canvasTabIndex: number;
  43832. /**
  43833. * Turn this value on if you want to pause FPS computation when in background
  43834. */
  43835. disablePerformanceMonitorInBackground: boolean;
  43836. private _performanceMonitor;
  43837. /**
  43838. * Gets the performance monitor attached to this engine
  43839. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43840. */
  43841. get performanceMonitor(): PerformanceMonitor;
  43842. private _onFocus;
  43843. private _onBlur;
  43844. private _onCanvasPointerOut;
  43845. private _onCanvasBlur;
  43846. private _onCanvasFocus;
  43847. private _onFullscreenChange;
  43848. private _onPointerLockChange;
  43849. /**
  43850. * Gets the HTML element used to attach event listeners
  43851. * @returns a HTML element
  43852. */
  43853. getInputElement(): Nullable<HTMLElement>;
  43854. /**
  43855. * Creates a new engine
  43856. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  43857. * @param antialias defines enable antialiasing (default: false)
  43858. * @param options defines further options to be sent to the getContext() function
  43859. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  43860. */
  43861. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  43862. /**
  43863. * Shared initialization across engines types.
  43864. * @param canvas The canvas associated with this instance of the engine.
  43865. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  43866. * @param audioEngine Defines if an audio engine should be created by default
  43867. */
  43868. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  43869. /**
  43870. * Gets current aspect ratio
  43871. * @param viewportOwner defines the camera to use to get the aspect ratio
  43872. * @param useScreen defines if screen size must be used (or the current render target if any)
  43873. * @returns a number defining the aspect ratio
  43874. */
  43875. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  43876. /**
  43877. * Gets current screen aspect ratio
  43878. * @returns a number defining the aspect ratio
  43879. */
  43880. getScreenAspectRatio(): number;
  43881. /**
  43882. * Gets the client rect of the HTML canvas attached with the current webGL context
  43883. * @returns a client rectanglee
  43884. */
  43885. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  43886. /**
  43887. * Gets the client rect of the HTML element used for events
  43888. * @returns a client rectanglee
  43889. */
  43890. getInputElementClientRect(): Nullable<ClientRect>;
  43891. /**
  43892. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43893. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43894. * @returns true if engine is in deterministic lock step mode
  43895. */
  43896. isDeterministicLockStep(): boolean;
  43897. /**
  43898. * Gets the max steps when engine is running in deterministic lock step
  43899. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43900. * @returns the max steps
  43901. */
  43902. getLockstepMaxSteps(): number;
  43903. /**
  43904. * Returns the time in ms between steps when using deterministic lock step.
  43905. * @returns time step in (ms)
  43906. */
  43907. getTimeStep(): number;
  43908. /**
  43909. * Force the mipmap generation for the given render target texture
  43910. * @param texture defines the render target texture to use
  43911. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  43912. */
  43913. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  43914. /** States */
  43915. /**
  43916. * Set various states to the webGL context
  43917. * @param culling defines backface culling state
  43918. * @param zOffset defines the value to apply to zOffset (0 by default)
  43919. * @param force defines if states must be applied even if cache is up to date
  43920. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43921. */
  43922. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43923. /**
  43924. * Set the z offset to apply to current rendering
  43925. * @param value defines the offset to apply
  43926. */
  43927. setZOffset(value: number): void;
  43928. /**
  43929. * Gets the current value of the zOffset
  43930. * @returns the current zOffset state
  43931. */
  43932. getZOffset(): number;
  43933. /**
  43934. * Gets a boolean indicating if depth testing is enabled
  43935. * @returns the current state
  43936. */
  43937. getDepthBuffer(): boolean;
  43938. /**
  43939. * Enable or disable depth buffering
  43940. * @param enable defines the state to set
  43941. */
  43942. setDepthBuffer(enable: boolean): void;
  43943. /**
  43944. * Gets a boolean indicating if depth writing is enabled
  43945. * @returns the current depth writing state
  43946. */
  43947. getDepthWrite(): boolean;
  43948. /**
  43949. * Enable or disable depth writing
  43950. * @param enable defines the state to set
  43951. */
  43952. setDepthWrite(enable: boolean): void;
  43953. /**
  43954. * Gets a boolean indicating if stencil buffer is enabled
  43955. * @returns the current stencil buffer state
  43956. */
  43957. getStencilBuffer(): boolean;
  43958. /**
  43959. * Enable or disable the stencil buffer
  43960. * @param enable defines if the stencil buffer must be enabled or disabled
  43961. */
  43962. setStencilBuffer(enable: boolean): void;
  43963. /**
  43964. * Gets the current stencil mask
  43965. * @returns a number defining the new stencil mask to use
  43966. */
  43967. getStencilMask(): number;
  43968. /**
  43969. * Sets the current stencil mask
  43970. * @param mask defines the new stencil mask to use
  43971. */
  43972. setStencilMask(mask: number): void;
  43973. /**
  43974. * Gets the current stencil function
  43975. * @returns a number defining the stencil function to use
  43976. */
  43977. getStencilFunction(): number;
  43978. /**
  43979. * Gets the current stencil reference value
  43980. * @returns a number defining the stencil reference value to use
  43981. */
  43982. getStencilFunctionReference(): number;
  43983. /**
  43984. * Gets the current stencil mask
  43985. * @returns a number defining the stencil mask to use
  43986. */
  43987. getStencilFunctionMask(): number;
  43988. /**
  43989. * Sets the current stencil function
  43990. * @param stencilFunc defines the new stencil function to use
  43991. */
  43992. setStencilFunction(stencilFunc: number): void;
  43993. /**
  43994. * Sets the current stencil reference
  43995. * @param reference defines the new stencil reference to use
  43996. */
  43997. setStencilFunctionReference(reference: number): void;
  43998. /**
  43999. * Sets the current stencil mask
  44000. * @param mask defines the new stencil mask to use
  44001. */
  44002. setStencilFunctionMask(mask: number): void;
  44003. /**
  44004. * Gets the current stencil operation when stencil fails
  44005. * @returns a number defining stencil operation to use when stencil fails
  44006. */
  44007. getStencilOperationFail(): number;
  44008. /**
  44009. * Gets the current stencil operation when depth fails
  44010. * @returns a number defining stencil operation to use when depth fails
  44011. */
  44012. getStencilOperationDepthFail(): number;
  44013. /**
  44014. * Gets the current stencil operation when stencil passes
  44015. * @returns a number defining stencil operation to use when stencil passes
  44016. */
  44017. getStencilOperationPass(): number;
  44018. /**
  44019. * Sets the stencil operation to use when stencil fails
  44020. * @param operation defines the stencil operation to use when stencil fails
  44021. */
  44022. setStencilOperationFail(operation: number): void;
  44023. /**
  44024. * Sets the stencil operation to use when depth fails
  44025. * @param operation defines the stencil operation to use when depth fails
  44026. */
  44027. setStencilOperationDepthFail(operation: number): void;
  44028. /**
  44029. * Sets the stencil operation to use when stencil passes
  44030. * @param operation defines the stencil operation to use when stencil passes
  44031. */
  44032. setStencilOperationPass(operation: number): void;
  44033. /**
  44034. * Sets a boolean indicating if the dithering state is enabled or disabled
  44035. * @param value defines the dithering state
  44036. */
  44037. setDitheringState(value: boolean): void;
  44038. /**
  44039. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  44040. * @param value defines the rasterizer state
  44041. */
  44042. setRasterizerState(value: boolean): void;
  44043. /**
  44044. * Gets the current depth function
  44045. * @returns a number defining the depth function
  44046. */
  44047. getDepthFunction(): Nullable<number>;
  44048. /**
  44049. * Sets the current depth function
  44050. * @param depthFunc defines the function to use
  44051. */
  44052. setDepthFunction(depthFunc: number): void;
  44053. /**
  44054. * Sets the current depth function to GREATER
  44055. */
  44056. setDepthFunctionToGreater(): void;
  44057. /**
  44058. * Sets the current depth function to GEQUAL
  44059. */
  44060. setDepthFunctionToGreaterOrEqual(): void;
  44061. /**
  44062. * Sets the current depth function to LESS
  44063. */
  44064. setDepthFunctionToLess(): void;
  44065. /**
  44066. * Sets the current depth function to LEQUAL
  44067. */
  44068. setDepthFunctionToLessOrEqual(): void;
  44069. private _cachedStencilBuffer;
  44070. private _cachedStencilFunction;
  44071. private _cachedStencilMask;
  44072. private _cachedStencilOperationPass;
  44073. private _cachedStencilOperationFail;
  44074. private _cachedStencilOperationDepthFail;
  44075. private _cachedStencilReference;
  44076. /**
  44077. * Caches the the state of the stencil buffer
  44078. */
  44079. cacheStencilState(): void;
  44080. /**
  44081. * Restores the state of the stencil buffer
  44082. */
  44083. restoreStencilState(): void;
  44084. /**
  44085. * Directly set the WebGL Viewport
  44086. * @param x defines the x coordinate of the viewport (in screen space)
  44087. * @param y defines the y coordinate of the viewport (in screen space)
  44088. * @param width defines the width of the viewport (in screen space)
  44089. * @param height defines the height of the viewport (in screen space)
  44090. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  44091. */
  44092. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  44093. /**
  44094. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  44095. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  44096. * @param y defines the y-coordinate of the corner of the clear rectangle
  44097. * @param width defines the width of the clear rectangle
  44098. * @param height defines the height of the clear rectangle
  44099. * @param clearColor defines the clear color
  44100. */
  44101. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  44102. /**
  44103. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  44104. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  44105. * @param y defines the y-coordinate of the corner of the clear rectangle
  44106. * @param width defines the width of the clear rectangle
  44107. * @param height defines the height of the clear rectangle
  44108. */
  44109. enableScissor(x: number, y: number, width: number, height: number): void;
  44110. /**
  44111. * Disable previously set scissor test rectangle
  44112. */
  44113. disableScissor(): void;
  44114. protected _reportDrawCall(): void;
  44115. /**
  44116. * Initializes a webVR display and starts listening to display change events
  44117. * The onVRDisplayChangedObservable will be notified upon these changes
  44118. * @returns The onVRDisplayChangedObservable
  44119. */
  44120. initWebVR(): Observable<IDisplayChangedEventArgs>;
  44121. /** @hidden */
  44122. _prepareVRComponent(): void;
  44123. /** @hidden */
  44124. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  44125. /** @hidden */
  44126. _submitVRFrame(): void;
  44127. /**
  44128. * Call this function to leave webVR mode
  44129. * Will do nothing if webVR is not supported or if there is no webVR device
  44130. * @see https://doc.babylonjs.com/how_to/webvr_camera
  44131. */
  44132. disableVR(): void;
  44133. /**
  44134. * Gets a boolean indicating that the system is in VR mode and is presenting
  44135. * @returns true if VR mode is engaged
  44136. */
  44137. isVRPresenting(): boolean;
  44138. /** @hidden */
  44139. _requestVRFrame(): void;
  44140. /** @hidden */
  44141. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44142. /**
  44143. * Gets the source code of the vertex shader associated with a specific webGL program
  44144. * @param program defines the program to use
  44145. * @returns a string containing the source code of the vertex shader associated with the program
  44146. */
  44147. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  44148. /**
  44149. * Gets the source code of the fragment shader associated with a specific webGL program
  44150. * @param program defines the program to use
  44151. * @returns a string containing the source code of the fragment shader associated with the program
  44152. */
  44153. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  44154. /**
  44155. * Sets a depth stencil texture from a render target to the according uniform.
  44156. * @param channel The texture channel
  44157. * @param uniform The uniform to set
  44158. * @param texture The render target texture containing the depth stencil texture to apply
  44159. * @param name The texture name
  44160. */
  44161. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  44162. /**
  44163. * Sets a texture to the webGL context from a postprocess
  44164. * @param channel defines the channel to use
  44165. * @param postProcess defines the source postprocess
  44166. * @param name name of the channel
  44167. */
  44168. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44169. /**
  44170. * Binds the output of the passed in post process to the texture channel specified
  44171. * @param channel The channel the texture should be bound to
  44172. * @param postProcess The post process which's output should be bound
  44173. * @param name name of the channel
  44174. */
  44175. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44176. protected _rebuildBuffers(): void;
  44177. /** @hidden */
  44178. _renderFrame(): void;
  44179. _renderLoop(): void;
  44180. /** @hidden */
  44181. _renderViews(): boolean;
  44182. /**
  44183. * Toggle full screen mode
  44184. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44185. */
  44186. switchFullscreen(requestPointerLock: boolean): void;
  44187. /**
  44188. * Enters full screen mode
  44189. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44190. */
  44191. enterFullscreen(requestPointerLock: boolean): void;
  44192. /**
  44193. * Exits full screen mode
  44194. */
  44195. exitFullscreen(): void;
  44196. /**
  44197. * Enters Pointerlock mode
  44198. */
  44199. enterPointerlock(): void;
  44200. /**
  44201. * Exits Pointerlock mode
  44202. */
  44203. exitPointerlock(): void;
  44204. /**
  44205. * Begin a new frame
  44206. */
  44207. beginFrame(): void;
  44208. /**
  44209. * End the current frame
  44210. */
  44211. endFrame(): void;
  44212. /**
  44213. * Resize the view according to the canvas' size
  44214. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44215. */
  44216. resize(forceSetSize?: boolean): void;
  44217. /**
  44218. * Force a specific size of the canvas
  44219. * @param width defines the new canvas' width
  44220. * @param height defines the new canvas' height
  44221. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44222. * @returns true if the size was changed
  44223. */
  44224. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44225. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44226. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44227. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44228. _releaseTexture(texture: InternalTexture): void;
  44229. /**
  44230. * @hidden
  44231. * Rescales a texture
  44232. * @param source input texutre
  44233. * @param destination destination texture
  44234. * @param scene scene to use to render the resize
  44235. * @param internalFormat format to use when resizing
  44236. * @param onComplete callback to be called when resize has completed
  44237. */
  44238. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  44239. /**
  44240. * Gets the current framerate
  44241. * @returns a number representing the framerate
  44242. */
  44243. getFps(): number;
  44244. /**
  44245. * Gets the time spent between current and previous frame
  44246. * @returns a number representing the delta time in ms
  44247. */
  44248. getDeltaTime(): number;
  44249. private _measureFps;
  44250. /** @hidden */
  44251. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  44252. /**
  44253. * Updates the sample count of a render target texture
  44254. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44255. * @param texture defines the texture to update
  44256. * @param samples defines the sample count to set
  44257. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44258. */
  44259. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  44260. /**
  44261. * Updates a depth texture Comparison Mode and Function.
  44262. * If the comparison Function is equal to 0, the mode will be set to none.
  44263. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  44264. * @param texture The texture to set the comparison function for
  44265. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  44266. */
  44267. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  44268. /**
  44269. * Creates a webGL buffer to use with instanciation
  44270. * @param capacity defines the size of the buffer
  44271. * @returns the webGL buffer
  44272. */
  44273. createInstancesBuffer(capacity: number): DataBuffer;
  44274. /**
  44275. * Delete a webGL buffer used with instanciation
  44276. * @param buffer defines the webGL buffer to delete
  44277. */
  44278. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  44279. private _clientWaitAsync;
  44280. /** @hidden */
  44281. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  44282. dispose(): void;
  44283. private _disableTouchAction;
  44284. /**
  44285. * Display the loading screen
  44286. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44287. */
  44288. displayLoadingUI(): void;
  44289. /**
  44290. * Hide the loading screen
  44291. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44292. */
  44293. hideLoadingUI(): void;
  44294. /**
  44295. * Gets the current loading screen object
  44296. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44297. */
  44298. get loadingScreen(): ILoadingScreen;
  44299. /**
  44300. * Sets the current loading screen object
  44301. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44302. */
  44303. set loadingScreen(loadingScreen: ILoadingScreen);
  44304. /**
  44305. * Sets the current loading screen text
  44306. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44307. */
  44308. set loadingUIText(text: string);
  44309. /**
  44310. * Sets the current loading screen background color
  44311. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44312. */
  44313. set loadingUIBackgroundColor(color: string);
  44314. /** Pointerlock and fullscreen */
  44315. /**
  44316. * Ask the browser to promote the current element to pointerlock mode
  44317. * @param element defines the DOM element to promote
  44318. */
  44319. static _RequestPointerlock(element: HTMLElement): void;
  44320. /**
  44321. * Asks the browser to exit pointerlock mode
  44322. */
  44323. static _ExitPointerlock(): void;
  44324. /**
  44325. * Ask the browser to promote the current element to fullscreen rendering mode
  44326. * @param element defines the DOM element to promote
  44327. */
  44328. static _RequestFullscreen(element: HTMLElement): void;
  44329. /**
  44330. * Asks the browser to exit fullscreen mode
  44331. */
  44332. static _ExitFullscreen(): void;
  44333. }
  44334. }
  44335. declare module "babylonjs/Engines/engineStore" {
  44336. import { Nullable } from "babylonjs/types";
  44337. import { Engine } from "babylonjs/Engines/engine";
  44338. import { Scene } from "babylonjs/scene";
  44339. /**
  44340. * The engine store class is responsible to hold all the instances of Engine and Scene created
  44341. * during the life time of the application.
  44342. */
  44343. export class EngineStore {
  44344. /** Gets the list of created engines */
  44345. static Instances: import("babylonjs/Engines/engine").Engine[];
  44346. /** @hidden */
  44347. static _LastCreatedScene: Nullable<Scene>;
  44348. /**
  44349. * Gets the latest created engine
  44350. */
  44351. static get LastCreatedEngine(): Nullable<Engine>;
  44352. /**
  44353. * Gets the latest created scene
  44354. */
  44355. static get LastCreatedScene(): Nullable<Scene>;
  44356. /**
  44357. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44358. * @ignorenaming
  44359. */
  44360. static UseFallbackTexture: boolean;
  44361. /**
  44362. * Texture content used if a texture cannot loaded
  44363. * @ignorenaming
  44364. */
  44365. static FallbackTexture: string;
  44366. }
  44367. }
  44368. declare module "babylonjs/Misc/promise" {
  44369. /**
  44370. * Helper class that provides a small promise polyfill
  44371. */
  44372. export class PromisePolyfill {
  44373. /**
  44374. * Static function used to check if the polyfill is required
  44375. * If this is the case then the function will inject the polyfill to window.Promise
  44376. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  44377. */
  44378. static Apply(force?: boolean): void;
  44379. }
  44380. }
  44381. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  44382. /**
  44383. * Interface for screenshot methods with describe argument called `size` as object with options
  44384. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  44385. */
  44386. export interface IScreenshotSize {
  44387. /**
  44388. * number in pixels for canvas height
  44389. */
  44390. height?: number;
  44391. /**
  44392. * multiplier allowing render at a higher or lower resolution
  44393. * If value is defined then height and width will be ignored and taken from camera
  44394. */
  44395. precision?: number;
  44396. /**
  44397. * number in pixels for canvas width
  44398. */
  44399. width?: number;
  44400. }
  44401. }
  44402. declare module "babylonjs/Misc/tools" {
  44403. import { Nullable, float } from "babylonjs/types";
  44404. import { DomManagement } from "babylonjs/Misc/domManagement";
  44405. import { WebRequest } from "babylonjs/Misc/webRequest";
  44406. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44407. import { ReadFileError } from "babylonjs/Misc/fileTools";
  44408. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44409. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  44410. import { Camera } from "babylonjs/Cameras/camera";
  44411. import { Engine } from "babylonjs/Engines/engine";
  44412. interface IColor4Like {
  44413. r: float;
  44414. g: float;
  44415. b: float;
  44416. a: float;
  44417. }
  44418. /**
  44419. * Class containing a set of static utilities functions
  44420. */
  44421. export class Tools {
  44422. /**
  44423. * Gets or sets the base URL to use to load assets
  44424. */
  44425. static get BaseUrl(): string;
  44426. static set BaseUrl(value: string);
  44427. /**
  44428. * Enable/Disable Custom HTTP Request Headers globally.
  44429. * default = false
  44430. * @see CustomRequestHeaders
  44431. */
  44432. static UseCustomRequestHeaders: boolean;
  44433. /**
  44434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  44435. * i.e. when loading files, where the server/service expects an Authorization header
  44436. */
  44437. static CustomRequestHeaders: {
  44438. [key: string]: string;
  44439. };
  44440. /**
  44441. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  44442. */
  44443. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  44444. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  44445. /**
  44446. * Default behaviour for cors in the application.
  44447. * It can be a string if the expected behavior is identical in the entire app.
  44448. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  44449. */
  44450. static get CorsBehavior(): string | ((url: string | string[]) => string);
  44451. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  44452. /**
  44453. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44454. * @ignorenaming
  44455. */
  44456. static get UseFallbackTexture(): boolean;
  44457. static set UseFallbackTexture(value: boolean);
  44458. /**
  44459. * Use this object to register external classes like custom textures or material
  44460. * to allow the laoders to instantiate them
  44461. */
  44462. static get RegisteredExternalClasses(): {
  44463. [key: string]: Object;
  44464. };
  44465. static set RegisteredExternalClasses(classes: {
  44466. [key: string]: Object;
  44467. });
  44468. /**
  44469. * Texture content used if a texture cannot loaded
  44470. * @ignorenaming
  44471. */
  44472. static get fallbackTexture(): string;
  44473. static set fallbackTexture(value: string);
  44474. /**
  44475. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  44476. * @param u defines the coordinate on X axis
  44477. * @param v defines the coordinate on Y axis
  44478. * @param width defines the width of the source data
  44479. * @param height defines the height of the source data
  44480. * @param pixels defines the source byte array
  44481. * @param color defines the output color
  44482. */
  44483. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  44484. /**
  44485. * Interpolates between a and b via alpha
  44486. * @param a The lower value (returned when alpha = 0)
  44487. * @param b The upper value (returned when alpha = 1)
  44488. * @param alpha The interpolation-factor
  44489. * @return The mixed value
  44490. */
  44491. static Mix(a: number, b: number, alpha: number): number;
  44492. /**
  44493. * Tries to instantiate a new object from a given class name
  44494. * @param className defines the class name to instantiate
  44495. * @returns the new object or null if the system was not able to do the instantiation
  44496. */
  44497. static Instantiate(className: string): any;
  44498. /**
  44499. * Provides a slice function that will work even on IE
  44500. * @param data defines the array to slice
  44501. * @param start defines the start of the data (optional)
  44502. * @param end defines the end of the data (optional)
  44503. * @returns the new sliced array
  44504. */
  44505. static Slice<T>(data: T, start?: number, end?: number): T;
  44506. /**
  44507. * Provides a slice function that will work even on IE
  44508. * The difference between this and Slice is that this will force-convert to array
  44509. * @param data defines the array to slice
  44510. * @param start defines the start of the data (optional)
  44511. * @param end defines the end of the data (optional)
  44512. * @returns the new sliced array
  44513. */
  44514. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  44515. /**
  44516. * Polyfill for setImmediate
  44517. * @param action defines the action to execute after the current execution block
  44518. */
  44519. static SetImmediate(action: () => void): void;
  44520. /**
  44521. * Function indicating if a number is an exponent of 2
  44522. * @param value defines the value to test
  44523. * @returns true if the value is an exponent of 2
  44524. */
  44525. static IsExponentOfTwo(value: number): boolean;
  44526. private static _tmpFloatArray;
  44527. /**
  44528. * Returns the nearest 32-bit single precision float representation of a Number
  44529. * @param value A Number. If the parameter is of a different type, it will get converted
  44530. * to a number or to NaN if it cannot be converted
  44531. * @returns number
  44532. */
  44533. static FloatRound(value: number): number;
  44534. /**
  44535. * Extracts the filename from a path
  44536. * @param path defines the path to use
  44537. * @returns the filename
  44538. */
  44539. static GetFilename(path: string): string;
  44540. /**
  44541. * Extracts the "folder" part of a path (everything before the filename).
  44542. * @param uri The URI to extract the info from
  44543. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  44544. * @returns The "folder" part of the path
  44545. */
  44546. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  44547. /**
  44548. * Extracts text content from a DOM element hierarchy
  44549. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  44550. */
  44551. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  44552. /**
  44553. * Convert an angle in radians to degrees
  44554. * @param angle defines the angle to convert
  44555. * @returns the angle in degrees
  44556. */
  44557. static ToDegrees(angle: number): number;
  44558. /**
  44559. * Convert an angle in degrees to radians
  44560. * @param angle defines the angle to convert
  44561. * @returns the angle in radians
  44562. */
  44563. static ToRadians(angle: number): number;
  44564. /**
  44565. * Returns an array if obj is not an array
  44566. * @param obj defines the object to evaluate as an array
  44567. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  44568. * @returns either obj directly if obj is an array or a new array containing obj
  44569. */
  44570. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  44571. /**
  44572. * Gets the pointer prefix to use
  44573. * @param engine defines the engine we are finding the prefix for
  44574. * @returns "pointer" if touch is enabled. Else returns "mouse"
  44575. */
  44576. static GetPointerPrefix(engine: Engine): string;
  44577. /**
  44578. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  44579. * @param url define the url we are trying
  44580. * @param element define the dom element where to configure the cors policy
  44581. */
  44582. static SetCorsBehavior(url: string | string[], element: {
  44583. crossOrigin: string | null;
  44584. }): void;
  44585. /**
  44586. * Removes unwanted characters from an url
  44587. * @param url defines the url to clean
  44588. * @returns the cleaned url
  44589. */
  44590. static CleanUrl(url: string): string;
  44591. /**
  44592. * Gets or sets a function used to pre-process url before using them to load assets
  44593. */
  44594. static get PreprocessUrl(): (url: string) => string;
  44595. static set PreprocessUrl(processor: (url: string) => string);
  44596. /**
  44597. * Loads an image as an HTMLImageElement.
  44598. * @param input url string, ArrayBuffer, or Blob to load
  44599. * @param onLoad callback called when the image successfully loads
  44600. * @param onError callback called when the image fails to load
  44601. * @param offlineProvider offline provider for caching
  44602. * @param mimeType optional mime type
  44603. * @returns the HTMLImageElement of the loaded image
  44604. */
  44605. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  44606. /**
  44607. * Loads a file from a url
  44608. * @param url url string, ArrayBuffer, or Blob to load
  44609. * @param onSuccess callback called when the file successfully loads
  44610. * @param onProgress callback called while file is loading (if the server supports this mode)
  44611. * @param offlineProvider defines the offline provider for caching
  44612. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44613. * @param onError callback called when the file fails to load
  44614. * @returns a file request object
  44615. */
  44616. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  44617. /**
  44618. * Loads a file from a url
  44619. * @param url the file url to load
  44620. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44621. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  44622. */
  44623. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  44624. /**
  44625. * Load a script (identified by an url). When the url returns, the
  44626. * content of this file is added into a new script element, attached to the DOM (body element)
  44627. * @param scriptUrl defines the url of the script to laod
  44628. * @param onSuccess defines the callback called when the script is loaded
  44629. * @param onError defines the callback to call if an error occurs
  44630. * @param scriptId defines the id of the script element
  44631. */
  44632. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  44633. /**
  44634. * Load an asynchronous script (identified by an url). When the url returns, the
  44635. * content of this file is added into a new script element, attached to the DOM (body element)
  44636. * @param scriptUrl defines the url of the script to laod
  44637. * @param scriptId defines the id of the script element
  44638. * @returns a promise request object
  44639. */
  44640. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  44641. /**
  44642. * Loads a file from a blob
  44643. * @param fileToLoad defines the blob to use
  44644. * @param callback defines the callback to call when data is loaded
  44645. * @param progressCallback defines the callback to call during loading process
  44646. * @returns a file request object
  44647. */
  44648. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  44649. /**
  44650. * Reads a file from a File object
  44651. * @param file defines the file to load
  44652. * @param onSuccess defines the callback to call when data is loaded
  44653. * @param onProgress defines the callback to call during loading process
  44654. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44655. * @param onError defines the callback to call when an error occurs
  44656. * @returns a file request object
  44657. */
  44658. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44659. /**
  44660. * Creates a data url from a given string content
  44661. * @param content defines the content to convert
  44662. * @returns the new data url link
  44663. */
  44664. static FileAsURL(content: string): string;
  44665. /**
  44666. * Format the given number to a specific decimal format
  44667. * @param value defines the number to format
  44668. * @param decimals defines the number of decimals to use
  44669. * @returns the formatted string
  44670. */
  44671. static Format(value: number, decimals?: number): string;
  44672. /**
  44673. * Tries to copy an object by duplicating every property
  44674. * @param source defines the source object
  44675. * @param destination defines the target object
  44676. * @param doNotCopyList defines a list of properties to avoid
  44677. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  44678. */
  44679. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  44680. /**
  44681. * Gets a boolean indicating if the given object has no own property
  44682. * @param obj defines the object to test
  44683. * @returns true if object has no own property
  44684. */
  44685. static IsEmpty(obj: any): boolean;
  44686. /**
  44687. * Function used to register events at window level
  44688. * @param windowElement defines the Window object to use
  44689. * @param events defines the events to register
  44690. */
  44691. static RegisterTopRootEvents(windowElement: Window, events: {
  44692. name: string;
  44693. handler: Nullable<(e: FocusEvent) => any>;
  44694. }[]): void;
  44695. /**
  44696. * Function used to unregister events from window level
  44697. * @param windowElement defines the Window object to use
  44698. * @param events defines the events to unregister
  44699. */
  44700. static UnregisterTopRootEvents(windowElement: Window, events: {
  44701. name: string;
  44702. handler: Nullable<(e: FocusEvent) => any>;
  44703. }[]): void;
  44704. /**
  44705. * @ignore
  44706. */
  44707. static _ScreenshotCanvas: HTMLCanvasElement;
  44708. /**
  44709. * Dumps the current bound framebuffer
  44710. * @param width defines the rendering width
  44711. * @param height defines the rendering height
  44712. * @param engine defines the hosting engine
  44713. * @param successCallback defines the callback triggered once the data are available
  44714. * @param mimeType defines the mime type of the result
  44715. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44716. * @return a void promise
  44717. */
  44718. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  44719. /**
  44720. * Dumps an array buffer
  44721. * @param width defines the rendering width
  44722. * @param height defines the rendering height
  44723. * @param data the data array
  44724. * @param successCallback defines the callback triggered once the data are available
  44725. * @param mimeType defines the mime type of the result
  44726. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44727. * @param invertY true to invert the picture in the Y dimension
  44728. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44729. */
  44730. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  44731. /**
  44732. * Dumps an array buffer
  44733. * @param width defines the rendering width
  44734. * @param height defines the rendering height
  44735. * @param data the data array
  44736. * @param successCallback defines the callback triggered once the data are available
  44737. * @param mimeType defines the mime type of the result
  44738. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44739. * @param invertY true to invert the picture in the Y dimension
  44740. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44741. * @return a promise that resolve to the final data
  44742. */
  44743. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44744. /**
  44745. * Converts the canvas data to blob.
  44746. * This acts as a polyfill for browsers not supporting the to blob function.
  44747. * @param canvas Defines the canvas to extract the data from
  44748. * @param successCallback Defines the callback triggered once the data are available
  44749. * @param mimeType Defines the mime type of the result
  44750. */
  44751. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  44752. /**
  44753. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  44754. * @param successCallback defines the callback triggered once the data are available
  44755. * @param mimeType defines the mime type of the result
  44756. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  44757. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  44758. */
  44759. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  44760. /**
  44761. * Downloads a blob in the browser
  44762. * @param blob defines the blob to download
  44763. * @param fileName defines the name of the downloaded file
  44764. */
  44765. static Download(blob: Blob, fileName: string): void;
  44766. /**
  44767. * Will return the right value of the noPreventDefault variable
  44768. * Needed to keep backwards compatibility to the old API.
  44769. *
  44770. * @param args arguments passed to the attachControl function
  44771. * @returns the correct value for noPreventDefault
  44772. */
  44773. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  44774. /**
  44775. * Captures a screenshot of the current rendering
  44776. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44777. * @param engine defines the rendering engine
  44778. * @param camera defines the source camera
  44779. * @param size This parameter can be set to a single number or to an object with the
  44780. * following (optional) properties: precision, width, height. If a single number is passed,
  44781. * it will be used for both width and height. If an object is passed, the screenshot size
  44782. * will be derived from the parameters. The precision property is a multiplier allowing
  44783. * rendering at a higher or lower resolution
  44784. * @param successCallback defines the callback receives a single parameter which contains the
  44785. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44786. * src parameter of an <img> to display it
  44787. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44788. * Check your browser for supported MIME types
  44789. */
  44790. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  44791. /**
  44792. * Captures a screenshot of the current rendering
  44793. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44794. * @param engine defines the rendering engine
  44795. * @param camera defines the source camera
  44796. * @param size This parameter can be set to a single number or to an object with the
  44797. * following (optional) properties: precision, width, height. If a single number is passed,
  44798. * it will be used for both width and height. If an object is passed, the screenshot size
  44799. * will be derived from the parameters. The precision property is a multiplier allowing
  44800. * rendering at a higher or lower resolution
  44801. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44802. * Check your browser for supported MIME types
  44803. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44804. * to the src parameter of an <img> to display it
  44805. */
  44806. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  44807. /**
  44808. * Generates an image screenshot from the specified camera.
  44809. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44810. * @param engine The engine to use for rendering
  44811. * @param camera The camera to use for rendering
  44812. * @param size This parameter can be set to a single number or to an object with the
  44813. * following (optional) properties: precision, width, height. If a single number is passed,
  44814. * it will be used for both width and height. If an object is passed, the screenshot size
  44815. * will be derived from the parameters. The precision property is a multiplier allowing
  44816. * rendering at a higher or lower resolution
  44817. * @param successCallback The callback receives a single parameter which contains the
  44818. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44819. * src parameter of an <img> to display it
  44820. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44821. * Check your browser for supported MIME types
  44822. * @param samples Texture samples (default: 1)
  44823. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44824. * @param fileName A name for for the downloaded file.
  44825. */
  44826. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  44827. /**
  44828. * Generates an image screenshot from the specified camera.
  44829. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44830. * @param engine The engine to use for rendering
  44831. * @param camera The camera to use for rendering
  44832. * @param size This parameter can be set to a single number or to an object with the
  44833. * following (optional) properties: precision, width, height. If a single number is passed,
  44834. * it will be used for both width and height. If an object is passed, the screenshot size
  44835. * will be derived from the parameters. The precision property is a multiplier allowing
  44836. * rendering at a higher or lower resolution
  44837. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44838. * Check your browser for supported MIME types
  44839. * @param samples Texture samples (default: 1)
  44840. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44841. * @param fileName A name for for the downloaded file.
  44842. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44843. * to the src parameter of an <img> to display it
  44844. */
  44845. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  44846. /**
  44847. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  44848. * Be aware Math.random() could cause collisions, but:
  44849. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  44850. * @returns a pseudo random id
  44851. */
  44852. static RandomId(): string;
  44853. /**
  44854. * Test if the given uri is a base64 string
  44855. * @param uri The uri to test
  44856. * @return True if the uri is a base64 string or false otherwise
  44857. */
  44858. static IsBase64(uri: string): boolean;
  44859. /**
  44860. * Decode the given base64 uri.
  44861. * @param uri The uri to decode
  44862. * @return The decoded base64 data.
  44863. */
  44864. static DecodeBase64(uri: string): ArrayBuffer;
  44865. /**
  44866. * Gets the absolute url.
  44867. * @param url the input url
  44868. * @return the absolute url
  44869. */
  44870. static GetAbsoluteUrl(url: string): string;
  44871. /**
  44872. * No log
  44873. */
  44874. static readonly NoneLogLevel: number;
  44875. /**
  44876. * Only message logs
  44877. */
  44878. static readonly MessageLogLevel: number;
  44879. /**
  44880. * Only warning logs
  44881. */
  44882. static readonly WarningLogLevel: number;
  44883. /**
  44884. * Only error logs
  44885. */
  44886. static readonly ErrorLogLevel: number;
  44887. /**
  44888. * All logs
  44889. */
  44890. static readonly AllLogLevel: number;
  44891. /**
  44892. * Gets a value indicating the number of loading errors
  44893. * @ignorenaming
  44894. */
  44895. static get errorsCount(): number;
  44896. /**
  44897. * Callback called when a new log is added
  44898. */
  44899. static OnNewCacheEntry: (entry: string) => void;
  44900. /**
  44901. * Log a message to the console
  44902. * @param message defines the message to log
  44903. */
  44904. static Log(message: string): void;
  44905. /**
  44906. * Write a warning message to the console
  44907. * @param message defines the message to log
  44908. */
  44909. static Warn(message: string): void;
  44910. /**
  44911. * Write an error message to the console
  44912. * @param message defines the message to log
  44913. */
  44914. static Error(message: string): void;
  44915. /**
  44916. * Gets current log cache (list of logs)
  44917. */
  44918. static get LogCache(): string;
  44919. /**
  44920. * Clears the log cache
  44921. */
  44922. static ClearLogCache(): void;
  44923. /**
  44924. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  44925. */
  44926. static set LogLevels(level: number);
  44927. /**
  44928. * Checks if the window object exists
  44929. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  44930. */
  44931. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  44932. /**
  44933. * No performance log
  44934. */
  44935. static readonly PerformanceNoneLogLevel: number;
  44936. /**
  44937. * Use user marks to log performance
  44938. */
  44939. static readonly PerformanceUserMarkLogLevel: number;
  44940. /**
  44941. * Log performance to the console
  44942. */
  44943. static readonly PerformanceConsoleLogLevel: number;
  44944. private static _performance;
  44945. /**
  44946. * Sets the current performance log level
  44947. */
  44948. static set PerformanceLogLevel(level: number);
  44949. private static _StartPerformanceCounterDisabled;
  44950. private static _EndPerformanceCounterDisabled;
  44951. private static _StartUserMark;
  44952. private static _EndUserMark;
  44953. private static _StartPerformanceConsole;
  44954. private static _EndPerformanceConsole;
  44955. /**
  44956. * Starts a performance counter
  44957. */
  44958. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44959. /**
  44960. * Ends a specific performance coutner
  44961. */
  44962. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44963. /**
  44964. * Gets either window.performance.now() if supported or Date.now() else
  44965. */
  44966. static get Now(): number;
  44967. /**
  44968. * This method will return the name of the class used to create the instance of the given object.
  44969. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  44970. * @param object the object to get the class name from
  44971. * @param isType defines if the object is actually a type
  44972. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  44973. */
  44974. static GetClassName(object: any, isType?: boolean): string;
  44975. /**
  44976. * Gets the first element of an array satisfying a given predicate
  44977. * @param array defines the array to browse
  44978. * @param predicate defines the predicate to use
  44979. * @returns null if not found or the element
  44980. */
  44981. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  44982. /**
  44983. * This method will return the name of the full name of the class, including its owning module (if any).
  44984. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  44985. * @param object the object to get the class name from
  44986. * @param isType defines if the object is actually a type
  44987. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  44988. * @ignorenaming
  44989. */
  44990. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  44991. /**
  44992. * Returns a promise that resolves after the given amount of time.
  44993. * @param delay Number of milliseconds to delay
  44994. * @returns Promise that resolves after the given amount of time
  44995. */
  44996. static DelayAsync(delay: number): Promise<void>;
  44997. /**
  44998. * Utility function to detect if the current user agent is Safari
  44999. * @returns whether or not the current user agent is safari
  45000. */
  45001. static IsSafari(): boolean;
  45002. }
  45003. /**
  45004. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  45005. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  45006. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  45007. * @param name The name of the class, case should be preserved
  45008. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  45009. */
  45010. export function className(name: string, module?: string): (target: Object) => void;
  45011. /**
  45012. * An implementation of a loop for asynchronous functions.
  45013. */
  45014. export class AsyncLoop {
  45015. /**
  45016. * Defines the number of iterations for the loop
  45017. */
  45018. iterations: number;
  45019. /**
  45020. * Defines the current index of the loop.
  45021. */
  45022. index: number;
  45023. private _done;
  45024. private _fn;
  45025. private _successCallback;
  45026. /**
  45027. * Constructor.
  45028. * @param iterations the number of iterations.
  45029. * @param func the function to run each iteration
  45030. * @param successCallback the callback that will be called upon succesful execution
  45031. * @param offset starting offset.
  45032. */
  45033. constructor(
  45034. /**
  45035. * Defines the number of iterations for the loop
  45036. */
  45037. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  45038. /**
  45039. * Execute the next iteration. Must be called after the last iteration was finished.
  45040. */
  45041. executeNext(): void;
  45042. /**
  45043. * Break the loop and run the success callback.
  45044. */
  45045. breakLoop(): void;
  45046. /**
  45047. * Create and run an async loop.
  45048. * @param iterations the number of iterations.
  45049. * @param fn the function to run each iteration
  45050. * @param successCallback the callback that will be called upon succesful execution
  45051. * @param offset starting offset.
  45052. * @returns the created async loop object
  45053. */
  45054. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  45055. /**
  45056. * A for-loop that will run a given number of iterations synchronous and the rest async.
  45057. * @param iterations total number of iterations
  45058. * @param syncedIterations number of synchronous iterations in each async iteration.
  45059. * @param fn the function to call each iteration.
  45060. * @param callback a success call back that will be called when iterating stops.
  45061. * @param breakFunction a break condition (optional)
  45062. * @param timeout timeout settings for the setTimeout function. default - 0.
  45063. * @returns the created async loop object
  45064. */
  45065. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  45066. }
  45067. }
  45068. declare module "babylonjs/Misc/stringDictionary" {
  45069. import { Nullable } from "babylonjs/types";
  45070. /**
  45071. * This class implement a typical dictionary using a string as key and the generic type T as value.
  45072. * The underlying implementation relies on an associative array to ensure the best performances.
  45073. * The value can be anything including 'null' but except 'undefined'
  45074. */
  45075. export class StringDictionary<T> {
  45076. /**
  45077. * This will clear this dictionary and copy the content from the 'source' one.
  45078. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  45079. * @param source the dictionary to take the content from and copy to this dictionary
  45080. */
  45081. copyFrom(source: StringDictionary<T>): void;
  45082. /**
  45083. * Get a value based from its key
  45084. * @param key the given key to get the matching value from
  45085. * @return the value if found, otherwise undefined is returned
  45086. */
  45087. get(key: string): T | undefined;
  45088. /**
  45089. * Get a value from its key or add it if it doesn't exist.
  45090. * This method will ensure you that a given key/data will be present in the dictionary.
  45091. * @param key the given key to get the matching value from
  45092. * @param factory the factory that will create the value if the key is not present in the dictionary.
  45093. * The factory will only be invoked if there's no data for the given key.
  45094. * @return the value corresponding to the key.
  45095. */
  45096. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  45097. /**
  45098. * Get a value from its key if present in the dictionary otherwise add it
  45099. * @param key the key to get the value from
  45100. * @param val if there's no such key/value pair in the dictionary add it with this value
  45101. * @return the value corresponding to the key
  45102. */
  45103. getOrAdd(key: string, val: T): T;
  45104. /**
  45105. * Check if there's a given key in the dictionary
  45106. * @param key the key to check for
  45107. * @return true if the key is present, false otherwise
  45108. */
  45109. contains(key: string): boolean;
  45110. /**
  45111. * Add a new key and its corresponding value
  45112. * @param key the key to add
  45113. * @param value the value corresponding to the key
  45114. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  45115. */
  45116. add(key: string, value: T): boolean;
  45117. /**
  45118. * Update a specific value associated to a key
  45119. * @param key defines the key to use
  45120. * @param value defines the value to store
  45121. * @returns true if the value was updated (or false if the key was not found)
  45122. */
  45123. set(key: string, value: T): boolean;
  45124. /**
  45125. * Get the element of the given key and remove it from the dictionary
  45126. * @param key defines the key to search
  45127. * @returns the value associated with the key or null if not found
  45128. */
  45129. getAndRemove(key: string): Nullable<T>;
  45130. /**
  45131. * Remove a key/value from the dictionary.
  45132. * @param key the key to remove
  45133. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  45134. */
  45135. remove(key: string): boolean;
  45136. /**
  45137. * Clear the whole content of the dictionary
  45138. */
  45139. clear(): void;
  45140. /**
  45141. * Gets the current count
  45142. */
  45143. get count(): number;
  45144. /**
  45145. * Execute a callback on each key/val of the dictionary.
  45146. * Note that you can remove any element in this dictionary in the callback implementation
  45147. * @param callback the callback to execute on a given key/value pair
  45148. */
  45149. forEach(callback: (key: string, val: T) => void): void;
  45150. /**
  45151. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  45152. * If the callback returns null or undefined the method will iterate to the next key/value pair
  45153. * Note that you can remove any element in this dictionary in the callback implementation
  45154. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  45155. * @returns the first item
  45156. */
  45157. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  45158. private _count;
  45159. private _data;
  45160. }
  45161. }
  45162. declare module "babylonjs/Collisions/collisionCoordinator" {
  45163. import { Nullable } from "babylonjs/types";
  45164. import { Scene } from "babylonjs/scene";
  45165. import { Vector3 } from "babylonjs/Maths/math.vector";
  45166. import { Collider } from "babylonjs/Collisions/collider";
  45167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45168. /** @hidden */
  45169. export interface ICollisionCoordinator {
  45170. createCollider(): Collider;
  45171. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45172. init(scene: Scene): void;
  45173. }
  45174. /** @hidden */
  45175. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  45176. private _scene;
  45177. private _scaledPosition;
  45178. private _scaledVelocity;
  45179. private _finalPosition;
  45180. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45181. createCollider(): Collider;
  45182. init(scene: Scene): void;
  45183. private _collideWithWorld;
  45184. }
  45185. }
  45186. declare module "babylonjs/Inputs/scene.inputManager" {
  45187. import { Nullable } from "babylonjs/types";
  45188. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45189. import { Vector2 } from "babylonjs/Maths/math.vector";
  45190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45191. import { Scene } from "babylonjs/scene";
  45192. /**
  45193. * Class used to manage all inputs for the scene.
  45194. */
  45195. export class InputManager {
  45196. /** The distance in pixel that you have to move to prevent some events */
  45197. static DragMovementThreshold: number;
  45198. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  45199. static LongPressDelay: number;
  45200. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  45201. static DoubleClickDelay: number;
  45202. /** If you need to check double click without raising a single click at first click, enable this flag */
  45203. static ExclusiveDoubleClickMode: boolean;
  45204. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  45205. private _alreadyAttached;
  45206. private _alreadyAttachedTo;
  45207. private _wheelEventName;
  45208. private _onPointerMove;
  45209. private _onPointerDown;
  45210. private _onPointerUp;
  45211. private _initClickEvent;
  45212. private _initActionManager;
  45213. private _delayedSimpleClick;
  45214. private _delayedSimpleClickTimeout;
  45215. private _previousDelayedSimpleClickTimeout;
  45216. private _meshPickProceed;
  45217. private _previousButtonPressed;
  45218. private _currentPickResult;
  45219. private _previousPickResult;
  45220. private _totalPointersPressed;
  45221. private _doubleClickOccured;
  45222. private _pointerOverMesh;
  45223. private _pickedDownMesh;
  45224. private _pickedUpMesh;
  45225. private _pointerX;
  45226. private _pointerY;
  45227. private _unTranslatedPointerX;
  45228. private _unTranslatedPointerY;
  45229. private _startingPointerPosition;
  45230. private _previousStartingPointerPosition;
  45231. private _startingPointerTime;
  45232. private _previousStartingPointerTime;
  45233. private _pointerCaptures;
  45234. private _meshUnderPointerId;
  45235. private _onKeyDown;
  45236. private _onKeyUp;
  45237. private _keyboardIsAttached;
  45238. private _onCanvasFocusObserver;
  45239. private _onCanvasBlurObserver;
  45240. private _scene;
  45241. /**
  45242. * Creates a new InputManager
  45243. * @param scene defines the hosting scene
  45244. */
  45245. constructor(scene: Scene);
  45246. /**
  45247. * Gets the mesh that is currently under the pointer
  45248. */
  45249. get meshUnderPointer(): Nullable<AbstractMesh>;
  45250. /**
  45251. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  45252. * @param pointerId the pointer id to use
  45253. * @returns The mesh under this pointer id or null if not found
  45254. */
  45255. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  45256. /**
  45257. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  45258. */
  45259. get unTranslatedPointer(): Vector2;
  45260. /**
  45261. * Gets or sets the current on-screen X position of the pointer
  45262. */
  45263. get pointerX(): number;
  45264. set pointerX(value: number);
  45265. /**
  45266. * Gets or sets the current on-screen Y position of the pointer
  45267. */
  45268. get pointerY(): number;
  45269. set pointerY(value: number);
  45270. private _updatePointerPosition;
  45271. private _processPointerMove;
  45272. private _setRayOnPointerInfo;
  45273. private _checkPrePointerObservable;
  45274. /**
  45275. * Use this method to simulate a pointer move on a mesh
  45276. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45277. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45278. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45279. */
  45280. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45281. /**
  45282. * Use this method to simulate a pointer down on a mesh
  45283. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45284. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45285. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45286. */
  45287. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45288. private _processPointerDown;
  45289. /** @hidden */
  45290. _isPointerSwiping(): boolean;
  45291. /**
  45292. * Use this method to simulate a pointer up on a mesh
  45293. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45294. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45295. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45296. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45297. */
  45298. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  45299. private _processPointerUp;
  45300. /**
  45301. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45302. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45303. * @returns true if the pointer was captured
  45304. */
  45305. isPointerCaptured(pointerId?: number): boolean;
  45306. /**
  45307. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45308. * @param attachUp defines if you want to attach events to pointerup
  45309. * @param attachDown defines if you want to attach events to pointerdown
  45310. * @param attachMove defines if you want to attach events to pointermove
  45311. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  45312. */
  45313. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  45314. /**
  45315. * Detaches all event handlers
  45316. */
  45317. detachControl(): void;
  45318. /**
  45319. * Force the value of meshUnderPointer
  45320. * @param mesh defines the mesh to use
  45321. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  45322. */
  45323. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45324. /**
  45325. * Gets the mesh under the pointer
  45326. * @returns a Mesh or null if no mesh is under the pointer
  45327. */
  45328. getPointerOverMesh(): Nullable<AbstractMesh>;
  45329. }
  45330. }
  45331. declare module "babylonjs/Animations/animationGroup" {
  45332. import { Animatable } from "babylonjs/Animations/animatable";
  45333. import { Animation } from "babylonjs/Animations/animation";
  45334. import { Scene, IDisposable } from "babylonjs/scene";
  45335. import { Observable } from "babylonjs/Misc/observable";
  45336. import { Nullable } from "babylonjs/types";
  45337. import "babylonjs/Animations/animatable";
  45338. /**
  45339. * This class defines the direct association between an animation and a target
  45340. */
  45341. export class TargetedAnimation {
  45342. /**
  45343. * Animation to perform
  45344. */
  45345. animation: Animation;
  45346. /**
  45347. * Target to animate
  45348. */
  45349. target: any;
  45350. /**
  45351. * Returns the string "TargetedAnimation"
  45352. * @returns "TargetedAnimation"
  45353. */
  45354. getClassName(): string;
  45355. /**
  45356. * Serialize the object
  45357. * @returns the JSON object representing the current entity
  45358. */
  45359. serialize(): any;
  45360. }
  45361. /**
  45362. * Use this class to create coordinated animations on multiple targets
  45363. */
  45364. export class AnimationGroup implements IDisposable {
  45365. /** The name of the animation group */
  45366. name: string;
  45367. private _scene;
  45368. private _targetedAnimations;
  45369. private _animatables;
  45370. private _from;
  45371. private _to;
  45372. private _isStarted;
  45373. private _isPaused;
  45374. private _speedRatio;
  45375. private _loopAnimation;
  45376. private _isAdditive;
  45377. /**
  45378. * Gets or sets the unique id of the node
  45379. */
  45380. uniqueId: number;
  45381. /**
  45382. * This observable will notify when one animation have ended
  45383. */
  45384. onAnimationEndObservable: Observable<TargetedAnimation>;
  45385. /**
  45386. * Observer raised when one animation loops
  45387. */
  45388. onAnimationLoopObservable: Observable<TargetedAnimation>;
  45389. /**
  45390. * Observer raised when all animations have looped
  45391. */
  45392. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  45393. /**
  45394. * This observable will notify when all animations have ended.
  45395. */
  45396. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  45397. /**
  45398. * This observable will notify when all animations have paused.
  45399. */
  45400. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  45401. /**
  45402. * This observable will notify when all animations are playing.
  45403. */
  45404. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  45405. /**
  45406. * Gets the first frame
  45407. */
  45408. get from(): number;
  45409. /**
  45410. * Gets the last frame
  45411. */
  45412. get to(): number;
  45413. /**
  45414. * Define if the animations are started
  45415. */
  45416. get isStarted(): boolean;
  45417. /**
  45418. * Gets a value indicating that the current group is playing
  45419. */
  45420. get isPlaying(): boolean;
  45421. /**
  45422. * Gets or sets the speed ratio to use for all animations
  45423. */
  45424. get speedRatio(): number;
  45425. /**
  45426. * Gets or sets the speed ratio to use for all animations
  45427. */
  45428. set speedRatio(value: number);
  45429. /**
  45430. * Gets or sets if all animations should loop or not
  45431. */
  45432. get loopAnimation(): boolean;
  45433. set loopAnimation(value: boolean);
  45434. /**
  45435. * Gets or sets if all animations should be evaluated additively
  45436. */
  45437. get isAdditive(): boolean;
  45438. set isAdditive(value: boolean);
  45439. /**
  45440. * Gets the targeted animations for this animation group
  45441. */
  45442. get targetedAnimations(): Array<TargetedAnimation>;
  45443. /**
  45444. * returning the list of animatables controlled by this animation group.
  45445. */
  45446. get animatables(): Array<Animatable>;
  45447. /**
  45448. * Gets the list of target animations
  45449. */
  45450. get children(): TargetedAnimation[];
  45451. /**
  45452. * Instantiates a new Animation Group.
  45453. * This helps managing several animations at once.
  45454. * @see https://doc.babylonjs.com/how_to/group
  45455. * @param name Defines the name of the group
  45456. * @param scene Defines the scene the group belongs to
  45457. */
  45458. constructor(
  45459. /** The name of the animation group */
  45460. name: string, scene?: Nullable<Scene>);
  45461. /**
  45462. * Add an animation (with its target) in the group
  45463. * @param animation defines the animation we want to add
  45464. * @param target defines the target of the animation
  45465. * @returns the TargetedAnimation object
  45466. */
  45467. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  45468. /**
  45469. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  45470. * It can add constant keys at begin or end
  45471. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  45472. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  45473. * @returns the animation group
  45474. */
  45475. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  45476. private _animationLoopCount;
  45477. private _animationLoopFlags;
  45478. private _processLoop;
  45479. /**
  45480. * Start all animations on given targets
  45481. * @param loop defines if animations must loop
  45482. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  45483. * @param from defines the from key (optional)
  45484. * @param to defines the to key (optional)
  45485. * @param isAdditive defines the additive state for the resulting animatables (optional)
  45486. * @returns the current animation group
  45487. */
  45488. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  45489. /**
  45490. * Pause all animations
  45491. * @returns the animation group
  45492. */
  45493. pause(): AnimationGroup;
  45494. /**
  45495. * Play all animations to initial state
  45496. * This function will start() the animations if they were not started or will restart() them if they were paused
  45497. * @param loop defines if animations must loop
  45498. * @returns the animation group
  45499. */
  45500. play(loop?: boolean): AnimationGroup;
  45501. /**
  45502. * Reset all animations to initial state
  45503. * @returns the animation group
  45504. */
  45505. reset(): AnimationGroup;
  45506. /**
  45507. * Restart animations from key 0
  45508. * @returns the animation group
  45509. */
  45510. restart(): AnimationGroup;
  45511. /**
  45512. * Stop all animations
  45513. * @returns the animation group
  45514. */
  45515. stop(): AnimationGroup;
  45516. /**
  45517. * Set animation weight for all animatables
  45518. * @param weight defines the weight to use
  45519. * @return the animationGroup
  45520. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45521. */
  45522. setWeightForAllAnimatables(weight: number): AnimationGroup;
  45523. /**
  45524. * Synchronize and normalize all animatables with a source animatable
  45525. * @param root defines the root animatable to synchronize with
  45526. * @return the animationGroup
  45527. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45528. */
  45529. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  45530. /**
  45531. * Goes to a specific frame in this animation group
  45532. * @param frame the frame number to go to
  45533. * @return the animationGroup
  45534. */
  45535. goToFrame(frame: number): AnimationGroup;
  45536. /**
  45537. * Dispose all associated resources
  45538. */
  45539. dispose(): void;
  45540. private _checkAnimationGroupEnded;
  45541. /**
  45542. * Clone the current animation group and returns a copy
  45543. * @param newName defines the name of the new group
  45544. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  45545. * @returns the new aniamtion group
  45546. */
  45547. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  45548. /**
  45549. * Serializes the animationGroup to an object
  45550. * @returns Serialized object
  45551. */
  45552. serialize(): any;
  45553. /**
  45554. * Returns a new AnimationGroup object parsed from the source provided.
  45555. * @param parsedAnimationGroup defines the source
  45556. * @param scene defines the scene that will receive the animationGroup
  45557. * @returns a new AnimationGroup
  45558. */
  45559. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  45560. /**
  45561. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  45562. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  45563. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  45564. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  45565. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  45566. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  45567. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  45568. */
  45569. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  45570. /**
  45571. * Returns the string "AnimationGroup"
  45572. * @returns "AnimationGroup"
  45573. */
  45574. getClassName(): string;
  45575. /**
  45576. * Creates a detailled string about the object
  45577. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  45578. * @returns a string representing the object
  45579. */
  45580. toString(fullDetails?: boolean): string;
  45581. }
  45582. }
  45583. declare module "babylonjs/Instrumentation/timeToken" {
  45584. import { Nullable } from "babylonjs/types";
  45585. /**
  45586. * @hidden
  45587. **/
  45588. export class _TimeToken {
  45589. _startTimeQuery: Nullable<WebGLQuery>;
  45590. _endTimeQuery: Nullable<WebGLQuery>;
  45591. _timeElapsedQuery: Nullable<WebGLQuery>;
  45592. _timeElapsedQueryEnded: boolean;
  45593. }
  45594. }
  45595. declare module "babylonjs/Engines/WebGPU/webgpuConstants" {
  45596. /** @hidden */
  45597. export enum ExtensionName {
  45598. DepthClamping = "depth-clamping",
  45599. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45600. Depth32FloatStencil8 = "depth32float-stencil8",
  45601. PipelineStatisticsQuery = "pipeline-statistics-query",
  45602. TextureCompressionBC = "texture-compression-bc",
  45603. TimestampQuery = "timestamp-query"
  45604. }
  45605. /** @hidden */
  45606. export enum AddressMode {
  45607. ClampToEdge = "clamp-to-edge",
  45608. Repeat = "repeat",
  45609. MirrorRepeat = "mirror-repeat"
  45610. }
  45611. /** @hidden */
  45612. export enum BindingType {
  45613. UniformBuffer = "uniform-buffer",
  45614. StorageBuffer = "storage-buffer",
  45615. ReadonlyStorageBuffer = "readonly-storage-buffer",
  45616. Sampler = "sampler",
  45617. ComparisonSampler = "comparison-sampler",
  45618. SampledTexture = "sampled-texture",
  45619. ReadonlyStorageTexture = "readonly-storage-texture",
  45620. WriteonlyStorageTexture = "writeonly-storage-texture"
  45621. }
  45622. /** @hidden */
  45623. export enum BlendFactor {
  45624. Zero = "zero",
  45625. One = "one",
  45626. SrcColor = "src-color",
  45627. OneMinusSrcColor = "one-minus-src-color",
  45628. SrcAlpha = "src-alpha",
  45629. OneMinusSrcAlpha = "one-minus-src-alpha",
  45630. DstColor = "dst-color",
  45631. OneMinusDstColor = "one-minus-dst-color",
  45632. DstAlpha = "dst-alpha",
  45633. OneMinusDstAlpha = "one-minus-dst-alpha",
  45634. SrcAlphaSaturated = "src-alpha-saturated",
  45635. BlendColor = "blend-color",
  45636. OneMinusBlendColor = "one-minus-blend-color"
  45637. }
  45638. /** @hidden */
  45639. export enum BlendOperation {
  45640. Add = "add",
  45641. Subtract = "subtract",
  45642. ReverseSubtract = "reverse-subtract",
  45643. Min = "min",
  45644. Max = "max"
  45645. }
  45646. /** @hidden */
  45647. export enum CompareFunction {
  45648. Never = "never",
  45649. Less = "less",
  45650. Equal = "equal",
  45651. LessEqual = "less-equal",
  45652. Greater = "greater",
  45653. NotEqual = "not-equal",
  45654. GreaterEqual = "greater-equal",
  45655. Always = "always"
  45656. }
  45657. /** @hidden */
  45658. export enum CullMode {
  45659. None = "none",
  45660. Front = "front",
  45661. Back = "back"
  45662. }
  45663. /** @hidden */
  45664. export enum FilterMode {
  45665. Nearest = "nearest",
  45666. Linear = "linear"
  45667. }
  45668. /** @hidden */
  45669. export enum FrontFace {
  45670. CCW = "ccw",
  45671. CW = "cw"
  45672. }
  45673. /** @hidden */
  45674. export enum IndexFormat {
  45675. Uint16 = "uint16",
  45676. Uint32 = "uint32"
  45677. }
  45678. /** @hidden */
  45679. export enum InputStepMode {
  45680. Vertex = "vertex",
  45681. Instance = "instance"
  45682. }
  45683. /** @hidden */
  45684. export enum LoadOp {
  45685. Load = "load"
  45686. }
  45687. /** @hidden */
  45688. export enum PrimitiveTopology {
  45689. PointList = "point-list",
  45690. LineList = "line-list",
  45691. LineStrip = "line-strip",
  45692. TriangleList = "triangle-list",
  45693. TriangleStrip = "triangle-strip"
  45694. }
  45695. /** @hidden */
  45696. export enum StencilOperation {
  45697. Keep = "keep",
  45698. Zero = "zero",
  45699. Replace = "replace",
  45700. Invert = "invert",
  45701. IncrementClamp = "increment-clamp",
  45702. DecrementClamp = "decrement-clamp",
  45703. IncrementWrap = "increment-wrap",
  45704. DecrementWrap = "decrement-wrap"
  45705. }
  45706. /** @hidden */
  45707. export enum StoreOp {
  45708. Store = "store",
  45709. Clear = "clear"
  45710. }
  45711. /** @hidden */
  45712. export enum TextureDimension {
  45713. E1d = "1d",
  45714. E2d = "2d",
  45715. E3d = "3d"
  45716. }
  45717. /** @hidden */
  45718. export enum TextureFormat {
  45719. R8Unorm = "r8unorm",
  45720. R8Snorm = "r8snorm",
  45721. R8Uint = "r8uint",
  45722. R8Sint = "r8sint",
  45723. R16Uint = "r16uint",
  45724. R16Sint = "r16sint",
  45725. R16Float = "r16float",
  45726. RG8Unorm = "rg8unorm",
  45727. RG8Snorm = "rg8snorm",
  45728. RG8Uint = "rg8uint",
  45729. RG8Sint = "rg8sint",
  45730. R32Uint = "r32uint",
  45731. R32Sint = "r32sint",
  45732. R32Float = "r32float",
  45733. RG16Uint = "rg16uint",
  45734. RG16Sint = "rg16sint",
  45735. RG16Float = "rg16float",
  45736. RGBA8Unorm = "rgba8unorm",
  45737. RGBA8UnormSRGB = "rgba8unorm-srgb",
  45738. RGBA8Snorm = "rgba8snorm",
  45739. RGBA8Uint = "rgba8uint",
  45740. RGBA8Sint = "rgba8sint",
  45741. BGRA8Unorm = "bgra8unorm",
  45742. BGRA8UnormSRGB = "bgra8unorm-srgb",
  45743. RGB9E5UFloat = "rgb9e5ufloat",
  45744. RGB10A2Unorm = "rgb10a2unorm",
  45745. RG11B10UFloat = "rg11b10ufloat",
  45746. RG32Uint = "rg32uint",
  45747. RG32Sint = "rg32sint",
  45748. RG32Float = "rg32float",
  45749. RGBA16Uint = "rgba16uint",
  45750. RGBA16Sint = "rgba16sint",
  45751. RGBA16Float = "rgba16float",
  45752. RGBA32Uint = "rgba32uint",
  45753. RGBA32Sint = "rgba32sint",
  45754. RGBA32Float = "rgba32float",
  45755. Stencil8 = "stencil8",
  45756. Depth16Unorm = "depth16unorm",
  45757. Depth24Plus = "depth24plus",
  45758. Depth24PlusStencil8 = "depth24plus-stencil8",
  45759. Depth32Float = "depth32float",
  45760. BC1RGBAUNorm = "bc1-rgba-unorm",
  45761. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  45762. BC2RGBAUnorm = "bc2-rgba-unorm",
  45763. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  45764. BC3RGBAUnorm = "bc3-rgba-unorm",
  45765. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  45766. BC4RUnorm = "bc4-r-unorm",
  45767. BC4RSnorm = "bc4-r-snorm",
  45768. BC5RGUnorm = "bc5-rg-unorm",
  45769. BC5RGSnorm = "bc5-rg-snorm",
  45770. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  45771. BC6HRGBFloat = "bc6h-rgb-float",
  45772. BC7RGBAUnorm = "bc7-rgba-unorm",
  45773. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  45774. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45775. Depth32FloatStencil8 = "depth32float-stencil8"
  45776. }
  45777. /** @hidden */
  45778. export enum TextureComponentType {
  45779. Float = "float",
  45780. Sint = "sint",
  45781. Uint = "uint",
  45782. DepthComparison = "depth-comparison"
  45783. }
  45784. /** @hidden */
  45785. export enum TextureViewDimension {
  45786. E1d = "1d",
  45787. E2d = "2d",
  45788. E2dArray = "2d-array",
  45789. Cube = "cube",
  45790. CubeArray = "cube-array",
  45791. E3d = "3d"
  45792. }
  45793. /** @hidden */
  45794. export enum VertexFormat {
  45795. Uchar2 = "uchar2",
  45796. Uchar4 = "uchar4",
  45797. Char2 = "char2",
  45798. Char4 = "char4",
  45799. Uchar2Norm = "uchar2norm",
  45800. Uchar4Norm = "uchar4norm",
  45801. Char2Norm = "char2norm",
  45802. Char4Norm = "char4norm",
  45803. Ushort2 = "ushort2",
  45804. Ushort4 = "ushort4",
  45805. Short2 = "short2",
  45806. Short4 = "short4",
  45807. Ushort2Norm = "ushort2norm",
  45808. Ushort4Norm = "ushort4norm",
  45809. Short2Norm = "short2norm",
  45810. Short4Norm = "short4norm",
  45811. Half2 = "half2",
  45812. Half4 = "half4",
  45813. Float = "float",
  45814. Float2 = "float2",
  45815. Float3 = "float3",
  45816. Float4 = "float4",
  45817. Uint = "uint",
  45818. Uint2 = "uint2",
  45819. Uint3 = "uint3",
  45820. Uint4 = "uint4",
  45821. Int = "int",
  45822. Int2 = "int2",
  45823. Int3 = "int3",
  45824. Int4 = "int4"
  45825. }
  45826. /** @hidden */
  45827. export enum TextureAspect {
  45828. All = "all",
  45829. StencilOnly = "stencil-only",
  45830. DepthOnly = "depth-only"
  45831. }
  45832. /** @hidden */
  45833. export enum CompilationMessageType {
  45834. Error = "error",
  45835. Warning = "warning",
  45836. Info = "info"
  45837. }
  45838. /** @hidden */
  45839. export enum QueryType {
  45840. Occlusion = "occlusion"
  45841. }
  45842. /** @hidden */
  45843. export enum BufferUsage {
  45844. MapRead = 1,
  45845. MapWrite = 2,
  45846. CopySrc = 4,
  45847. CopyDst = 8,
  45848. Index = 16,
  45849. Vertex = 32,
  45850. Uniform = 64,
  45851. Storage = 128,
  45852. Indirect = 256,
  45853. QueryResolve = 512
  45854. }
  45855. /** @hidden */
  45856. export enum ColorWrite {
  45857. Red = 1,
  45858. Green = 2,
  45859. Blue = 4,
  45860. Alpha = 8,
  45861. All = 15
  45862. }
  45863. /** @hidden */
  45864. export enum ShaderStage {
  45865. Vertex = 1,
  45866. Fragment = 2,
  45867. Compute = 4
  45868. }
  45869. /** @hidden */
  45870. export enum TextureUsage {
  45871. CopySrc = 1,
  45872. CopyDst = 2,
  45873. Sampled = 4,
  45874. Storage = 8,
  45875. OutputAttachment = 16
  45876. }
  45877. /** @hidden */
  45878. export enum MapMode {
  45879. Read = 1,
  45880. Write = 2
  45881. }
  45882. }
  45883. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext" {
  45884. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  45885. /** @hidden */
  45886. export interface WebGPUBindingInfo {
  45887. setIndex: number;
  45888. bindingIndex: number;
  45889. }
  45890. /** @hidden */
  45891. export interface WebGPUTextureSamplerBindingDescription {
  45892. sampler: WebGPUBindingInfo;
  45893. isTextureArray: boolean;
  45894. textures: Array<WebGPUBindingInfo>;
  45895. }
  45896. /** @hidden
  45897. * If the binding is a UBO, isSampler=isTexture=false
  45898. */
  45899. export interface WebGPUBindingDescription {
  45900. name: string;
  45901. usedInVertex: boolean;
  45902. usedInFragment: boolean;
  45903. isSampler: boolean;
  45904. isComparisonSampler?: boolean;
  45905. isTexture: boolean;
  45906. componentType?: GPUTextureComponentType;
  45907. textureDimension?: GPUTextureViewDimension;
  45908. }
  45909. /**
  45910. * @hidden
  45911. */
  45912. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  45913. uboNextBindingIndex: number;
  45914. freeSetIndex: number;
  45915. freeBindingIndex: number;
  45916. availableVaryings: {
  45917. [key: string]: number;
  45918. };
  45919. availableAttributes: {
  45920. [key: string]: number;
  45921. };
  45922. availableUBOs: {
  45923. [key: string]: {
  45924. setIndex: number;
  45925. bindingIndex: number;
  45926. };
  45927. };
  45928. availableSamplers: {
  45929. [key: string]: WebGPUTextureSamplerBindingDescription;
  45930. };
  45931. leftOverUniforms: {
  45932. name: string;
  45933. type: string;
  45934. length: number;
  45935. }[];
  45936. orderedAttributes: string[];
  45937. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  45938. uniformBufferNames: string[];
  45939. private _attributeNextLocation;
  45940. private _varyingNextLocation;
  45941. constructor();
  45942. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  45943. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  45944. getNextFreeUBOBinding(): {
  45945. setIndex: number;
  45946. bindingIndex: number;
  45947. };
  45948. private _getNextFreeBinding;
  45949. }
  45950. }
  45951. declare module "babylonjs/Engines/WebGPU/webgpuPipelineContext" {
  45952. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45953. import { Nullable } from "babylonjs/types";
  45954. import { WebGPUEngine } from "babylonjs/Engines/webgpuEngine";
  45955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45956. import { Effect } from "babylonjs/Materials/effect";
  45957. import { WebGPUShaderProcessingContext } from "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext";
  45958. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45959. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  45960. /** @hidden */
  45961. export interface IWebGPUPipelineContextSamplerCache {
  45962. samplerBinding: number;
  45963. firstTextureName: string;
  45964. }
  45965. /** @hidden */
  45966. export interface IWebGPUPipelineContextTextureCache {
  45967. textureBinding: number;
  45968. texture: InternalTexture;
  45969. }
  45970. /** @hidden */
  45971. export interface IWebGPUPipelineContextVertexInputsCache {
  45972. indexBuffer: Nullable<GPUBuffer>;
  45973. indexOffset: number;
  45974. vertexStartSlot: number;
  45975. vertexBuffers: GPUBuffer[];
  45976. vertexOffsets: number[];
  45977. }
  45978. /** @hidden */
  45979. export interface IWebGPURenderPipelineStageDescriptor {
  45980. vertexStage: GPUProgrammableStageDescriptor;
  45981. fragmentStage?: GPUProgrammableStageDescriptor;
  45982. }
  45983. /** @hidden */
  45984. export class WebGPUPipelineContext implements IPipelineContext {
  45985. engine: WebGPUEngine;
  45986. shaderProcessingContext: WebGPUShaderProcessingContext;
  45987. leftOverUniformsByName: {
  45988. [name: string]: string;
  45989. };
  45990. sources: {
  45991. vertex: string;
  45992. fragment: string;
  45993. rawVertex: string;
  45994. rawFragment: string;
  45995. };
  45996. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  45997. samplers: {
  45998. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  45999. };
  46000. textures: {
  46001. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  46002. };
  46003. bindGroupLayouts: GPUBindGroupLayout[];
  46004. bindGroupsCache: {
  46005. [key: string]: GPUBindGroup[];
  46006. };
  46007. /**
  46008. * Stores the uniform buffer
  46009. */
  46010. uniformBuffer: Nullable<UniformBuffer>;
  46011. onCompiled?: () => void;
  46012. get isAsync(): boolean;
  46013. get isReady(): boolean;
  46014. /** @hidden */
  46015. _name: string;
  46016. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  46017. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  46018. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  46019. [key: string]: number;
  46020. }, uniformsNames: string[], uniforms: {
  46021. [key: string]: Nullable<WebGLUniformLocation>;
  46022. }, samplerList: string[], samplers: {
  46023. [key: string]: number;
  46024. }, attributesNames: string[], attributes: number[]): void;
  46025. /** @hidden */
  46026. /**
  46027. * Build the uniform buffer used in the material.
  46028. */
  46029. buildUniformLayout(): void;
  46030. /**
  46031. * Release all associated resources.
  46032. **/
  46033. dispose(): void;
  46034. /**
  46035. * Sets an integer value on a uniform variable.
  46036. * @param uniformName Name of the variable.
  46037. * @param value Value to be set.
  46038. */
  46039. setInt(uniformName: string, value: number): void;
  46040. /**
  46041. * Sets an int2 value on a uniform variable.
  46042. * @param uniformName Name of the variable.
  46043. * @param x First int in int2.
  46044. * @param y Second int in int2.
  46045. */
  46046. setInt2(uniformName: string, x: number, y: number): void;
  46047. /**
  46048. * Sets an int3 value on a uniform variable.
  46049. * @param uniformName Name of the variable.
  46050. * @param x First int in int3.
  46051. * @param y Second int in int3.
  46052. * @param z Third int in int3.
  46053. */
  46054. setInt3(uniformName: string, x: number, y: number, z: number): void;
  46055. /**
  46056. * Sets an int4 value on a uniform variable.
  46057. * @param uniformName Name of the variable.
  46058. * @param x First int in int4.
  46059. * @param y Second int in int4.
  46060. * @param z Third int in int4.
  46061. * @param w Fourth int in int4.
  46062. */
  46063. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  46064. /**
  46065. * Sets an int array on a uniform variable.
  46066. * @param uniformName Name of the variable.
  46067. * @param array array to be set.
  46068. */
  46069. setIntArray(uniformName: string, array: Int32Array): void;
  46070. /**
  46071. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  46072. * @param uniformName Name of the variable.
  46073. * @param array array to be set.
  46074. */
  46075. setIntArray2(uniformName: string, array: Int32Array): void;
  46076. /**
  46077. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  46078. * @param uniformName Name of the variable.
  46079. * @param array array to be set.
  46080. */
  46081. setIntArray3(uniformName: string, array: Int32Array): void;
  46082. /**
  46083. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  46084. * @param uniformName Name of the variable.
  46085. * @param array array to be set.
  46086. */
  46087. setIntArray4(uniformName: string, array: Int32Array): void;
  46088. /**
  46089. * Sets an array on a uniform variable.
  46090. * @param uniformName Name of the variable.
  46091. * @param array array to be set.
  46092. */
  46093. setArray(uniformName: string, array: number[]): void;
  46094. /**
  46095. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  46096. * @param uniformName Name of the variable.
  46097. * @param array array to be set.
  46098. */
  46099. setArray2(uniformName: string, array: number[]): void;
  46100. /**
  46101. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  46102. * @param uniformName Name of the variable.
  46103. * @param array array to be set.
  46104. * @returns this effect.
  46105. */
  46106. setArray3(uniformName: string, array: number[]): void;
  46107. /**
  46108. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  46109. * @param uniformName Name of the variable.
  46110. * @param array array to be set.
  46111. */
  46112. setArray4(uniformName: string, array: number[]): void;
  46113. /**
  46114. * Sets matrices on a uniform variable.
  46115. * @param uniformName Name of the variable.
  46116. * @param matrices matrices to be set.
  46117. */
  46118. setMatrices(uniformName: string, matrices: Float32Array): void;
  46119. /**
  46120. * Sets matrix on a uniform variable.
  46121. * @param uniformName Name of the variable.
  46122. * @param matrix matrix to be set.
  46123. */
  46124. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  46125. /**
  46126. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  46127. * @param uniformName Name of the variable.
  46128. * @param matrix matrix to be set.
  46129. */
  46130. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  46131. /**
  46132. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  46133. * @param uniformName Name of the variable.
  46134. * @param matrix matrix to be set.
  46135. */
  46136. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  46137. /**
  46138. * Sets a float on a uniform variable.
  46139. * @param uniformName Name of the variable.
  46140. * @param value value to be set.
  46141. * @returns this effect.
  46142. */
  46143. setFloat(uniformName: string, value: number): void;
  46144. /**
  46145. * Sets a Vector2 on a uniform variable.
  46146. * @param uniformName Name of the variable.
  46147. * @param vector2 vector2 to be set.
  46148. */
  46149. setVector2(uniformName: string, vector2: IVector2Like): void;
  46150. /**
  46151. * Sets a float2 on a uniform variable.
  46152. * @param uniformName Name of the variable.
  46153. * @param x First float in float2.
  46154. * @param y Second float in float2.
  46155. */
  46156. setFloat2(uniformName: string, x: number, y: number): void;
  46157. /**
  46158. * Sets a Vector3 on a uniform variable.
  46159. * @param uniformName Name of the variable.
  46160. * @param vector3 Value to be set.
  46161. */
  46162. setVector3(uniformName: string, vector3: IVector3Like): void;
  46163. /**
  46164. * Sets a float3 on a uniform variable.
  46165. * @param uniformName Name of the variable.
  46166. * @param x First float in float3.
  46167. * @param y Second float in float3.
  46168. * @param z Third float in float3.
  46169. */
  46170. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  46171. /**
  46172. * Sets a Vector4 on a uniform variable.
  46173. * @param uniformName Name of the variable.
  46174. * @param vector4 Value to be set.
  46175. */
  46176. setVector4(uniformName: string, vector4: IVector4Like): void;
  46177. /**
  46178. * Sets a float4 on a uniform variable.
  46179. * @param uniformName Name of the variable.
  46180. * @param x First float in float4.
  46181. * @param y Second float in float4.
  46182. * @param z Third float in float4.
  46183. * @param w Fourth float in float4.
  46184. * @returns this effect.
  46185. */
  46186. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  46187. /**
  46188. * Sets a Color3 on a uniform variable.
  46189. * @param uniformName Name of the variable.
  46190. * @param color3 Value to be set.
  46191. */
  46192. setColor3(uniformName: string, color3: IColor3Like): void;
  46193. /**
  46194. * Sets a Color4 on a uniform variable.
  46195. * @param uniformName Name of the variable.
  46196. * @param color3 Value to be set.
  46197. * @param alpha Alpha value to be set.
  46198. */
  46199. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  46200. /**
  46201. * Sets a Color4 on a uniform variable
  46202. * @param uniformName defines the name of the variable
  46203. * @param color4 defines the value to be set
  46204. */
  46205. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  46206. _getVertexShaderCode(): string | null;
  46207. _getFragmentShaderCode(): string | null;
  46208. }
  46209. }
  46210. declare module "babylonjs/Meshes/WebGPU/webgpuDataBuffer" {
  46211. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46212. /** @hidden */
  46213. export class WebGPUDataBuffer extends DataBuffer {
  46214. private _buffer;
  46215. constructor(resource: GPUBuffer);
  46216. get underlyingResource(): any;
  46217. }
  46218. }
  46219. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  46220. /**
  46221. * Class used to inline functions in shader code
  46222. */
  46223. export class ShaderCodeInliner {
  46224. private static readonly _RegexpFindFunctionNameAndType;
  46225. private _sourceCode;
  46226. private _functionDescr;
  46227. private _numMaxIterations;
  46228. /** Gets or sets the token used to mark the functions to inline */
  46229. inlineToken: string;
  46230. /** Gets or sets the debug mode */
  46231. debug: boolean;
  46232. /** Gets the code after the inlining process */
  46233. get code(): string;
  46234. /**
  46235. * Initializes the inliner
  46236. * @param sourceCode shader code source to inline
  46237. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  46238. */
  46239. constructor(sourceCode: string, numMaxIterations?: number);
  46240. /**
  46241. * Start the processing of the shader code
  46242. */
  46243. processCode(): void;
  46244. private _collectFunctions;
  46245. private _processInlining;
  46246. private _extractBetweenMarkers;
  46247. private _skipWhitespaces;
  46248. private _isIdentifierChar;
  46249. private _removeComments;
  46250. private _replaceFunctionCallsByCode;
  46251. private _findBackward;
  46252. private _escapeRegExp;
  46253. private _replaceNames;
  46254. }
  46255. }
  46256. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessors" {
  46257. import { Nullable } from "babylonjs/types";
  46258. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46259. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46260. /** @hidden */
  46261. export class WebGPUShaderProcessor implements IShaderProcessor {
  46262. protected _missingVaryings: Array<string>;
  46263. protected _textureArrayProcessing: Array<string>;
  46264. protected _preProcessors: {
  46265. [key: string]: string;
  46266. };
  46267. private _getArraySize;
  46268. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  46269. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  46270. [key: string]: string;
  46271. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46272. attributeProcessor(attribute: string, preProcessors: {
  46273. [key: string]: string;
  46274. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46275. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  46276. [key: string]: string;
  46277. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46278. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46279. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46280. private _applyTextureArrayProcessing;
  46281. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  46282. vertexCode: string;
  46283. fragmentCode: string;
  46284. };
  46285. }
  46286. }
  46287. declare module "babylonjs/Engines/WebGPU/webgpuBufferManager" {
  46288. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46289. import { WebGPUDataBuffer } from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  46290. import { Nullable } from "babylonjs/types";
  46291. /** @hidden */
  46292. export class WebGPUBufferManager {
  46293. private _device;
  46294. private _deferredReleaseBuffers;
  46295. private static _IsGPUBuffer;
  46296. constructor(device: GPUDevice);
  46297. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  46298. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  46299. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  46300. private _FromHalfFloat;
  46301. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  46302. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  46303. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  46304. destroyDeferredBuffers(): void;
  46305. }
  46306. }
  46307. declare module "babylonjs/Engines/WebGPU/webgpuHardwareTexture" {
  46308. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46309. import { Nullable } from "babylonjs/types";
  46310. /** @hidden */
  46311. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  46312. private _webgpuTexture;
  46313. private _webgpuMSAATexture;
  46314. get underlyingResource(): Nullable<GPUTexture>;
  46315. get msaaTexture(): Nullable<GPUTexture>;
  46316. set msaaTexture(texture: Nullable<GPUTexture>);
  46317. view: Nullable<GPUTextureView>;
  46318. format: GPUTextureFormat;
  46319. textureUsages: number;
  46320. constructor(existingTexture?: Nullable<GPUTexture>);
  46321. set(hardwareTexture: GPUTexture): void;
  46322. setMSAATexture(hardwareTexture: GPUTexture): void;
  46323. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  46324. createView(descriptor?: GPUTextureViewDescriptor): void;
  46325. reset(): void;
  46326. release(): void;
  46327. }
  46328. }
  46329. declare module "babylonjs/Engines/WebGPU/webgpuTextureHelper" {
  46330. import { WebGPUBufferManager } from "babylonjs/Engines/WebGPU/webgpuBufferManager";
  46331. import { Nullable } from "babylonjs/types";
  46332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46333. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46334. import { IColor4Like } from "babylonjs/Maths/math.like";
  46335. /** @hidden */
  46336. export class WebGPUTextureHelper {
  46337. private _device;
  46338. private _glslang;
  46339. private _bufferManager;
  46340. private _mipmapSampler;
  46341. private _invertYPreMultiplyAlphaSampler;
  46342. private _pipelines;
  46343. private _compiledShaders;
  46344. private _deferredReleaseTextures;
  46345. private _commandEncoderForCreation;
  46346. static ComputeNumMipmapLevels(width: number, height: number): number;
  46347. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  46348. private _getPipeline;
  46349. private static _GetTextureTypeFromFormat;
  46350. private static _GetBlockInformationFromFormat;
  46351. private static _IsHardwareTexture;
  46352. private static _IsInternalTexture;
  46353. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  46354. static IsImageBitmap(imageBitmap: ImageBitmap | {
  46355. width: number;
  46356. height: number;
  46357. }): imageBitmap is ImageBitmap;
  46358. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  46359. width: number;
  46360. height: number;
  46361. }): imageBitmap is ImageBitmap[];
  46362. setCommandEncoder(encoder: GPUCommandEncoder): void;
  46363. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  46364. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  46365. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46366. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  46367. createTexture(imageBitmap: ImageBitmap | {
  46368. width: number;
  46369. height: number;
  46370. layers: number;
  46371. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46372. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  46373. width: number;
  46374. height: number;
  46375. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46376. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  46377. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46378. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  46379. createMSAATexture(texture: InternalTexture, samples: number): void;
  46380. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  46381. updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  46382. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  46383. releaseTexture(texture: InternalTexture | GPUTexture): void;
  46384. destroyDeferredTextures(): void;
  46385. }
  46386. }
  46387. declare module "babylonjs/Engines/WebGPU/webgpuRenderPassWrapper" {
  46388. import { Nullable } from "babylonjs/types";
  46389. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46390. /** @hidden */
  46391. export class WebGPURenderPassWrapper {
  46392. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  46393. renderPass: Nullable<GPURenderPassEncoder>;
  46394. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46395. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46396. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  46397. depthTextureFormat: GPUTextureFormat | undefined;
  46398. constructor();
  46399. reset(fullReset?: boolean): void;
  46400. }
  46401. }
  46402. declare module "babylonjs/Engines/WebGPU/webgpuCacheSampler" {
  46403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46404. /** @hidden */
  46405. export class WebGPUCacheSampler {
  46406. private _samplers;
  46407. private _device;
  46408. disabled: boolean;
  46409. constructor(device: GPUDevice);
  46410. private static _GetSamplerHashCode;
  46411. private static _GetSamplerFilterDescriptor;
  46412. private static _GetWrappingMode;
  46413. private static _GetSamplerWrappingDescriptor;
  46414. private static _GetSamplerDescriptor;
  46415. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  46416. }
  46417. }
  46418. declare module "babylonjs/Engines/WebGPU/webgpuShaderManager" {
  46419. import { IWebGPURenderPipelineStageDescriptor } from "babylonjs/Engines/WebGPU/webgpuPipelineContext";
  46420. /** @hidden */
  46421. export class WebGPUShaderManager {
  46422. private _shaders;
  46423. private _device;
  46424. constructor(device: GPUDevice);
  46425. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  46426. }
  46427. }
  46428. declare module "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline" {
  46429. import { Effect } from "babylonjs/Materials/effect";
  46430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46431. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46432. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46433. import { Nullable } from "babylonjs/types";
  46434. /** @hidden */
  46435. export class WebGPUCacheRenderPipeline {
  46436. static NumCacheHitWithoutHash: number;
  46437. static NumCacheHitWithHash: number;
  46438. static NumCacheMiss: number;
  46439. static NumPipelineCreationLastFrame: number;
  46440. disabled: boolean;
  46441. private static _Cache;
  46442. private static _NumPipelineCreationCurrentFrame;
  46443. private _device;
  46444. private _states;
  46445. private _isDirty;
  46446. private _currentRenderPipeline;
  46447. private _emptyVertexBuffer;
  46448. private _shaderId;
  46449. private _alphaToCoverageEnabled;
  46450. private _frontFace;
  46451. private _cullEnabled;
  46452. private _cullFace;
  46453. private _clampDepth;
  46454. private _rasterizationState;
  46455. private _depthBias;
  46456. private _depthBiasClamp;
  46457. private _depthBiasSlopeScale;
  46458. private _colorFormat;
  46459. private _webgpuColorFormat;
  46460. private _mrtAttachments1;
  46461. private _mrtAttachments2;
  46462. private _mrtFormats;
  46463. private _alphaBlendEnabled;
  46464. private _alphaBlendFuncParams;
  46465. private _alphaBlendEqParams;
  46466. private _writeMask;
  46467. private _colorStates;
  46468. private _depthStencilFormat;
  46469. private _webgpuDepthStencilFormat;
  46470. private _depthTestEnabled;
  46471. private _depthWriteEnabled;
  46472. private _depthCompare;
  46473. private _stencilEnabled;
  46474. private _stencilFrontCompare;
  46475. private _stencilFrontDepthFailOp;
  46476. private _stencilFrontPassOp;
  46477. private _stencilFrontFailOp;
  46478. private _stencilReadMask;
  46479. private _stencilWriteMask;
  46480. private _depthStencilState;
  46481. private _vertexBuffers;
  46482. private _overrideVertexBuffers;
  46483. private _indexBuffer;
  46484. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  46485. reset(): void;
  46486. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  46487. endFrame(): void;
  46488. setAlphaToCoverage(enabled: boolean): void;
  46489. setFrontFace(frontFace: number): void;
  46490. setCullEnabled(enabled: boolean): void;
  46491. setCullFace(cullFace: number): void;
  46492. setClampDepth(clampDepth: boolean): void;
  46493. resetDepthCullingState(): void;
  46494. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  46495. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  46496. setColorFormat(format: GPUTextureFormat): void;
  46497. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  46498. setAlphaBlendEnabled(enabled: boolean): void;
  46499. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  46500. setWriteMask(mask: number): void;
  46501. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  46502. setDepthTestEnabled(enabled: boolean): void;
  46503. setDepthWriteEnabled(enabled: boolean): void;
  46504. setDepthCompare(func: Nullable<number>): void;
  46505. setStencilEnabled(enabled: boolean): void;
  46506. setStencilCompare(func: Nullable<number>): void;
  46507. setStencilDepthFailOp(op: Nullable<number>): void;
  46508. setStencilPassOp(op: Nullable<number>): void;
  46509. setStencilFailOp(op: Nullable<number>): void;
  46510. setStencilReadMask(mask: number): void;
  46511. setStencilWriteMask(mask: number): void;
  46512. resetStencilState(): void;
  46513. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  46514. setBuffers(vertexBuffers: Nullable<{
  46515. [key: string]: Nullable<VertexBuffer>;
  46516. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  46517. [key: string]: Nullable<VertexBuffer>;
  46518. }>): void;
  46519. private static _GetTopology;
  46520. private static _GetAphaBlendOperation;
  46521. private static _GetAphaBlendFactor;
  46522. private static _GetCompareFunction;
  46523. private static _GetStencilOpFunction;
  46524. private static _GetVertexInputDescriptorFormat;
  46525. private _getAphaBlendState;
  46526. private _getColorBlendState;
  46527. private _setShaderStage;
  46528. private _setRasterizationState;
  46529. private _setColorStates;
  46530. private _setDepthStencilState;
  46531. private _setVertexState;
  46532. private _createPipelineLayout;
  46533. private _getVertexInputDescriptor;
  46534. private _createRenderPipeline;
  46535. }
  46536. }
  46537. declare module "babylonjs/Shaders/clearQuad.vertex" {
  46538. /** @hidden */
  46539. export var clearQuadVertexShader: {
  46540. name: string;
  46541. shader: string;
  46542. };
  46543. }
  46544. declare module "babylonjs/Shaders/clearQuad.fragment" {
  46545. /** @hidden */
  46546. export var clearQuadPixelShader: {
  46547. name: string;
  46548. shader: string;
  46549. };
  46550. }
  46551. declare module "babylonjs/Engines/webgpuEngine" {
  46552. import { Nullable, DataArray, IndicesArray, FloatArray, Immutable } from "babylonjs/types";
  46553. import { Engine } from "babylonjs/Engines/engine";
  46554. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  46555. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46556. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46557. import { IEffectCreationOptions, Effect } from "babylonjs/Materials/effect";
  46558. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  46559. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46560. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46561. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46563. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46564. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46565. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  46566. import { Scene } from "babylonjs/scene";
  46567. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  46568. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46569. import { IColor4Like } from "babylonjs/Maths/math.like";
  46570. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46571. import "babylonjs/Shaders/clearQuad.vertex";
  46572. import "babylonjs/Shaders/clearQuad.fragment";
  46573. /**
  46574. * Options to load the associated Glslang library
  46575. */
  46576. export interface GlslangOptions {
  46577. /**
  46578. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  46579. */
  46580. glslang?: any;
  46581. /**
  46582. * Defines the URL of the glslang JS File.
  46583. */
  46584. jsPath?: string;
  46585. /**
  46586. * Defines the URL of the glslang WASM File.
  46587. */
  46588. wasmPath?: string;
  46589. }
  46590. /**
  46591. * Options to create the WebGPU engine
  46592. */
  46593. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  46594. /**
  46595. * If delta time between frames should be constant
  46596. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46597. */
  46598. deterministicLockstep?: boolean;
  46599. /**
  46600. * Maximum about of steps between frames (Default: 4)
  46601. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46602. */
  46603. lockstepMaxSteps?: number;
  46604. /**
  46605. * Defines the seconds between each deterministic lock step
  46606. */
  46607. timeStep?: number;
  46608. /**
  46609. * Defines that engine should ignore modifying touch action attribute and style
  46610. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  46611. */
  46612. doNotHandleTouchAction?: boolean;
  46613. /**
  46614. * Defines if webaudio should be initialized as well
  46615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  46616. */
  46617. audioEngine?: boolean;
  46618. /**
  46619. * Defines the category of adapter to use.
  46620. * Is it the discrete or integrated device.
  46621. */
  46622. powerPreference?: GPUPowerPreference;
  46623. /**
  46624. * Defines the device descriptor used to create a device.
  46625. */
  46626. deviceDescriptor?: GPUDeviceDescriptor;
  46627. /**
  46628. * Defines the requested Swap Chain Format.
  46629. */
  46630. swapChainFormat?: GPUTextureFormat;
  46631. /**
  46632. * Defines wether MSAA is enabled on the canvas.
  46633. */
  46634. antialiasing?: boolean;
  46635. /**
  46636. * Defines wether the stencil buffer should be enabled.
  46637. */
  46638. stencil?: boolean;
  46639. /**
  46640. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  46641. */
  46642. enableGPUDebugMarkers?: boolean;
  46643. /**
  46644. * Options to load the associated Glslang library
  46645. */
  46646. glslangOptions?: GlslangOptions;
  46647. }
  46648. /**
  46649. * The web GPU engine class provides support for WebGPU version of babylon.js.
  46650. */
  46651. export class WebGPUEngine extends Engine {
  46652. private static readonly _glslangDefaultOptions;
  46653. private readonly _uploadEncoderDescriptor;
  46654. private readonly _renderEncoderDescriptor;
  46655. private readonly _renderTargetEncoderDescriptor;
  46656. private readonly _clearDepthValue;
  46657. private readonly _clearReverseDepthValue;
  46658. private readonly _clearStencilValue;
  46659. private readonly _defaultSampleCount;
  46660. private _canvas;
  46661. private _options;
  46662. private _glslang;
  46663. private _adapter;
  46664. private _adapterSupportedExtensions;
  46665. private _device;
  46666. private _deviceEnabledExtensions;
  46667. private _context;
  46668. private _swapChain;
  46669. private _swapChainTexture;
  46670. private _mainPassSampleCount;
  46671. private _textureHelper;
  46672. private _bufferManager;
  46673. private _shaderManager;
  46674. private _cacheSampler;
  46675. private _cacheRenderPipeline;
  46676. private _emptyVertexBuffer;
  46677. private _lastCachedWrapU;
  46678. private _lastCachedWrapV;
  46679. private _lastCachedWrapR;
  46680. private _mrtAttachments;
  46681. private _counters;
  46682. private _mainTexture;
  46683. private _depthTexture;
  46684. private _mainTextureExtends;
  46685. private _depthTextureFormat;
  46686. private _colorFormat;
  46687. private _uploadEncoder;
  46688. private _renderEncoder;
  46689. private _renderTargetEncoder;
  46690. private _commandBuffers;
  46691. private _currentRenderPass;
  46692. private _mainRenderPassWrapper;
  46693. private _rttRenderPassWrapper;
  46694. private _pendingDebugCommands;
  46695. private _currentVertexBuffers;
  46696. private _currentOverrideVertexBuffers;
  46697. private _currentIndexBuffer;
  46698. private __colorWrite;
  46699. private _uniformsBuffers;
  46700. private _forceEnableEffect;
  46701. /** @hidden */
  46702. dbgShowShaderCode: boolean;
  46703. /** @hidden */
  46704. dbgSanityChecks: boolean;
  46705. /** @hidden */
  46706. dbgGenerateLogs: boolean;
  46707. /** @hidden */
  46708. dbgVerboseLogsForFirstFrames: boolean;
  46709. /** @hidden */
  46710. dbgVerboseLogsNumFrames: number;
  46711. /** @hidden */
  46712. dbgShowWarningsNotImplemented: boolean;
  46713. /**
  46714. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  46715. */
  46716. get disableCacheSamplers(): boolean;
  46717. set disableCacheSamplers(disable: boolean);
  46718. /**
  46719. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  46720. */
  46721. get disableCacheRenderPipelines(): boolean;
  46722. set disableCacheRenderPipelines(disable: boolean);
  46723. /**
  46724. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  46725. * @returns true if the engine can be created
  46726. */
  46727. static get IsSupported(): boolean;
  46728. /**
  46729. * Gets a boolean indicating that the engine supports uniform buffers
  46730. */
  46731. get supportsUniformBuffers(): boolean;
  46732. /** Gets the supported extensions by the WebGPU adapter */
  46733. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  46734. /** Gets the currently enabled extensions on the WebGPU device */
  46735. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  46736. /**
  46737. * Returns the name of the engine
  46738. */
  46739. get name(): string;
  46740. /**
  46741. * Returns a string describing the current engine
  46742. */
  46743. get description(): string;
  46744. /**
  46745. * Returns the version of the engine
  46746. */
  46747. get version(): number;
  46748. /**
  46749. * Create a new instance of the gpu engine asynchronously
  46750. * @param canvas Defines the canvas to use to display the result
  46751. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46752. * @returns a promise that resolves with the created engine
  46753. */
  46754. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  46755. /**
  46756. * Create a new instance of the gpu engine.
  46757. * @param canvas Defines the canvas to use to display the result
  46758. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46759. */
  46760. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  46761. /**
  46762. * Initializes the WebGPU context and dependencies.
  46763. * @param glslangOptions Defines the GLSLang compiler options if necessary
  46764. * @returns a promise notifying the readiness of the engine.
  46765. */
  46766. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  46767. private _initGlslang;
  46768. private _initializeLimits;
  46769. private _initializeContextAndSwapChain;
  46770. private _initializeMainAttachments;
  46771. /**
  46772. * Force a specific size of the canvas
  46773. * @param width defines the new canvas' width
  46774. * @param height defines the new canvas' height
  46775. * @param forceSetSize true to force setting the sizes of the underlying canvas
  46776. * @returns true if the size was changed
  46777. */
  46778. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  46779. /**
  46780. * Gets a shader processor implementation fitting with the current engine type.
  46781. * @returns The shader processor implementation.
  46782. */
  46783. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  46784. /** @hidden */
  46785. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  46786. /**
  46787. * Force the entire cache to be cleared
  46788. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  46789. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46790. */
  46791. wipeCaches(bruteForce?: boolean): void;
  46792. /**
  46793. * Enable or disable color writing
  46794. * @param enable defines the state to set
  46795. */
  46796. setColorWrite(enable: boolean): void;
  46797. /**
  46798. * Gets a boolean indicating if color writing is enabled
  46799. * @returns the current color writing state
  46800. */
  46801. getColorWrite(): boolean;
  46802. private _viewportsCurrent;
  46803. private _resetCurrentViewport;
  46804. private _applyViewport;
  46805. /** @hidden */
  46806. _viewport(x: number, y: number, width: number, height: number): void;
  46807. private _scissorsCurrent;
  46808. protected _scissorCached: {
  46809. x: number;
  46810. y: number;
  46811. z: number;
  46812. w: number;
  46813. };
  46814. private _resetCurrentScissor;
  46815. private _applyScissor;
  46816. private _scissorIsActive;
  46817. enableScissor(x: number, y: number, width: number, height: number): void;
  46818. disableScissor(): void;
  46819. /**
  46820. * Clear the current render buffer or the current render target (if any is set up)
  46821. * @param color defines the color to use
  46822. * @param backBuffer defines if the back buffer must be cleared
  46823. * @param depth defines if the depth buffer must be cleared
  46824. * @param stencil defines if the stencil buffer must be cleared
  46825. */
  46826. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46827. /**
  46828. * Clears a list of attachments
  46829. * @param attachments list of the attachments
  46830. * @param colorMain clear color for the main attachment (the first one)
  46831. * @param colorOthers clear color for the other attachments
  46832. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  46833. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  46834. */
  46835. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  46836. /**
  46837. * Creates a vertex buffer
  46838. * @param data the data for the vertex buffer
  46839. * @returns the new buffer
  46840. */
  46841. createVertexBuffer(data: DataArray): DataBuffer;
  46842. /**
  46843. * Creates a vertex buffer
  46844. * @param data the data for the dynamic vertex buffer
  46845. * @returns the new buffer
  46846. */
  46847. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46848. /**
  46849. * Updates a vertex buffer.
  46850. * @param vertexBuffer the vertex buffer to update
  46851. * @param data the data used to update the vertex buffer
  46852. * @param byteOffset the byte offset of the data
  46853. * @param byteLength the byte length of the data
  46854. */
  46855. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46856. /**
  46857. * Creates a new index buffer
  46858. * @param indices defines the content of the index buffer
  46859. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  46860. * @returns a new buffer
  46861. */
  46862. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  46863. /**
  46864. * Update an index buffer
  46865. * @param indexBuffer defines the target index buffer
  46866. * @param indices defines the data to update
  46867. * @param offset defines the offset in the target index buffer where update should start
  46868. */
  46869. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46870. /** @hidden */
  46871. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  46872. /** @hidden */
  46873. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  46874. /**
  46875. * Bind a list of vertex buffers with the engine
  46876. * @param vertexBuffers defines the list of vertex buffers to bind
  46877. * @param indexBuffer defines the index buffer to bind
  46878. * @param effect defines the effect associated with the vertex buffers
  46879. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  46880. */
  46881. bindBuffers(vertexBuffers: {
  46882. [key: string]: Nullable<VertexBuffer>;
  46883. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  46884. [kind: string]: Nullable<VertexBuffer>;
  46885. }): void;
  46886. /** @hidden */
  46887. _releaseBuffer(buffer: DataBuffer): boolean;
  46888. createUniformBuffer(elements: FloatArray): DataBuffer;
  46889. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  46890. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  46891. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  46892. /**
  46893. * Create a new effect (used to store vertex/fragment shaders)
  46894. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  46895. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  46896. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  46897. * @param samplers defines an array of string used to represent textures
  46898. * @param defines defines the string containing the defines to use to compile the shaders
  46899. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  46900. * @param onCompiled defines a function to call when the effect creation is successful
  46901. * @param onError defines a function to call when the effect creation has failed
  46902. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  46903. * @returns the new Effect
  46904. */
  46905. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  46906. private _compileRawShaderToSpirV;
  46907. private _compileShaderToSpirV;
  46908. private _createPipelineStageDescriptor;
  46909. private _compileRawPipelineStageDescriptor;
  46910. private _compilePipelineStageDescriptor;
  46911. /** @hidden */
  46912. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46913. /** @hidden */
  46914. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46915. /**
  46916. * Creates a new pipeline context
  46917. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  46918. * @returns the new pipeline
  46919. */
  46920. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  46921. /** @hidden */
  46922. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  46923. /**
  46924. * Gets the list of active attributes for a given WebGPU program
  46925. * @param pipelineContext defines the pipeline context to use
  46926. * @param attributesNames defines the list of attribute names to get
  46927. * @returns an array of indices indicating the offset of each attribute
  46928. */
  46929. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46930. /**
  46931. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46932. * @param effect defines the effect to activate
  46933. */
  46934. enableEffect(effect: Nullable<Effect>): void;
  46935. /** @hidden */
  46936. _releaseEffect(effect: Effect): void;
  46937. /**
  46938. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  46939. */
  46940. releaseEffects(): void;
  46941. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46942. /**
  46943. * Gets a boolean indicating that only power of 2 textures are supported
  46944. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  46945. */
  46946. get needPOTTextures(): boolean;
  46947. /** @hidden */
  46948. _createHardwareTexture(): HardwareTextureWrapper;
  46949. /** @hidden */
  46950. _releaseTexture(texture: InternalTexture): void;
  46951. /** @hidden */
  46952. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  46953. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  46954. /**
  46955. * Usually called from Texture.ts.
  46956. * Passed information to create a hardware texture
  46957. * @param url defines a value which contains one of the following:
  46958. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46959. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46960. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46961. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46962. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  46963. * @param scene needed for loading to the correct scene
  46964. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46965. * @param onLoad optional callback to be called upon successful completion
  46966. * @param onError optional callback to be called upon failure
  46967. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  46968. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46969. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46970. * @param forcedExtension defines the extension to use to pick the right loader
  46971. * @param mimeType defines an optional mime type
  46972. * @param loaderOptions options to be passed to the loader
  46973. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46974. */
  46975. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  46976. /** @hidden */
  46977. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  46978. /**
  46979. * Creates a cube texture
  46980. * @param rootUrl defines the url where the files to load is located
  46981. * @param scene defines the current scene
  46982. * @param files defines the list of files to load (1 per face)
  46983. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46984. * @param onLoad defines an optional callback raised when the texture is loaded
  46985. * @param onError defines an optional callback raised if there is an issue to load the texture
  46986. * @param format defines the format of the data
  46987. * @param forcedExtension defines the extension to use to pick the right loader
  46988. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46989. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46990. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46991. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46992. * @param loaderOptions options to be passed to the loader
  46993. * @returns the cube texture as an InternalTexture
  46994. */
  46995. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  46996. /**
  46997. * Creates a raw texture
  46998. * @param data defines the data to store in the texture
  46999. * @param width defines the width of the texture
  47000. * @param height defines the height of the texture
  47001. * @param format defines the format of the data
  47002. * @param generateMipMaps defines if the engine should generate the mip levels
  47003. * @param invertY defines if data must be stored with Y axis inverted
  47004. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  47005. * @param compression defines the compression used (null by default)
  47006. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47007. * @returns the raw texture inside an InternalTexture
  47008. */
  47009. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  47010. /**
  47011. * Creates a new raw cube texture
  47012. * @param data defines the array of data to use to create each face
  47013. * @param size defines the size of the textures
  47014. * @param format defines the format of the data
  47015. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  47016. * @param generateMipMaps defines if the engine should generate the mip levels
  47017. * @param invertY defines if data must be stored with Y axis inverted
  47018. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47019. * @param compression defines the compression used (null by default)
  47020. * @returns the cube texture as an InternalTexture
  47021. */
  47022. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  47023. /**
  47024. * Creates a new raw cube texture from a specified url
  47025. * @param url defines the url where the data is located
  47026. * @param scene defines the current scene
  47027. * @param size defines the size of the textures
  47028. * @param format defines the format of the data
  47029. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  47030. * @param noMipmap defines if the engine should avoid generating the mip levels
  47031. * @param callback defines a callback used to extract texture data from loaded data
  47032. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  47033. * @param onLoad defines a callback called when texture is loaded
  47034. * @param onError defines a callback called if there is an error
  47035. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47036. * @param invertY defines if data must be stored with Y axis inverted
  47037. * @returns the cube texture as an InternalTexture
  47038. */
  47039. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  47040. /**
  47041. * Creates a new raw 2D array texture
  47042. * @param data defines the data used to create the texture
  47043. * @param width defines the width of the texture
  47044. * @param height defines the height of the texture
  47045. * @param depth defines the number of layers of the texture
  47046. * @param format defines the format of the texture
  47047. * @param generateMipMaps defines if the engine must generate mip levels
  47048. * @param invertY defines if data must be stored with Y axis inverted
  47049. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47050. * @param compression defines the compressed used (can be null)
  47051. * @param textureType defines the compressed used (can be null)
  47052. * @returns a new raw 2D array texture (stored in an InternalTexture)
  47053. */
  47054. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  47055. /**
  47056. * Creates a new raw 3D texture
  47057. * @param data defines the data used to create the texture
  47058. * @param width defines the width of the texture
  47059. * @param height defines the height of the texture
  47060. * @param depth defines the depth of the texture
  47061. * @param format defines the format of the texture
  47062. * @param generateMipMaps defines if the engine must generate mip levels
  47063. * @param invertY defines if data must be stored with Y axis inverted
  47064. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47065. * @param compression defines the compressed used (can be null)
  47066. * @param textureType defines the compressed used (can be null)
  47067. * @returns a new raw 3D texture (stored in an InternalTexture)
  47068. */
  47069. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  47070. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  47071. /**
  47072. * Update the sampling mode of a given texture
  47073. * @param samplingMode defines the required sampling mode
  47074. * @param texture defines the texture to update
  47075. * @param generateMipMaps defines whether to generate mipmaps for the texture
  47076. */
  47077. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  47078. /**
  47079. * Update the sampling mode of a given texture
  47080. * @param texture defines the texture to update
  47081. * @param wrapU defines the texture wrap mode of the u coordinates
  47082. * @param wrapV defines the texture wrap mode of the v coordinates
  47083. * @param wrapR defines the texture wrap mode of the r coordinates
  47084. */
  47085. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  47086. /**
  47087. * Update the dimensions of a texture
  47088. * @param texture texture to update
  47089. * @param width new width of the texture
  47090. * @param height new height of the texture
  47091. * @param depth new depth of the texture
  47092. */
  47093. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  47094. private _setInternalTexture;
  47095. /**
  47096. * Sets a texture to the according uniform.
  47097. * @param channel The texture channel
  47098. * @param unused unused parameter
  47099. * @param texture The texture to apply
  47100. * @param name The name of the uniform in the effect
  47101. */
  47102. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  47103. /**
  47104. * Sets an array of texture to the WebGPU context
  47105. * @param channel defines the channel where the texture array must be set
  47106. * @param unused unused parameter
  47107. * @param textures defines the array of textures to bind
  47108. * @param name name of the channel
  47109. */
  47110. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  47111. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  47112. /** @hidden */
  47113. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  47114. /** @hidden */
  47115. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  47116. private _generateMipmaps;
  47117. /**
  47118. * Update the content of a texture
  47119. * @param texture defines the texture to update
  47120. * @param canvas defines the source containing the data
  47121. * @param invertY defines if data must be stored with Y axis inverted
  47122. * @param premulAlpha defines if alpha is stored as premultiplied
  47123. * @param format defines the format of the data
  47124. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47125. */
  47126. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  47127. /**
  47128. * Update a portion of an internal texture
  47129. * @param texture defines the texture to update
  47130. * @param imageData defines the data to store into the texture
  47131. * @param xOffset defines the x coordinates of the update rectangle
  47132. * @param yOffset defines the y coordinates of the update rectangle
  47133. * @param width defines the width of the update rectangle
  47134. * @param height defines the height of the update rectangle
  47135. * @param faceIndex defines the face index if texture is a cube (0 by default)
  47136. * @param lod defines the lod level to update (0 by default)
  47137. */
  47138. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  47139. /**
  47140. * Update a video texture
  47141. * @param texture defines the texture to update
  47142. * @param video defines the video element to use
  47143. * @param invertY defines if data must be stored with Y axis inverted
  47144. */
  47145. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  47146. /** @hidden */
  47147. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47148. /** @hidden */
  47149. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  47150. /** @hidden */
  47151. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47152. /** @hidden */
  47153. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  47154. /**
  47155. * Update a raw texture
  47156. * @param texture defines the texture to update
  47157. * @param bufferView defines the data to store in the texture
  47158. * @param format defines the format of the data
  47159. * @param invertY defines if data must be stored with Y axis inverted
  47160. * @param compression defines the compression used (null by default)
  47161. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47162. */
  47163. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  47164. /**
  47165. * Update a raw cube texture
  47166. * @param texture defines the texture to udpdate
  47167. * @param bufferView defines the data to store
  47168. * @param format defines the data format
  47169. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47170. * @param invertY defines if data must be stored with Y axis inverted
  47171. * @param compression defines the compression used (null by default)
  47172. * @param level defines which level of the texture to update
  47173. */
  47174. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47175. /**
  47176. * Update a raw 2D array texture
  47177. * @param texture defines the texture to update
  47178. * @param bufferView defines the data to store
  47179. * @param format defines the data format
  47180. * @param invertY defines if data must be stored with Y axis inverted
  47181. * @param compression defines the used compression (can be null)
  47182. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47183. */
  47184. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  47185. /**
  47186. * Update a raw 3D texture
  47187. * @param texture defines the texture to update
  47188. * @param bufferView defines the data to store
  47189. * @param format defines the data format
  47190. * @param invertY defines if data must be stored with Y axis inverted
  47191. * @param compression defines the used compression (can be null)
  47192. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47193. */
  47194. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  47195. /**
  47196. * Reads pixels from the current frame buffer. Please note that this function can be slow
  47197. * @param x defines the x coordinate of the rectangle where pixels must be read
  47198. * @param y defines the y coordinate of the rectangle where pixels must be read
  47199. * @param width defines the width of the rectangle where pixels must be read
  47200. * @param height defines the height of the rectangle where pixels must be read
  47201. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  47202. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  47203. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  47204. */
  47205. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  47206. /** @hidden */
  47207. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  47208. /** @hidden */
  47209. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  47210. /**
  47211. * Creates a new render target texture
  47212. * @param size defines the size of the texture
  47213. * @param options defines the options used to create the texture
  47214. * @returns a new render target texture stored in an InternalTexture
  47215. */
  47216. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47217. /**
  47218. * Create a multi render target texture
  47219. * @param size defines the size of the texture
  47220. * @param options defines the creation options
  47221. * @returns the cube texture as an InternalTexture
  47222. */
  47223. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47224. /**
  47225. * Creates a new render target cube texture
  47226. * @param size defines the size of the texture
  47227. * @param options defines the options used to create the texture
  47228. * @returns a new render target cube texture stored in an InternalTexture
  47229. */
  47230. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  47231. /** @hidden */
  47232. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  47233. width: number;
  47234. height: number;
  47235. layers?: number;
  47236. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  47237. /** @hidden */
  47238. _createDepthStencilTexture(size: number | {
  47239. width: number;
  47240. height: number;
  47241. layers?: number;
  47242. }, options: DepthTextureCreationOptions): InternalTexture;
  47243. /** @hidden */
  47244. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  47245. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  47246. /**
  47247. * Update the sample count for a given multiple render target texture
  47248. * @param textures defines the textures to update
  47249. * @param samples defines the sample count to set
  47250. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47251. */
  47252. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47253. /**
  47254. * Begin a new frame
  47255. */
  47256. beginFrame(): void;
  47257. /**
  47258. * End the current frame
  47259. */
  47260. endFrame(): void;
  47261. /**
  47262. * Force a WebGPU flush (ie. a flush of all waiting commands)
  47263. */
  47264. flushFramebuffer(): void;
  47265. private _startRenderTargetRenderPass;
  47266. private _endRenderTargetRenderPass;
  47267. private _getCurrentRenderPass;
  47268. private _startMainRenderPass;
  47269. private _endMainRenderPass;
  47270. /**
  47271. * Restores the WebGPU state to only draw on the main color attachment
  47272. */
  47273. restoreSingleAttachment(): void;
  47274. /**
  47275. * Creates a layout object to draw/clear on specific textures in a MRT
  47276. * @param textureStatus textureStatus[i] indicates if the i-th is active
  47277. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  47278. */
  47279. buildTextureLayout(textureStatus: boolean[]): number[];
  47280. /**
  47281. * Select a subsets of attachments to draw to.
  47282. * @param attachments index of attachments
  47283. */
  47284. bindAttachments(attachments: number[]): void;
  47285. /**
  47286. * Binds the frame buffer to the specified texture.
  47287. * @param texture The texture to render to or null for the default canvas
  47288. * @param faceIndex The face of the texture to render to in case of cube texture
  47289. * @param requiredWidth The width of the target to render to
  47290. * @param requiredHeight The height of the target to render to
  47291. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47292. * @param lodLevel defines the lod level to bind to the frame buffer
  47293. * @param layer defines the 2d array index to bind to frame buffer to
  47294. */
  47295. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  47296. /**
  47297. * Unbind the current render target texture from the WebGPU context
  47298. * @param texture defines the render target texture to unbind
  47299. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47300. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47301. */
  47302. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47303. /**
  47304. * Unbind a list of render target textures from the WebGPU context
  47305. * @param textures defines the render target textures to unbind
  47306. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47307. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47308. */
  47309. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47310. /**
  47311. * Unbind the current render target and bind the default framebuffer
  47312. */
  47313. restoreDefaultFramebuffer(): void;
  47314. setZOffset(value: number): void;
  47315. private _setColorFormat;
  47316. private _setDepthTextureFormat;
  47317. setDepthBuffer(enable: boolean): void;
  47318. setDepthWrite(enable: boolean): void;
  47319. setStencilBuffer(enable: boolean): void;
  47320. setStencilMask(mask: number): void;
  47321. setStencilFunction(stencilFunc: number): void;
  47322. setStencilFunctionReference(reference: number): void;
  47323. setStencilFunctionMask(mask: number): void;
  47324. setStencilOperationFail(operation: number): void;
  47325. setStencilOperationDepthFail(operation: number): void;
  47326. setStencilOperationPass(operation: number): void;
  47327. setDitheringState(value: boolean): void;
  47328. setRasterizerState(value: boolean): void;
  47329. setDepthFunction(depthFunc: number): void;
  47330. setDepthFunctionToGreater(): void;
  47331. setDepthFunctionToGreaterOrEqual(): void;
  47332. setDepthFunctionToLess(): void;
  47333. setDepthFunctionToLessOrEqual(): void;
  47334. /**
  47335. * Set various states to the context
  47336. * @param culling defines backface culling state
  47337. * @param zOffset defines the value to apply to zOffset (0 by default)
  47338. * @param force defines if states must be applied even if cache is up to date
  47339. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47340. */
  47341. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47342. /**
  47343. * Sets the current alpha mode
  47344. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47345. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47347. */
  47348. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47349. /**
  47350. * Sets the current alpha equation
  47351. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  47352. */
  47353. setAlphaEquation(equation: number): void;
  47354. private _getBindGroupsToRender;
  47355. private _bindVertexInputs;
  47356. private _setRenderBindGroups;
  47357. private _setRenderPipeline;
  47358. /**
  47359. * Draw a list of indexed primitives
  47360. * @param fillMode defines the primitive to use
  47361. * @param indexStart defines the starting index
  47362. * @param indexCount defines the number of index to draw
  47363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47364. */
  47365. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47366. /**
  47367. * Draw a list of unindexed primitives
  47368. * @param fillMode defines the primitive to use
  47369. * @param verticesStart defines the index of first vertex to draw
  47370. * @param verticesCount defines the count of vertices to draw
  47371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47372. */
  47373. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47374. private _bundleEncoder;
  47375. /**
  47376. * Start recording all the gpu calls into a bundle.
  47377. */
  47378. startRecordBundle(): void;
  47379. /**
  47380. * Stops recording the bundle.
  47381. * @returns the recorded bundle
  47382. */
  47383. stopRecordBundle(): GPURenderBundle;
  47384. /**
  47385. * Execute the previously recorded bundle.
  47386. * @param bundles defines the bundle to replay
  47387. */
  47388. executeBundles(bundles: GPURenderBundle[]): void;
  47389. /**
  47390. * Dispose and release all associated resources
  47391. */
  47392. dispose(): void;
  47393. /**
  47394. * Gets the current render width
  47395. * @param useScreen defines if screen size must be used (or the current render target if any)
  47396. * @returns a number defining the current render width
  47397. */
  47398. getRenderWidth(useScreen?: boolean): number;
  47399. /**
  47400. * Gets the current render height
  47401. * @param useScreen defines if screen size must be used (or the current render target if any)
  47402. * @returns a number defining the current render height
  47403. */
  47404. getRenderHeight(useScreen?: boolean): number;
  47405. /**
  47406. * Gets the HTML canvas attached with the current WebGPU context
  47407. * @returns a HTML canvas
  47408. */
  47409. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  47410. /** @hidden */
  47411. _debugPushGroup(groupName: string, targetObject?: number): void;
  47412. /** @hidden */
  47413. _debugPopGroup(targetObject?: number): void;
  47414. /** @hidden */
  47415. _debugInsertMarker(text: string, targetObject?: number): void;
  47416. private _debugFlushPendingCommands;
  47417. /**
  47418. * Get the current error code of the WebGPU context
  47419. * @returns the error code
  47420. */
  47421. getError(): number;
  47422. /** @hidden */
  47423. bindSamplers(effect: Effect): void;
  47424. /** @hidden */
  47425. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  47426. /** @hidden */
  47427. _releaseFramebufferObjects(texture: InternalTexture): void;
  47428. /** @hidden */
  47429. applyStates(): void;
  47430. /**
  47431. * Gets a boolean indicating if all created effects are ready
  47432. * @returns always true - No parallel shader compilation
  47433. */
  47434. areAllEffectsReady(): boolean;
  47435. /** @hidden */
  47436. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47437. /** @hidden */
  47438. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47439. /** @hidden */
  47440. _getUnpackAlignement(): number;
  47441. /** @hidden */
  47442. _unpackFlipY(value: boolean): void;
  47443. /** @hidden */
  47444. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  47445. min: number;
  47446. mag: number;
  47447. };
  47448. /** @hidden */
  47449. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47450. /** @hidden */
  47451. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47452. /** @hidden */
  47453. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47454. /** @hidden */
  47455. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47456. /** @hidden */
  47457. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47458. /** @hidden */
  47459. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47460. /** @hidden */
  47461. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  47462. /** @hidden */
  47463. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  47464. /** @hidden */
  47465. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  47466. /** @hidden */
  47467. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  47468. /** @hidden */
  47469. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  47470. /** @hidden */
  47471. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47472. /** @hidden */
  47473. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47474. /** @hidden */
  47475. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  47476. /** @hidden */
  47477. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  47478. /** @hidden */
  47479. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  47480. /** @hidden */
  47481. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  47482. }
  47483. }
  47484. declare module "babylonjs/scene" {
  47485. import { Nullable } from "babylonjs/types";
  47486. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47487. import { Observable } from "babylonjs/Misc/observable";
  47488. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47489. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  47490. import { Geometry } from "babylonjs/Meshes/geometry";
  47491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47494. import { Mesh } from "babylonjs/Meshes/mesh";
  47495. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47496. import { Bone } from "babylonjs/Bones/bone";
  47497. import { Skeleton } from "babylonjs/Bones/skeleton";
  47498. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  47499. import { Camera } from "babylonjs/Cameras/camera";
  47500. import { AbstractScene } from "babylonjs/abstractScene";
  47501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47503. import { Material } from "babylonjs/Materials/material";
  47504. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47505. import { Effect } from "babylonjs/Materials/effect";
  47506. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47507. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  47508. import { Light } from "babylonjs/Lights/light";
  47509. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47510. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  47511. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  47512. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  47513. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  47514. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  47515. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  47516. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  47517. import { Engine } from "babylonjs/Engines/engine";
  47518. import { Node } from "babylonjs/node";
  47519. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  47520. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  47521. import { WebRequest } from "babylonjs/Misc/webRequest";
  47522. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  47523. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  47524. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47525. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  47526. import { Plane } from "babylonjs/Maths/math.plane";
  47527. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  47528. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  47529. import { Ray } from "babylonjs/Culling/ray";
  47530. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  47531. import { Animation } from "babylonjs/Animations/animation";
  47532. import { Animatable } from "babylonjs/Animations/animatable";
  47533. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47534. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  47535. import { Collider } from "babylonjs/Collisions/collider";
  47536. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47537. /**
  47538. * Define an interface for all classes that will hold resources
  47539. */
  47540. export interface IDisposable {
  47541. /**
  47542. * Releases all held resources
  47543. */
  47544. dispose(): void;
  47545. }
  47546. /** Interface defining initialization parameters for Scene class */
  47547. export interface SceneOptions {
  47548. /**
  47549. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  47550. * It will improve performance when the number of geometries becomes important.
  47551. */
  47552. useGeometryUniqueIdsMap?: boolean;
  47553. /**
  47554. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  47555. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47556. */
  47557. useMaterialMeshMap?: boolean;
  47558. /**
  47559. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  47560. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47561. */
  47562. useClonedMeshMap?: boolean;
  47563. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  47564. virtual?: boolean;
  47565. }
  47566. /**
  47567. * Represents a scene to be rendered by the engine.
  47568. * @see https://doc.babylonjs.com/features/scene
  47569. */
  47570. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  47571. /** The fog is deactivated */
  47572. static readonly FOGMODE_NONE: number;
  47573. /** The fog density is following an exponential function */
  47574. static readonly FOGMODE_EXP: number;
  47575. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  47576. static readonly FOGMODE_EXP2: number;
  47577. /** The fog density is following a linear function. */
  47578. static readonly FOGMODE_LINEAR: number;
  47579. /**
  47580. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  47581. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47582. */
  47583. static MinDeltaTime: number;
  47584. /**
  47585. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  47586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47587. */
  47588. static MaxDeltaTime: number;
  47589. /**
  47590. * Factory used to create the default material.
  47591. * @param name The name of the material to create
  47592. * @param scene The scene to create the material for
  47593. * @returns The default material
  47594. */
  47595. static DefaultMaterialFactory(scene: Scene): Material;
  47596. /**
  47597. * Factory used to create the a collision coordinator.
  47598. * @returns The collision coordinator
  47599. */
  47600. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  47601. /** @hidden */
  47602. _inputManager: InputManager;
  47603. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  47604. cameraToUseForPointers: Nullable<Camera>;
  47605. /** @hidden */
  47606. readonly _isScene: boolean;
  47607. /** @hidden */
  47608. _blockEntityCollection: boolean;
  47609. /**
  47610. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  47611. */
  47612. autoClear: boolean;
  47613. /**
  47614. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  47615. */
  47616. autoClearDepthAndStencil: boolean;
  47617. /**
  47618. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  47619. */
  47620. clearColor: Color4;
  47621. /**
  47622. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  47623. */
  47624. ambientColor: Color3;
  47625. /**
  47626. * This is use to store the default BRDF lookup for PBR materials in your scene.
  47627. * It should only be one of the following (if not the default embedded one):
  47628. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47629. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  47630. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47631. * The material properties need to be setup according to the type of texture in use.
  47632. */
  47633. environmentBRDFTexture: BaseTexture;
  47634. /**
  47635. * Texture used in all pbr material as the reflection texture.
  47636. * As in the majority of the scene they are the same (exception for multi room and so on),
  47637. * this is easier to reference from here than from all the materials.
  47638. */
  47639. get environmentTexture(): Nullable<BaseTexture>;
  47640. /**
  47641. * Texture used in all pbr material as the reflection texture.
  47642. * As in the majority of the scene they are the same (exception for multi room and so on),
  47643. * this is easier to set here than in all the materials.
  47644. */
  47645. set environmentTexture(value: Nullable<BaseTexture>);
  47646. /** @hidden */
  47647. protected _environmentIntensity: number;
  47648. /**
  47649. * Intensity of the environment in all pbr material.
  47650. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47651. * As in the majority of the scene they are the same (exception for multi room and so on),
  47652. * this is easier to reference from here than from all the materials.
  47653. */
  47654. get environmentIntensity(): number;
  47655. /**
  47656. * Intensity of the environment in all pbr material.
  47657. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47658. * As in the majority of the scene they are the same (exception for multi room and so on),
  47659. * this is easier to set here than in all the materials.
  47660. */
  47661. set environmentIntensity(value: number);
  47662. /** @hidden */
  47663. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47664. /**
  47665. * Default image processing configuration used either in the rendering
  47666. * Forward main pass or through the imageProcessingPostProcess if present.
  47667. * As in the majority of the scene they are the same (exception for multi camera),
  47668. * this is easier to reference from here than from all the materials and post process.
  47669. *
  47670. * No setter as we it is a shared configuration, you can set the values instead.
  47671. */
  47672. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47673. private _forceWireframe;
  47674. /**
  47675. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  47676. */
  47677. set forceWireframe(value: boolean);
  47678. get forceWireframe(): boolean;
  47679. private _skipFrustumClipping;
  47680. /**
  47681. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  47682. */
  47683. set skipFrustumClipping(value: boolean);
  47684. get skipFrustumClipping(): boolean;
  47685. private _forcePointsCloud;
  47686. /**
  47687. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  47688. */
  47689. set forcePointsCloud(value: boolean);
  47690. get forcePointsCloud(): boolean;
  47691. /**
  47692. * Gets or sets the active clipplane 1
  47693. */
  47694. clipPlane: Nullable<Plane>;
  47695. /**
  47696. * Gets or sets the active clipplane 2
  47697. */
  47698. clipPlane2: Nullable<Plane>;
  47699. /**
  47700. * Gets or sets the active clipplane 3
  47701. */
  47702. clipPlane3: Nullable<Plane>;
  47703. /**
  47704. * Gets or sets the active clipplane 4
  47705. */
  47706. clipPlane4: Nullable<Plane>;
  47707. /**
  47708. * Gets or sets the active clipplane 5
  47709. */
  47710. clipPlane5: Nullable<Plane>;
  47711. /**
  47712. * Gets or sets the active clipplane 6
  47713. */
  47714. clipPlane6: Nullable<Plane>;
  47715. /**
  47716. * Gets or sets a boolean indicating if animations are enabled
  47717. */
  47718. animationsEnabled: boolean;
  47719. private _animationPropertiesOverride;
  47720. /**
  47721. * Gets or sets the animation properties override
  47722. */
  47723. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  47724. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  47725. /**
  47726. * Gets or sets a boolean indicating if a constant deltatime has to be used
  47727. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  47728. */
  47729. useConstantAnimationDeltaTime: boolean;
  47730. /**
  47731. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  47732. * Please note that it requires to run a ray cast through the scene on every frame
  47733. */
  47734. constantlyUpdateMeshUnderPointer: boolean;
  47735. /**
  47736. * Defines the HTML cursor to use when hovering over interactive elements
  47737. */
  47738. hoverCursor: string;
  47739. /**
  47740. * Defines the HTML default cursor to use (empty by default)
  47741. */
  47742. defaultCursor: string;
  47743. /**
  47744. * Defines whether cursors are handled by the scene.
  47745. */
  47746. doNotHandleCursors: boolean;
  47747. /**
  47748. * This is used to call preventDefault() on pointer down
  47749. * in order to block unwanted artifacts like system double clicks
  47750. */
  47751. preventDefaultOnPointerDown: boolean;
  47752. /**
  47753. * This is used to call preventDefault() on pointer up
  47754. * in order to block unwanted artifacts like system double clicks
  47755. */
  47756. preventDefaultOnPointerUp: boolean;
  47757. /**
  47758. * Gets or sets user defined metadata
  47759. */
  47760. metadata: any;
  47761. /**
  47762. * For internal use only. Please do not use.
  47763. */
  47764. reservedDataStore: any;
  47765. /**
  47766. * Gets the name of the plugin used to load this scene (null by default)
  47767. */
  47768. loadingPluginName: string;
  47769. /**
  47770. * Use this array to add regular expressions used to disable offline support for specific urls
  47771. */
  47772. disableOfflineSupportExceptionRules: RegExp[];
  47773. /**
  47774. * An event triggered when the scene is disposed.
  47775. */
  47776. onDisposeObservable: Observable<Scene>;
  47777. private _onDisposeObserver;
  47778. /** Sets a function to be executed when this scene is disposed. */
  47779. set onDispose(callback: () => void);
  47780. /**
  47781. * An event triggered before rendering the scene (right after animations and physics)
  47782. */
  47783. onBeforeRenderObservable: Observable<Scene>;
  47784. private _onBeforeRenderObserver;
  47785. /** Sets a function to be executed before rendering this scene */
  47786. set beforeRender(callback: Nullable<() => void>);
  47787. /**
  47788. * An event triggered after rendering the scene
  47789. */
  47790. onAfterRenderObservable: Observable<Scene>;
  47791. /**
  47792. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  47793. */
  47794. onAfterRenderCameraObservable: Observable<Camera>;
  47795. private _onAfterRenderObserver;
  47796. /** Sets a function to be executed after rendering this scene */
  47797. set afterRender(callback: Nullable<() => void>);
  47798. /**
  47799. * An event triggered before animating the scene
  47800. */
  47801. onBeforeAnimationsObservable: Observable<Scene>;
  47802. /**
  47803. * An event triggered after animations processing
  47804. */
  47805. onAfterAnimationsObservable: Observable<Scene>;
  47806. /**
  47807. * An event triggered before draw calls are ready to be sent
  47808. */
  47809. onBeforeDrawPhaseObservable: Observable<Scene>;
  47810. /**
  47811. * An event triggered after draw calls have been sent
  47812. */
  47813. onAfterDrawPhaseObservable: Observable<Scene>;
  47814. /**
  47815. * An event triggered when the scene is ready
  47816. */
  47817. onReadyObservable: Observable<Scene>;
  47818. /**
  47819. * An event triggered before rendering a camera
  47820. */
  47821. onBeforeCameraRenderObservable: Observable<Camera>;
  47822. private _onBeforeCameraRenderObserver;
  47823. /** Sets a function to be executed before rendering a camera*/
  47824. set beforeCameraRender(callback: () => void);
  47825. /**
  47826. * An event triggered after rendering a camera
  47827. */
  47828. onAfterCameraRenderObservable: Observable<Camera>;
  47829. private _onAfterCameraRenderObserver;
  47830. /** Sets a function to be executed after rendering a camera*/
  47831. set afterCameraRender(callback: () => void);
  47832. /**
  47833. * An event triggered when active meshes evaluation is about to start
  47834. */
  47835. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  47836. /**
  47837. * An event triggered when active meshes evaluation is done
  47838. */
  47839. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  47840. /**
  47841. * An event triggered when particles rendering is about to start
  47842. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47843. */
  47844. onBeforeParticlesRenderingObservable: Observable<Scene>;
  47845. /**
  47846. * An event triggered when particles rendering is done
  47847. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47848. */
  47849. onAfterParticlesRenderingObservable: Observable<Scene>;
  47850. /**
  47851. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  47852. */
  47853. onDataLoadedObservable: Observable<Scene>;
  47854. /**
  47855. * An event triggered when a camera is created
  47856. */
  47857. onNewCameraAddedObservable: Observable<Camera>;
  47858. /**
  47859. * An event triggered when a camera is removed
  47860. */
  47861. onCameraRemovedObservable: Observable<Camera>;
  47862. /**
  47863. * An event triggered when a light is created
  47864. */
  47865. onNewLightAddedObservable: Observable<Light>;
  47866. /**
  47867. * An event triggered when a light is removed
  47868. */
  47869. onLightRemovedObservable: Observable<Light>;
  47870. /**
  47871. * An event triggered when a geometry is created
  47872. */
  47873. onNewGeometryAddedObservable: Observable<Geometry>;
  47874. /**
  47875. * An event triggered when a geometry is removed
  47876. */
  47877. onGeometryRemovedObservable: Observable<Geometry>;
  47878. /**
  47879. * An event triggered when a transform node is created
  47880. */
  47881. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  47882. /**
  47883. * An event triggered when a transform node is removed
  47884. */
  47885. onTransformNodeRemovedObservable: Observable<TransformNode>;
  47886. /**
  47887. * An event triggered when a mesh is created
  47888. */
  47889. onNewMeshAddedObservable: Observable<AbstractMesh>;
  47890. /**
  47891. * An event triggered when a mesh is removed
  47892. */
  47893. onMeshRemovedObservable: Observable<AbstractMesh>;
  47894. /**
  47895. * An event triggered when a skeleton is created
  47896. */
  47897. onNewSkeletonAddedObservable: Observable<Skeleton>;
  47898. /**
  47899. * An event triggered when a skeleton is removed
  47900. */
  47901. onSkeletonRemovedObservable: Observable<Skeleton>;
  47902. /**
  47903. * An event triggered when a material is created
  47904. */
  47905. onNewMaterialAddedObservable: Observable<Material>;
  47906. /**
  47907. * An event triggered when a multi material is created
  47908. */
  47909. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  47910. /**
  47911. * An event triggered when a material is removed
  47912. */
  47913. onMaterialRemovedObservable: Observable<Material>;
  47914. /**
  47915. * An event triggered when a multi material is removed
  47916. */
  47917. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  47918. /**
  47919. * An event triggered when a texture is created
  47920. */
  47921. onNewTextureAddedObservable: Observable<BaseTexture>;
  47922. /**
  47923. * An event triggered when a texture is removed
  47924. */
  47925. onTextureRemovedObservable: Observable<BaseTexture>;
  47926. /**
  47927. * An event triggered when render targets are about to be rendered
  47928. * Can happen multiple times per frame.
  47929. */
  47930. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  47931. /**
  47932. * An event triggered when render targets were rendered.
  47933. * Can happen multiple times per frame.
  47934. */
  47935. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  47936. /**
  47937. * An event triggered before calculating deterministic simulation step
  47938. */
  47939. onBeforeStepObservable: Observable<Scene>;
  47940. /**
  47941. * An event triggered after calculating deterministic simulation step
  47942. */
  47943. onAfterStepObservable: Observable<Scene>;
  47944. /**
  47945. * An event triggered when the activeCamera property is updated
  47946. */
  47947. onActiveCameraChanged: Observable<Scene>;
  47948. /**
  47949. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  47950. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47951. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  47952. */
  47953. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47954. /**
  47955. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  47956. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47957. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  47958. */
  47959. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47960. /**
  47961. * This Observable will when a mesh has been imported into the scene.
  47962. */
  47963. onMeshImportedObservable: Observable<AbstractMesh>;
  47964. /**
  47965. * This Observable will when an animation file has been imported into the scene.
  47966. */
  47967. onAnimationFileImportedObservable: Observable<Scene>;
  47968. /**
  47969. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  47970. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  47971. */
  47972. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  47973. /** @hidden */
  47974. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  47975. /**
  47976. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  47977. */
  47978. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  47979. /**
  47980. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  47981. */
  47982. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  47983. /**
  47984. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  47985. */
  47986. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  47987. /** Callback called when a pointer move is detected */
  47988. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47989. /** Callback called when a pointer down is detected */
  47990. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47991. /** Callback called when a pointer up is detected */
  47992. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  47993. /** Callback called when a pointer pick is detected */
  47994. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  47995. /**
  47996. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  47997. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  47998. */
  47999. onPrePointerObservable: Observable<PointerInfoPre>;
  48000. /**
  48001. * Observable event triggered each time an input event is received from the rendering canvas
  48002. */
  48003. onPointerObservable: Observable<PointerInfo>;
  48004. /**
  48005. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  48006. */
  48007. get unTranslatedPointer(): Vector2;
  48008. /**
  48009. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  48010. */
  48011. static get DragMovementThreshold(): number;
  48012. static set DragMovementThreshold(value: number);
  48013. /**
  48014. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  48015. */
  48016. static get LongPressDelay(): number;
  48017. static set LongPressDelay(value: number);
  48018. /**
  48019. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  48020. */
  48021. static get DoubleClickDelay(): number;
  48022. static set DoubleClickDelay(value: number);
  48023. /** If you need to check double click without raising a single click at first click, enable this flag */
  48024. static get ExclusiveDoubleClickMode(): boolean;
  48025. static set ExclusiveDoubleClickMode(value: boolean);
  48026. /** @hidden */
  48027. _mirroredCameraPosition: Nullable<Vector3>;
  48028. /**
  48029. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  48030. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  48031. */
  48032. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  48033. /**
  48034. * Observable event triggered each time an keyboard event is received from the hosting window
  48035. */
  48036. onKeyboardObservable: Observable<KeyboardInfo>;
  48037. private _useRightHandedSystem;
  48038. /**
  48039. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  48040. */
  48041. set useRightHandedSystem(value: boolean);
  48042. get useRightHandedSystem(): boolean;
  48043. private _timeAccumulator;
  48044. private _currentStepId;
  48045. private _currentInternalStep;
  48046. /**
  48047. * Sets the step Id used by deterministic lock step
  48048. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48049. * @param newStepId defines the step Id
  48050. */
  48051. setStepId(newStepId: number): void;
  48052. /**
  48053. * Gets the step Id used by deterministic lock step
  48054. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48055. * @returns the step Id
  48056. */
  48057. getStepId(): number;
  48058. /**
  48059. * Gets the internal step used by deterministic lock step
  48060. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48061. * @returns the internal step
  48062. */
  48063. getInternalStep(): number;
  48064. private _fogEnabled;
  48065. /**
  48066. * Gets or sets a boolean indicating if fog is enabled on this scene
  48067. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48068. * (Default is true)
  48069. */
  48070. set fogEnabled(value: boolean);
  48071. get fogEnabled(): boolean;
  48072. private _fogMode;
  48073. /**
  48074. * Gets or sets the fog mode to use
  48075. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48076. * | mode | value |
  48077. * | --- | --- |
  48078. * | FOGMODE_NONE | 0 |
  48079. * | FOGMODE_EXP | 1 |
  48080. * | FOGMODE_EXP2 | 2 |
  48081. * | FOGMODE_LINEAR | 3 |
  48082. */
  48083. set fogMode(value: number);
  48084. get fogMode(): number;
  48085. /**
  48086. * Gets or sets the fog color to use
  48087. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48088. * (Default is Color3(0.2, 0.2, 0.3))
  48089. */
  48090. fogColor: Color3;
  48091. /**
  48092. * Gets or sets the fog density to use
  48093. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48094. * (Default is 0.1)
  48095. */
  48096. fogDensity: number;
  48097. /**
  48098. * Gets or sets the fog start distance to use
  48099. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48100. * (Default is 0)
  48101. */
  48102. fogStart: number;
  48103. /**
  48104. * Gets or sets the fog end distance to use
  48105. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48106. * (Default is 1000)
  48107. */
  48108. fogEnd: number;
  48109. /**
  48110. * Flag indicating that the frame buffer binding is handled by another component
  48111. */
  48112. prePass: boolean;
  48113. private _shadowsEnabled;
  48114. /**
  48115. * Gets or sets a boolean indicating if shadows are enabled on this scene
  48116. */
  48117. set shadowsEnabled(value: boolean);
  48118. get shadowsEnabled(): boolean;
  48119. private _lightsEnabled;
  48120. /**
  48121. * Gets or sets a boolean indicating if lights are enabled on this scene
  48122. */
  48123. set lightsEnabled(value: boolean);
  48124. get lightsEnabled(): boolean;
  48125. /** All of the active cameras added to this scene. */
  48126. activeCameras: Nullable<Camera[]>;
  48127. /** @hidden */
  48128. _activeCamera: Nullable<Camera>;
  48129. /** Gets or sets the current active camera */
  48130. get activeCamera(): Nullable<Camera>;
  48131. set activeCamera(value: Nullable<Camera>);
  48132. private _defaultMaterial;
  48133. /** The default material used on meshes when no material is affected */
  48134. get defaultMaterial(): Material;
  48135. /** The default material used on meshes when no material is affected */
  48136. set defaultMaterial(value: Material);
  48137. private _texturesEnabled;
  48138. /**
  48139. * Gets or sets a boolean indicating if textures are enabled on this scene
  48140. */
  48141. set texturesEnabled(value: boolean);
  48142. get texturesEnabled(): boolean;
  48143. /**
  48144. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  48145. */
  48146. physicsEnabled: boolean;
  48147. /**
  48148. * Gets or sets a boolean indicating if particles are enabled on this scene
  48149. */
  48150. particlesEnabled: boolean;
  48151. /**
  48152. * Gets or sets a boolean indicating if sprites are enabled on this scene
  48153. */
  48154. spritesEnabled: boolean;
  48155. private _skeletonsEnabled;
  48156. /**
  48157. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  48158. */
  48159. set skeletonsEnabled(value: boolean);
  48160. get skeletonsEnabled(): boolean;
  48161. /**
  48162. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  48163. */
  48164. lensFlaresEnabled: boolean;
  48165. /**
  48166. * Gets or sets a boolean indicating if collisions are enabled on this scene
  48167. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  48168. */
  48169. collisionsEnabled: boolean;
  48170. private _collisionCoordinator;
  48171. /** @hidden */
  48172. get collisionCoordinator(): ICollisionCoordinator;
  48173. /**
  48174. * Defines the gravity applied to this scene (used only for collisions)
  48175. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  48176. */
  48177. gravity: Vector3;
  48178. /**
  48179. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  48180. */
  48181. postProcessesEnabled: boolean;
  48182. /**
  48183. * Gets the current postprocess manager
  48184. */
  48185. postProcessManager: PostProcessManager;
  48186. /**
  48187. * Gets or sets a boolean indicating if render targets are enabled on this scene
  48188. */
  48189. renderTargetsEnabled: boolean;
  48190. /**
  48191. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  48192. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  48193. */
  48194. dumpNextRenderTargets: boolean;
  48195. /**
  48196. * The list of user defined render targets added to the scene
  48197. */
  48198. customRenderTargets: RenderTargetTexture[];
  48199. /**
  48200. * Defines if texture loading must be delayed
  48201. * If true, textures will only be loaded when they need to be rendered
  48202. */
  48203. useDelayedTextureLoading: boolean;
  48204. /**
  48205. * Gets the list of meshes imported to the scene through SceneLoader
  48206. */
  48207. importedMeshesFiles: String[];
  48208. /**
  48209. * Gets or sets a boolean indicating if probes are enabled on this scene
  48210. */
  48211. probesEnabled: boolean;
  48212. /**
  48213. * Gets or sets the current offline provider to use to store scene data
  48214. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  48215. */
  48216. offlineProvider: IOfflineProvider;
  48217. /**
  48218. * Gets or sets the action manager associated with the scene
  48219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48220. */
  48221. actionManager: AbstractActionManager;
  48222. private _meshesForIntersections;
  48223. /**
  48224. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  48225. */
  48226. proceduralTexturesEnabled: boolean;
  48227. private _engine;
  48228. private _totalVertices;
  48229. /** @hidden */
  48230. _activeIndices: PerfCounter;
  48231. /** @hidden */
  48232. _activeParticles: PerfCounter;
  48233. /** @hidden */
  48234. _activeBones: PerfCounter;
  48235. private _animationRatio;
  48236. /** @hidden */
  48237. _animationTimeLast: number;
  48238. /** @hidden */
  48239. _animationTime: number;
  48240. /**
  48241. * Gets or sets a general scale for animation speed
  48242. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  48243. */
  48244. animationTimeScale: number;
  48245. /** @hidden */
  48246. _cachedMaterial: Nullable<Material>;
  48247. /** @hidden */
  48248. _cachedEffect: Nullable<Effect>;
  48249. /** @hidden */
  48250. _cachedVisibility: Nullable<number>;
  48251. private _renderId;
  48252. private _frameId;
  48253. private _executeWhenReadyTimeoutId;
  48254. private _intermediateRendering;
  48255. private _viewUpdateFlag;
  48256. private _projectionUpdateFlag;
  48257. /** @hidden */
  48258. _toBeDisposed: Nullable<IDisposable>[];
  48259. private _activeRequests;
  48260. /** @hidden */
  48261. _pendingData: any[];
  48262. private _isDisposed;
  48263. /**
  48264. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  48265. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  48266. */
  48267. dispatchAllSubMeshesOfActiveMeshes: boolean;
  48268. private _activeMeshes;
  48269. private _processedMaterials;
  48270. private _renderTargets;
  48271. /** @hidden */
  48272. _activeParticleSystems: SmartArray<IParticleSystem>;
  48273. private _activeSkeletons;
  48274. private _softwareSkinnedMeshes;
  48275. private _renderingManager;
  48276. /** @hidden */
  48277. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  48278. private _transformMatrix;
  48279. private _sceneUbo;
  48280. /** @hidden */
  48281. _viewMatrix: Matrix;
  48282. /** @hidden */
  48283. _projectionMatrix: Matrix;
  48284. /** @hidden */
  48285. _forcedViewPosition: Nullable<Vector3>;
  48286. /** @hidden */
  48287. _frustumPlanes: Plane[];
  48288. /**
  48289. * Gets the list of frustum planes (built from the active camera)
  48290. */
  48291. get frustumPlanes(): Plane[];
  48292. /**
  48293. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  48294. * This is useful if there are more lights that the maximum simulteanous authorized
  48295. */
  48296. requireLightSorting: boolean;
  48297. /** @hidden */
  48298. readonly useMaterialMeshMap: boolean;
  48299. /** @hidden */
  48300. readonly useClonedMeshMap: boolean;
  48301. private _externalData;
  48302. private _uid;
  48303. /**
  48304. * @hidden
  48305. * Backing store of defined scene components.
  48306. */
  48307. _components: ISceneComponent[];
  48308. /**
  48309. * @hidden
  48310. * Backing store of defined scene components.
  48311. */
  48312. _serializableComponents: ISceneSerializableComponent[];
  48313. /**
  48314. * List of components to register on the next registration step.
  48315. */
  48316. private _transientComponents;
  48317. /**
  48318. * Registers the transient components if needed.
  48319. */
  48320. private _registerTransientComponents;
  48321. /**
  48322. * @hidden
  48323. * Add a component to the scene.
  48324. * Note that the ccomponent could be registered on th next frame if this is called after
  48325. * the register component stage.
  48326. * @param component Defines the component to add to the scene
  48327. */
  48328. _addComponent(component: ISceneComponent): void;
  48329. /**
  48330. * @hidden
  48331. * Gets a component from the scene.
  48332. * @param name defines the name of the component to retrieve
  48333. * @returns the component or null if not present
  48334. */
  48335. _getComponent(name: string): Nullable<ISceneComponent>;
  48336. /**
  48337. * @hidden
  48338. * Defines the actions happening before camera updates.
  48339. */
  48340. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  48341. /**
  48342. * @hidden
  48343. * Defines the actions happening before clear the canvas.
  48344. */
  48345. _beforeClearStage: Stage<SimpleStageAction>;
  48346. /**
  48347. * @hidden
  48348. * Defines the actions when collecting render targets for the frame.
  48349. */
  48350. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48351. /**
  48352. * @hidden
  48353. * Defines the actions happening for one camera in the frame.
  48354. */
  48355. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48356. /**
  48357. * @hidden
  48358. * Defines the actions happening during the per mesh ready checks.
  48359. */
  48360. _isReadyForMeshStage: Stage<MeshStageAction>;
  48361. /**
  48362. * @hidden
  48363. * Defines the actions happening before evaluate active mesh checks.
  48364. */
  48365. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  48366. /**
  48367. * @hidden
  48368. * Defines the actions happening during the evaluate sub mesh checks.
  48369. */
  48370. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  48371. /**
  48372. * @hidden
  48373. * Defines the actions happening during the active mesh stage.
  48374. */
  48375. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  48376. /**
  48377. * @hidden
  48378. * Defines the actions happening during the per camera render target step.
  48379. */
  48380. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  48381. /**
  48382. * @hidden
  48383. * Defines the actions happening just before the active camera is drawing.
  48384. */
  48385. _beforeCameraDrawStage: Stage<CameraStageAction>;
  48386. /**
  48387. * @hidden
  48388. * Defines the actions happening just before a render target is drawing.
  48389. */
  48390. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48391. /**
  48392. * @hidden
  48393. * Defines the actions happening just before a rendering group is drawing.
  48394. */
  48395. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48396. /**
  48397. * @hidden
  48398. * Defines the actions happening just before a mesh is drawing.
  48399. */
  48400. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48401. /**
  48402. * @hidden
  48403. * Defines the actions happening just after a mesh has been drawn.
  48404. */
  48405. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48406. /**
  48407. * @hidden
  48408. * Defines the actions happening just after a rendering group has been drawn.
  48409. */
  48410. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48411. /**
  48412. * @hidden
  48413. * Defines the actions happening just after the active camera has been drawn.
  48414. */
  48415. _afterCameraDrawStage: Stage<CameraStageAction>;
  48416. /**
  48417. * @hidden
  48418. * Defines the actions happening just after a render target has been drawn.
  48419. */
  48420. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48421. /**
  48422. * @hidden
  48423. * Defines the actions happening just after rendering all cameras and computing intersections.
  48424. */
  48425. _afterRenderStage: Stage<SimpleStageAction>;
  48426. /**
  48427. * @hidden
  48428. * Defines the actions happening when a pointer move event happens.
  48429. */
  48430. _pointerMoveStage: Stage<PointerMoveStageAction>;
  48431. /**
  48432. * @hidden
  48433. * Defines the actions happening when a pointer down event happens.
  48434. */
  48435. _pointerDownStage: Stage<PointerUpDownStageAction>;
  48436. /**
  48437. * @hidden
  48438. * Defines the actions happening when a pointer up event happens.
  48439. */
  48440. _pointerUpStage: Stage<PointerUpDownStageAction>;
  48441. /**
  48442. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  48443. */
  48444. private geometriesByUniqueId;
  48445. private _renderBundles;
  48446. /**
  48447. * Creates a new Scene
  48448. * @param engine defines the engine to use to render this scene
  48449. * @param options defines the scene options
  48450. */
  48451. constructor(engine: Engine, options?: SceneOptions);
  48452. /**
  48453. * Gets a string identifying the name of the class
  48454. * @returns "Scene" string
  48455. */
  48456. getClassName(): string;
  48457. private _defaultMeshCandidates;
  48458. /**
  48459. * @hidden
  48460. */
  48461. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48462. private _defaultSubMeshCandidates;
  48463. /**
  48464. * @hidden
  48465. */
  48466. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48467. /**
  48468. * Sets the default candidate providers for the scene.
  48469. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  48470. * and getCollidingSubMeshCandidates to their default function
  48471. */
  48472. setDefaultCandidateProviders(): void;
  48473. /**
  48474. * Gets the mesh that is currently under the pointer
  48475. */
  48476. get meshUnderPointer(): Nullable<AbstractMesh>;
  48477. /**
  48478. * Gets or sets the current on-screen X position of the pointer
  48479. */
  48480. get pointerX(): number;
  48481. set pointerX(value: number);
  48482. /**
  48483. * Gets or sets the current on-screen Y position of the pointer
  48484. */
  48485. get pointerY(): number;
  48486. set pointerY(value: number);
  48487. /**
  48488. * Gets the cached material (ie. the latest rendered one)
  48489. * @returns the cached material
  48490. */
  48491. getCachedMaterial(): Nullable<Material>;
  48492. /**
  48493. * Gets the cached effect (ie. the latest rendered one)
  48494. * @returns the cached effect
  48495. */
  48496. getCachedEffect(): Nullable<Effect>;
  48497. /**
  48498. * Gets the cached visibility state (ie. the latest rendered one)
  48499. * @returns the cached visibility state
  48500. */
  48501. getCachedVisibility(): Nullable<number>;
  48502. /**
  48503. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  48504. * @param material defines the current material
  48505. * @param effect defines the current effect
  48506. * @param visibility defines the current visibility state
  48507. * @returns true if one parameter is not cached
  48508. */
  48509. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  48510. /**
  48511. * Gets the engine associated with the scene
  48512. * @returns an Engine
  48513. */
  48514. getEngine(): Engine;
  48515. /**
  48516. * Gets the total number of vertices rendered per frame
  48517. * @returns the total number of vertices rendered per frame
  48518. */
  48519. getTotalVertices(): number;
  48520. /**
  48521. * Gets the performance counter for total vertices
  48522. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48523. */
  48524. get totalVerticesPerfCounter(): PerfCounter;
  48525. /**
  48526. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  48527. * @returns the total number of active indices rendered per frame
  48528. */
  48529. getActiveIndices(): number;
  48530. /**
  48531. * Gets the performance counter for active indices
  48532. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48533. */
  48534. get totalActiveIndicesPerfCounter(): PerfCounter;
  48535. /**
  48536. * Gets the total number of active particles rendered per frame
  48537. * @returns the total number of active particles rendered per frame
  48538. */
  48539. getActiveParticles(): number;
  48540. /**
  48541. * Gets the performance counter for active particles
  48542. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48543. */
  48544. get activeParticlesPerfCounter(): PerfCounter;
  48545. /**
  48546. * Gets the total number of active bones rendered per frame
  48547. * @returns the total number of active bones rendered per frame
  48548. */
  48549. getActiveBones(): number;
  48550. /**
  48551. * Gets the performance counter for active bones
  48552. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48553. */
  48554. get activeBonesPerfCounter(): PerfCounter;
  48555. /**
  48556. * Gets the array of active meshes
  48557. * @returns an array of AbstractMesh
  48558. */
  48559. getActiveMeshes(): SmartArray<AbstractMesh>;
  48560. /**
  48561. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  48562. * @returns a number
  48563. */
  48564. getAnimationRatio(): number;
  48565. /**
  48566. * Gets an unique Id for the current render phase
  48567. * @returns a number
  48568. */
  48569. getRenderId(): number;
  48570. /**
  48571. * Gets an unique Id for the current frame
  48572. * @returns a number
  48573. */
  48574. getFrameId(): number;
  48575. /** Call this function if you want to manually increment the render Id*/
  48576. incrementRenderId(): void;
  48577. private _createUbo;
  48578. /**
  48579. * Use this method to simulate a pointer move on a mesh
  48580. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48581. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48582. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48583. * @returns the current scene
  48584. */
  48585. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48586. /**
  48587. * Use this method to simulate a pointer down on a mesh
  48588. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48589. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48590. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48591. * @returns the current scene
  48592. */
  48593. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48594. /**
  48595. * Use this method to simulate a pointer up on a mesh
  48596. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48597. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48598. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48599. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  48600. * @returns the current scene
  48601. */
  48602. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  48603. /**
  48604. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  48605. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  48606. * @returns true if the pointer was captured
  48607. */
  48608. isPointerCaptured(pointerId?: number): boolean;
  48609. /**
  48610. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  48611. * @param attachUp defines if you want to attach events to pointerup
  48612. * @param attachDown defines if you want to attach events to pointerdown
  48613. * @param attachMove defines if you want to attach events to pointermove
  48614. */
  48615. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  48616. /** Detaches all event handlers*/
  48617. detachControl(): void;
  48618. /**
  48619. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  48620. * Delay loaded resources are not taking in account
  48621. * @return true if all required resources are ready
  48622. */
  48623. isReady(): boolean;
  48624. /** Resets all cached information relative to material (including effect and visibility) */
  48625. resetCachedMaterial(): void;
  48626. /**
  48627. * Registers a function to be called before every frame render
  48628. * @param func defines the function to register
  48629. */
  48630. registerBeforeRender(func: () => void): void;
  48631. /**
  48632. * Unregisters a function called before every frame render
  48633. * @param func defines the function to unregister
  48634. */
  48635. unregisterBeforeRender(func: () => void): void;
  48636. /**
  48637. * Registers a function to be called after every frame render
  48638. * @param func defines the function to register
  48639. */
  48640. registerAfterRender(func: () => void): void;
  48641. /**
  48642. * Unregisters a function called after every frame render
  48643. * @param func defines the function to unregister
  48644. */
  48645. unregisterAfterRender(func: () => void): void;
  48646. private _executeOnceBeforeRender;
  48647. /**
  48648. * The provided function will run before render once and will be disposed afterwards.
  48649. * A timeout delay can be provided so that the function will be executed in N ms.
  48650. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  48651. * @param func The function to be executed.
  48652. * @param timeout optional delay in ms
  48653. */
  48654. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  48655. /** @hidden */
  48656. _addPendingData(data: any): void;
  48657. /** @hidden */
  48658. _removePendingData(data: any): void;
  48659. /**
  48660. * Returns the number of items waiting to be loaded
  48661. * @returns the number of items waiting to be loaded
  48662. */
  48663. getWaitingItemsCount(): number;
  48664. /**
  48665. * Returns a boolean indicating if the scene is still loading data
  48666. */
  48667. get isLoading(): boolean;
  48668. /**
  48669. * Registers a function to be executed when the scene is ready
  48670. * @param {Function} func - the function to be executed
  48671. */
  48672. executeWhenReady(func: () => void): void;
  48673. /**
  48674. * Returns a promise that resolves when the scene is ready
  48675. * @returns A promise that resolves when the scene is ready
  48676. */
  48677. whenReadyAsync(): Promise<void>;
  48678. /** @hidden */
  48679. _checkIsReady(): void;
  48680. /**
  48681. * Gets all animatable attached to the scene
  48682. */
  48683. get animatables(): Animatable[];
  48684. /**
  48685. * Resets the last animation time frame.
  48686. * Useful to override when animations start running when loading a scene for the first time.
  48687. */
  48688. resetLastAnimationTimeFrame(): void;
  48689. /**
  48690. * Gets the current view matrix
  48691. * @returns a Matrix
  48692. */
  48693. getViewMatrix(): Matrix;
  48694. /**
  48695. * Gets the current projection matrix
  48696. * @returns a Matrix
  48697. */
  48698. getProjectionMatrix(): Matrix;
  48699. /**
  48700. * Gets the current transform matrix
  48701. * @returns a Matrix made of View * Projection
  48702. */
  48703. getTransformMatrix(): Matrix;
  48704. /**
  48705. * Sets the current transform matrix
  48706. * @param viewL defines the View matrix to use
  48707. * @param projectionL defines the Projection matrix to use
  48708. * @param viewR defines the right View matrix to use (if provided)
  48709. * @param projectionR defines the right Projection matrix to use (if provided)
  48710. */
  48711. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  48712. /**
  48713. * Gets the uniform buffer used to store scene data
  48714. * @returns a UniformBuffer
  48715. */
  48716. getSceneUniformBuffer(): UniformBuffer;
  48717. /**
  48718. * Gets an unique (relatively to the current scene) Id
  48719. * @returns an unique number for the scene
  48720. */
  48721. getUniqueId(): number;
  48722. /**
  48723. * Add a mesh to the list of scene's meshes
  48724. * @param newMesh defines the mesh to add
  48725. * @param recursive if all child meshes should also be added to the scene
  48726. */
  48727. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  48728. /**
  48729. * Remove a mesh for the list of scene's meshes
  48730. * @param toRemove defines the mesh to remove
  48731. * @param recursive if all child meshes should also be removed from the scene
  48732. * @returns the index where the mesh was in the mesh list
  48733. */
  48734. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  48735. /**
  48736. * Add a transform node to the list of scene's transform nodes
  48737. * @param newTransformNode defines the transform node to add
  48738. */
  48739. addTransformNode(newTransformNode: TransformNode): void;
  48740. /**
  48741. * Remove a transform node for the list of scene's transform nodes
  48742. * @param toRemove defines the transform node to remove
  48743. * @returns the index where the transform node was in the transform node list
  48744. */
  48745. removeTransformNode(toRemove: TransformNode): number;
  48746. /**
  48747. * Remove a skeleton for the list of scene's skeletons
  48748. * @param toRemove defines the skeleton to remove
  48749. * @returns the index where the skeleton was in the skeleton list
  48750. */
  48751. removeSkeleton(toRemove: Skeleton): number;
  48752. /**
  48753. * Remove a morph target for the list of scene's morph targets
  48754. * @param toRemove defines the morph target to remove
  48755. * @returns the index where the morph target was in the morph target list
  48756. */
  48757. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  48758. /**
  48759. * Remove a light for the list of scene's lights
  48760. * @param toRemove defines the light to remove
  48761. * @returns the index where the light was in the light list
  48762. */
  48763. removeLight(toRemove: Light): number;
  48764. /**
  48765. * Remove a camera for the list of scene's cameras
  48766. * @param toRemove defines the camera to remove
  48767. * @returns the index where the camera was in the camera list
  48768. */
  48769. removeCamera(toRemove: Camera): number;
  48770. /**
  48771. * Remove a particle system for the list of scene's particle systems
  48772. * @param toRemove defines the particle system to remove
  48773. * @returns the index where the particle system was in the particle system list
  48774. */
  48775. removeParticleSystem(toRemove: IParticleSystem): number;
  48776. /**
  48777. * Remove a animation for the list of scene's animations
  48778. * @param toRemove defines the animation to remove
  48779. * @returns the index where the animation was in the animation list
  48780. */
  48781. removeAnimation(toRemove: Animation): number;
  48782. /**
  48783. * Will stop the animation of the given target
  48784. * @param target - the target
  48785. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  48786. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  48787. */
  48788. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  48789. /**
  48790. * Removes the given animation group from this scene.
  48791. * @param toRemove The animation group to remove
  48792. * @returns The index of the removed animation group
  48793. */
  48794. removeAnimationGroup(toRemove: AnimationGroup): number;
  48795. /**
  48796. * Removes the given multi-material from this scene.
  48797. * @param toRemove The multi-material to remove
  48798. * @returns The index of the removed multi-material
  48799. */
  48800. removeMultiMaterial(toRemove: MultiMaterial): number;
  48801. /**
  48802. * Removes the given material from this scene.
  48803. * @param toRemove The material to remove
  48804. * @returns The index of the removed material
  48805. */
  48806. removeMaterial(toRemove: Material): number;
  48807. /**
  48808. * Removes the given action manager from this scene.
  48809. * @param toRemove The action manager to remove
  48810. * @returns The index of the removed action manager
  48811. */
  48812. removeActionManager(toRemove: AbstractActionManager): number;
  48813. /**
  48814. * Removes the given texture from this scene.
  48815. * @param toRemove The texture to remove
  48816. * @returns The index of the removed texture
  48817. */
  48818. removeTexture(toRemove: BaseTexture): number;
  48819. /**
  48820. * Adds the given light to this scene
  48821. * @param newLight The light to add
  48822. */
  48823. addLight(newLight: Light): void;
  48824. /**
  48825. * Sorts the list list based on light priorities
  48826. */
  48827. sortLightsByPriority(): void;
  48828. /**
  48829. * Adds the given camera to this scene
  48830. * @param newCamera The camera to add
  48831. */
  48832. addCamera(newCamera: Camera): void;
  48833. /**
  48834. * Adds the given skeleton to this scene
  48835. * @param newSkeleton The skeleton to add
  48836. */
  48837. addSkeleton(newSkeleton: Skeleton): void;
  48838. /**
  48839. * Adds the given particle system to this scene
  48840. * @param newParticleSystem The particle system to add
  48841. */
  48842. addParticleSystem(newParticleSystem: IParticleSystem): void;
  48843. /**
  48844. * Adds the given animation to this scene
  48845. * @param newAnimation The animation to add
  48846. */
  48847. addAnimation(newAnimation: Animation): void;
  48848. /**
  48849. * Adds the given animation group to this scene.
  48850. * @param newAnimationGroup The animation group to add
  48851. */
  48852. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  48853. /**
  48854. * Adds the given multi-material to this scene
  48855. * @param newMultiMaterial The multi-material to add
  48856. */
  48857. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  48858. /**
  48859. * Adds the given material to this scene
  48860. * @param newMaterial The material to add
  48861. */
  48862. addMaterial(newMaterial: Material): void;
  48863. /**
  48864. * Adds the given morph target to this scene
  48865. * @param newMorphTargetManager The morph target to add
  48866. */
  48867. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  48868. /**
  48869. * Adds the given geometry to this scene
  48870. * @param newGeometry The geometry to add
  48871. */
  48872. addGeometry(newGeometry: Geometry): void;
  48873. /**
  48874. * Adds the given action manager to this scene
  48875. * @param newActionManager The action manager to add
  48876. */
  48877. addActionManager(newActionManager: AbstractActionManager): void;
  48878. /**
  48879. * Adds the given texture to this scene.
  48880. * @param newTexture The texture to add
  48881. */
  48882. addTexture(newTexture: BaseTexture): void;
  48883. /**
  48884. * Switch active camera
  48885. * @param newCamera defines the new active camera
  48886. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  48887. */
  48888. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  48889. /**
  48890. * sets the active camera of the scene using its ID
  48891. * @param id defines the camera's ID
  48892. * @return the new active camera or null if none found.
  48893. */
  48894. setActiveCameraByID(id: string): Nullable<Camera>;
  48895. /**
  48896. * sets the active camera of the scene using its name
  48897. * @param name defines the camera's name
  48898. * @returns the new active camera or null if none found.
  48899. */
  48900. setActiveCameraByName(name: string): Nullable<Camera>;
  48901. /**
  48902. * get an animation group using its name
  48903. * @param name defines the material's name
  48904. * @return the animation group or null if none found.
  48905. */
  48906. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  48907. /**
  48908. * Get a material using its unique id
  48909. * @param uniqueId defines the material's unique id
  48910. * @return the material or null if none found.
  48911. */
  48912. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  48913. /**
  48914. * get a material using its id
  48915. * @param id defines the material's ID
  48916. * @return the material or null if none found.
  48917. */
  48918. getMaterialByID(id: string): Nullable<Material>;
  48919. /**
  48920. * Gets a the last added material using a given id
  48921. * @param id defines the material's ID
  48922. * @return the last material with the given id or null if none found.
  48923. */
  48924. getLastMaterialByID(id: string): Nullable<Material>;
  48925. /**
  48926. * Gets a material using its name
  48927. * @param name defines the material's name
  48928. * @return the material or null if none found.
  48929. */
  48930. getMaterialByName(name: string): Nullable<Material>;
  48931. /**
  48932. * Get a texture using its unique id
  48933. * @param uniqueId defines the texture's unique id
  48934. * @return the texture or null if none found.
  48935. */
  48936. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  48937. /**
  48938. * Gets a camera using its id
  48939. * @param id defines the id to look for
  48940. * @returns the camera or null if not found
  48941. */
  48942. getCameraByID(id: string): Nullable<Camera>;
  48943. /**
  48944. * Gets a camera using its unique id
  48945. * @param uniqueId defines the unique id to look for
  48946. * @returns the camera or null if not found
  48947. */
  48948. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  48949. /**
  48950. * Gets a camera using its name
  48951. * @param name defines the camera's name
  48952. * @return the camera or null if none found.
  48953. */
  48954. getCameraByName(name: string): Nullable<Camera>;
  48955. /**
  48956. * Gets a bone using its id
  48957. * @param id defines the bone's id
  48958. * @return the bone or null if not found
  48959. */
  48960. getBoneByID(id: string): Nullable<Bone>;
  48961. /**
  48962. * Gets a bone using its id
  48963. * @param name defines the bone's name
  48964. * @return the bone or null if not found
  48965. */
  48966. getBoneByName(name: string): Nullable<Bone>;
  48967. /**
  48968. * Gets a light node using its name
  48969. * @param name defines the the light's name
  48970. * @return the light or null if none found.
  48971. */
  48972. getLightByName(name: string): Nullable<Light>;
  48973. /**
  48974. * Gets a light node using its id
  48975. * @param id defines the light's id
  48976. * @return the light or null if none found.
  48977. */
  48978. getLightByID(id: string): Nullable<Light>;
  48979. /**
  48980. * Gets a light node using its scene-generated unique ID
  48981. * @param uniqueId defines the light's unique id
  48982. * @return the light or null if none found.
  48983. */
  48984. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  48985. /**
  48986. * Gets a particle system by id
  48987. * @param id defines the particle system id
  48988. * @return the corresponding system or null if none found
  48989. */
  48990. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  48991. /**
  48992. * Gets a geometry using its ID
  48993. * @param id defines the geometry's id
  48994. * @return the geometry or null if none found.
  48995. */
  48996. getGeometryByID(id: string): Nullable<Geometry>;
  48997. private _getGeometryByUniqueID;
  48998. /**
  48999. * Add a new geometry to this scene
  49000. * @param geometry defines the geometry to be added to the scene.
  49001. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  49002. * @return a boolean defining if the geometry was added or not
  49003. */
  49004. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  49005. /**
  49006. * Removes an existing geometry
  49007. * @param geometry defines the geometry to be removed from the scene
  49008. * @return a boolean defining if the geometry was removed or not
  49009. */
  49010. removeGeometry(geometry: Geometry): boolean;
  49011. /**
  49012. * Gets the list of geometries attached to the scene
  49013. * @returns an array of Geometry
  49014. */
  49015. getGeometries(): Geometry[];
  49016. /**
  49017. * Gets the first added mesh found of a given ID
  49018. * @param id defines the id to search for
  49019. * @return the mesh found or null if not found at all
  49020. */
  49021. getMeshByID(id: string): Nullable<AbstractMesh>;
  49022. /**
  49023. * Gets a list of meshes using their id
  49024. * @param id defines the id to search for
  49025. * @returns a list of meshes
  49026. */
  49027. getMeshesByID(id: string): Array<AbstractMesh>;
  49028. /**
  49029. * Gets the first added transform node found of a given ID
  49030. * @param id defines the id to search for
  49031. * @return the found transform node or null if not found at all.
  49032. */
  49033. getTransformNodeByID(id: string): Nullable<TransformNode>;
  49034. /**
  49035. * Gets a transform node with its auto-generated unique id
  49036. * @param uniqueId efines the unique id to search for
  49037. * @return the found transform node or null if not found at all.
  49038. */
  49039. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  49040. /**
  49041. * Gets a list of transform nodes using their id
  49042. * @param id defines the id to search for
  49043. * @returns a list of transform nodes
  49044. */
  49045. getTransformNodesByID(id: string): Array<TransformNode>;
  49046. /**
  49047. * Gets a mesh with its auto-generated unique id
  49048. * @param uniqueId defines the unique id to search for
  49049. * @return the found mesh or null if not found at all.
  49050. */
  49051. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  49052. /**
  49053. * Gets a the last added mesh using a given id
  49054. * @param id defines the id to search for
  49055. * @return the found mesh or null if not found at all.
  49056. */
  49057. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  49058. /**
  49059. * Gets a the last added node (Mesh, Camera, Light) using a given id
  49060. * @param id defines the id to search for
  49061. * @return the found node or null if not found at all
  49062. */
  49063. getLastEntryByID(id: string): Nullable<Node>;
  49064. /**
  49065. * Gets a node (Mesh, Camera, Light) using a given id
  49066. * @param id defines the id to search for
  49067. * @return the found node or null if not found at all
  49068. */
  49069. getNodeByID(id: string): Nullable<Node>;
  49070. /**
  49071. * Gets a node (Mesh, Camera, Light) using a given name
  49072. * @param name defines the name to search for
  49073. * @return the found node or null if not found at all.
  49074. */
  49075. getNodeByName(name: string): Nullable<Node>;
  49076. /**
  49077. * Gets a mesh using a given name
  49078. * @param name defines the name to search for
  49079. * @return the found mesh or null if not found at all.
  49080. */
  49081. getMeshByName(name: string): Nullable<AbstractMesh>;
  49082. /**
  49083. * Gets a transform node using a given name
  49084. * @param name defines the name to search for
  49085. * @return the found transform node or null if not found at all.
  49086. */
  49087. getTransformNodeByName(name: string): Nullable<TransformNode>;
  49088. /**
  49089. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  49090. * @param id defines the id to search for
  49091. * @return the found skeleton or null if not found at all.
  49092. */
  49093. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  49094. /**
  49095. * Gets a skeleton using a given auto generated unique id
  49096. * @param uniqueId defines the unique id to search for
  49097. * @return the found skeleton or null if not found at all.
  49098. */
  49099. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  49100. /**
  49101. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  49102. * @param id defines the id to search for
  49103. * @return the found skeleton or null if not found at all.
  49104. */
  49105. getSkeletonById(id: string): Nullable<Skeleton>;
  49106. /**
  49107. * Gets a skeleton using a given name
  49108. * @param name defines the name to search for
  49109. * @return the found skeleton or null if not found at all.
  49110. */
  49111. getSkeletonByName(name: string): Nullable<Skeleton>;
  49112. /**
  49113. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  49114. * @param id defines the id to search for
  49115. * @return the found morph target manager or null if not found at all.
  49116. */
  49117. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  49118. /**
  49119. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  49120. * @param id defines the id to search for
  49121. * @return the found morph target or null if not found at all.
  49122. */
  49123. getMorphTargetById(id: string): Nullable<MorphTarget>;
  49124. /**
  49125. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  49126. * @param name defines the name to search for
  49127. * @return the found morph target or null if not found at all.
  49128. */
  49129. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  49130. /**
  49131. * Gets a post process using a given name (if many are found, this function will pick the first one)
  49132. * @param name defines the name to search for
  49133. * @return the found post process or null if not found at all.
  49134. */
  49135. getPostProcessByName(name: string): Nullable<PostProcess>;
  49136. /**
  49137. * Gets a boolean indicating if the given mesh is active
  49138. * @param mesh defines the mesh to look for
  49139. * @returns true if the mesh is in the active list
  49140. */
  49141. isActiveMesh(mesh: AbstractMesh): boolean;
  49142. /**
  49143. * Return a unique id as a string which can serve as an identifier for the scene
  49144. */
  49145. get uid(): string;
  49146. /**
  49147. * Add an externaly attached data from its key.
  49148. * This method call will fail and return false, if such key already exists.
  49149. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  49150. * @param key the unique key that identifies the data
  49151. * @param data the data object to associate to the key for this Engine instance
  49152. * @return true if no such key were already present and the data was added successfully, false otherwise
  49153. */
  49154. addExternalData<T>(key: string, data: T): boolean;
  49155. /**
  49156. * Get an externaly attached data from its key
  49157. * @param key the unique key that identifies the data
  49158. * @return the associated data, if present (can be null), or undefined if not present
  49159. */
  49160. getExternalData<T>(key: string): Nullable<T>;
  49161. /**
  49162. * Get an externaly attached data from its key, create it using a factory if it's not already present
  49163. * @param key the unique key that identifies the data
  49164. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  49165. * @return the associated data, can be null if the factory returned null.
  49166. */
  49167. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  49168. /**
  49169. * Remove an externaly attached data from the Engine instance
  49170. * @param key the unique key that identifies the data
  49171. * @return true if the data was successfully removed, false if it doesn't exist
  49172. */
  49173. removeExternalData(key: string): boolean;
  49174. private _evaluateSubMesh;
  49175. /**
  49176. * Clear the processed materials smart array preventing retention point in material dispose.
  49177. */
  49178. freeProcessedMaterials(): void;
  49179. private _preventFreeActiveMeshesAndRenderingGroups;
  49180. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  49181. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  49182. * when disposing several meshes in a row or a hierarchy of meshes.
  49183. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  49184. */
  49185. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  49186. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  49187. /**
  49188. * Clear the active meshes smart array preventing retention point in mesh dispose.
  49189. */
  49190. freeActiveMeshes(): void;
  49191. /**
  49192. * Clear the info related to rendering groups preventing retention points during dispose.
  49193. */
  49194. freeRenderingGroups(): void;
  49195. /** @hidden */
  49196. _isInIntermediateRendering(): boolean;
  49197. /**
  49198. * Lambda returning the list of potentially active meshes.
  49199. */
  49200. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  49201. /**
  49202. * Lambda returning the list of potentially active sub meshes.
  49203. */
  49204. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  49205. /**
  49206. * Lambda returning the list of potentially intersecting sub meshes.
  49207. */
  49208. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  49209. /**
  49210. * Lambda returning the list of potentially colliding sub meshes.
  49211. */
  49212. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  49213. /** @hidden */
  49214. _activeMeshesFrozen: boolean;
  49215. private _skipEvaluateActiveMeshesCompletely;
  49216. /**
  49217. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  49218. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  49219. * @param onSuccess optional success callback
  49220. * @param onError optional error callback
  49221. * @returns the current scene
  49222. */
  49223. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  49224. /**
  49225. * Use this function to restart evaluating active meshes on every frame
  49226. * @returns the current scene
  49227. */
  49228. unfreezeActiveMeshes(): Scene;
  49229. private _evaluateActiveMeshes;
  49230. private _activeMesh;
  49231. /**
  49232. * Update the transform matrix to update from the current active camera
  49233. * @param force defines a boolean used to force the update even if cache is up to date
  49234. */
  49235. updateTransformMatrix(force?: boolean): void;
  49236. private _bindFrameBuffer;
  49237. /** @hidden */
  49238. _allowPostProcessClearColor: boolean;
  49239. /** @hidden */
  49240. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  49241. private _processSubCameras;
  49242. private _checkIntersections;
  49243. /** @hidden */
  49244. _advancePhysicsEngineStep(step: number): void;
  49245. /**
  49246. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  49247. */
  49248. getDeterministicFrameTime: () => number;
  49249. /** @hidden */
  49250. _animate(): void;
  49251. /** Execute all animations (for a frame) */
  49252. animate(): void;
  49253. /**
  49254. * Render the scene
  49255. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  49256. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  49257. */
  49258. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  49259. /**
  49260. * Freeze all materials
  49261. * A frozen material will not be updatable but should be faster to render
  49262. */
  49263. freezeMaterials(): void;
  49264. /**
  49265. * Unfreeze all materials
  49266. * A frozen material will not be updatable but should be faster to render
  49267. */
  49268. unfreezeMaterials(): void;
  49269. /**
  49270. * Releases all held ressources
  49271. */
  49272. dispose(): void;
  49273. /**
  49274. * Gets if the scene is already disposed
  49275. */
  49276. get isDisposed(): boolean;
  49277. /**
  49278. * Call this function to reduce memory footprint of the scene.
  49279. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  49280. */
  49281. clearCachedVertexData(): void;
  49282. /**
  49283. * This function will remove the local cached buffer data from texture.
  49284. * It will save memory but will prevent the texture from being rebuilt
  49285. */
  49286. cleanCachedTextureBuffer(): void;
  49287. /**
  49288. * Get the world extend vectors with an optional filter
  49289. *
  49290. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  49291. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  49292. */
  49293. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  49294. min: Vector3;
  49295. max: Vector3;
  49296. };
  49297. /**
  49298. * Creates a ray that can be used to pick in the scene
  49299. * @param x defines the x coordinate of the origin (on-screen)
  49300. * @param y defines the y coordinate of the origin (on-screen)
  49301. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49302. * @param camera defines the camera to use for the picking
  49303. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49304. * @returns a Ray
  49305. */
  49306. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  49307. /**
  49308. * Creates a ray that can be used to pick in the scene
  49309. * @param x defines the x coordinate of the origin (on-screen)
  49310. * @param y defines the y coordinate of the origin (on-screen)
  49311. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49312. * @param result defines the ray where to store the picking ray
  49313. * @param camera defines the camera to use for the picking
  49314. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49315. * @returns the current scene
  49316. */
  49317. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  49318. /**
  49319. * Creates a ray that can be used to pick in the scene
  49320. * @param x defines the x coordinate of the origin (on-screen)
  49321. * @param y defines the y coordinate of the origin (on-screen)
  49322. * @param camera defines the camera to use for the picking
  49323. * @returns a Ray
  49324. */
  49325. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  49326. /**
  49327. * Creates a ray that can be used to pick in the scene
  49328. * @param x defines the x coordinate of the origin (on-screen)
  49329. * @param y defines the y coordinate of the origin (on-screen)
  49330. * @param result defines the ray where to store the picking ray
  49331. * @param camera defines the camera to use for the picking
  49332. * @returns the current scene
  49333. */
  49334. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  49335. /** Launch a ray to try to pick a mesh in the scene
  49336. * @param x position on screen
  49337. * @param y position on screen
  49338. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  49339. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49340. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49341. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49342. * @returns a PickingInfo
  49343. */
  49344. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49345. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  49346. * @param x position on screen
  49347. * @param y position on screen
  49348. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  49349. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49350. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49351. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  49352. */
  49353. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  49354. /** Use the given ray to pick a mesh in the scene
  49355. * @param ray The ray to use to pick meshes
  49356. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  49357. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49359. * @returns a PickingInfo
  49360. */
  49361. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49362. /**
  49363. * Launch a ray to try to pick a mesh in the scene
  49364. * @param x X position on screen
  49365. * @param y Y position on screen
  49366. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  49367. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49369. * @returns an array of PickingInfo
  49370. */
  49371. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49372. /**
  49373. * Launch a ray to try to pick a mesh in the scene
  49374. * @param ray Ray to use
  49375. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  49376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49377. * @returns an array of PickingInfo
  49378. */
  49379. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49380. /**
  49381. * Force the value of meshUnderPointer
  49382. * @param mesh defines the mesh to use
  49383. * @param pointerId optional pointer id when using more than one pointer
  49384. */
  49385. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  49386. /**
  49387. * Gets the mesh under the pointer
  49388. * @returns a Mesh or null if no mesh is under the pointer
  49389. */
  49390. getPointerOverMesh(): Nullable<AbstractMesh>;
  49391. /** @hidden */
  49392. _rebuildGeometries(): void;
  49393. /** @hidden */
  49394. _rebuildTextures(): void;
  49395. private _getByTags;
  49396. /**
  49397. * Get a list of meshes by tags
  49398. * @param tagsQuery defines the tags query to use
  49399. * @param forEach defines a predicate used to filter results
  49400. * @returns an array of Mesh
  49401. */
  49402. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  49403. /**
  49404. * Get a list of cameras by tags
  49405. * @param tagsQuery defines the tags query to use
  49406. * @param forEach defines a predicate used to filter results
  49407. * @returns an array of Camera
  49408. */
  49409. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  49410. /**
  49411. * Get a list of lights by tags
  49412. * @param tagsQuery defines the tags query to use
  49413. * @param forEach defines a predicate used to filter results
  49414. * @returns an array of Light
  49415. */
  49416. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  49417. /**
  49418. * Get a list of materials by tags
  49419. * @param tagsQuery defines the tags query to use
  49420. * @param forEach defines a predicate used to filter results
  49421. * @returns an array of Material
  49422. */
  49423. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  49424. /**
  49425. * Get a list of transform nodes by tags
  49426. * @param tagsQuery defines the tags query to use
  49427. * @param forEach defines a predicate used to filter results
  49428. * @returns an array of TransformNode
  49429. */
  49430. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  49431. /**
  49432. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  49433. * This allowed control for front to back rendering or reversly depending of the special needs.
  49434. *
  49435. * @param renderingGroupId The rendering group id corresponding to its index
  49436. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  49437. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  49438. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  49439. */
  49440. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  49441. /**
  49442. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  49443. *
  49444. * @param renderingGroupId The rendering group id corresponding to its index
  49445. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49446. * @param depth Automatically clears depth between groups if true and autoClear is true.
  49447. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  49448. */
  49449. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  49450. /**
  49451. * Gets the current auto clear configuration for one rendering group of the rendering
  49452. * manager.
  49453. * @param index the rendering group index to get the information for
  49454. * @returns The auto clear setup for the requested rendering group
  49455. */
  49456. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  49457. private _blockMaterialDirtyMechanism;
  49458. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  49459. get blockMaterialDirtyMechanism(): boolean;
  49460. set blockMaterialDirtyMechanism(value: boolean);
  49461. /**
  49462. * Will flag all materials as dirty to trigger new shader compilation
  49463. * @param flag defines the flag used to specify which material part must be marked as dirty
  49464. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  49465. */
  49466. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  49467. /** @hidden */
  49468. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  49469. /** @hidden */
  49470. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49471. /** @hidden */
  49472. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  49473. /** @hidden */
  49474. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  49475. /** @hidden */
  49476. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  49477. /** @hidden */
  49478. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49479. }
  49480. }
  49481. declare module "babylonjs/assetContainer" {
  49482. import { AbstractScene } from "babylonjs/abstractScene";
  49483. import { Scene } from "babylonjs/scene";
  49484. import { Mesh } from "babylonjs/Meshes/mesh";
  49485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49486. import { Skeleton } from "babylonjs/Bones/skeleton";
  49487. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49488. import { Animatable } from "babylonjs/Animations/animatable";
  49489. import { Nullable } from "babylonjs/types";
  49490. import { Node } from "babylonjs/node";
  49491. /**
  49492. * Set of assets to keep when moving a scene into an asset container.
  49493. */
  49494. export class KeepAssets extends AbstractScene {
  49495. }
  49496. /**
  49497. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  49498. */
  49499. export class InstantiatedEntries {
  49500. /**
  49501. * List of new root nodes (eg. nodes with no parent)
  49502. */
  49503. rootNodes: TransformNode[];
  49504. /**
  49505. * List of new skeletons
  49506. */
  49507. skeletons: Skeleton[];
  49508. /**
  49509. * List of new animation groups
  49510. */
  49511. animationGroups: AnimationGroup[];
  49512. }
  49513. /**
  49514. * Container with a set of assets that can be added or removed from a scene.
  49515. */
  49516. export class AssetContainer extends AbstractScene {
  49517. private _wasAddedToScene;
  49518. /**
  49519. * The scene the AssetContainer belongs to.
  49520. */
  49521. scene: Scene;
  49522. /**
  49523. * Instantiates an AssetContainer.
  49524. * @param scene The scene the AssetContainer belongs to.
  49525. */
  49526. constructor(scene: Scene);
  49527. /**
  49528. * Instantiate or clone all meshes and add the new ones to the scene.
  49529. * Skeletons and animation groups will all be cloned
  49530. * @param nameFunction defines an optional function used to get new names for clones
  49531. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  49532. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  49533. */
  49534. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  49535. /**
  49536. * Adds all the assets from the container to the scene.
  49537. */
  49538. addAllToScene(): void;
  49539. /**
  49540. * Removes all the assets in the container from the scene
  49541. */
  49542. removeAllFromScene(): void;
  49543. /**
  49544. * Disposes all the assets in the container
  49545. */
  49546. dispose(): void;
  49547. private _moveAssets;
  49548. /**
  49549. * Removes all the assets contained in the scene and adds them to the container.
  49550. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  49551. */
  49552. moveAllFromScene(keepAssets?: KeepAssets): void;
  49553. /**
  49554. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  49555. * @returns the root mesh
  49556. */
  49557. createRootMesh(): Mesh;
  49558. /**
  49559. * Merge animations (direct and animation groups) from this asset container into a scene
  49560. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49561. * @param animatables set of animatables to retarget to a node from the scene
  49562. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  49563. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  49564. */
  49565. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  49566. }
  49567. }
  49568. declare module "babylonjs/abstractScene" {
  49569. import { Scene } from "babylonjs/scene";
  49570. import { Nullable } from "babylonjs/types";
  49571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49572. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49573. import { Geometry } from "babylonjs/Meshes/geometry";
  49574. import { Skeleton } from "babylonjs/Bones/skeleton";
  49575. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  49576. import { AssetContainer } from "babylonjs/assetContainer";
  49577. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49578. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49580. import { Material } from "babylonjs/Materials/material";
  49581. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  49582. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  49583. import { Camera } from "babylonjs/Cameras/camera";
  49584. import { Light } from "babylonjs/Lights/light";
  49585. import { Node } from "babylonjs/node";
  49586. import { Animation } from "babylonjs/Animations/animation";
  49587. /**
  49588. * Defines how the parser contract is defined.
  49589. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  49590. */
  49591. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  49592. /**
  49593. * Defines how the individual parser contract is defined.
  49594. * These parser can parse an individual asset
  49595. */
  49596. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  49597. /**
  49598. * Base class of the scene acting as a container for the different elements composing a scene.
  49599. * This class is dynamically extended by the different components of the scene increasing
  49600. * flexibility and reducing coupling
  49601. */
  49602. export abstract class AbstractScene {
  49603. /**
  49604. * Stores the list of available parsers in the application.
  49605. */
  49606. private static _BabylonFileParsers;
  49607. /**
  49608. * Stores the list of available individual parsers in the application.
  49609. */
  49610. private static _IndividualBabylonFileParsers;
  49611. /**
  49612. * Adds a parser in the list of available ones
  49613. * @param name Defines the name of the parser
  49614. * @param parser Defines the parser to add
  49615. */
  49616. static AddParser(name: string, parser: BabylonFileParser): void;
  49617. /**
  49618. * Gets a general parser from the list of avaialble ones
  49619. * @param name Defines the name of the parser
  49620. * @returns the requested parser or null
  49621. */
  49622. static GetParser(name: string): Nullable<BabylonFileParser>;
  49623. /**
  49624. * Adds n individual parser in the list of available ones
  49625. * @param name Defines the name of the parser
  49626. * @param parser Defines the parser to add
  49627. */
  49628. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  49629. /**
  49630. * Gets an individual parser from the list of avaialble ones
  49631. * @param name Defines the name of the parser
  49632. * @returns the requested parser or null
  49633. */
  49634. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  49635. /**
  49636. * Parser json data and populate both a scene and its associated container object
  49637. * @param jsonData Defines the data to parse
  49638. * @param scene Defines the scene to parse the data for
  49639. * @param container Defines the container attached to the parsing sequence
  49640. * @param rootUrl Defines the root url of the data
  49641. */
  49642. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  49643. /**
  49644. * Gets the list of root nodes (ie. nodes with no parent)
  49645. */
  49646. rootNodes: Node[];
  49647. /** All of the cameras added to this scene
  49648. * @see https://doc.babylonjs.com/babylon101/cameras
  49649. */
  49650. cameras: Camera[];
  49651. /**
  49652. * All of the lights added to this scene
  49653. * @see https://doc.babylonjs.com/babylon101/lights
  49654. */
  49655. lights: Light[];
  49656. /**
  49657. * All of the (abstract) meshes added to this scene
  49658. */
  49659. meshes: AbstractMesh[];
  49660. /**
  49661. * The list of skeletons added to the scene
  49662. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  49663. */
  49664. skeletons: Skeleton[];
  49665. /**
  49666. * All of the particle systems added to this scene
  49667. * @see https://doc.babylonjs.com/babylon101/particles
  49668. */
  49669. particleSystems: IParticleSystem[];
  49670. /**
  49671. * Gets a list of Animations associated with the scene
  49672. */
  49673. animations: Animation[];
  49674. /**
  49675. * All of the animation groups added to this scene
  49676. * @see https://doc.babylonjs.com/how_to/group
  49677. */
  49678. animationGroups: AnimationGroup[];
  49679. /**
  49680. * All of the multi-materials added to this scene
  49681. * @see https://doc.babylonjs.com/how_to/multi_materials
  49682. */
  49683. multiMaterials: MultiMaterial[];
  49684. /**
  49685. * All of the materials added to this scene
  49686. * In the context of a Scene, it is not supposed to be modified manually.
  49687. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  49688. * Note also that the order of the Material within the array is not significant and might change.
  49689. * @see https://doc.babylonjs.com/babylon101/materials
  49690. */
  49691. materials: Material[];
  49692. /**
  49693. * The list of morph target managers added to the scene
  49694. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  49695. */
  49696. morphTargetManagers: MorphTargetManager[];
  49697. /**
  49698. * The list of geometries used in the scene.
  49699. */
  49700. geometries: Geometry[];
  49701. /**
  49702. * All of the tranform nodes added to this scene
  49703. * In the context of a Scene, it is not supposed to be modified manually.
  49704. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  49705. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  49706. * @see https://doc.babylonjs.com/how_to/transformnode
  49707. */
  49708. transformNodes: TransformNode[];
  49709. /**
  49710. * ActionManagers available on the scene.
  49711. */
  49712. actionManagers: AbstractActionManager[];
  49713. /**
  49714. * Textures to keep.
  49715. */
  49716. textures: BaseTexture[];
  49717. /** @hidden */
  49718. protected _environmentTexture: Nullable<BaseTexture>;
  49719. /**
  49720. * Texture used in all pbr material as the reflection texture.
  49721. * As in the majority of the scene they are the same (exception for multi room and so on),
  49722. * this is easier to reference from here than from all the materials.
  49723. */
  49724. get environmentTexture(): Nullable<BaseTexture>;
  49725. set environmentTexture(value: Nullable<BaseTexture>);
  49726. /**
  49727. * The list of postprocesses added to the scene
  49728. */
  49729. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  49730. /**
  49731. * @returns all meshes, lights, cameras, transformNodes and bones
  49732. */
  49733. getNodes(): Array<Node>;
  49734. }
  49735. }
  49736. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  49737. /**
  49738. * Interface used to define options for Sound class
  49739. */
  49740. export interface ISoundOptions {
  49741. /**
  49742. * Does the sound autoplay once loaded.
  49743. */
  49744. autoplay?: boolean;
  49745. /**
  49746. * Does the sound loop after it finishes playing once.
  49747. */
  49748. loop?: boolean;
  49749. /**
  49750. * Sound's volume
  49751. */
  49752. volume?: number;
  49753. /**
  49754. * Is it a spatial sound?
  49755. */
  49756. spatialSound?: boolean;
  49757. /**
  49758. * Maximum distance to hear that sound
  49759. */
  49760. maxDistance?: number;
  49761. /**
  49762. * Uses user defined attenuation function
  49763. */
  49764. useCustomAttenuation?: boolean;
  49765. /**
  49766. * Define the roll off factor of spatial sounds.
  49767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49768. */
  49769. rolloffFactor?: number;
  49770. /**
  49771. * Define the reference distance the sound should be heard perfectly.
  49772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49773. */
  49774. refDistance?: number;
  49775. /**
  49776. * Define the distance attenuation model the sound will follow.
  49777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49778. */
  49779. distanceModel?: string;
  49780. /**
  49781. * Defines the playback speed (1 by default)
  49782. */
  49783. playbackRate?: number;
  49784. /**
  49785. * Defines if the sound is from a streaming source
  49786. */
  49787. streaming?: boolean;
  49788. /**
  49789. * Defines an optional length (in seconds) inside the sound file
  49790. */
  49791. length?: number;
  49792. /**
  49793. * Defines an optional offset (in seconds) inside the sound file
  49794. */
  49795. offset?: number;
  49796. /**
  49797. * If true, URLs will not be required to state the audio file codec to use.
  49798. */
  49799. skipCodecCheck?: boolean;
  49800. }
  49801. }
  49802. declare module "babylonjs/Audio/sound" {
  49803. import { Observable } from "babylonjs/Misc/observable";
  49804. import { Vector3 } from "babylonjs/Maths/math.vector";
  49805. import { Nullable } from "babylonjs/types";
  49806. import { Scene } from "babylonjs/scene";
  49807. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49808. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  49809. /**
  49810. * Defines a sound that can be played in the application.
  49811. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  49812. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49813. */
  49814. export class Sound {
  49815. /**
  49816. * The name of the sound in the scene.
  49817. */
  49818. name: string;
  49819. /**
  49820. * Does the sound autoplay once loaded.
  49821. */
  49822. autoplay: boolean;
  49823. private _loop;
  49824. /**
  49825. * Does the sound loop after it finishes playing once.
  49826. */
  49827. get loop(): boolean;
  49828. set loop(value: boolean);
  49829. /**
  49830. * Does the sound use a custom attenuation curve to simulate the falloff
  49831. * happening when the source gets further away from the camera.
  49832. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49833. */
  49834. useCustomAttenuation: boolean;
  49835. /**
  49836. * The sound track id this sound belongs to.
  49837. */
  49838. soundTrackId: number;
  49839. /**
  49840. * Is this sound currently played.
  49841. */
  49842. isPlaying: boolean;
  49843. /**
  49844. * Is this sound currently paused.
  49845. */
  49846. isPaused: boolean;
  49847. /**
  49848. * Does this sound enables spatial sound.
  49849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49850. */
  49851. spatialSound: boolean;
  49852. /**
  49853. * Define the reference distance the sound should be heard perfectly.
  49854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49855. */
  49856. refDistance: number;
  49857. /**
  49858. * Define the roll off factor of spatial sounds.
  49859. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49860. */
  49861. rolloffFactor: number;
  49862. /**
  49863. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  49864. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49865. */
  49866. maxDistance: number;
  49867. /**
  49868. * Define the distance attenuation model the sound will follow.
  49869. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49870. */
  49871. distanceModel: string;
  49872. /**
  49873. * @hidden
  49874. * Back Compat
  49875. **/
  49876. onended: () => any;
  49877. /**
  49878. * Gets or sets an object used to store user defined information for the sound.
  49879. */
  49880. metadata: any;
  49881. /**
  49882. * Observable event when the current playing sound finishes.
  49883. */
  49884. onEndedObservable: Observable<Sound>;
  49885. /**
  49886. * Gets the current time for the sound.
  49887. */
  49888. get currentTime(): number;
  49889. private _panningModel;
  49890. private _playbackRate;
  49891. private _streaming;
  49892. private _startTime;
  49893. private _startOffset;
  49894. private _position;
  49895. /** @hidden */
  49896. _positionInEmitterSpace: boolean;
  49897. private _localDirection;
  49898. private _volume;
  49899. private _isReadyToPlay;
  49900. private _isDirectional;
  49901. private _readyToPlayCallback;
  49902. private _audioBuffer;
  49903. private _soundSource;
  49904. private _streamingSource;
  49905. private _soundPanner;
  49906. private _soundGain;
  49907. private _inputAudioNode;
  49908. private _outputAudioNode;
  49909. private _coneInnerAngle;
  49910. private _coneOuterAngle;
  49911. private _coneOuterGain;
  49912. private _scene;
  49913. private _connectedTransformNode;
  49914. private _customAttenuationFunction;
  49915. private _registerFunc;
  49916. private _isOutputConnected;
  49917. private _htmlAudioElement;
  49918. private _urlType;
  49919. private _length?;
  49920. private _offset?;
  49921. /** @hidden */
  49922. static _SceneComponentInitialization: (scene: Scene) => void;
  49923. /**
  49924. * Create a sound and attach it to a scene
  49925. * @param name Name of your sound
  49926. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  49927. * @param scene defines the scene the sound belongs to
  49928. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  49929. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  49930. */
  49931. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  49932. /**
  49933. * Release the sound and its associated resources
  49934. */
  49935. dispose(): void;
  49936. /**
  49937. * Gets if the sounds is ready to be played or not.
  49938. * @returns true if ready, otherwise false
  49939. */
  49940. isReady(): boolean;
  49941. /**
  49942. * Get the current class name.
  49943. * @returns current class name
  49944. */
  49945. getClassName(): string;
  49946. private _soundLoaded;
  49947. /**
  49948. * Sets the data of the sound from an audiobuffer
  49949. * @param audioBuffer The audioBuffer containing the data
  49950. */
  49951. setAudioBuffer(audioBuffer: AudioBuffer): void;
  49952. /**
  49953. * Updates the current sounds options such as maxdistance, loop...
  49954. * @param options A JSON object containing values named as the object properties
  49955. */
  49956. updateOptions(options: ISoundOptions): void;
  49957. private _createSpatialParameters;
  49958. private _updateSpatialParameters;
  49959. /**
  49960. * Switch the panning model to HRTF:
  49961. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49963. */
  49964. switchPanningModelToHRTF(): void;
  49965. /**
  49966. * Switch the panning model to Equal Power:
  49967. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49969. */
  49970. switchPanningModelToEqualPower(): void;
  49971. private _switchPanningModel;
  49972. /**
  49973. * Connect this sound to a sound track audio node like gain...
  49974. * @param soundTrackAudioNode the sound track audio node to connect to
  49975. */
  49976. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  49977. /**
  49978. * Transform this sound into a directional source
  49979. * @param coneInnerAngle Size of the inner cone in degree
  49980. * @param coneOuterAngle Size of the outer cone in degree
  49981. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  49982. */
  49983. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  49984. /**
  49985. * Gets or sets the inner angle for the directional cone.
  49986. */
  49987. get directionalConeInnerAngle(): number;
  49988. /**
  49989. * Gets or sets the inner angle for the directional cone.
  49990. */
  49991. set directionalConeInnerAngle(value: number);
  49992. /**
  49993. * Gets or sets the outer angle for the directional cone.
  49994. */
  49995. get directionalConeOuterAngle(): number;
  49996. /**
  49997. * Gets or sets the outer angle for the directional cone.
  49998. */
  49999. set directionalConeOuterAngle(value: number);
  50000. /**
  50001. * Sets the position of the emitter if spatial sound is enabled
  50002. * @param newPosition Defines the new posisiton
  50003. */
  50004. setPosition(newPosition: Vector3): void;
  50005. /**
  50006. * Sets the local direction of the emitter if spatial sound is enabled
  50007. * @param newLocalDirection Defines the new local direction
  50008. */
  50009. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  50010. private _updateDirection;
  50011. /** @hidden */
  50012. updateDistanceFromListener(): void;
  50013. /**
  50014. * Sets a new custom attenuation function for the sound.
  50015. * @param callback Defines the function used for the attenuation
  50016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  50017. */
  50018. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  50019. /**
  50020. * Play the sound
  50021. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  50022. * @param offset (optional) Start the sound at a specific time in seconds
  50023. * @param length (optional) Sound duration (in seconds)
  50024. */
  50025. play(time?: number, offset?: number, length?: number): void;
  50026. private _onended;
  50027. /**
  50028. * Stop the sound
  50029. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  50030. */
  50031. stop(time?: number): void;
  50032. /**
  50033. * Put the sound in pause
  50034. */
  50035. pause(): void;
  50036. /**
  50037. * Sets a dedicated volume for this sounds
  50038. * @param newVolume Define the new volume of the sound
  50039. * @param time Define time for gradual change to new volume
  50040. */
  50041. setVolume(newVolume: number, time?: number): void;
  50042. /**
  50043. * Set the sound play back rate
  50044. * @param newPlaybackRate Define the playback rate the sound should be played at
  50045. */
  50046. setPlaybackRate(newPlaybackRate: number): void;
  50047. /**
  50048. * Gets the volume of the sound.
  50049. * @returns the volume of the sound
  50050. */
  50051. getVolume(): number;
  50052. /**
  50053. * Attach the sound to a dedicated mesh
  50054. * @param transformNode The transform node to connect the sound with
  50055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  50056. */
  50057. attachToMesh(transformNode: TransformNode): void;
  50058. /**
  50059. * Detach the sound from the previously attached mesh
  50060. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  50061. */
  50062. detachFromMesh(): void;
  50063. private _onRegisterAfterWorldMatrixUpdate;
  50064. /**
  50065. * Clone the current sound in the scene.
  50066. * @returns the new sound clone
  50067. */
  50068. clone(): Nullable<Sound>;
  50069. /**
  50070. * Gets the current underlying audio buffer containing the data
  50071. * @returns the audio buffer
  50072. */
  50073. getAudioBuffer(): Nullable<AudioBuffer>;
  50074. /**
  50075. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  50076. * @returns the source node
  50077. */
  50078. getSoundSource(): Nullable<AudioBufferSourceNode>;
  50079. /**
  50080. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  50081. * @returns the gain node
  50082. */
  50083. getSoundGain(): Nullable<GainNode>;
  50084. /**
  50085. * Serializes the Sound in a JSON representation
  50086. * @returns the JSON representation of the sound
  50087. */
  50088. serialize(): any;
  50089. /**
  50090. * Parse a JSON representation of a sound to innstantiate in a given scene
  50091. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  50092. * @param scene Define the scene the new parsed sound should be created in
  50093. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  50094. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  50095. * @returns the newly parsed sound
  50096. */
  50097. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  50098. }
  50099. }
  50100. declare module "babylonjs/Actions/directAudioActions" {
  50101. import { Action } from "babylonjs/Actions/action";
  50102. import { Condition } from "babylonjs/Actions/condition";
  50103. import { Sound } from "babylonjs/Audio/sound";
  50104. /**
  50105. * This defines an action helpful to play a defined sound on a triggered action.
  50106. */
  50107. export class PlaySoundAction extends Action {
  50108. private _sound;
  50109. /**
  50110. * Instantiate the action
  50111. * @param triggerOptions defines the trigger options
  50112. * @param sound defines the sound to play
  50113. * @param condition defines the trigger related conditions
  50114. */
  50115. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  50116. /** @hidden */
  50117. _prepare(): void;
  50118. /**
  50119. * Execute the action and play the sound.
  50120. */
  50121. execute(): void;
  50122. /**
  50123. * Serializes the actions and its related information.
  50124. * @param parent defines the object to serialize in
  50125. * @returns the serialized object
  50126. */
  50127. serialize(parent: any): any;
  50128. }
  50129. /**
  50130. * This defines an action helpful to stop a defined sound on a triggered action.
  50131. */
  50132. export class StopSoundAction extends Action {
  50133. private _sound;
  50134. /**
  50135. * Instantiate the action
  50136. * @param triggerOptions defines the trigger options
  50137. * @param sound defines the sound to stop
  50138. * @param condition defines the trigger related conditions
  50139. */
  50140. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  50141. /** @hidden */
  50142. _prepare(): void;
  50143. /**
  50144. * Execute the action and stop the sound.
  50145. */
  50146. execute(): void;
  50147. /**
  50148. * Serializes the actions and its related information.
  50149. * @param parent defines the object to serialize in
  50150. * @returns the serialized object
  50151. */
  50152. serialize(parent: any): any;
  50153. }
  50154. }
  50155. declare module "babylonjs/Actions/interpolateValueAction" {
  50156. import { Action } from "babylonjs/Actions/action";
  50157. import { Condition } from "babylonjs/Actions/condition";
  50158. import { Observable } from "babylonjs/Misc/observable";
  50159. /**
  50160. * This defines an action responsible to change the value of a property
  50161. * by interpolating between its current value and the newly set one once triggered.
  50162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  50163. */
  50164. export class InterpolateValueAction extends Action {
  50165. /**
  50166. * Defines the path of the property where the value should be interpolated
  50167. */
  50168. propertyPath: string;
  50169. /**
  50170. * Defines the target value at the end of the interpolation.
  50171. */
  50172. value: any;
  50173. /**
  50174. * Defines the time it will take for the property to interpolate to the value.
  50175. */
  50176. duration: number;
  50177. /**
  50178. * Defines if the other scene animations should be stopped when the action has been triggered
  50179. */
  50180. stopOtherAnimations?: boolean;
  50181. /**
  50182. * Defines a callback raised once the interpolation animation has been done.
  50183. */
  50184. onInterpolationDone?: () => void;
  50185. /**
  50186. * Observable triggered once the interpolation animation has been done.
  50187. */
  50188. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  50189. private _target;
  50190. private _effectiveTarget;
  50191. private _property;
  50192. /**
  50193. * Instantiate the action
  50194. * @param triggerOptions defines the trigger options
  50195. * @param target defines the object containing the value to interpolate
  50196. * @param propertyPath defines the path to the property in the target object
  50197. * @param value defines the target value at the end of the interpolation
  50198. * @param duration deines the time it will take for the property to interpolate to the value.
  50199. * @param condition defines the trigger related conditions
  50200. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  50201. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  50202. */
  50203. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  50204. /** @hidden */
  50205. _prepare(): void;
  50206. /**
  50207. * Execute the action starts the value interpolation.
  50208. */
  50209. execute(): void;
  50210. /**
  50211. * Serializes the actions and its related information.
  50212. * @param parent defines the object to serialize in
  50213. * @returns the serialized object
  50214. */
  50215. serialize(parent: any): any;
  50216. }
  50217. }
  50218. declare module "babylonjs/Actions/index" {
  50219. export * from "babylonjs/Actions/abstractActionManager";
  50220. export * from "babylonjs/Actions/action";
  50221. export * from "babylonjs/Actions/actionEvent";
  50222. export * from "babylonjs/Actions/actionManager";
  50223. export * from "babylonjs/Actions/condition";
  50224. export * from "babylonjs/Actions/directActions";
  50225. export * from "babylonjs/Actions/directAudioActions";
  50226. export * from "babylonjs/Actions/interpolateValueAction";
  50227. }
  50228. declare module "babylonjs/Animations/index" {
  50229. export * from "babylonjs/Animations/animatable";
  50230. export * from "babylonjs/Animations/animation";
  50231. export * from "babylonjs/Animations/animationGroup";
  50232. export * from "babylonjs/Animations/animationPropertiesOverride";
  50233. export * from "babylonjs/Animations/easing";
  50234. export * from "babylonjs/Animations/runtimeAnimation";
  50235. export * from "babylonjs/Animations/animationEvent";
  50236. export * from "babylonjs/Animations/animationGroup";
  50237. export * from "babylonjs/Animations/animationKey";
  50238. export * from "babylonjs/Animations/animationRange";
  50239. export * from "babylonjs/Animations/animatable.interface";
  50240. }
  50241. declare module "babylonjs/Audio/audioEngine" {
  50242. import { Analyser } from "babylonjs/Audio/analyser";
  50243. import { Nullable } from "babylonjs/types";
  50244. import { Observable } from "babylonjs/Misc/observable";
  50245. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  50246. /**
  50247. * This represents the default audio engine used in babylon.
  50248. * It is responsible to play, synchronize and analyse sounds throughout the application.
  50249. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50250. */
  50251. export class AudioEngine implements IAudioEngine {
  50252. private _audioContext;
  50253. private _audioContextInitialized;
  50254. private _muteButton;
  50255. private _hostElement;
  50256. /**
  50257. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  50258. */
  50259. canUseWebAudio: boolean;
  50260. /**
  50261. * The master gain node defines the global audio volume of your audio engine.
  50262. */
  50263. masterGain: GainNode;
  50264. /**
  50265. * Defines if Babylon should emit a warning if WebAudio is not supported.
  50266. * @ignoreNaming
  50267. */
  50268. WarnedWebAudioUnsupported: boolean;
  50269. /**
  50270. * Gets whether or not mp3 are supported by your browser.
  50271. */
  50272. isMP3supported: boolean;
  50273. /**
  50274. * Gets whether or not ogg are supported by your browser.
  50275. */
  50276. isOGGsupported: boolean;
  50277. /**
  50278. * Gets whether audio has been unlocked on the device.
  50279. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  50280. * a user interaction has happened.
  50281. */
  50282. unlocked: boolean;
  50283. /**
  50284. * Defines if the audio engine relies on a custom unlocked button.
  50285. * In this case, the embedded button will not be displayed.
  50286. */
  50287. useCustomUnlockedButton: boolean;
  50288. /**
  50289. * Event raised when audio has been unlocked on the browser.
  50290. */
  50291. onAudioUnlockedObservable: Observable<IAudioEngine>;
  50292. /**
  50293. * Event raised when audio has been locked on the browser.
  50294. */
  50295. onAudioLockedObservable: Observable<IAudioEngine>;
  50296. /**
  50297. * Gets the current AudioContext if available.
  50298. */
  50299. get audioContext(): Nullable<AudioContext>;
  50300. private _connectedAnalyser;
  50301. /**
  50302. * Instantiates a new audio engine.
  50303. *
  50304. * There should be only one per page as some browsers restrict the number
  50305. * of audio contexts you can create.
  50306. * @param hostElement defines the host element where to display the mute icon if necessary
  50307. */
  50308. constructor(hostElement?: Nullable<HTMLElement>);
  50309. /**
  50310. * Flags the audio engine in Locked state.
  50311. * This happens due to new browser policies preventing audio to autoplay.
  50312. */
  50313. lock(): void;
  50314. /**
  50315. * Unlocks the audio engine once a user action has been done on the dom.
  50316. * This is helpful to resume play once browser policies have been satisfied.
  50317. */
  50318. unlock(): void;
  50319. private _resumeAudioContext;
  50320. private _initializeAudioContext;
  50321. private _tryToRun;
  50322. private _triggerRunningState;
  50323. private _triggerSuspendedState;
  50324. private _displayMuteButton;
  50325. private _moveButtonToTopLeft;
  50326. private _onResize;
  50327. private _hideMuteButton;
  50328. /**
  50329. * Destroy and release the resources associated with the audio ccontext.
  50330. */
  50331. dispose(): void;
  50332. /**
  50333. * Gets the global volume sets on the master gain.
  50334. * @returns the global volume if set or -1 otherwise
  50335. */
  50336. getGlobalVolume(): number;
  50337. /**
  50338. * Sets the global volume of your experience (sets on the master gain).
  50339. * @param newVolume Defines the new global volume of the application
  50340. */
  50341. setGlobalVolume(newVolume: number): void;
  50342. /**
  50343. * Connect the audio engine to an audio analyser allowing some amazing
  50344. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50345. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50346. * @param analyser The analyser to connect to the engine
  50347. */
  50348. connectToAnalyser(analyser: Analyser): void;
  50349. }
  50350. }
  50351. declare module "babylonjs/Audio/soundTrack" {
  50352. import { Sound } from "babylonjs/Audio/sound";
  50353. import { Analyser } from "babylonjs/Audio/analyser";
  50354. import { Scene } from "babylonjs/scene";
  50355. /**
  50356. * Options allowed during the creation of a sound track.
  50357. */
  50358. export interface ISoundTrackOptions {
  50359. /**
  50360. * The volume the sound track should take during creation
  50361. */
  50362. volume?: number;
  50363. /**
  50364. * Define if the sound track is the main sound track of the scene
  50365. */
  50366. mainTrack?: boolean;
  50367. }
  50368. /**
  50369. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  50370. * It will be also used in a future release to apply effects on a specific track.
  50371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50372. */
  50373. export class SoundTrack {
  50374. /**
  50375. * The unique identifier of the sound track in the scene.
  50376. */
  50377. id: number;
  50378. /**
  50379. * The list of sounds included in the sound track.
  50380. */
  50381. soundCollection: Array<Sound>;
  50382. private _outputAudioNode;
  50383. private _scene;
  50384. private _connectedAnalyser;
  50385. private _options;
  50386. private _isInitialized;
  50387. /**
  50388. * Creates a new sound track.
  50389. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50390. * @param scene Define the scene the sound track belongs to
  50391. * @param options
  50392. */
  50393. constructor(scene: Scene, options?: ISoundTrackOptions);
  50394. private _initializeSoundTrackAudioGraph;
  50395. /**
  50396. * Release the sound track and its associated resources
  50397. */
  50398. dispose(): void;
  50399. /**
  50400. * Adds a sound to this sound track
  50401. * @param sound define the cound to add
  50402. * @ignoreNaming
  50403. */
  50404. addSound(sound: Sound): void;
  50405. /**
  50406. * Removes a sound to this sound track
  50407. * @param sound define the cound to remove
  50408. * @ignoreNaming
  50409. */
  50410. removeSound(sound: Sound): void;
  50411. /**
  50412. * Set a global volume for the full sound track.
  50413. * @param newVolume Define the new volume of the sound track
  50414. */
  50415. setVolume(newVolume: number): void;
  50416. /**
  50417. * Switch the panning model to HRTF:
  50418. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  50419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50420. */
  50421. switchPanningModelToHRTF(): void;
  50422. /**
  50423. * Switch the panning model to Equal Power:
  50424. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  50425. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50426. */
  50427. switchPanningModelToEqualPower(): void;
  50428. /**
  50429. * Connect the sound track to an audio analyser allowing some amazing
  50430. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50431. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50432. * @param analyser The analyser to connect to the engine
  50433. */
  50434. connectToAnalyser(analyser: Analyser): void;
  50435. }
  50436. }
  50437. declare module "babylonjs/Audio/audioSceneComponent" {
  50438. import { Sound } from "babylonjs/Audio/sound";
  50439. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  50440. import { Nullable } from "babylonjs/types";
  50441. import { Vector3 } from "babylonjs/Maths/math.vector";
  50442. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50443. import { Scene } from "babylonjs/scene";
  50444. import { AbstractScene } from "babylonjs/abstractScene";
  50445. import "babylonjs/Audio/audioEngine";
  50446. module "babylonjs/abstractScene" {
  50447. interface AbstractScene {
  50448. /**
  50449. * The list of sounds used in the scene.
  50450. */
  50451. sounds: Nullable<Array<Sound>>;
  50452. }
  50453. }
  50454. module "babylonjs/scene" {
  50455. interface Scene {
  50456. /**
  50457. * @hidden
  50458. * Backing field
  50459. */
  50460. _mainSoundTrack: SoundTrack;
  50461. /**
  50462. * The main sound track played by the scene.
  50463. * It cotains your primary collection of sounds.
  50464. */
  50465. mainSoundTrack: SoundTrack;
  50466. /**
  50467. * The list of sound tracks added to the scene
  50468. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50469. */
  50470. soundTracks: Nullable<Array<SoundTrack>>;
  50471. /**
  50472. * Gets a sound using a given name
  50473. * @param name defines the name to search for
  50474. * @return the found sound or null if not found at all.
  50475. */
  50476. getSoundByName(name: string): Nullable<Sound>;
  50477. /**
  50478. * Gets or sets if audio support is enabled
  50479. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50480. */
  50481. audioEnabled: boolean;
  50482. /**
  50483. * Gets or sets if audio will be output to headphones
  50484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50485. */
  50486. headphone: boolean;
  50487. /**
  50488. * Gets or sets custom audio listener position provider
  50489. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50490. */
  50491. audioListenerPositionProvider: Nullable<() => Vector3>;
  50492. /**
  50493. * Gets or sets a refresh rate when using 3D audio positioning
  50494. */
  50495. audioPositioningRefreshRate: number;
  50496. }
  50497. }
  50498. /**
  50499. * Defines the sound scene component responsible to manage any sounds
  50500. * in a given scene.
  50501. */
  50502. export class AudioSceneComponent implements ISceneSerializableComponent {
  50503. private static _CameraDirectionLH;
  50504. private static _CameraDirectionRH;
  50505. /**
  50506. * The component name helpfull to identify the component in the list of scene components.
  50507. */
  50508. readonly name: string;
  50509. /**
  50510. * The scene the component belongs to.
  50511. */
  50512. scene: Scene;
  50513. private _audioEnabled;
  50514. /**
  50515. * Gets whether audio is enabled or not.
  50516. * Please use related enable/disable method to switch state.
  50517. */
  50518. get audioEnabled(): boolean;
  50519. private _headphone;
  50520. /**
  50521. * Gets whether audio is outputing to headphone or not.
  50522. * Please use the according Switch methods to change output.
  50523. */
  50524. get headphone(): boolean;
  50525. /**
  50526. * Gets or sets a refresh rate when using 3D audio positioning
  50527. */
  50528. audioPositioningRefreshRate: number;
  50529. private _audioListenerPositionProvider;
  50530. /**
  50531. * Gets the current audio listener position provider
  50532. */
  50533. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  50534. /**
  50535. * Sets a custom listener position for all sounds in the scene
  50536. * By default, this is the position of the first active camera
  50537. */
  50538. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  50539. /**
  50540. * Creates a new instance of the component for the given scene
  50541. * @param scene Defines the scene to register the component in
  50542. */
  50543. constructor(scene: Scene);
  50544. /**
  50545. * Registers the component in a given scene
  50546. */
  50547. register(): void;
  50548. /**
  50549. * Rebuilds the elements related to this component in case of
  50550. * context lost for instance.
  50551. */
  50552. rebuild(): void;
  50553. /**
  50554. * Serializes the component data to the specified json object
  50555. * @param serializationObject The object to serialize to
  50556. */
  50557. serialize(serializationObject: any): void;
  50558. /**
  50559. * Adds all the elements from the container to the scene
  50560. * @param container the container holding the elements
  50561. */
  50562. addFromContainer(container: AbstractScene): void;
  50563. /**
  50564. * Removes all the elements in the container from the scene
  50565. * @param container contains the elements to remove
  50566. * @param dispose if the removed element should be disposed (default: false)
  50567. */
  50568. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50569. /**
  50570. * Disposes the component and the associated ressources.
  50571. */
  50572. dispose(): void;
  50573. /**
  50574. * Disables audio in the associated scene.
  50575. */
  50576. disableAudio(): void;
  50577. /**
  50578. * Enables audio in the associated scene.
  50579. */
  50580. enableAudio(): void;
  50581. /**
  50582. * Switch audio to headphone output.
  50583. */
  50584. switchAudioModeForHeadphones(): void;
  50585. /**
  50586. * Switch audio to normal speakers.
  50587. */
  50588. switchAudioModeForNormalSpeakers(): void;
  50589. private _cachedCameraDirection;
  50590. private _cachedCameraPosition;
  50591. private _lastCheck;
  50592. private _afterRender;
  50593. }
  50594. }
  50595. declare module "babylonjs/Audio/weightedsound" {
  50596. import { Sound } from "babylonjs/Audio/sound";
  50597. /**
  50598. * Wraps one or more Sound objects and selects one with random weight for playback.
  50599. */
  50600. export class WeightedSound {
  50601. /** When true a Sound will be selected and played when the current playing Sound completes. */
  50602. loop: boolean;
  50603. private _coneInnerAngle;
  50604. private _coneOuterAngle;
  50605. private _volume;
  50606. /** A Sound is currently playing. */
  50607. isPlaying: boolean;
  50608. /** A Sound is currently paused. */
  50609. isPaused: boolean;
  50610. private _sounds;
  50611. private _weights;
  50612. private _currentIndex?;
  50613. /**
  50614. * Creates a new WeightedSound from the list of sounds given.
  50615. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  50616. * @param sounds Array of Sounds that will be selected from.
  50617. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  50618. */
  50619. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  50620. /**
  50621. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  50622. */
  50623. get directionalConeInnerAngle(): number;
  50624. /**
  50625. * The size of cone in degress for a directional sound in which there will be no attenuation.
  50626. */
  50627. set directionalConeInnerAngle(value: number);
  50628. /**
  50629. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50630. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50631. */
  50632. get directionalConeOuterAngle(): number;
  50633. /**
  50634. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50635. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50636. */
  50637. set directionalConeOuterAngle(value: number);
  50638. /**
  50639. * Playback volume.
  50640. */
  50641. get volume(): number;
  50642. /**
  50643. * Playback volume.
  50644. */
  50645. set volume(value: number);
  50646. private _onended;
  50647. /**
  50648. * Suspend playback
  50649. */
  50650. pause(): void;
  50651. /**
  50652. * Stop playback
  50653. */
  50654. stop(): void;
  50655. /**
  50656. * Start playback.
  50657. * @param startOffset Position the clip head at a specific time in seconds.
  50658. */
  50659. play(startOffset?: number): void;
  50660. }
  50661. }
  50662. declare module "babylonjs/Audio/index" {
  50663. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  50664. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  50665. export * from "babylonjs/Audio/analyser";
  50666. export * from "babylonjs/Audio/audioEngine";
  50667. export * from "babylonjs/Audio/audioSceneComponent";
  50668. export * from "babylonjs/Audio/sound";
  50669. export * from "babylonjs/Audio/soundTrack";
  50670. export * from "babylonjs/Audio/weightedsound";
  50671. }
  50672. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  50673. import { Behavior } from "babylonjs/Behaviors/behavior";
  50674. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50675. import { BackEase } from "babylonjs/Animations/easing";
  50676. /**
  50677. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  50678. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50679. */
  50680. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  50681. /**
  50682. * Gets the name of the behavior.
  50683. */
  50684. get name(): string;
  50685. /**
  50686. * The easing function used by animations
  50687. */
  50688. static EasingFunction: BackEase;
  50689. /**
  50690. * The easing mode used by animations
  50691. */
  50692. static EasingMode: number;
  50693. /**
  50694. * The duration of the animation, in milliseconds
  50695. */
  50696. transitionDuration: number;
  50697. /**
  50698. * Length of the distance animated by the transition when lower radius is reached
  50699. */
  50700. lowerRadiusTransitionRange: number;
  50701. /**
  50702. * Length of the distance animated by the transition when upper radius is reached
  50703. */
  50704. upperRadiusTransitionRange: number;
  50705. private _autoTransitionRange;
  50706. /**
  50707. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50708. */
  50709. get autoTransitionRange(): boolean;
  50710. /**
  50711. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50712. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  50713. */
  50714. set autoTransitionRange(value: boolean);
  50715. private _attachedCamera;
  50716. private _onAfterCheckInputsObserver;
  50717. private _onMeshTargetChangedObserver;
  50718. /**
  50719. * Initializes the behavior.
  50720. */
  50721. init(): void;
  50722. /**
  50723. * Attaches the behavior to its arc rotate camera.
  50724. * @param camera Defines the camera to attach the behavior to
  50725. */
  50726. attach(camera: ArcRotateCamera): void;
  50727. /**
  50728. * Detaches the behavior from its current arc rotate camera.
  50729. */
  50730. detach(): void;
  50731. private _radiusIsAnimating;
  50732. private _radiusBounceTransition;
  50733. private _animatables;
  50734. private _cachedWheelPrecision;
  50735. /**
  50736. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  50737. * @param radiusLimit The limit to check against.
  50738. * @return Bool to indicate if at limit.
  50739. */
  50740. private _isRadiusAtLimit;
  50741. /**
  50742. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  50743. * @param radiusDelta The delta by which to animate to. Can be negative.
  50744. */
  50745. private _applyBoundRadiusAnimation;
  50746. /**
  50747. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  50748. */
  50749. protected _clearAnimationLocks(): void;
  50750. /**
  50751. * Stops and removes all animations that have been applied to the camera
  50752. */
  50753. stopAllAnimations(): void;
  50754. }
  50755. }
  50756. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  50757. import { Behavior } from "babylonjs/Behaviors/behavior";
  50758. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50759. import { ExponentialEase } from "babylonjs/Animations/easing";
  50760. import { Nullable } from "babylonjs/types";
  50761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50762. import { Vector3 } from "babylonjs/Maths/math.vector";
  50763. /**
  50764. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  50765. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50766. */
  50767. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  50768. /**
  50769. * Gets the name of the behavior.
  50770. */
  50771. get name(): string;
  50772. private _mode;
  50773. private _radiusScale;
  50774. private _positionScale;
  50775. private _defaultElevation;
  50776. private _elevationReturnTime;
  50777. private _elevationReturnWaitTime;
  50778. private _zoomStopsAnimation;
  50779. private _framingTime;
  50780. /**
  50781. * The easing function used by animations
  50782. */
  50783. static EasingFunction: ExponentialEase;
  50784. /**
  50785. * The easing mode used by animations
  50786. */
  50787. static EasingMode: number;
  50788. /**
  50789. * Sets the current mode used by the behavior
  50790. */
  50791. set mode(mode: number);
  50792. /**
  50793. * Gets current mode used by the behavior.
  50794. */
  50795. get mode(): number;
  50796. /**
  50797. * Sets the scale applied to the radius (1 by default)
  50798. */
  50799. set radiusScale(radius: number);
  50800. /**
  50801. * Gets the scale applied to the radius
  50802. */
  50803. get radiusScale(): number;
  50804. /**
  50805. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50806. */
  50807. set positionScale(scale: number);
  50808. /**
  50809. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50810. */
  50811. get positionScale(): number;
  50812. /**
  50813. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50814. * behaviour is triggered, in radians.
  50815. */
  50816. set defaultElevation(elevation: number);
  50817. /**
  50818. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50819. * behaviour is triggered, in radians.
  50820. */
  50821. get defaultElevation(): number;
  50822. /**
  50823. * Sets the time (in milliseconds) taken to return to the default beta position.
  50824. * Negative value indicates camera should not return to default.
  50825. */
  50826. set elevationReturnTime(speed: number);
  50827. /**
  50828. * Gets the time (in milliseconds) taken to return to the default beta position.
  50829. * Negative value indicates camera should not return to default.
  50830. */
  50831. get elevationReturnTime(): number;
  50832. /**
  50833. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50834. */
  50835. set elevationReturnWaitTime(time: number);
  50836. /**
  50837. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50838. */
  50839. get elevationReturnWaitTime(): number;
  50840. /**
  50841. * Sets the flag that indicates if user zooming should stop animation.
  50842. */
  50843. set zoomStopsAnimation(flag: boolean);
  50844. /**
  50845. * Gets the flag that indicates if user zooming should stop animation.
  50846. */
  50847. get zoomStopsAnimation(): boolean;
  50848. /**
  50849. * Sets the transition time when framing the mesh, in milliseconds
  50850. */
  50851. set framingTime(time: number);
  50852. /**
  50853. * Gets the transition time when framing the mesh, in milliseconds
  50854. */
  50855. get framingTime(): number;
  50856. /**
  50857. * Define if the behavior should automatically change the configured
  50858. * camera limits and sensibilities.
  50859. */
  50860. autoCorrectCameraLimitsAndSensibility: boolean;
  50861. private _onPrePointerObservableObserver;
  50862. private _onAfterCheckInputsObserver;
  50863. private _onMeshTargetChangedObserver;
  50864. private _attachedCamera;
  50865. private _isPointerDown;
  50866. private _lastInteractionTime;
  50867. /**
  50868. * Initializes the behavior.
  50869. */
  50870. init(): void;
  50871. /**
  50872. * Attaches the behavior to its arc rotate camera.
  50873. * @param camera Defines the camera to attach the behavior to
  50874. */
  50875. attach(camera: ArcRotateCamera): void;
  50876. /**
  50877. * Detaches the behavior from its current arc rotate camera.
  50878. */
  50879. detach(): void;
  50880. private _animatables;
  50881. private _betaIsAnimating;
  50882. private _betaTransition;
  50883. private _radiusTransition;
  50884. private _vectorTransition;
  50885. /**
  50886. * Targets the given mesh and updates zoom level accordingly.
  50887. * @param mesh The mesh to target.
  50888. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50889. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50890. */
  50891. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50892. /**
  50893. * Targets the given mesh with its children and updates zoom level accordingly.
  50894. * @param mesh The mesh to target.
  50895. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50896. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50897. */
  50898. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50899. /**
  50900. * Targets the given meshes with their children and updates zoom level accordingly.
  50901. * @param meshes The mesh to target.
  50902. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50903. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50904. */
  50905. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50906. /**
  50907. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  50908. * @param minimumWorld Determines the smaller position of the bounding box extend
  50909. * @param maximumWorld Determines the bigger position of the bounding box extend
  50910. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50911. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50912. */
  50913. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50914. /**
  50915. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  50916. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  50917. * frustum width.
  50918. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  50919. * to fully enclose the mesh in the viewing frustum.
  50920. */
  50921. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  50922. /**
  50923. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  50924. * is automatically returned to its default position (expected to be above ground plane).
  50925. */
  50926. private _maintainCameraAboveGround;
  50927. /**
  50928. * Returns the frustum slope based on the canvas ratio and camera FOV
  50929. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  50930. */
  50931. private _getFrustumSlope;
  50932. /**
  50933. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  50934. */
  50935. private _clearAnimationLocks;
  50936. /**
  50937. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50938. */
  50939. private _applyUserInteraction;
  50940. /**
  50941. * Stops and removes all animations that have been applied to the camera
  50942. */
  50943. stopAllAnimations(): void;
  50944. /**
  50945. * Gets a value indicating if the user is moving the camera
  50946. */
  50947. get isUserIsMoving(): boolean;
  50948. /**
  50949. * The camera can move all the way towards the mesh.
  50950. */
  50951. static IgnoreBoundsSizeMode: number;
  50952. /**
  50953. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  50954. */
  50955. static FitFrustumSidesMode: number;
  50956. }
  50957. }
  50958. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  50959. import { Nullable } from "babylonjs/types";
  50960. import { Camera } from "babylonjs/Cameras/camera";
  50961. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50962. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50963. /**
  50964. * Base class for Camera Pointer Inputs.
  50965. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  50966. * for example usage.
  50967. */
  50968. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  50969. /**
  50970. * Defines the camera the input is attached to.
  50971. */
  50972. abstract camera: Camera;
  50973. /**
  50974. * Whether keyboard modifier keys are pressed at time of last mouse event.
  50975. */
  50976. protected _altKey: boolean;
  50977. protected _ctrlKey: boolean;
  50978. protected _metaKey: boolean;
  50979. protected _shiftKey: boolean;
  50980. /**
  50981. * Which mouse buttons were pressed at time of last mouse event.
  50982. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  50983. */
  50984. protected _buttonsPressed: number;
  50985. /**
  50986. * Defines the buttons associated with the input to handle camera move.
  50987. */
  50988. buttons: number[];
  50989. /**
  50990. * Attach the input controls to a specific dom element to get the input from.
  50991. * @param element Defines the element the controls should be listened from
  50992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50993. */
  50994. attachControl(noPreventDefault?: boolean): void;
  50995. /**
  50996. * Detach the current controls from the specified dom element.
  50997. */
  50998. detachControl(): void;
  50999. /**
  51000. * Gets the class name of the current input.
  51001. * @returns the class name
  51002. */
  51003. getClassName(): string;
  51004. /**
  51005. * Get the friendly name associated with the input class.
  51006. * @returns the input friendly name
  51007. */
  51008. getSimpleName(): string;
  51009. /**
  51010. * Called on pointer POINTERDOUBLETAP event.
  51011. * Override this method to provide functionality on POINTERDOUBLETAP event.
  51012. */
  51013. protected onDoubleTap(type: string): void;
  51014. /**
  51015. * Called on pointer POINTERMOVE event if only a single touch is active.
  51016. * Override this method to provide functionality.
  51017. */
  51018. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51019. /**
  51020. * Called on pointer POINTERMOVE event if multiple touches are active.
  51021. * Override this method to provide functionality.
  51022. */
  51023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51024. /**
  51025. * Called on JS contextmenu event.
  51026. * Override this method to provide functionality.
  51027. */
  51028. protected onContextMenu(evt: PointerEvent): void;
  51029. /**
  51030. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  51031. * press.
  51032. * Override this method to provide functionality.
  51033. */
  51034. protected onButtonDown(evt: PointerEvent): void;
  51035. /**
  51036. * Called each time a new POINTERUP event occurs. Ie, for each button
  51037. * release.
  51038. * Override this method to provide functionality.
  51039. */
  51040. protected onButtonUp(evt: PointerEvent): void;
  51041. /**
  51042. * Called when window becomes inactive.
  51043. * Override this method to provide functionality.
  51044. */
  51045. protected onLostFocus(): void;
  51046. private _pointerInput;
  51047. private _observer;
  51048. private _onLostFocus;
  51049. private pointA;
  51050. private pointB;
  51051. }
  51052. }
  51053. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  51054. import { Nullable } from "babylonjs/types";
  51055. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51056. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  51057. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  51058. /**
  51059. * Manage the pointers inputs to control an arc rotate camera.
  51060. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51061. */
  51062. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  51063. /**
  51064. * Defines the camera the input is attached to.
  51065. */
  51066. camera: ArcRotateCamera;
  51067. /**
  51068. * Gets the class name of the current input.
  51069. * @returns the class name
  51070. */
  51071. getClassName(): string;
  51072. /**
  51073. * Defines the buttons associated with the input to handle camera move.
  51074. */
  51075. buttons: number[];
  51076. /**
  51077. * Defines the pointer angular sensibility along the X axis or how fast is
  51078. * the camera rotating.
  51079. */
  51080. angularSensibilityX: number;
  51081. /**
  51082. * Defines the pointer angular sensibility along the Y axis or how fast is
  51083. * the camera rotating.
  51084. */
  51085. angularSensibilityY: number;
  51086. /**
  51087. * Defines the pointer pinch precision or how fast is the camera zooming.
  51088. */
  51089. pinchPrecision: number;
  51090. /**
  51091. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51092. * from 0.
  51093. * It defines the percentage of current camera.radius to use as delta when
  51094. * pinch zoom is used.
  51095. */
  51096. pinchDeltaPercentage: number;
  51097. /**
  51098. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  51099. * that any object in the plane at the camera's target point will scale
  51100. * perfectly with finger motion.
  51101. * Overrides pinchDeltaPercentage and pinchPrecision.
  51102. */
  51103. useNaturalPinchZoom: boolean;
  51104. /**
  51105. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  51106. */
  51107. pinchZoom: boolean;
  51108. /**
  51109. * Defines the pointer panning sensibility or how fast is the camera moving.
  51110. */
  51111. panningSensibility: number;
  51112. /**
  51113. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  51114. */
  51115. multiTouchPanning: boolean;
  51116. /**
  51117. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  51118. * zoom (pinch) through multitouch.
  51119. */
  51120. multiTouchPanAndZoom: boolean;
  51121. /**
  51122. * Revers pinch action direction.
  51123. */
  51124. pinchInwards: boolean;
  51125. private _isPanClick;
  51126. private _twoFingerActivityCount;
  51127. private _isPinching;
  51128. /**
  51129. * Move camera from multi touch panning positions.
  51130. */
  51131. private _computeMultiTouchPanning;
  51132. /**
  51133. * Move camera from pinch zoom distances.
  51134. */
  51135. private _computePinchZoom;
  51136. /**
  51137. * Called on pointer POINTERMOVE event if only a single touch is active.
  51138. */
  51139. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51140. /**
  51141. * Called on pointer POINTERDOUBLETAP event.
  51142. */
  51143. protected onDoubleTap(type: string): void;
  51144. /**
  51145. * Called on pointer POINTERMOVE event if multiple touches are active.
  51146. */
  51147. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51148. /**
  51149. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  51150. * press.
  51151. */
  51152. protected onButtonDown(evt: PointerEvent): void;
  51153. /**
  51154. * Called each time a new POINTERUP event occurs. Ie, for each button
  51155. * release.
  51156. */
  51157. protected onButtonUp(evt: PointerEvent): void;
  51158. /**
  51159. * Called when window becomes inactive.
  51160. */
  51161. protected onLostFocus(): void;
  51162. }
  51163. }
  51164. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  51165. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51166. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  51167. /**
  51168. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  51169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51170. */
  51171. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  51172. /**
  51173. * Defines the camera the input is attached to.
  51174. */
  51175. camera: ArcRotateCamera;
  51176. /**
  51177. * Defines the list of key codes associated with the up action (increase alpha)
  51178. */
  51179. keysUp: number[];
  51180. /**
  51181. * Defines the list of key codes associated with the down action (decrease alpha)
  51182. */
  51183. keysDown: number[];
  51184. /**
  51185. * Defines the list of key codes associated with the left action (increase beta)
  51186. */
  51187. keysLeft: number[];
  51188. /**
  51189. * Defines the list of key codes associated with the right action (decrease beta)
  51190. */
  51191. keysRight: number[];
  51192. /**
  51193. * Defines the list of key codes associated with the reset action.
  51194. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  51195. */
  51196. keysReset: number[];
  51197. /**
  51198. * Defines the panning sensibility of the inputs.
  51199. * (How fast is the camera panning)
  51200. */
  51201. panningSensibility: number;
  51202. /**
  51203. * Defines the zooming sensibility of the inputs.
  51204. * (How fast is the camera zooming)
  51205. */
  51206. zoomingSensibility: number;
  51207. /**
  51208. * Defines whether maintaining the alt key down switch the movement mode from
  51209. * orientation to zoom.
  51210. */
  51211. useAltToZoom: boolean;
  51212. /**
  51213. * Rotation speed of the camera
  51214. */
  51215. angularSpeed: number;
  51216. private _keys;
  51217. private _ctrlPressed;
  51218. private _altPressed;
  51219. private _onCanvasBlurObserver;
  51220. private _onKeyboardObserver;
  51221. private _engine;
  51222. private _scene;
  51223. /**
  51224. * Attach the input controls to a specific dom element to get the input from.
  51225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51226. */
  51227. attachControl(noPreventDefault?: boolean): void;
  51228. /**
  51229. * Detach the current controls from the specified dom element.
  51230. */
  51231. detachControl(): void;
  51232. /**
  51233. * Update the current camera state depending on the inputs that have been used this frame.
  51234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51235. */
  51236. checkInputs(): void;
  51237. /**
  51238. * Gets the class name of the current intput.
  51239. * @returns the class name
  51240. */
  51241. getClassName(): string;
  51242. /**
  51243. * Get the friendly name associated with the input class.
  51244. * @returns the input friendly name
  51245. */
  51246. getSimpleName(): string;
  51247. }
  51248. }
  51249. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  51250. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51251. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  51252. /**
  51253. * Manage the mouse wheel inputs to control an arc rotate camera.
  51254. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51255. */
  51256. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  51257. /**
  51258. * Defines the camera the input is attached to.
  51259. */
  51260. camera: ArcRotateCamera;
  51261. /**
  51262. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51263. */
  51264. wheelPrecision: number;
  51265. /**
  51266. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51267. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51268. */
  51269. wheelDeltaPercentage: number;
  51270. private _wheel;
  51271. private _observer;
  51272. private computeDeltaFromMouseWheelLegacyEvent;
  51273. /**
  51274. * Attach the input controls to a specific dom element to get the input from.
  51275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51276. */
  51277. attachControl(noPreventDefault?: boolean): void;
  51278. /**
  51279. * Detach the current controls from the specified dom element.
  51280. */
  51281. detachControl(): void;
  51282. /**
  51283. * Gets the class name of the current intput.
  51284. * @returns the class name
  51285. */
  51286. getClassName(): string;
  51287. /**
  51288. * Get the friendly name associated with the input class.
  51289. * @returns the input friendly name
  51290. */
  51291. getSimpleName(): string;
  51292. }
  51293. }
  51294. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51295. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51296. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  51297. /**
  51298. * Default Inputs manager for the ArcRotateCamera.
  51299. * It groups all the default supported inputs for ease of use.
  51300. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51301. */
  51302. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  51303. /**
  51304. * Instantiates a new ArcRotateCameraInputsManager.
  51305. * @param camera Defines the camera the inputs belong to
  51306. */
  51307. constructor(camera: ArcRotateCamera);
  51308. /**
  51309. * Add mouse wheel input support to the input manager.
  51310. * @returns the current input manager
  51311. */
  51312. addMouseWheel(): ArcRotateCameraInputsManager;
  51313. /**
  51314. * Add pointers input support to the input manager.
  51315. * @returns the current input manager
  51316. */
  51317. addPointers(): ArcRotateCameraInputsManager;
  51318. /**
  51319. * Add keyboard input support to the input manager.
  51320. * @returns the current input manager
  51321. */
  51322. addKeyboard(): ArcRotateCameraInputsManager;
  51323. }
  51324. }
  51325. declare module "babylonjs/Cameras/arcRotateCamera" {
  51326. import { Observable } from "babylonjs/Misc/observable";
  51327. import { Nullable } from "babylonjs/types";
  51328. import { Scene } from "babylonjs/scene";
  51329. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  51330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51331. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51332. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51333. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  51334. import { Camera } from "babylonjs/Cameras/camera";
  51335. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  51336. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51337. import { Collider } from "babylonjs/Collisions/collider";
  51338. /**
  51339. * This represents an orbital type of camera.
  51340. *
  51341. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  51342. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  51343. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  51344. */
  51345. export class ArcRotateCamera extends TargetCamera {
  51346. /**
  51347. * Defines the rotation angle of the camera along the longitudinal axis.
  51348. */
  51349. alpha: number;
  51350. /**
  51351. * Defines the rotation angle of the camera along the latitudinal axis.
  51352. */
  51353. beta: number;
  51354. /**
  51355. * Defines the radius of the camera from it s target point.
  51356. */
  51357. radius: number;
  51358. protected _target: Vector3;
  51359. protected _targetHost: Nullable<AbstractMesh>;
  51360. /**
  51361. * Defines the target point of the camera.
  51362. * The camera looks towards it form the radius distance.
  51363. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  51364. */
  51365. get target(): Vector3;
  51366. set target(value: Vector3);
  51367. /**
  51368. * Define the current local position of the camera in the scene
  51369. */
  51370. get position(): Vector3;
  51371. set position(newPosition: Vector3);
  51372. protected _upToYMatrix: Matrix;
  51373. protected _YToUpMatrix: Matrix;
  51374. /**
  51375. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  51376. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  51377. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  51378. */
  51379. set upVector(vec: Vector3);
  51380. get upVector(): Vector3;
  51381. /**
  51382. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  51383. */
  51384. setMatUp(): void;
  51385. /**
  51386. * Current inertia value on the longitudinal axis.
  51387. * The bigger this number the longer it will take for the camera to stop.
  51388. */
  51389. inertialAlphaOffset: number;
  51390. /**
  51391. * Current inertia value on the latitudinal axis.
  51392. * The bigger this number the longer it will take for the camera to stop.
  51393. */
  51394. inertialBetaOffset: number;
  51395. /**
  51396. * Current inertia value on the radius axis.
  51397. * The bigger this number the longer it will take for the camera to stop.
  51398. */
  51399. inertialRadiusOffset: number;
  51400. /**
  51401. * Minimum allowed angle on the longitudinal axis.
  51402. * This can help limiting how the Camera is able to move in the scene.
  51403. */
  51404. lowerAlphaLimit: Nullable<number>;
  51405. /**
  51406. * Maximum allowed angle on the longitudinal axis.
  51407. * This can help limiting how the Camera is able to move in the scene.
  51408. */
  51409. upperAlphaLimit: Nullable<number>;
  51410. /**
  51411. * Minimum allowed angle on the latitudinal axis.
  51412. * This can help limiting how the Camera is able to move in the scene.
  51413. */
  51414. lowerBetaLimit: number;
  51415. /**
  51416. * Maximum allowed angle on the latitudinal axis.
  51417. * This can help limiting how the Camera is able to move in the scene.
  51418. */
  51419. upperBetaLimit: number;
  51420. /**
  51421. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  51422. * This can help limiting how the Camera is able to move in the scene.
  51423. */
  51424. lowerRadiusLimit: Nullable<number>;
  51425. /**
  51426. * Maximum allowed distance of the camera to the target (The camera can not get further).
  51427. * This can help limiting how the Camera is able to move in the scene.
  51428. */
  51429. upperRadiusLimit: Nullable<number>;
  51430. /**
  51431. * Defines the current inertia value used during panning of the camera along the X axis.
  51432. */
  51433. inertialPanningX: number;
  51434. /**
  51435. * Defines the current inertia value used during panning of the camera along the Y axis.
  51436. */
  51437. inertialPanningY: number;
  51438. /**
  51439. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  51440. * Basically if your fingers moves away from more than this distance you will be considered
  51441. * in pinch mode.
  51442. */
  51443. pinchToPanMaxDistance: number;
  51444. /**
  51445. * Defines the maximum distance the camera can pan.
  51446. * This could help keeping the cammera always in your scene.
  51447. */
  51448. panningDistanceLimit: Nullable<number>;
  51449. /**
  51450. * Defines the target of the camera before paning.
  51451. */
  51452. panningOriginTarget: Vector3;
  51453. /**
  51454. * Defines the value of the inertia used during panning.
  51455. * 0 would mean stop inertia and one would mean no decelleration at all.
  51456. */
  51457. panningInertia: number;
  51458. /**
  51459. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  51460. */
  51461. get angularSensibilityX(): number;
  51462. set angularSensibilityX(value: number);
  51463. /**
  51464. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  51465. */
  51466. get angularSensibilityY(): number;
  51467. set angularSensibilityY(value: number);
  51468. /**
  51469. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  51470. */
  51471. get pinchPrecision(): number;
  51472. set pinchPrecision(value: number);
  51473. /**
  51474. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  51475. * It will be used instead of pinchDeltaPrecision if different from 0.
  51476. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51477. */
  51478. get pinchDeltaPercentage(): number;
  51479. set pinchDeltaPercentage(value: number);
  51480. /**
  51481. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  51482. * and pinch delta percentage.
  51483. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  51484. * that any object in the plane at the camera's target point will scale
  51485. * perfectly with finger motion.
  51486. */
  51487. get useNaturalPinchZoom(): boolean;
  51488. set useNaturalPinchZoom(value: boolean);
  51489. /**
  51490. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  51491. */
  51492. get panningSensibility(): number;
  51493. set panningSensibility(value: number);
  51494. /**
  51495. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  51496. */
  51497. get keysUp(): number[];
  51498. set keysUp(value: number[]);
  51499. /**
  51500. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  51501. */
  51502. get keysDown(): number[];
  51503. set keysDown(value: number[]);
  51504. /**
  51505. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  51506. */
  51507. get keysLeft(): number[];
  51508. set keysLeft(value: number[]);
  51509. /**
  51510. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  51511. */
  51512. get keysRight(): number[];
  51513. set keysRight(value: number[]);
  51514. /**
  51515. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51516. */
  51517. get wheelPrecision(): number;
  51518. set wheelPrecision(value: number);
  51519. /**
  51520. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  51521. * It will be used instead of pinchDeltaPrecision if different from 0.
  51522. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51523. */
  51524. get wheelDeltaPercentage(): number;
  51525. set wheelDeltaPercentage(value: number);
  51526. /**
  51527. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  51528. */
  51529. zoomOnFactor: number;
  51530. /**
  51531. * Defines a screen offset for the camera position.
  51532. */
  51533. targetScreenOffset: Vector2;
  51534. /**
  51535. * Allows the camera to be completely reversed.
  51536. * If false the camera can not arrive upside down.
  51537. */
  51538. allowUpsideDown: boolean;
  51539. /**
  51540. * Define if double tap/click is used to restore the previously saved state of the camera.
  51541. */
  51542. useInputToRestoreState: boolean;
  51543. /** @hidden */
  51544. _viewMatrix: Matrix;
  51545. /** @hidden */
  51546. _useCtrlForPanning: boolean;
  51547. /** @hidden */
  51548. _panningMouseButton: number;
  51549. /**
  51550. * Defines the input associated to the camera.
  51551. */
  51552. inputs: ArcRotateCameraInputsManager;
  51553. /** @hidden */
  51554. _reset: () => void;
  51555. /**
  51556. * Defines the allowed panning axis.
  51557. */
  51558. panningAxis: Vector3;
  51559. protected _transformedDirection: Vector3;
  51560. private _bouncingBehavior;
  51561. /**
  51562. * Gets the bouncing behavior of the camera if it has been enabled.
  51563. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51564. */
  51565. get bouncingBehavior(): Nullable<BouncingBehavior>;
  51566. /**
  51567. * Defines if the bouncing behavior of the camera is enabled on the camera.
  51568. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51569. */
  51570. get useBouncingBehavior(): boolean;
  51571. set useBouncingBehavior(value: boolean);
  51572. private _framingBehavior;
  51573. /**
  51574. * Gets the framing behavior of the camera if it has been enabled.
  51575. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51576. */
  51577. get framingBehavior(): Nullable<FramingBehavior>;
  51578. /**
  51579. * Defines if the framing behavior of the camera is enabled on the camera.
  51580. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51581. */
  51582. get useFramingBehavior(): boolean;
  51583. set useFramingBehavior(value: boolean);
  51584. private _autoRotationBehavior;
  51585. /**
  51586. * Gets the auto rotation behavior of the camera if it has been enabled.
  51587. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51588. */
  51589. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  51590. /**
  51591. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  51592. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51593. */
  51594. get useAutoRotationBehavior(): boolean;
  51595. set useAutoRotationBehavior(value: boolean);
  51596. /**
  51597. * Observable triggered when the mesh target has been changed on the camera.
  51598. */
  51599. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  51600. /**
  51601. * Event raised when the camera is colliding with a mesh.
  51602. */
  51603. onCollide: (collidedMesh: AbstractMesh) => void;
  51604. /**
  51605. * Defines whether the camera should check collision with the objects oh the scene.
  51606. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  51607. */
  51608. checkCollisions: boolean;
  51609. /**
  51610. * Defines the collision radius of the camera.
  51611. * This simulates a sphere around the camera.
  51612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51613. */
  51614. collisionRadius: Vector3;
  51615. protected _collider: Collider;
  51616. protected _previousPosition: Vector3;
  51617. protected _collisionVelocity: Vector3;
  51618. protected _newPosition: Vector3;
  51619. protected _previousAlpha: number;
  51620. protected _previousBeta: number;
  51621. protected _previousRadius: number;
  51622. protected _collisionTriggered: boolean;
  51623. protected _targetBoundingCenter: Nullable<Vector3>;
  51624. private _computationVector;
  51625. /**
  51626. * Instantiates a new ArcRotateCamera in a given scene
  51627. * @param name Defines the name of the camera
  51628. * @param alpha Defines the camera rotation along the logitudinal axis
  51629. * @param beta Defines the camera rotation along the latitudinal axis
  51630. * @param radius Defines the camera distance from its target
  51631. * @param target Defines the camera target
  51632. * @param scene Defines the scene the camera belongs to
  51633. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  51634. */
  51635. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51636. /** @hidden */
  51637. _initCache(): void;
  51638. /** @hidden */
  51639. _updateCache(ignoreParentClass?: boolean): void;
  51640. protected _getTargetPosition(): Vector3;
  51641. private _storedAlpha;
  51642. private _storedBeta;
  51643. private _storedRadius;
  51644. private _storedTarget;
  51645. private _storedTargetScreenOffset;
  51646. /**
  51647. * Stores the current state of the camera (alpha, beta, radius and target)
  51648. * @returns the camera itself
  51649. */
  51650. storeState(): Camera;
  51651. /**
  51652. * @hidden
  51653. * Restored camera state. You must call storeState() first
  51654. */
  51655. _restoreStateValues(): boolean;
  51656. /** @hidden */
  51657. _isSynchronizedViewMatrix(): boolean;
  51658. /**
  51659. * Attach the input controls to a specific dom element to get the input from.
  51660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51661. */
  51662. attachControl(noPreventDefault?: boolean): void;
  51663. /**
  51664. * Attach the input controls to a specific dom element to get the input from.
  51665. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  51666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51667. */
  51668. attachControl(ignored: any, noPreventDefault?: boolean): void;
  51669. /**
  51670. * Attached controls to the current camera.
  51671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51672. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51673. */
  51674. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51675. /**
  51676. * Attached controls to the current camera.
  51677. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  51678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51679. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51680. */
  51681. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51682. /**
  51683. * Attached controls to the current camera.
  51684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51685. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51686. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  51687. */
  51688. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  51689. /**
  51690. * Detach the current controls from the specified dom element.
  51691. */
  51692. detachControl(): void;
  51693. /**
  51694. * Detach the current controls from the specified dom element.
  51695. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  51696. */
  51697. detachControl(ignored: any): void;
  51698. /** @hidden */
  51699. _checkInputs(): void;
  51700. protected _checkLimits(): void;
  51701. /**
  51702. * Rebuilds angles (alpha, beta) and radius from the give position and target
  51703. */
  51704. rebuildAnglesAndRadius(): void;
  51705. /**
  51706. * Use a position to define the current camera related information like alpha, beta and radius
  51707. * @param position Defines the position to set the camera at
  51708. */
  51709. setPosition(position: Vector3): void;
  51710. /**
  51711. * Defines the target the camera should look at.
  51712. * This will automatically adapt alpha beta and radius to fit within the new target.
  51713. * @param target Defines the new target as a Vector or a mesh
  51714. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  51715. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  51716. */
  51717. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  51718. /** @hidden */
  51719. _getViewMatrix(): Matrix;
  51720. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  51721. /**
  51722. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  51723. * @param meshes Defines the mesh to zoom on
  51724. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  51725. */
  51726. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  51727. /**
  51728. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  51729. * The target will be changed but the radius
  51730. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  51731. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  51732. */
  51733. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  51734. min: Vector3;
  51735. max: Vector3;
  51736. distance: number;
  51737. }, doNotUpdateMaxZ?: boolean): void;
  51738. /**
  51739. * @override
  51740. * Override Camera.createRigCamera
  51741. */
  51742. createRigCamera(name: string, cameraIndex: number): Camera;
  51743. /**
  51744. * @hidden
  51745. * @override
  51746. * Override Camera._updateRigCameras
  51747. */
  51748. _updateRigCameras(): void;
  51749. /**
  51750. * Destroy the camera and release the current resources hold by it.
  51751. */
  51752. dispose(): void;
  51753. /**
  51754. * Gets the current object class name.
  51755. * @return the class name
  51756. */
  51757. getClassName(): string;
  51758. }
  51759. }
  51760. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  51761. import { Behavior } from "babylonjs/Behaviors/behavior";
  51762. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51763. /**
  51764. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  51765. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51766. */
  51767. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  51768. /**
  51769. * Gets the name of the behavior.
  51770. */
  51771. get name(): string;
  51772. private _zoomStopsAnimation;
  51773. private _idleRotationSpeed;
  51774. private _idleRotationWaitTime;
  51775. private _idleRotationSpinupTime;
  51776. /**
  51777. * Sets the flag that indicates if user zooming should stop animation.
  51778. */
  51779. set zoomStopsAnimation(flag: boolean);
  51780. /**
  51781. * Gets the flag that indicates if user zooming should stop animation.
  51782. */
  51783. get zoomStopsAnimation(): boolean;
  51784. /**
  51785. * Sets the default speed at which the camera rotates around the model.
  51786. */
  51787. set idleRotationSpeed(speed: number);
  51788. /**
  51789. * Gets the default speed at which the camera rotates around the model.
  51790. */
  51791. get idleRotationSpeed(): number;
  51792. /**
  51793. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  51794. */
  51795. set idleRotationWaitTime(time: number);
  51796. /**
  51797. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  51798. */
  51799. get idleRotationWaitTime(): number;
  51800. /**
  51801. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51802. */
  51803. set idleRotationSpinupTime(time: number);
  51804. /**
  51805. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51806. */
  51807. get idleRotationSpinupTime(): number;
  51808. /**
  51809. * Gets a value indicating if the camera is currently rotating because of this behavior
  51810. */
  51811. get rotationInProgress(): boolean;
  51812. private _onPrePointerObservableObserver;
  51813. private _onAfterCheckInputsObserver;
  51814. private _attachedCamera;
  51815. private _isPointerDown;
  51816. private _lastFrameTime;
  51817. private _lastInteractionTime;
  51818. private _cameraRotationSpeed;
  51819. /**
  51820. * Initializes the behavior.
  51821. */
  51822. init(): void;
  51823. /**
  51824. * Attaches the behavior to its arc rotate camera.
  51825. * @param camera Defines the camera to attach the behavior to
  51826. */
  51827. attach(camera: ArcRotateCamera): void;
  51828. /**
  51829. * Detaches the behavior from its current arc rotate camera.
  51830. */
  51831. detach(): void;
  51832. /**
  51833. * Returns true if user is scrolling.
  51834. * @return true if user is scrolling.
  51835. */
  51836. private _userIsZooming;
  51837. private _lastFrameRadius;
  51838. private _shouldAnimationStopForInteraction;
  51839. /**
  51840. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51841. */
  51842. private _applyUserInteraction;
  51843. private _userIsMoving;
  51844. }
  51845. }
  51846. declare module "babylonjs/Behaviors/Cameras/index" {
  51847. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51848. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51849. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  51850. }
  51851. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  51852. import { Mesh } from "babylonjs/Meshes/mesh";
  51853. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51854. import { Behavior } from "babylonjs/Behaviors/behavior";
  51855. /**
  51856. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  51857. */
  51858. export class AttachToBoxBehavior implements Behavior<Mesh> {
  51859. private ui;
  51860. /**
  51861. * The name of the behavior
  51862. */
  51863. name: string;
  51864. /**
  51865. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  51866. */
  51867. distanceAwayFromFace: number;
  51868. /**
  51869. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  51870. */
  51871. distanceAwayFromBottomOfFace: number;
  51872. private _faceVectors;
  51873. private _target;
  51874. private _scene;
  51875. private _onRenderObserver;
  51876. private _tmpMatrix;
  51877. private _tmpVector;
  51878. /**
  51879. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  51880. * @param ui The transform node that should be attched to the mesh
  51881. */
  51882. constructor(ui: TransformNode);
  51883. /**
  51884. * Initializes the behavior
  51885. */
  51886. init(): void;
  51887. private _closestFace;
  51888. private _zeroVector;
  51889. private _lookAtTmpMatrix;
  51890. private _lookAtToRef;
  51891. /**
  51892. * Attaches the AttachToBoxBehavior to the passed in mesh
  51893. * @param target The mesh that the specified node will be attached to
  51894. */
  51895. attach(target: Mesh): void;
  51896. /**
  51897. * Detaches the behavior from the mesh
  51898. */
  51899. detach(): void;
  51900. }
  51901. }
  51902. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  51903. import { Behavior } from "babylonjs/Behaviors/behavior";
  51904. import { Mesh } from "babylonjs/Meshes/mesh";
  51905. /**
  51906. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  51907. */
  51908. export class FadeInOutBehavior implements Behavior<Mesh> {
  51909. /**
  51910. * Time in milliseconds to delay before fading in (Default: 0)
  51911. */
  51912. delay: number;
  51913. /**
  51914. * Time in milliseconds for the mesh to fade in (Default: 300)
  51915. */
  51916. fadeInTime: number;
  51917. private _millisecondsPerFrame;
  51918. private _hovered;
  51919. private _hoverValue;
  51920. private _ownerNode;
  51921. /**
  51922. * Instatiates the FadeInOutBehavior
  51923. */
  51924. constructor();
  51925. /**
  51926. * The name of the behavior
  51927. */
  51928. get name(): string;
  51929. /**
  51930. * Initializes the behavior
  51931. */
  51932. init(): void;
  51933. /**
  51934. * Attaches the fade behavior on the passed in mesh
  51935. * @param ownerNode The mesh that will be faded in/out once attached
  51936. */
  51937. attach(ownerNode: Mesh): void;
  51938. /**
  51939. * Detaches the behavior from the mesh
  51940. */
  51941. detach(): void;
  51942. /**
  51943. * Triggers the mesh to begin fading in or out
  51944. * @param value if the object should fade in or out (true to fade in)
  51945. */
  51946. fadeIn(value: boolean): void;
  51947. private _update;
  51948. private _setAllVisibility;
  51949. }
  51950. }
  51951. declare module "babylonjs/Misc/pivotTools" {
  51952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51953. /**
  51954. * Class containing a set of static utilities functions for managing Pivots
  51955. * @hidden
  51956. */
  51957. export class PivotTools {
  51958. private static _PivotCached;
  51959. private static _OldPivotPoint;
  51960. private static _PivotTranslation;
  51961. private static _PivotTmpVector;
  51962. private static _PivotPostMultiplyPivotMatrix;
  51963. /** @hidden */
  51964. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  51965. /** @hidden */
  51966. static _RestorePivotPoint(mesh: AbstractMesh): void;
  51967. }
  51968. }
  51969. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  51970. import { Scene } from "babylonjs/scene";
  51971. import { Vector4 } from "babylonjs/Maths/math.vector";
  51972. import { Mesh } from "babylonjs/Meshes/mesh";
  51973. import { Nullable } from "babylonjs/types";
  51974. import { Plane } from "babylonjs/Maths/math.plane";
  51975. /**
  51976. * Class containing static functions to help procedurally build meshes
  51977. */
  51978. export class PlaneBuilder {
  51979. /**
  51980. * Creates a plane mesh
  51981. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51982. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51983. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51987. * @param name defines the name of the mesh
  51988. * @param options defines the options used to create the mesh
  51989. * @param scene defines the hosting scene
  51990. * @returns the plane mesh
  51991. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51992. */
  51993. static CreatePlane(name: string, options: {
  51994. size?: number;
  51995. width?: number;
  51996. height?: number;
  51997. sideOrientation?: number;
  51998. frontUVs?: Vector4;
  51999. backUVs?: Vector4;
  52000. updatable?: boolean;
  52001. sourcePlane?: Plane;
  52002. }, scene?: Nullable<Scene>): Mesh;
  52003. }
  52004. }
  52005. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  52006. import { Behavior } from "babylonjs/Behaviors/behavior";
  52007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52008. import { Observable } from "babylonjs/Misc/observable";
  52009. import { Vector3 } from "babylonjs/Maths/math.vector";
  52010. import { Ray } from "babylonjs/Culling/ray";
  52011. import "babylonjs/Meshes/Builders/planeBuilder";
  52012. /**
  52013. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  52014. */
  52015. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  52016. private static _AnyMouseID;
  52017. /**
  52018. * Abstract mesh the behavior is set on
  52019. */
  52020. attachedNode: AbstractMesh;
  52021. private _dragPlane;
  52022. private _scene;
  52023. private _pointerObserver;
  52024. private _beforeRenderObserver;
  52025. private static _planeScene;
  52026. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  52027. /**
  52028. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  52029. */
  52030. maxDragAngle: number;
  52031. /**
  52032. * @hidden
  52033. */
  52034. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  52035. /**
  52036. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  52037. */
  52038. currentDraggingPointerID: number;
  52039. /**
  52040. * The last position where the pointer hit the drag plane in world space
  52041. */
  52042. lastDragPosition: Vector3;
  52043. /**
  52044. * If the behavior is currently in a dragging state
  52045. */
  52046. dragging: boolean;
  52047. /**
  52048. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  52049. */
  52050. dragDeltaRatio: number;
  52051. /**
  52052. * If the drag plane orientation should be updated during the dragging (Default: true)
  52053. */
  52054. updateDragPlane: boolean;
  52055. private _debugMode;
  52056. private _moving;
  52057. /**
  52058. * Fires each time the attached mesh is dragged with the pointer
  52059. * * delta between last drag position and current drag position in world space
  52060. * * dragDistance along the drag axis
  52061. * * dragPlaneNormal normal of the current drag plane used during the drag
  52062. * * dragPlanePoint in world space where the drag intersects the drag plane
  52063. */
  52064. onDragObservable: Observable<{
  52065. delta: Vector3;
  52066. dragPlanePoint: Vector3;
  52067. dragPlaneNormal: Vector3;
  52068. dragDistance: number;
  52069. pointerId: number;
  52070. }>;
  52071. /**
  52072. * Fires each time a drag begins (eg. mouse down on mesh)
  52073. */
  52074. onDragStartObservable: Observable<{
  52075. dragPlanePoint: Vector3;
  52076. pointerId: number;
  52077. }>;
  52078. /**
  52079. * Fires each time a drag ends (eg. mouse release after drag)
  52080. */
  52081. onDragEndObservable: Observable<{
  52082. dragPlanePoint: Vector3;
  52083. pointerId: number;
  52084. }>;
  52085. /**
  52086. * If the attached mesh should be moved when dragged
  52087. */
  52088. moveAttached: boolean;
  52089. /**
  52090. * If the drag behavior will react to drag events (Default: true)
  52091. */
  52092. enabled: boolean;
  52093. /**
  52094. * If pointer events should start and release the drag (Default: true)
  52095. */
  52096. startAndReleaseDragOnPointerEvents: boolean;
  52097. /**
  52098. * If camera controls should be detached during the drag
  52099. */
  52100. detachCameraControls: boolean;
  52101. /**
  52102. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  52103. */
  52104. useObjectOrientationForDragging: boolean;
  52105. private _options;
  52106. /**
  52107. * Gets the options used by the behavior
  52108. */
  52109. get options(): {
  52110. dragAxis?: Vector3;
  52111. dragPlaneNormal?: Vector3;
  52112. };
  52113. /**
  52114. * Sets the options used by the behavior
  52115. */
  52116. set options(options: {
  52117. dragAxis?: Vector3;
  52118. dragPlaneNormal?: Vector3;
  52119. });
  52120. /**
  52121. * Creates a pointer drag behavior that can be attached to a mesh
  52122. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  52123. */
  52124. constructor(options?: {
  52125. dragAxis?: Vector3;
  52126. dragPlaneNormal?: Vector3;
  52127. });
  52128. /**
  52129. * Predicate to determine if it is valid to move the object to a new position when it is moved
  52130. */
  52131. validateDrag: (targetPosition: Vector3) => boolean;
  52132. /**
  52133. * The name of the behavior
  52134. */
  52135. get name(): string;
  52136. /**
  52137. * Initializes the behavior
  52138. */
  52139. init(): void;
  52140. private _tmpVector;
  52141. private _alternatePickedPoint;
  52142. private _worldDragAxis;
  52143. private _targetPosition;
  52144. private _attachedToElement;
  52145. /**
  52146. * Attaches the drag behavior the passed in mesh
  52147. * @param ownerNode The mesh that will be dragged around once attached
  52148. * @param predicate Predicate to use for pick filtering
  52149. */
  52150. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  52151. /**
  52152. * Force relase the drag action by code.
  52153. */
  52154. releaseDrag(): void;
  52155. private _startDragRay;
  52156. private _lastPointerRay;
  52157. /**
  52158. * Simulates the start of a pointer drag event on the behavior
  52159. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  52160. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  52161. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  52162. */
  52163. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  52164. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  52165. private _dragDelta;
  52166. protected _moveDrag(ray: Ray): void;
  52167. private _pickWithRayOnDragPlane;
  52168. private _pointA;
  52169. private _pointC;
  52170. private _localAxis;
  52171. private _lookAt;
  52172. private _updateDragPlanePosition;
  52173. /**
  52174. * Detaches the behavior from the mesh
  52175. */
  52176. detach(): void;
  52177. }
  52178. }
  52179. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  52180. import { Mesh } from "babylonjs/Meshes/mesh";
  52181. import { Behavior } from "babylonjs/Behaviors/behavior";
  52182. /**
  52183. * A behavior that when attached to a mesh will allow the mesh to be scaled
  52184. */
  52185. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  52186. private _dragBehaviorA;
  52187. private _dragBehaviorB;
  52188. private _startDistance;
  52189. private _initialScale;
  52190. private _targetScale;
  52191. private _ownerNode;
  52192. private _sceneRenderObserver;
  52193. /**
  52194. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  52195. */
  52196. constructor();
  52197. /**
  52198. * The name of the behavior
  52199. */
  52200. get name(): string;
  52201. /**
  52202. * Initializes the behavior
  52203. */
  52204. init(): void;
  52205. private _getCurrentDistance;
  52206. /**
  52207. * Attaches the scale behavior the passed in mesh
  52208. * @param ownerNode The mesh that will be scaled around once attached
  52209. */
  52210. attach(ownerNode: Mesh): void;
  52211. /**
  52212. * Detaches the behavior from the mesh
  52213. */
  52214. detach(): void;
  52215. }
  52216. }
  52217. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  52218. import { Behavior } from "babylonjs/Behaviors/behavior";
  52219. import { Mesh } from "babylonjs/Meshes/mesh";
  52220. import { Observable } from "babylonjs/Misc/observable";
  52221. /**
  52222. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  52223. */
  52224. export class SixDofDragBehavior implements Behavior<Mesh> {
  52225. private static _virtualScene;
  52226. private _ownerNode;
  52227. private _sceneRenderObserver;
  52228. private _scene;
  52229. private _targetPosition;
  52230. private _virtualOriginMesh;
  52231. private _virtualDragMesh;
  52232. private _pointerObserver;
  52233. private _moving;
  52234. private _startingOrientation;
  52235. private _attachedToElement;
  52236. /**
  52237. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  52238. */
  52239. private zDragFactor;
  52240. /**
  52241. * If the object should rotate to face the drag origin
  52242. */
  52243. rotateDraggedObject: boolean;
  52244. /**
  52245. * If the behavior is currently in a dragging state
  52246. */
  52247. dragging: boolean;
  52248. /**
  52249. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  52250. */
  52251. dragDeltaRatio: number;
  52252. /**
  52253. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  52254. */
  52255. currentDraggingPointerID: number;
  52256. /**
  52257. * If camera controls should be detached during the drag
  52258. */
  52259. detachCameraControls: boolean;
  52260. /**
  52261. * Fires each time a drag starts
  52262. */
  52263. onDragStartObservable: Observable<{}>;
  52264. /**
  52265. * Fires each time a drag happens
  52266. */
  52267. onDragObservable: Observable<void>;
  52268. /**
  52269. * Fires each time a drag ends (eg. mouse release after drag)
  52270. */
  52271. onDragEndObservable: Observable<{}>;
  52272. /**
  52273. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  52274. */
  52275. constructor();
  52276. /**
  52277. * The name of the behavior
  52278. */
  52279. get name(): string;
  52280. /**
  52281. * Initializes the behavior
  52282. */
  52283. init(): void;
  52284. /**
  52285. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  52286. */
  52287. private get _pointerCamera();
  52288. /**
  52289. * Attaches the scale behavior the passed in mesh
  52290. * @param ownerNode The mesh that will be scaled around once attached
  52291. */
  52292. attach(ownerNode: Mesh): void;
  52293. /**
  52294. * Detaches the behavior from the mesh
  52295. */
  52296. detach(): void;
  52297. }
  52298. }
  52299. declare module "babylonjs/Behaviors/Meshes/index" {
  52300. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  52301. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  52302. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  52303. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52304. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  52305. }
  52306. declare module "babylonjs/Behaviors/index" {
  52307. export * from "babylonjs/Behaviors/behavior";
  52308. export * from "babylonjs/Behaviors/Cameras/index";
  52309. export * from "babylonjs/Behaviors/Meshes/index";
  52310. }
  52311. declare module "babylonjs/Bones/boneIKController" {
  52312. import { Bone } from "babylonjs/Bones/bone";
  52313. import { Vector3 } from "babylonjs/Maths/math.vector";
  52314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52315. import { Nullable } from "babylonjs/types";
  52316. /**
  52317. * Class used to apply inverse kinematics to bones
  52318. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  52319. */
  52320. export class BoneIKController {
  52321. private static _tmpVecs;
  52322. private static _tmpQuat;
  52323. private static _tmpMats;
  52324. /**
  52325. * Gets or sets the target mesh
  52326. */
  52327. targetMesh: AbstractMesh;
  52328. /** Gets or sets the mesh used as pole */
  52329. poleTargetMesh: AbstractMesh;
  52330. /**
  52331. * Gets or sets the bone used as pole
  52332. */
  52333. poleTargetBone: Nullable<Bone>;
  52334. /**
  52335. * Gets or sets the target position
  52336. */
  52337. targetPosition: Vector3;
  52338. /**
  52339. * Gets or sets the pole target position
  52340. */
  52341. poleTargetPosition: Vector3;
  52342. /**
  52343. * Gets or sets the pole target local offset
  52344. */
  52345. poleTargetLocalOffset: Vector3;
  52346. /**
  52347. * Gets or sets the pole angle
  52348. */
  52349. poleAngle: number;
  52350. /**
  52351. * Gets or sets the mesh associated with the controller
  52352. */
  52353. mesh: AbstractMesh;
  52354. /**
  52355. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  52356. */
  52357. slerpAmount: number;
  52358. private _bone1Quat;
  52359. private _bone1Mat;
  52360. private _bone2Ang;
  52361. private _bone1;
  52362. private _bone2;
  52363. private _bone1Length;
  52364. private _bone2Length;
  52365. private _maxAngle;
  52366. private _maxReach;
  52367. private _rightHandedSystem;
  52368. private _bendAxis;
  52369. private _slerping;
  52370. private _adjustRoll;
  52371. /**
  52372. * Gets or sets maximum allowed angle
  52373. */
  52374. get maxAngle(): number;
  52375. set maxAngle(value: number);
  52376. /**
  52377. * Creates a new BoneIKController
  52378. * @param mesh defines the mesh to control
  52379. * @param bone defines the bone to control
  52380. * @param options defines options to set up the controller
  52381. */
  52382. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  52383. targetMesh?: AbstractMesh;
  52384. poleTargetMesh?: AbstractMesh;
  52385. poleTargetBone?: Bone;
  52386. poleTargetLocalOffset?: Vector3;
  52387. poleAngle?: number;
  52388. bendAxis?: Vector3;
  52389. maxAngle?: number;
  52390. slerpAmount?: number;
  52391. });
  52392. private _setMaxAngle;
  52393. /**
  52394. * Force the controller to update the bones
  52395. */
  52396. update(): void;
  52397. }
  52398. }
  52399. declare module "babylonjs/Bones/boneLookController" {
  52400. import { Vector3 } from "babylonjs/Maths/math.vector";
  52401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52402. import { Bone } from "babylonjs/Bones/bone";
  52403. import { Space } from "babylonjs/Maths/math.axis";
  52404. /**
  52405. * Class used to make a bone look toward a point in space
  52406. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  52407. */
  52408. export class BoneLookController {
  52409. private static _tmpVecs;
  52410. private static _tmpQuat;
  52411. private static _tmpMats;
  52412. /**
  52413. * The target Vector3 that the bone will look at
  52414. */
  52415. target: Vector3;
  52416. /**
  52417. * The mesh that the bone is attached to
  52418. */
  52419. mesh: AbstractMesh;
  52420. /**
  52421. * The bone that will be looking to the target
  52422. */
  52423. bone: Bone;
  52424. /**
  52425. * The up axis of the coordinate system that is used when the bone is rotated
  52426. */
  52427. upAxis: Vector3;
  52428. /**
  52429. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  52430. */
  52431. upAxisSpace: Space;
  52432. /**
  52433. * Used to make an adjustment to the yaw of the bone
  52434. */
  52435. adjustYaw: number;
  52436. /**
  52437. * Used to make an adjustment to the pitch of the bone
  52438. */
  52439. adjustPitch: number;
  52440. /**
  52441. * Used to make an adjustment to the roll of the bone
  52442. */
  52443. adjustRoll: number;
  52444. /**
  52445. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  52446. */
  52447. slerpAmount: number;
  52448. private _minYaw;
  52449. private _maxYaw;
  52450. private _minPitch;
  52451. private _maxPitch;
  52452. private _minYawSin;
  52453. private _minYawCos;
  52454. private _maxYawSin;
  52455. private _maxYawCos;
  52456. private _midYawConstraint;
  52457. private _minPitchTan;
  52458. private _maxPitchTan;
  52459. private _boneQuat;
  52460. private _slerping;
  52461. private _transformYawPitch;
  52462. private _transformYawPitchInv;
  52463. private _firstFrameSkipped;
  52464. private _yawRange;
  52465. private _fowardAxis;
  52466. /**
  52467. * Gets or sets the minimum yaw angle that the bone can look to
  52468. */
  52469. get minYaw(): number;
  52470. set minYaw(value: number);
  52471. /**
  52472. * Gets or sets the maximum yaw angle that the bone can look to
  52473. */
  52474. get maxYaw(): number;
  52475. set maxYaw(value: number);
  52476. /**
  52477. * Gets or sets the minimum pitch angle that the bone can look to
  52478. */
  52479. get minPitch(): number;
  52480. set minPitch(value: number);
  52481. /**
  52482. * Gets or sets the maximum pitch angle that the bone can look to
  52483. */
  52484. get maxPitch(): number;
  52485. set maxPitch(value: number);
  52486. /**
  52487. * Create a BoneLookController
  52488. * @param mesh the mesh that the bone belongs to
  52489. * @param bone the bone that will be looking to the target
  52490. * @param target the target Vector3 to look at
  52491. * @param options optional settings:
  52492. * * maxYaw: the maximum angle the bone will yaw to
  52493. * * minYaw: the minimum angle the bone will yaw to
  52494. * * maxPitch: the maximum angle the bone will pitch to
  52495. * * minPitch: the minimum angle the bone will yaw to
  52496. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  52497. * * upAxis: the up axis of the coordinate system
  52498. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  52499. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  52500. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  52501. * * adjustYaw: used to make an adjustment to the yaw of the bone
  52502. * * adjustPitch: used to make an adjustment to the pitch of the bone
  52503. * * adjustRoll: used to make an adjustment to the roll of the bone
  52504. **/
  52505. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  52506. maxYaw?: number;
  52507. minYaw?: number;
  52508. maxPitch?: number;
  52509. minPitch?: number;
  52510. slerpAmount?: number;
  52511. upAxis?: Vector3;
  52512. upAxisSpace?: Space;
  52513. yawAxis?: Vector3;
  52514. pitchAxis?: Vector3;
  52515. adjustYaw?: number;
  52516. adjustPitch?: number;
  52517. adjustRoll?: number;
  52518. });
  52519. /**
  52520. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  52521. */
  52522. update(): void;
  52523. private _getAngleDiff;
  52524. private _getAngleBetween;
  52525. private _isAngleBetween;
  52526. }
  52527. }
  52528. declare module "babylonjs/Bones/index" {
  52529. export * from "babylonjs/Bones/bone";
  52530. export * from "babylonjs/Bones/boneIKController";
  52531. export * from "babylonjs/Bones/boneLookController";
  52532. export * from "babylonjs/Bones/skeleton";
  52533. }
  52534. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  52535. import { Nullable } from "babylonjs/types";
  52536. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52537. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52538. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  52539. /**
  52540. * Manage the gamepad inputs to control an arc rotate camera.
  52541. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52542. */
  52543. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  52544. /**
  52545. * Defines the camera the input is attached to.
  52546. */
  52547. camera: ArcRotateCamera;
  52548. /**
  52549. * Defines the gamepad the input is gathering event from.
  52550. */
  52551. gamepad: Nullable<Gamepad>;
  52552. /**
  52553. * Defines the gamepad rotation sensiblity.
  52554. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52555. */
  52556. gamepadRotationSensibility: number;
  52557. /**
  52558. * Defines the gamepad move sensiblity.
  52559. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52560. */
  52561. gamepadMoveSensibility: number;
  52562. private _yAxisScale;
  52563. /**
  52564. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52565. */
  52566. get invertYAxis(): boolean;
  52567. set invertYAxis(value: boolean);
  52568. private _onGamepadConnectedObserver;
  52569. private _onGamepadDisconnectedObserver;
  52570. /**
  52571. * Attach the input controls to a specific dom element to get the input from.
  52572. */
  52573. attachControl(): void;
  52574. /**
  52575. * Detach the current controls from the specified dom element.
  52576. */
  52577. detachControl(): void;
  52578. /**
  52579. * Update the current camera state depending on the inputs that have been used this frame.
  52580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52581. */
  52582. checkInputs(): void;
  52583. /**
  52584. * Gets the class name of the current intput.
  52585. * @returns the class name
  52586. */
  52587. getClassName(): string;
  52588. /**
  52589. * Get the friendly name associated with the input class.
  52590. * @returns the input friendly name
  52591. */
  52592. getSimpleName(): string;
  52593. }
  52594. }
  52595. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  52596. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52597. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52598. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  52599. interface ArcRotateCameraInputsManager {
  52600. /**
  52601. * Add orientation input support to the input manager.
  52602. * @returns the current input manager
  52603. */
  52604. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  52605. }
  52606. }
  52607. /**
  52608. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  52609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52610. */
  52611. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  52612. /**
  52613. * Defines the camera the input is attached to.
  52614. */
  52615. camera: ArcRotateCamera;
  52616. /**
  52617. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  52618. */
  52619. alphaCorrection: number;
  52620. /**
  52621. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  52622. */
  52623. gammaCorrection: number;
  52624. private _alpha;
  52625. private _gamma;
  52626. private _dirty;
  52627. private _deviceOrientationHandler;
  52628. /**
  52629. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  52630. */
  52631. constructor();
  52632. /**
  52633. * Attach the input controls to a specific dom element to get the input from.
  52634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52635. */
  52636. attachControl(noPreventDefault?: boolean): void;
  52637. /** @hidden */
  52638. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  52639. /**
  52640. * Update the current camera state depending on the inputs that have been used this frame.
  52641. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52642. */
  52643. checkInputs(): void;
  52644. /**
  52645. * Detach the current controls from the specified dom element.
  52646. */
  52647. detachControl(): void;
  52648. /**
  52649. * Gets the class name of the current intput.
  52650. * @returns the class name
  52651. */
  52652. getClassName(): string;
  52653. /**
  52654. * Get the friendly name associated with the input class.
  52655. * @returns the input friendly name
  52656. */
  52657. getSimpleName(): string;
  52658. }
  52659. }
  52660. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  52661. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52662. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52663. /**
  52664. * Listen to mouse events to control the camera.
  52665. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52666. */
  52667. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  52668. /**
  52669. * Defines the camera the input is attached to.
  52670. */
  52671. camera: FlyCamera;
  52672. /**
  52673. * Defines if touch is enabled. (Default is true.)
  52674. */
  52675. touchEnabled: boolean;
  52676. /**
  52677. * Defines the buttons associated with the input to handle camera rotation.
  52678. */
  52679. buttons: number[];
  52680. /**
  52681. * Assign buttons for Yaw control.
  52682. */
  52683. buttonsYaw: number[];
  52684. /**
  52685. * Assign buttons for Pitch control.
  52686. */
  52687. buttonsPitch: number[];
  52688. /**
  52689. * Assign buttons for Roll control.
  52690. */
  52691. buttonsRoll: number[];
  52692. /**
  52693. * Detect if any button is being pressed while mouse is moved.
  52694. * -1 = Mouse locked.
  52695. * 0 = Left button.
  52696. * 1 = Middle Button.
  52697. * 2 = Right Button.
  52698. */
  52699. activeButton: number;
  52700. /**
  52701. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  52702. * Higher values reduce its sensitivity.
  52703. */
  52704. angularSensibility: number;
  52705. private _observer;
  52706. private _rollObserver;
  52707. private previousPosition;
  52708. private noPreventDefault;
  52709. private element;
  52710. /**
  52711. * Listen to mouse events to control the camera.
  52712. * @param touchEnabled Define if touch is enabled. (Default is true.)
  52713. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52714. */
  52715. constructor(touchEnabled?: boolean);
  52716. /**
  52717. * Attach the mouse control to the HTML DOM element.
  52718. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  52719. */
  52720. attachControl(noPreventDefault?: boolean): void;
  52721. /**
  52722. * Detach the current controls from the specified dom element.
  52723. */
  52724. detachControl(): void;
  52725. /**
  52726. * Gets the class name of the current input.
  52727. * @returns the class name.
  52728. */
  52729. getClassName(): string;
  52730. /**
  52731. * Get the friendly name associated with the input class.
  52732. * @returns the input's friendly name.
  52733. */
  52734. getSimpleName(): string;
  52735. private _pointerInput;
  52736. private _onMouseMove;
  52737. /**
  52738. * Rotate camera by mouse offset.
  52739. */
  52740. private rotateCamera;
  52741. }
  52742. }
  52743. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  52744. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52745. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  52746. /**
  52747. * Default Inputs manager for the FlyCamera.
  52748. * It groups all the default supported inputs for ease of use.
  52749. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52750. */
  52751. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  52752. /**
  52753. * Instantiates a new FlyCameraInputsManager.
  52754. * @param camera Defines the camera the inputs belong to.
  52755. */
  52756. constructor(camera: FlyCamera);
  52757. /**
  52758. * Add keyboard input support to the input manager.
  52759. * @returns the new FlyCameraKeyboardMoveInput().
  52760. */
  52761. addKeyboard(): FlyCameraInputsManager;
  52762. /**
  52763. * Add mouse input support to the input manager.
  52764. * @param touchEnabled Enable touch screen support.
  52765. * @returns the new FlyCameraMouseInput().
  52766. */
  52767. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  52768. }
  52769. }
  52770. declare module "babylonjs/Cameras/flyCamera" {
  52771. import { Scene } from "babylonjs/scene";
  52772. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52774. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  52775. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  52776. /**
  52777. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52778. * such as in a 3D Space Shooter or a Flight Simulator.
  52779. */
  52780. export class FlyCamera extends TargetCamera {
  52781. /**
  52782. * Define the collision ellipsoid of the camera.
  52783. * This is helpful for simulating a camera body, like a player's body.
  52784. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  52785. */
  52786. ellipsoid: Vector3;
  52787. /**
  52788. * Define an offset for the position of the ellipsoid around the camera.
  52789. * This can be helpful if the camera is attached away from the player's body center,
  52790. * such as at its head.
  52791. */
  52792. ellipsoidOffset: Vector3;
  52793. /**
  52794. * Enable or disable collisions of the camera with the rest of the scene objects.
  52795. */
  52796. checkCollisions: boolean;
  52797. /**
  52798. * Enable or disable gravity on the camera.
  52799. */
  52800. applyGravity: boolean;
  52801. /**
  52802. * Define the current direction the camera is moving to.
  52803. */
  52804. cameraDirection: Vector3;
  52805. /**
  52806. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  52807. * This overrides and empties cameraRotation.
  52808. */
  52809. rotationQuaternion: Quaternion;
  52810. /**
  52811. * Track Roll to maintain the wanted Rolling when looking around.
  52812. */
  52813. _trackRoll: number;
  52814. /**
  52815. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  52816. */
  52817. rollCorrect: number;
  52818. /**
  52819. * Mimic a banked turn, Rolling the camera when Yawing.
  52820. * It's recommended to use rollCorrect = 10 for faster banking correction.
  52821. */
  52822. bankedTurn: boolean;
  52823. /**
  52824. * Limit in radians for how much Roll banking will add. (Default: 90°)
  52825. */
  52826. bankedTurnLimit: number;
  52827. /**
  52828. * Value of 0 disables the banked Roll.
  52829. * Value of 1 is equal to the Yaw angle in radians.
  52830. */
  52831. bankedTurnMultiplier: number;
  52832. /**
  52833. * The inputs manager loads all the input sources, such as keyboard and mouse.
  52834. */
  52835. inputs: FlyCameraInputsManager;
  52836. /**
  52837. * Gets the input sensibility for mouse input.
  52838. * Higher values reduce sensitivity.
  52839. */
  52840. get angularSensibility(): number;
  52841. /**
  52842. * Sets the input sensibility for a mouse input.
  52843. * Higher values reduce sensitivity.
  52844. */
  52845. set angularSensibility(value: number);
  52846. /**
  52847. * Get the keys for camera movement forward.
  52848. */
  52849. get keysForward(): number[];
  52850. /**
  52851. * Set the keys for camera movement forward.
  52852. */
  52853. set keysForward(value: number[]);
  52854. /**
  52855. * Get the keys for camera movement backward.
  52856. */
  52857. get keysBackward(): number[];
  52858. set keysBackward(value: number[]);
  52859. /**
  52860. * Get the keys for camera movement up.
  52861. */
  52862. get keysUp(): number[];
  52863. /**
  52864. * Set the keys for camera movement up.
  52865. */
  52866. set keysUp(value: number[]);
  52867. /**
  52868. * Get the keys for camera movement down.
  52869. */
  52870. get keysDown(): number[];
  52871. /**
  52872. * Set the keys for camera movement down.
  52873. */
  52874. set keysDown(value: number[]);
  52875. /**
  52876. * Get the keys for camera movement left.
  52877. */
  52878. get keysLeft(): number[];
  52879. /**
  52880. * Set the keys for camera movement left.
  52881. */
  52882. set keysLeft(value: number[]);
  52883. /**
  52884. * Set the keys for camera movement right.
  52885. */
  52886. get keysRight(): number[];
  52887. /**
  52888. * Set the keys for camera movement right.
  52889. */
  52890. set keysRight(value: number[]);
  52891. /**
  52892. * Event raised when the camera collides with a mesh in the scene.
  52893. */
  52894. onCollide: (collidedMesh: AbstractMesh) => void;
  52895. private _collider;
  52896. private _needMoveForGravity;
  52897. private _oldPosition;
  52898. private _diffPosition;
  52899. private _newPosition;
  52900. /** @hidden */
  52901. _localDirection: Vector3;
  52902. /** @hidden */
  52903. _transformedDirection: Vector3;
  52904. /**
  52905. * Instantiates a FlyCamera.
  52906. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52907. * such as in a 3D Space Shooter or a Flight Simulator.
  52908. * @param name Define the name of the camera in the scene.
  52909. * @param position Define the starting position of the camera in the scene.
  52910. * @param scene Define the scene the camera belongs to.
  52911. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  52912. */
  52913. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52914. /**
  52915. * Attach the input controls to a specific dom element to get the input from.
  52916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52917. */
  52918. attachControl(noPreventDefault?: boolean): void;
  52919. /**
  52920. * Detach a control from the HTML DOM element.
  52921. * The camera will stop reacting to that input.
  52922. */
  52923. detachControl(): void;
  52924. private _collisionMask;
  52925. /**
  52926. * Get the mask that the camera ignores in collision events.
  52927. */
  52928. get collisionMask(): number;
  52929. /**
  52930. * Set the mask that the camera ignores in collision events.
  52931. */
  52932. set collisionMask(mask: number);
  52933. /** @hidden */
  52934. _collideWithWorld(displacement: Vector3): void;
  52935. /** @hidden */
  52936. private _onCollisionPositionChange;
  52937. /** @hidden */
  52938. _checkInputs(): void;
  52939. /** @hidden */
  52940. _decideIfNeedsToMove(): boolean;
  52941. /** @hidden */
  52942. _updatePosition(): void;
  52943. /**
  52944. * Restore the Roll to its target value at the rate specified.
  52945. * @param rate - Higher means slower restoring.
  52946. * @hidden
  52947. */
  52948. restoreRoll(rate: number): void;
  52949. /**
  52950. * Destroy the camera and release the current resources held by it.
  52951. */
  52952. dispose(): void;
  52953. /**
  52954. * Get the current object class name.
  52955. * @returns the class name.
  52956. */
  52957. getClassName(): string;
  52958. }
  52959. }
  52960. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  52961. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52962. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52963. /**
  52964. * Listen to keyboard events to control the camera.
  52965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52966. */
  52967. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  52968. /**
  52969. * Defines the camera the input is attached to.
  52970. */
  52971. camera: FlyCamera;
  52972. /**
  52973. * The list of keyboard keys used to control the forward move of the camera.
  52974. */
  52975. keysForward: number[];
  52976. /**
  52977. * The list of keyboard keys used to control the backward move of the camera.
  52978. */
  52979. keysBackward: number[];
  52980. /**
  52981. * The list of keyboard keys used to control the forward move of the camera.
  52982. */
  52983. keysUp: number[];
  52984. /**
  52985. * The list of keyboard keys used to control the backward move of the camera.
  52986. */
  52987. keysDown: number[];
  52988. /**
  52989. * The list of keyboard keys used to control the right strafe move of the camera.
  52990. */
  52991. keysRight: number[];
  52992. /**
  52993. * The list of keyboard keys used to control the left strafe move of the camera.
  52994. */
  52995. keysLeft: number[];
  52996. private _keys;
  52997. private _onCanvasBlurObserver;
  52998. private _onKeyboardObserver;
  52999. private _engine;
  53000. private _scene;
  53001. /**
  53002. * Attach the input controls to a specific dom element to get the input from.
  53003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53004. */
  53005. attachControl(noPreventDefault?: boolean): void;
  53006. /**
  53007. * Detach the current controls from the specified dom element.
  53008. */
  53009. detachControl(): void;
  53010. /**
  53011. * Gets the class name of the current intput.
  53012. * @returns the class name
  53013. */
  53014. getClassName(): string;
  53015. /** @hidden */
  53016. _onLostFocus(e: FocusEvent): void;
  53017. /**
  53018. * Get the friendly name associated with the input class.
  53019. * @returns the input friendly name
  53020. */
  53021. getSimpleName(): string;
  53022. /**
  53023. * Update the current camera state depending on the inputs that have been used this frame.
  53024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53025. */
  53026. checkInputs(): void;
  53027. }
  53028. }
  53029. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  53030. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53031. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53032. /**
  53033. * Manage the mouse wheel inputs to control a follow camera.
  53034. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53035. */
  53036. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  53037. /**
  53038. * Defines the camera the input is attached to.
  53039. */
  53040. camera: FollowCamera;
  53041. /**
  53042. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  53043. */
  53044. axisControlRadius: boolean;
  53045. /**
  53046. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  53047. */
  53048. axisControlHeight: boolean;
  53049. /**
  53050. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  53051. */
  53052. axisControlRotation: boolean;
  53053. /**
  53054. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  53055. * relation to mouseWheel events.
  53056. */
  53057. wheelPrecision: number;
  53058. /**
  53059. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  53060. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  53061. */
  53062. wheelDeltaPercentage: number;
  53063. private _wheel;
  53064. private _observer;
  53065. /**
  53066. * Attach the input controls to a specific dom element to get the input from.
  53067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53068. */
  53069. attachControl(noPreventDefault?: boolean): void;
  53070. /**
  53071. * Detach the current controls from the specified dom element.
  53072. */
  53073. detachControl(): void;
  53074. /**
  53075. * Gets the class name of the current intput.
  53076. * @returns the class name
  53077. */
  53078. getClassName(): string;
  53079. /**
  53080. * Get the friendly name associated with the input class.
  53081. * @returns the input friendly name
  53082. */
  53083. getSimpleName(): string;
  53084. }
  53085. }
  53086. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  53087. import { Nullable } from "babylonjs/types";
  53088. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53089. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  53090. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  53091. /**
  53092. * Manage the pointers inputs to control an follow camera.
  53093. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53094. */
  53095. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  53096. /**
  53097. * Defines the camera the input is attached to.
  53098. */
  53099. camera: FollowCamera;
  53100. /**
  53101. * Gets the class name of the current input.
  53102. * @returns the class name
  53103. */
  53104. getClassName(): string;
  53105. /**
  53106. * Defines the pointer angular sensibility along the X axis or how fast is
  53107. * the camera rotating.
  53108. * A negative number will reverse the axis direction.
  53109. */
  53110. angularSensibilityX: number;
  53111. /**
  53112. * Defines the pointer angular sensibility along the Y axis or how fast is
  53113. * the camera rotating.
  53114. * A negative number will reverse the axis direction.
  53115. */
  53116. angularSensibilityY: number;
  53117. /**
  53118. * Defines the pointer pinch precision or how fast is the camera zooming.
  53119. * A negative number will reverse the axis direction.
  53120. */
  53121. pinchPrecision: number;
  53122. /**
  53123. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  53124. * from 0.
  53125. * It defines the percentage of current camera.radius to use as delta when
  53126. * pinch zoom is used.
  53127. */
  53128. pinchDeltaPercentage: number;
  53129. /**
  53130. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  53131. */
  53132. axisXControlRadius: boolean;
  53133. /**
  53134. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  53135. */
  53136. axisXControlHeight: boolean;
  53137. /**
  53138. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  53139. */
  53140. axisXControlRotation: boolean;
  53141. /**
  53142. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  53143. */
  53144. axisYControlRadius: boolean;
  53145. /**
  53146. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  53147. */
  53148. axisYControlHeight: boolean;
  53149. /**
  53150. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  53151. */
  53152. axisYControlRotation: boolean;
  53153. /**
  53154. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  53155. */
  53156. axisPinchControlRadius: boolean;
  53157. /**
  53158. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  53159. */
  53160. axisPinchControlHeight: boolean;
  53161. /**
  53162. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  53163. */
  53164. axisPinchControlRotation: boolean;
  53165. /**
  53166. * Log error messages if basic misconfiguration has occurred.
  53167. */
  53168. warningEnable: boolean;
  53169. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  53170. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  53171. private _warningCounter;
  53172. private _warning;
  53173. }
  53174. }
  53175. declare module "babylonjs/Cameras/followCameraInputsManager" {
  53176. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  53177. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53178. /**
  53179. * Default Inputs manager for the FollowCamera.
  53180. * It groups all the default supported inputs for ease of use.
  53181. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53182. */
  53183. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  53184. /**
  53185. * Instantiates a new FollowCameraInputsManager.
  53186. * @param camera Defines the camera the inputs belong to
  53187. */
  53188. constructor(camera: FollowCamera);
  53189. /**
  53190. * Add keyboard input support to the input manager.
  53191. * @returns the current input manager
  53192. */
  53193. addKeyboard(): FollowCameraInputsManager;
  53194. /**
  53195. * Add mouse wheel input support to the input manager.
  53196. * @returns the current input manager
  53197. */
  53198. addMouseWheel(): FollowCameraInputsManager;
  53199. /**
  53200. * Add pointers input support to the input manager.
  53201. * @returns the current input manager
  53202. */
  53203. addPointers(): FollowCameraInputsManager;
  53204. /**
  53205. * Add orientation input support to the input manager.
  53206. * @returns the current input manager
  53207. */
  53208. addVRDeviceOrientation(): FollowCameraInputsManager;
  53209. }
  53210. }
  53211. declare module "babylonjs/Cameras/followCamera" {
  53212. import { Nullable } from "babylonjs/types";
  53213. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  53214. import { Scene } from "babylonjs/scene";
  53215. import { Vector3 } from "babylonjs/Maths/math.vector";
  53216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53217. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  53218. /**
  53219. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  53220. * an arc rotate version arcFollowCamera are available.
  53221. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53222. */
  53223. export class FollowCamera extends TargetCamera {
  53224. /**
  53225. * Distance the follow camera should follow an object at
  53226. */
  53227. radius: number;
  53228. /**
  53229. * Minimum allowed distance of the camera to the axis of rotation
  53230. * (The camera can not get closer).
  53231. * This can help limiting how the Camera is able to move in the scene.
  53232. */
  53233. lowerRadiusLimit: Nullable<number>;
  53234. /**
  53235. * Maximum allowed distance of the camera to the axis of rotation
  53236. * (The camera can not get further).
  53237. * This can help limiting how the Camera is able to move in the scene.
  53238. */
  53239. upperRadiusLimit: Nullable<number>;
  53240. /**
  53241. * Define a rotation offset between the camera and the object it follows
  53242. */
  53243. rotationOffset: number;
  53244. /**
  53245. * Minimum allowed angle to camera position relative to target object.
  53246. * This can help limiting how the Camera is able to move in the scene.
  53247. */
  53248. lowerRotationOffsetLimit: Nullable<number>;
  53249. /**
  53250. * Maximum allowed angle to camera position relative to target object.
  53251. * This can help limiting how the Camera is able to move in the scene.
  53252. */
  53253. upperRotationOffsetLimit: Nullable<number>;
  53254. /**
  53255. * Define a height offset between the camera and the object it follows.
  53256. * It can help following an object from the top (like a car chaing a plane)
  53257. */
  53258. heightOffset: number;
  53259. /**
  53260. * Minimum allowed height of camera position relative to target object.
  53261. * This can help limiting how the Camera is able to move in the scene.
  53262. */
  53263. lowerHeightOffsetLimit: Nullable<number>;
  53264. /**
  53265. * Maximum allowed height of camera position relative to target object.
  53266. * This can help limiting how the Camera is able to move in the scene.
  53267. */
  53268. upperHeightOffsetLimit: Nullable<number>;
  53269. /**
  53270. * Define how fast the camera can accelerate to follow it s target.
  53271. */
  53272. cameraAcceleration: number;
  53273. /**
  53274. * Define the speed limit of the camera following an object.
  53275. */
  53276. maxCameraSpeed: number;
  53277. /**
  53278. * Define the target of the camera.
  53279. */
  53280. lockedTarget: Nullable<AbstractMesh>;
  53281. /**
  53282. * Defines the input associated with the camera.
  53283. */
  53284. inputs: FollowCameraInputsManager;
  53285. /**
  53286. * Instantiates the follow camera.
  53287. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53288. * @param name Define the name of the camera in the scene
  53289. * @param position Define the position of the camera
  53290. * @param scene Define the scene the camera belong to
  53291. * @param lockedTarget Define the target of the camera
  53292. */
  53293. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  53294. private _follow;
  53295. /**
  53296. * Attach the input controls to a specific dom element to get the input from.
  53297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53298. */
  53299. attachControl(noPreventDefault?: boolean): void;
  53300. /**
  53301. * Detach the current controls from the specified dom element.
  53302. */
  53303. detachControl(): void;
  53304. /** @hidden */
  53305. _checkInputs(): void;
  53306. private _checkLimits;
  53307. /**
  53308. * Gets the camera class name.
  53309. * @returns the class name
  53310. */
  53311. getClassName(): string;
  53312. }
  53313. /**
  53314. * Arc Rotate version of the follow camera.
  53315. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  53316. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53317. */
  53318. export class ArcFollowCamera extends TargetCamera {
  53319. /** The longitudinal angle of the camera */
  53320. alpha: number;
  53321. /** The latitudinal angle of the camera */
  53322. beta: number;
  53323. /** The radius of the camera from its target */
  53324. radius: number;
  53325. private _cartesianCoordinates;
  53326. /** Define the camera target (the mesh it should follow) */
  53327. private _meshTarget;
  53328. /**
  53329. * Instantiates a new ArcFollowCamera
  53330. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53331. * @param name Define the name of the camera
  53332. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  53333. * @param beta Define the rotation angle of the camera around the elevation axis
  53334. * @param radius Define the radius of the camera from its target point
  53335. * @param target Define the target of the camera
  53336. * @param scene Define the scene the camera belongs to
  53337. */
  53338. constructor(name: string,
  53339. /** The longitudinal angle of the camera */
  53340. alpha: number,
  53341. /** The latitudinal angle of the camera */
  53342. beta: number,
  53343. /** The radius of the camera from its target */
  53344. radius: number,
  53345. /** Define the camera target (the mesh it should follow) */
  53346. target: Nullable<AbstractMesh>, scene: Scene);
  53347. private _follow;
  53348. /** @hidden */
  53349. _checkInputs(): void;
  53350. /**
  53351. * Returns the class name of the object.
  53352. * It is mostly used internally for serialization purposes.
  53353. */
  53354. getClassName(): string;
  53355. }
  53356. }
  53357. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  53358. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53359. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53360. /**
  53361. * Manage the keyboard inputs to control the movement of a follow camera.
  53362. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53363. */
  53364. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  53365. /**
  53366. * Defines the camera the input is attached to.
  53367. */
  53368. camera: FollowCamera;
  53369. /**
  53370. * Defines the list of key codes associated with the up action (increase heightOffset)
  53371. */
  53372. keysHeightOffsetIncr: number[];
  53373. /**
  53374. * Defines the list of key codes associated with the down action (decrease heightOffset)
  53375. */
  53376. keysHeightOffsetDecr: number[];
  53377. /**
  53378. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  53379. */
  53380. keysHeightOffsetModifierAlt: boolean;
  53381. /**
  53382. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  53383. */
  53384. keysHeightOffsetModifierCtrl: boolean;
  53385. /**
  53386. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  53387. */
  53388. keysHeightOffsetModifierShift: boolean;
  53389. /**
  53390. * Defines the list of key codes associated with the left action (increase rotationOffset)
  53391. */
  53392. keysRotationOffsetIncr: number[];
  53393. /**
  53394. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  53395. */
  53396. keysRotationOffsetDecr: number[];
  53397. /**
  53398. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  53399. */
  53400. keysRotationOffsetModifierAlt: boolean;
  53401. /**
  53402. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  53403. */
  53404. keysRotationOffsetModifierCtrl: boolean;
  53405. /**
  53406. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  53407. */
  53408. keysRotationOffsetModifierShift: boolean;
  53409. /**
  53410. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  53411. */
  53412. keysRadiusIncr: number[];
  53413. /**
  53414. * Defines the list of key codes associated with the zoom-out action (increase radius)
  53415. */
  53416. keysRadiusDecr: number[];
  53417. /**
  53418. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  53419. */
  53420. keysRadiusModifierAlt: boolean;
  53421. /**
  53422. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  53423. */
  53424. keysRadiusModifierCtrl: boolean;
  53425. /**
  53426. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  53427. */
  53428. keysRadiusModifierShift: boolean;
  53429. /**
  53430. * Defines the rate of change of heightOffset.
  53431. */
  53432. heightSensibility: number;
  53433. /**
  53434. * Defines the rate of change of rotationOffset.
  53435. */
  53436. rotationSensibility: number;
  53437. /**
  53438. * Defines the rate of change of radius.
  53439. */
  53440. radiusSensibility: number;
  53441. private _keys;
  53442. private _ctrlPressed;
  53443. private _altPressed;
  53444. private _shiftPressed;
  53445. private _onCanvasBlurObserver;
  53446. private _onKeyboardObserver;
  53447. private _engine;
  53448. private _scene;
  53449. /**
  53450. * Attach the input controls to a specific dom element to get the input from.
  53451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53452. */
  53453. attachControl(noPreventDefault?: boolean): void;
  53454. /**
  53455. * Detach the current controls from the specified dom element.
  53456. */
  53457. detachControl(): void;
  53458. /**
  53459. * Update the current camera state depending on the inputs that have been used this frame.
  53460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53461. */
  53462. checkInputs(): void;
  53463. /**
  53464. * Gets the class name of the current input.
  53465. * @returns the class name
  53466. */
  53467. getClassName(): string;
  53468. /**
  53469. * Get the friendly name associated with the input class.
  53470. * @returns the input friendly name
  53471. */
  53472. getSimpleName(): string;
  53473. /**
  53474. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53475. * allow modification of the heightOffset value.
  53476. */
  53477. private _modifierHeightOffset;
  53478. /**
  53479. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53480. * allow modification of the rotationOffset value.
  53481. */
  53482. private _modifierRotationOffset;
  53483. /**
  53484. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53485. * allow modification of the radius value.
  53486. */
  53487. private _modifierRadius;
  53488. }
  53489. }
  53490. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  53491. import { Nullable } from "babylonjs/types";
  53492. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53493. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53494. import { Observable } from "babylonjs/Misc/observable";
  53495. module "babylonjs/Cameras/freeCameraInputsManager" {
  53496. interface FreeCameraInputsManager {
  53497. /**
  53498. * @hidden
  53499. */
  53500. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  53501. /**
  53502. * Add orientation input support to the input manager.
  53503. * @returns the current input manager
  53504. */
  53505. addDeviceOrientation(): FreeCameraInputsManager;
  53506. }
  53507. }
  53508. /**
  53509. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  53510. * Screen rotation is taken into account.
  53511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53512. */
  53513. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  53514. private _camera;
  53515. private _screenOrientationAngle;
  53516. private _constantTranform;
  53517. private _screenQuaternion;
  53518. private _alpha;
  53519. private _beta;
  53520. private _gamma;
  53521. /**
  53522. * Can be used to detect if a device orientation sensor is available on a device
  53523. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  53524. * @returns a promise that will resolve on orientation change
  53525. */
  53526. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  53527. /**
  53528. * @hidden
  53529. */
  53530. _onDeviceOrientationChangedObservable: Observable<void>;
  53531. /**
  53532. * Instantiates a new input
  53533. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53534. */
  53535. constructor();
  53536. /**
  53537. * Define the camera controlled by the input.
  53538. */
  53539. get camera(): FreeCamera;
  53540. set camera(camera: FreeCamera);
  53541. /**
  53542. * Attach the input controls to a specific dom element to get the input from.
  53543. */
  53544. attachControl(): void;
  53545. private _orientationChanged;
  53546. private _deviceOrientation;
  53547. /**
  53548. * Detach the current controls from the specified dom element.
  53549. */
  53550. detachControl(): void;
  53551. /**
  53552. * Update the current camera state depending on the inputs that have been used this frame.
  53553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53554. */
  53555. checkInputs(): void;
  53556. /**
  53557. * Gets the class name of the current intput.
  53558. * @returns the class name
  53559. */
  53560. getClassName(): string;
  53561. /**
  53562. * Get the friendly name associated with the input class.
  53563. * @returns the input friendly name
  53564. */
  53565. getSimpleName(): string;
  53566. }
  53567. }
  53568. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  53569. import { Nullable } from "babylonjs/types";
  53570. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53571. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53572. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53573. /**
  53574. * Manage the gamepad inputs to control a free camera.
  53575. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53576. */
  53577. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  53578. /**
  53579. * Define the camera the input is attached to.
  53580. */
  53581. camera: FreeCamera;
  53582. /**
  53583. * Define the Gamepad controlling the input
  53584. */
  53585. gamepad: Nullable<Gamepad>;
  53586. /**
  53587. * Defines the gamepad rotation sensiblity.
  53588. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53589. */
  53590. gamepadAngularSensibility: number;
  53591. /**
  53592. * Defines the gamepad move sensiblity.
  53593. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53594. */
  53595. gamepadMoveSensibility: number;
  53596. private _yAxisScale;
  53597. /**
  53598. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  53599. */
  53600. get invertYAxis(): boolean;
  53601. set invertYAxis(value: boolean);
  53602. private _onGamepadConnectedObserver;
  53603. private _onGamepadDisconnectedObserver;
  53604. private _cameraTransform;
  53605. private _deltaTransform;
  53606. private _vector3;
  53607. private _vector2;
  53608. /**
  53609. * Attach the input controls to a specific dom element to get the input from.
  53610. */
  53611. attachControl(): void;
  53612. /**
  53613. * Detach the current controls from the specified dom element.
  53614. */
  53615. detachControl(): void;
  53616. /**
  53617. * Update the current camera state depending on the inputs that have been used this frame.
  53618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53619. */
  53620. checkInputs(): void;
  53621. /**
  53622. * Gets the class name of the current intput.
  53623. * @returns the class name
  53624. */
  53625. getClassName(): string;
  53626. /**
  53627. * Get the friendly name associated with the input class.
  53628. * @returns the input friendly name
  53629. */
  53630. getSimpleName(): string;
  53631. }
  53632. }
  53633. declare module "babylonjs/Misc/virtualJoystick" {
  53634. import { Nullable } from "babylonjs/types";
  53635. import { Vector3 } from "babylonjs/Maths/math.vector";
  53636. /**
  53637. * Defines the potential axis of a Joystick
  53638. */
  53639. export enum JoystickAxis {
  53640. /** X axis */
  53641. X = 0,
  53642. /** Y axis */
  53643. Y = 1,
  53644. /** Z axis */
  53645. Z = 2
  53646. }
  53647. /**
  53648. * Represents the different customization options available
  53649. * for VirtualJoystick
  53650. */
  53651. interface VirtualJoystickCustomizations {
  53652. /**
  53653. * Size of the joystick's puck
  53654. */
  53655. puckSize: number;
  53656. /**
  53657. * Size of the joystick's container
  53658. */
  53659. containerSize: number;
  53660. /**
  53661. * Color of the joystick && puck
  53662. */
  53663. color: string;
  53664. /**
  53665. * Image URL for the joystick's puck
  53666. */
  53667. puckImage?: string;
  53668. /**
  53669. * Image URL for the joystick's container
  53670. */
  53671. containerImage?: string;
  53672. /**
  53673. * Defines the unmoving position of the joystick container
  53674. */
  53675. position?: {
  53676. x: number;
  53677. y: number;
  53678. };
  53679. /**
  53680. * Defines whether or not the joystick container is always visible
  53681. */
  53682. alwaysVisible: boolean;
  53683. /**
  53684. * Defines whether or not to limit the movement of the puck to the joystick's container
  53685. */
  53686. limitToContainer: boolean;
  53687. }
  53688. /**
  53689. * Class used to define virtual joystick (used in touch mode)
  53690. */
  53691. export class VirtualJoystick {
  53692. /**
  53693. * Gets or sets a boolean indicating that left and right values must be inverted
  53694. */
  53695. reverseLeftRight: boolean;
  53696. /**
  53697. * Gets or sets a boolean indicating that up and down values must be inverted
  53698. */
  53699. reverseUpDown: boolean;
  53700. /**
  53701. * Gets the offset value for the position (ie. the change of the position value)
  53702. */
  53703. deltaPosition: Vector3;
  53704. /**
  53705. * Gets a boolean indicating if the virtual joystick was pressed
  53706. */
  53707. pressed: boolean;
  53708. /**
  53709. * Canvas the virtual joystick will render onto, default z-index of this is 5
  53710. */
  53711. static Canvas: Nullable<HTMLCanvasElement>;
  53712. /**
  53713. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  53714. */
  53715. limitToContainer: boolean;
  53716. private static _globalJoystickIndex;
  53717. private static _alwaysVisibleSticks;
  53718. private static vjCanvasContext;
  53719. private static vjCanvasWidth;
  53720. private static vjCanvasHeight;
  53721. private static halfWidth;
  53722. private static _GetDefaultOptions;
  53723. private _action;
  53724. private _axisTargetedByLeftAndRight;
  53725. private _axisTargetedByUpAndDown;
  53726. private _joystickSensibility;
  53727. private _inversedSensibility;
  53728. private _joystickPointerID;
  53729. private _joystickColor;
  53730. private _joystickPointerPos;
  53731. private _joystickPreviousPointerPos;
  53732. private _joystickPointerStartPos;
  53733. private _deltaJoystickVector;
  53734. private _leftJoystick;
  53735. private _touches;
  53736. private _joystickPosition;
  53737. private _alwaysVisible;
  53738. private _puckImage;
  53739. private _containerImage;
  53740. private _joystickPuckSize;
  53741. private _joystickContainerSize;
  53742. private _clearPuckSize;
  53743. private _clearContainerSize;
  53744. private _clearPuckSizeOffset;
  53745. private _clearContainerSizeOffset;
  53746. private _onPointerDownHandlerRef;
  53747. private _onPointerMoveHandlerRef;
  53748. private _onPointerUpHandlerRef;
  53749. private _onResize;
  53750. /**
  53751. * Creates a new virtual joystick
  53752. * @param leftJoystick defines that the joystick is for left hand (false by default)
  53753. * @param customizations Defines the options we want to customize the VirtualJoystick
  53754. */
  53755. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  53756. /**
  53757. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  53758. * @param newJoystickSensibility defines the new sensibility
  53759. */
  53760. setJoystickSensibility(newJoystickSensibility: number): void;
  53761. private _onPointerDown;
  53762. private _onPointerMove;
  53763. private _onPointerUp;
  53764. /**
  53765. * Change the color of the virtual joystick
  53766. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  53767. */
  53768. setJoystickColor(newColor: string): void;
  53769. /**
  53770. * Size of the joystick's container
  53771. */
  53772. set containerSize(newSize: number);
  53773. get containerSize(): number;
  53774. /**
  53775. * Size of the joystick's puck
  53776. */
  53777. set puckSize(newSize: number);
  53778. get puckSize(): number;
  53779. /**
  53780. * Clears the set position of the joystick
  53781. */
  53782. clearPosition(): void;
  53783. /**
  53784. * Defines whether or not the joystick container is always visible
  53785. */
  53786. set alwaysVisible(value: boolean);
  53787. get alwaysVisible(): boolean;
  53788. /**
  53789. * Sets the constant position of the Joystick container
  53790. * @param x X axis coordinate
  53791. * @param y Y axis coordinate
  53792. */
  53793. setPosition(x: number, y: number): void;
  53794. /**
  53795. * Defines a callback to call when the joystick is touched
  53796. * @param action defines the callback
  53797. */
  53798. setActionOnTouch(action: () => any): void;
  53799. /**
  53800. * Defines which axis you'd like to control for left & right
  53801. * @param axis defines the axis to use
  53802. */
  53803. setAxisForLeftRight(axis: JoystickAxis): void;
  53804. /**
  53805. * Defines which axis you'd like to control for up & down
  53806. * @param axis defines the axis to use
  53807. */
  53808. setAxisForUpDown(axis: JoystickAxis): void;
  53809. /**
  53810. * Clears the canvas from the previous puck / container draw
  53811. */
  53812. private _clearPreviousDraw;
  53813. /**
  53814. * Loads `urlPath` to be used for the container's image
  53815. * @param urlPath defines the urlPath of an image to use
  53816. */
  53817. setContainerImage(urlPath: string): void;
  53818. /**
  53819. * Loads `urlPath` to be used for the puck's image
  53820. * @param urlPath defines the urlPath of an image to use
  53821. */
  53822. setPuckImage(urlPath: string): void;
  53823. /**
  53824. * Draws the Virtual Joystick's container
  53825. */
  53826. private _drawContainer;
  53827. /**
  53828. * Draws the Virtual Joystick's puck
  53829. */
  53830. private _drawPuck;
  53831. private _drawVirtualJoystick;
  53832. /**
  53833. * Release internal HTML canvas
  53834. */
  53835. releaseCanvas(): void;
  53836. }
  53837. }
  53838. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  53839. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  53840. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53841. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53842. module "babylonjs/Cameras/freeCameraInputsManager" {
  53843. interface FreeCameraInputsManager {
  53844. /**
  53845. * Add virtual joystick input support to the input manager.
  53846. * @returns the current input manager
  53847. */
  53848. addVirtualJoystick(): FreeCameraInputsManager;
  53849. }
  53850. }
  53851. /**
  53852. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  53853. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53854. */
  53855. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  53856. /**
  53857. * Defines the camera the input is attached to.
  53858. */
  53859. camera: FreeCamera;
  53860. private _leftjoystick;
  53861. private _rightjoystick;
  53862. /**
  53863. * Gets the left stick of the virtual joystick.
  53864. * @returns The virtual Joystick
  53865. */
  53866. getLeftJoystick(): VirtualJoystick;
  53867. /**
  53868. * Gets the right stick of the virtual joystick.
  53869. * @returns The virtual Joystick
  53870. */
  53871. getRightJoystick(): VirtualJoystick;
  53872. /**
  53873. * Update the current camera state depending on the inputs that have been used this frame.
  53874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53875. */
  53876. checkInputs(): void;
  53877. /**
  53878. * Attach the input controls to a specific dom element to get the input from.
  53879. */
  53880. attachControl(): void;
  53881. /**
  53882. * Detach the current controls from the specified dom element.
  53883. */
  53884. detachControl(): void;
  53885. /**
  53886. * Gets the class name of the current intput.
  53887. * @returns the class name
  53888. */
  53889. getClassName(): string;
  53890. /**
  53891. * Get the friendly name associated with the input class.
  53892. * @returns the input friendly name
  53893. */
  53894. getSimpleName(): string;
  53895. }
  53896. }
  53897. declare module "babylonjs/Cameras/Inputs/index" {
  53898. export * from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  53899. export * from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  53900. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  53901. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  53902. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  53903. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  53904. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  53905. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  53906. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  53907. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  53908. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  53909. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  53910. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53911. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  53912. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  53913. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  53914. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  53915. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  53916. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  53917. }
  53918. declare module "babylonjs/Cameras/touchCamera" {
  53919. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53920. import { Scene } from "babylonjs/scene";
  53921. import { Vector3 } from "babylonjs/Maths/math.vector";
  53922. /**
  53923. * This represents a FPS type of camera controlled by touch.
  53924. * This is like a universal camera minus the Gamepad controls.
  53925. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53926. */
  53927. export class TouchCamera extends FreeCamera {
  53928. /**
  53929. * Defines the touch sensibility for rotation.
  53930. * The higher the faster.
  53931. */
  53932. get touchAngularSensibility(): number;
  53933. set touchAngularSensibility(value: number);
  53934. /**
  53935. * Defines the touch sensibility for move.
  53936. * The higher the faster.
  53937. */
  53938. get touchMoveSensibility(): number;
  53939. set touchMoveSensibility(value: number);
  53940. /**
  53941. * Instantiates a new touch camera.
  53942. * This represents a FPS type of camera controlled by touch.
  53943. * This is like a universal camera minus the Gamepad controls.
  53944. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53945. * @param name Define the name of the camera in the scene
  53946. * @param position Define the start position of the camera in the scene
  53947. * @param scene Define the scene the camera belongs to
  53948. */
  53949. constructor(name: string, position: Vector3, scene: Scene);
  53950. /**
  53951. * Gets the current object class name.
  53952. * @return the class name
  53953. */
  53954. getClassName(): string;
  53955. /** @hidden */
  53956. _setupInputs(): void;
  53957. }
  53958. }
  53959. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  53960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53961. import { Scene } from "babylonjs/scene";
  53962. import { Vector3 } from "babylonjs/Maths/math.vector";
  53963. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53964. import { Axis } from "babylonjs/Maths/math.axis";
  53965. /**
  53966. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  53967. * being tilted forward or back and left or right.
  53968. */
  53969. export class DeviceOrientationCamera extends FreeCamera {
  53970. private _initialQuaternion;
  53971. private _quaternionCache;
  53972. private _tmpDragQuaternion;
  53973. private _disablePointerInputWhenUsingDeviceOrientation;
  53974. /**
  53975. * Creates a new device orientation camera
  53976. * @param name The name of the camera
  53977. * @param position The start position camera
  53978. * @param scene The scene the camera belongs to
  53979. */
  53980. constructor(name: string, position: Vector3, scene: Scene);
  53981. /**
  53982. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  53983. */
  53984. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  53985. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  53986. private _dragFactor;
  53987. /**
  53988. * Enabled turning on the y axis when the orientation sensor is active
  53989. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  53990. */
  53991. enableHorizontalDragging(dragFactor?: number): void;
  53992. /**
  53993. * Gets the current instance class name ("DeviceOrientationCamera").
  53994. * This helps avoiding instanceof at run time.
  53995. * @returns the class name
  53996. */
  53997. getClassName(): string;
  53998. /**
  53999. * @hidden
  54000. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  54001. */
  54002. _checkInputs(): void;
  54003. /**
  54004. * Reset the camera to its default orientation on the specified axis only.
  54005. * @param axis The axis to reset
  54006. */
  54007. resetToCurrentRotation(axis?: Axis): void;
  54008. }
  54009. }
  54010. declare module "babylonjs/Gamepads/xboxGamepad" {
  54011. import { Observable } from "babylonjs/Misc/observable";
  54012. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54013. /**
  54014. * Defines supported buttons for XBox360 compatible gamepads
  54015. */
  54016. export enum Xbox360Button {
  54017. /** A */
  54018. A = 0,
  54019. /** B */
  54020. B = 1,
  54021. /** X */
  54022. X = 2,
  54023. /** Y */
  54024. Y = 3,
  54025. /** Left button */
  54026. LB = 4,
  54027. /** Right button */
  54028. RB = 5,
  54029. /** Back */
  54030. Back = 8,
  54031. /** Start */
  54032. Start = 9,
  54033. /** Left stick */
  54034. LeftStick = 10,
  54035. /** Right stick */
  54036. RightStick = 11
  54037. }
  54038. /** Defines values for XBox360 DPad */
  54039. export enum Xbox360Dpad {
  54040. /** Up */
  54041. Up = 12,
  54042. /** Down */
  54043. Down = 13,
  54044. /** Left */
  54045. Left = 14,
  54046. /** Right */
  54047. Right = 15
  54048. }
  54049. /**
  54050. * Defines a XBox360 gamepad
  54051. */
  54052. export class Xbox360Pad extends Gamepad {
  54053. private _leftTrigger;
  54054. private _rightTrigger;
  54055. private _onlefttriggerchanged;
  54056. private _onrighttriggerchanged;
  54057. private _onbuttondown;
  54058. private _onbuttonup;
  54059. private _ondpaddown;
  54060. private _ondpadup;
  54061. /** Observable raised when a button is pressed */
  54062. onButtonDownObservable: Observable<Xbox360Button>;
  54063. /** Observable raised when a button is released */
  54064. onButtonUpObservable: Observable<Xbox360Button>;
  54065. /** Observable raised when a pad is pressed */
  54066. onPadDownObservable: Observable<Xbox360Dpad>;
  54067. /** Observable raised when a pad is released */
  54068. onPadUpObservable: Observable<Xbox360Dpad>;
  54069. private _buttonA;
  54070. private _buttonB;
  54071. private _buttonX;
  54072. private _buttonY;
  54073. private _buttonBack;
  54074. private _buttonStart;
  54075. private _buttonLB;
  54076. private _buttonRB;
  54077. private _buttonLeftStick;
  54078. private _buttonRightStick;
  54079. private _dPadUp;
  54080. private _dPadDown;
  54081. private _dPadLeft;
  54082. private _dPadRight;
  54083. private _isXboxOnePad;
  54084. /**
  54085. * Creates a new XBox360 gamepad object
  54086. * @param id defines the id of this gamepad
  54087. * @param index defines its index
  54088. * @param gamepad defines the internal HTML gamepad object
  54089. * @param xboxOne defines if it is a XBox One gamepad
  54090. */
  54091. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  54092. /**
  54093. * Defines the callback to call when left trigger is pressed
  54094. * @param callback defines the callback to use
  54095. */
  54096. onlefttriggerchanged(callback: (value: number) => void): void;
  54097. /**
  54098. * Defines the callback to call when right trigger is pressed
  54099. * @param callback defines the callback to use
  54100. */
  54101. onrighttriggerchanged(callback: (value: number) => void): void;
  54102. /**
  54103. * Gets the left trigger value
  54104. */
  54105. get leftTrigger(): number;
  54106. /**
  54107. * Sets the left trigger value
  54108. */
  54109. set leftTrigger(newValue: number);
  54110. /**
  54111. * Gets the right trigger value
  54112. */
  54113. get rightTrigger(): number;
  54114. /**
  54115. * Sets the right trigger value
  54116. */
  54117. set rightTrigger(newValue: number);
  54118. /**
  54119. * Defines the callback to call when a button is pressed
  54120. * @param callback defines the callback to use
  54121. */
  54122. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  54123. /**
  54124. * Defines the callback to call when a button is released
  54125. * @param callback defines the callback to use
  54126. */
  54127. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  54128. /**
  54129. * Defines the callback to call when a pad is pressed
  54130. * @param callback defines the callback to use
  54131. */
  54132. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  54133. /**
  54134. * Defines the callback to call when a pad is released
  54135. * @param callback defines the callback to use
  54136. */
  54137. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  54138. private _setButtonValue;
  54139. private _setDPadValue;
  54140. /**
  54141. * Gets the value of the `A` button
  54142. */
  54143. get buttonA(): number;
  54144. /**
  54145. * Sets the value of the `A` button
  54146. */
  54147. set buttonA(value: number);
  54148. /**
  54149. * Gets the value of the `B` button
  54150. */
  54151. get buttonB(): number;
  54152. /**
  54153. * Sets the value of the `B` button
  54154. */
  54155. set buttonB(value: number);
  54156. /**
  54157. * Gets the value of the `X` button
  54158. */
  54159. get buttonX(): number;
  54160. /**
  54161. * Sets the value of the `X` button
  54162. */
  54163. set buttonX(value: number);
  54164. /**
  54165. * Gets the value of the `Y` button
  54166. */
  54167. get buttonY(): number;
  54168. /**
  54169. * Sets the value of the `Y` button
  54170. */
  54171. set buttonY(value: number);
  54172. /**
  54173. * Gets the value of the `Start` button
  54174. */
  54175. get buttonStart(): number;
  54176. /**
  54177. * Sets the value of the `Start` button
  54178. */
  54179. set buttonStart(value: number);
  54180. /**
  54181. * Gets the value of the `Back` button
  54182. */
  54183. get buttonBack(): number;
  54184. /**
  54185. * Sets the value of the `Back` button
  54186. */
  54187. set buttonBack(value: number);
  54188. /**
  54189. * Gets the value of the `Left` button
  54190. */
  54191. get buttonLB(): number;
  54192. /**
  54193. * Sets the value of the `Left` button
  54194. */
  54195. set buttonLB(value: number);
  54196. /**
  54197. * Gets the value of the `Right` button
  54198. */
  54199. get buttonRB(): number;
  54200. /**
  54201. * Sets the value of the `Right` button
  54202. */
  54203. set buttonRB(value: number);
  54204. /**
  54205. * Gets the value of the Left joystick
  54206. */
  54207. get buttonLeftStick(): number;
  54208. /**
  54209. * Sets the value of the Left joystick
  54210. */
  54211. set buttonLeftStick(value: number);
  54212. /**
  54213. * Gets the value of the Right joystick
  54214. */
  54215. get buttonRightStick(): number;
  54216. /**
  54217. * Sets the value of the Right joystick
  54218. */
  54219. set buttonRightStick(value: number);
  54220. /**
  54221. * Gets the value of D-pad up
  54222. */
  54223. get dPadUp(): number;
  54224. /**
  54225. * Sets the value of D-pad up
  54226. */
  54227. set dPadUp(value: number);
  54228. /**
  54229. * Gets the value of D-pad down
  54230. */
  54231. get dPadDown(): number;
  54232. /**
  54233. * Sets the value of D-pad down
  54234. */
  54235. set dPadDown(value: number);
  54236. /**
  54237. * Gets the value of D-pad left
  54238. */
  54239. get dPadLeft(): number;
  54240. /**
  54241. * Sets the value of D-pad left
  54242. */
  54243. set dPadLeft(value: number);
  54244. /**
  54245. * Gets the value of D-pad right
  54246. */
  54247. get dPadRight(): number;
  54248. /**
  54249. * Sets the value of D-pad right
  54250. */
  54251. set dPadRight(value: number);
  54252. /**
  54253. * Force the gamepad to synchronize with device values
  54254. */
  54255. update(): void;
  54256. /**
  54257. * Disposes the gamepad
  54258. */
  54259. dispose(): void;
  54260. }
  54261. }
  54262. declare module "babylonjs/Gamepads/dualShockGamepad" {
  54263. import { Observable } from "babylonjs/Misc/observable";
  54264. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54265. /**
  54266. * Defines supported buttons for DualShock compatible gamepads
  54267. */
  54268. export enum DualShockButton {
  54269. /** Cross */
  54270. Cross = 0,
  54271. /** Circle */
  54272. Circle = 1,
  54273. /** Square */
  54274. Square = 2,
  54275. /** Triangle */
  54276. Triangle = 3,
  54277. /** L1 */
  54278. L1 = 4,
  54279. /** R1 */
  54280. R1 = 5,
  54281. /** Share */
  54282. Share = 8,
  54283. /** Options */
  54284. Options = 9,
  54285. /** Left stick */
  54286. LeftStick = 10,
  54287. /** Right stick */
  54288. RightStick = 11
  54289. }
  54290. /** Defines values for DualShock DPad */
  54291. export enum DualShockDpad {
  54292. /** Up */
  54293. Up = 12,
  54294. /** Down */
  54295. Down = 13,
  54296. /** Left */
  54297. Left = 14,
  54298. /** Right */
  54299. Right = 15
  54300. }
  54301. /**
  54302. * Defines a DualShock gamepad
  54303. */
  54304. export class DualShockPad extends Gamepad {
  54305. private _leftTrigger;
  54306. private _rightTrigger;
  54307. private _onlefttriggerchanged;
  54308. private _onrighttriggerchanged;
  54309. private _onbuttondown;
  54310. private _onbuttonup;
  54311. private _ondpaddown;
  54312. private _ondpadup;
  54313. /** Observable raised when a button is pressed */
  54314. onButtonDownObservable: Observable<DualShockButton>;
  54315. /** Observable raised when a button is released */
  54316. onButtonUpObservable: Observable<DualShockButton>;
  54317. /** Observable raised when a pad is pressed */
  54318. onPadDownObservable: Observable<DualShockDpad>;
  54319. /** Observable raised when a pad is released */
  54320. onPadUpObservable: Observable<DualShockDpad>;
  54321. private _buttonCross;
  54322. private _buttonCircle;
  54323. private _buttonSquare;
  54324. private _buttonTriangle;
  54325. private _buttonShare;
  54326. private _buttonOptions;
  54327. private _buttonL1;
  54328. private _buttonR1;
  54329. private _buttonLeftStick;
  54330. private _buttonRightStick;
  54331. private _dPadUp;
  54332. private _dPadDown;
  54333. private _dPadLeft;
  54334. private _dPadRight;
  54335. /**
  54336. * Creates a new DualShock gamepad object
  54337. * @param id defines the id of this gamepad
  54338. * @param index defines its index
  54339. * @param gamepad defines the internal HTML gamepad object
  54340. */
  54341. constructor(id: string, index: number, gamepad: any);
  54342. /**
  54343. * Defines the callback to call when left trigger is pressed
  54344. * @param callback defines the callback to use
  54345. */
  54346. onlefttriggerchanged(callback: (value: number) => void): void;
  54347. /**
  54348. * Defines the callback to call when right trigger is pressed
  54349. * @param callback defines the callback to use
  54350. */
  54351. onrighttriggerchanged(callback: (value: number) => void): void;
  54352. /**
  54353. * Gets the left trigger value
  54354. */
  54355. get leftTrigger(): number;
  54356. /**
  54357. * Sets the left trigger value
  54358. */
  54359. set leftTrigger(newValue: number);
  54360. /**
  54361. * Gets the right trigger value
  54362. */
  54363. get rightTrigger(): number;
  54364. /**
  54365. * Sets the right trigger value
  54366. */
  54367. set rightTrigger(newValue: number);
  54368. /**
  54369. * Defines the callback to call when a button is pressed
  54370. * @param callback defines the callback to use
  54371. */
  54372. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  54373. /**
  54374. * Defines the callback to call when a button is released
  54375. * @param callback defines the callback to use
  54376. */
  54377. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  54378. /**
  54379. * Defines the callback to call when a pad is pressed
  54380. * @param callback defines the callback to use
  54381. */
  54382. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  54383. /**
  54384. * Defines the callback to call when a pad is released
  54385. * @param callback defines the callback to use
  54386. */
  54387. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  54388. private _setButtonValue;
  54389. private _setDPadValue;
  54390. /**
  54391. * Gets the value of the `Cross` button
  54392. */
  54393. get buttonCross(): number;
  54394. /**
  54395. * Sets the value of the `Cross` button
  54396. */
  54397. set buttonCross(value: number);
  54398. /**
  54399. * Gets the value of the `Circle` button
  54400. */
  54401. get buttonCircle(): number;
  54402. /**
  54403. * Sets the value of the `Circle` button
  54404. */
  54405. set buttonCircle(value: number);
  54406. /**
  54407. * Gets the value of the `Square` button
  54408. */
  54409. get buttonSquare(): number;
  54410. /**
  54411. * Sets the value of the `Square` button
  54412. */
  54413. set buttonSquare(value: number);
  54414. /**
  54415. * Gets the value of the `Triangle` button
  54416. */
  54417. get buttonTriangle(): number;
  54418. /**
  54419. * Sets the value of the `Triangle` button
  54420. */
  54421. set buttonTriangle(value: number);
  54422. /**
  54423. * Gets the value of the `Options` button
  54424. */
  54425. get buttonOptions(): number;
  54426. /**
  54427. * Sets the value of the `Options` button
  54428. */
  54429. set buttonOptions(value: number);
  54430. /**
  54431. * Gets the value of the `Share` button
  54432. */
  54433. get buttonShare(): number;
  54434. /**
  54435. * Sets the value of the `Share` button
  54436. */
  54437. set buttonShare(value: number);
  54438. /**
  54439. * Gets the value of the `L1` button
  54440. */
  54441. get buttonL1(): number;
  54442. /**
  54443. * Sets the value of the `L1` button
  54444. */
  54445. set buttonL1(value: number);
  54446. /**
  54447. * Gets the value of the `R1` button
  54448. */
  54449. get buttonR1(): number;
  54450. /**
  54451. * Sets the value of the `R1` button
  54452. */
  54453. set buttonR1(value: number);
  54454. /**
  54455. * Gets the value of the Left joystick
  54456. */
  54457. get buttonLeftStick(): number;
  54458. /**
  54459. * Sets the value of the Left joystick
  54460. */
  54461. set buttonLeftStick(value: number);
  54462. /**
  54463. * Gets the value of the Right joystick
  54464. */
  54465. get buttonRightStick(): number;
  54466. /**
  54467. * Sets the value of the Right joystick
  54468. */
  54469. set buttonRightStick(value: number);
  54470. /**
  54471. * Gets the value of D-pad up
  54472. */
  54473. get dPadUp(): number;
  54474. /**
  54475. * Sets the value of D-pad up
  54476. */
  54477. set dPadUp(value: number);
  54478. /**
  54479. * Gets the value of D-pad down
  54480. */
  54481. get dPadDown(): number;
  54482. /**
  54483. * Sets the value of D-pad down
  54484. */
  54485. set dPadDown(value: number);
  54486. /**
  54487. * Gets the value of D-pad left
  54488. */
  54489. get dPadLeft(): number;
  54490. /**
  54491. * Sets the value of D-pad left
  54492. */
  54493. set dPadLeft(value: number);
  54494. /**
  54495. * Gets the value of D-pad right
  54496. */
  54497. get dPadRight(): number;
  54498. /**
  54499. * Sets the value of D-pad right
  54500. */
  54501. set dPadRight(value: number);
  54502. /**
  54503. * Force the gamepad to synchronize with device values
  54504. */
  54505. update(): void;
  54506. /**
  54507. * Disposes the gamepad
  54508. */
  54509. dispose(): void;
  54510. }
  54511. }
  54512. declare module "babylonjs/Gamepads/gamepadManager" {
  54513. import { Observable } from "babylonjs/Misc/observable";
  54514. import { Nullable } from "babylonjs/types";
  54515. import { Scene } from "babylonjs/scene";
  54516. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54517. /**
  54518. * Manager for handling gamepads
  54519. */
  54520. export class GamepadManager {
  54521. private _scene?;
  54522. private _babylonGamepads;
  54523. private _oneGamepadConnected;
  54524. /** @hidden */
  54525. _isMonitoring: boolean;
  54526. private _gamepadEventSupported;
  54527. private _gamepadSupport?;
  54528. /**
  54529. * observable to be triggered when the gamepad controller has been connected
  54530. */
  54531. onGamepadConnectedObservable: Observable<Gamepad>;
  54532. /**
  54533. * observable to be triggered when the gamepad controller has been disconnected
  54534. */
  54535. onGamepadDisconnectedObservable: Observable<Gamepad>;
  54536. private _onGamepadConnectedEvent;
  54537. private _onGamepadDisconnectedEvent;
  54538. /**
  54539. * Initializes the gamepad manager
  54540. * @param _scene BabylonJS scene
  54541. */
  54542. constructor(_scene?: Scene | undefined);
  54543. /**
  54544. * The gamepads in the game pad manager
  54545. */
  54546. get gamepads(): Gamepad[];
  54547. /**
  54548. * Get the gamepad controllers based on type
  54549. * @param type The type of gamepad controller
  54550. * @returns Nullable gamepad
  54551. */
  54552. getGamepadByType(type?: number): Nullable<Gamepad>;
  54553. /**
  54554. * Disposes the gamepad manager
  54555. */
  54556. dispose(): void;
  54557. private _addNewGamepad;
  54558. private _startMonitoringGamepads;
  54559. private _stopMonitoringGamepads;
  54560. /** @hidden */
  54561. _checkGamepadsStatus(): void;
  54562. private _updateGamepadObjects;
  54563. }
  54564. }
  54565. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  54566. import { Nullable } from "babylonjs/types";
  54567. import { Scene } from "babylonjs/scene";
  54568. import { ISceneComponent } from "babylonjs/sceneComponent";
  54569. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  54570. module "babylonjs/scene" {
  54571. interface Scene {
  54572. /** @hidden */
  54573. _gamepadManager: Nullable<GamepadManager>;
  54574. /**
  54575. * Gets the gamepad manager associated with the scene
  54576. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  54577. */
  54578. gamepadManager: GamepadManager;
  54579. }
  54580. }
  54581. module "babylonjs/Cameras/freeCameraInputsManager" {
  54582. /**
  54583. * Interface representing a free camera inputs manager
  54584. */
  54585. interface FreeCameraInputsManager {
  54586. /**
  54587. * Adds gamepad input support to the FreeCameraInputsManager.
  54588. * @returns the FreeCameraInputsManager
  54589. */
  54590. addGamepad(): FreeCameraInputsManager;
  54591. }
  54592. }
  54593. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  54594. /**
  54595. * Interface representing an arc rotate camera inputs manager
  54596. */
  54597. interface ArcRotateCameraInputsManager {
  54598. /**
  54599. * Adds gamepad input support to the ArcRotateCamera InputManager.
  54600. * @returns the camera inputs manager
  54601. */
  54602. addGamepad(): ArcRotateCameraInputsManager;
  54603. }
  54604. }
  54605. /**
  54606. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  54607. */
  54608. export class GamepadSystemSceneComponent implements ISceneComponent {
  54609. /**
  54610. * The component name helpfull to identify the component in the list of scene components.
  54611. */
  54612. readonly name: string;
  54613. /**
  54614. * The scene the component belongs to.
  54615. */
  54616. scene: Scene;
  54617. /**
  54618. * Creates a new instance of the component for the given scene
  54619. * @param scene Defines the scene to register the component in
  54620. */
  54621. constructor(scene: Scene);
  54622. /**
  54623. * Registers the component in a given scene
  54624. */
  54625. register(): void;
  54626. /**
  54627. * Rebuilds the elements related to this component in case of
  54628. * context lost for instance.
  54629. */
  54630. rebuild(): void;
  54631. /**
  54632. * Disposes the component and the associated ressources
  54633. */
  54634. dispose(): void;
  54635. private _beforeCameraUpdate;
  54636. }
  54637. }
  54638. declare module "babylonjs/Cameras/universalCamera" {
  54639. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  54640. import { Scene } from "babylonjs/scene";
  54641. import { Vector3 } from "babylonjs/Maths/math.vector";
  54642. import "babylonjs/Gamepads/gamepadSceneComponent";
  54643. /**
  54644. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  54645. * which still works and will still be found in many Playgrounds.
  54646. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54647. */
  54648. export class UniversalCamera extends TouchCamera {
  54649. /**
  54650. * Defines the gamepad rotation sensiblity.
  54651. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  54652. */
  54653. get gamepadAngularSensibility(): number;
  54654. set gamepadAngularSensibility(value: number);
  54655. /**
  54656. * Defines the gamepad move sensiblity.
  54657. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  54658. */
  54659. get gamepadMoveSensibility(): number;
  54660. set gamepadMoveSensibility(value: number);
  54661. /**
  54662. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  54663. * which still works and will still be found in many Playgrounds.
  54664. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54665. * @param name Define the name of the camera in the scene
  54666. * @param position Define the start position of the camera in the scene
  54667. * @param scene Define the scene the camera belongs to
  54668. */
  54669. constructor(name: string, position: Vector3, scene: Scene);
  54670. /**
  54671. * Gets the current object class name.
  54672. * @return the class name
  54673. */
  54674. getClassName(): string;
  54675. }
  54676. }
  54677. declare module "babylonjs/Cameras/gamepadCamera" {
  54678. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54679. import { Scene } from "babylonjs/scene";
  54680. import { Vector3 } from "babylonjs/Maths/math.vector";
  54681. /**
  54682. * This represents a FPS type of camera. This is only here for back compat purpose.
  54683. * Please use the UniversalCamera instead as both are identical.
  54684. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54685. */
  54686. export class GamepadCamera extends UniversalCamera {
  54687. /**
  54688. * Instantiates a new Gamepad Camera
  54689. * This represents a FPS type of camera. This is only here for back compat purpose.
  54690. * Please use the UniversalCamera instead as both are identical.
  54691. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54692. * @param name Define the name of the camera in the scene
  54693. * @param position Define the start position of the camera in the scene
  54694. * @param scene Define the scene the camera belongs to
  54695. */
  54696. constructor(name: string, position: Vector3, scene: Scene);
  54697. /**
  54698. * Gets the current object class name.
  54699. * @return the class name
  54700. */
  54701. getClassName(): string;
  54702. }
  54703. }
  54704. declare module "babylonjs/Shaders/anaglyph.fragment" {
  54705. /** @hidden */
  54706. export var anaglyphPixelShader: {
  54707. name: string;
  54708. shader: string;
  54709. };
  54710. }
  54711. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  54712. import { Engine } from "babylonjs/Engines/engine";
  54713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54714. import { Camera } from "babylonjs/Cameras/camera";
  54715. import "babylonjs/Shaders/anaglyph.fragment";
  54716. /**
  54717. * Postprocess used to generate anaglyphic rendering
  54718. */
  54719. export class AnaglyphPostProcess extends PostProcess {
  54720. private _passedProcess;
  54721. /**
  54722. * Gets a string identifying the name of the class
  54723. * @returns "AnaglyphPostProcess" string
  54724. */
  54725. getClassName(): string;
  54726. /**
  54727. * Creates a new AnaglyphPostProcess
  54728. * @param name defines postprocess name
  54729. * @param options defines creation options or target ratio scale
  54730. * @param rigCameras defines cameras using this postprocess
  54731. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  54732. * @param engine defines hosting engine
  54733. * @param reusable defines if the postprocess will be reused multiple times per frame
  54734. */
  54735. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  54736. }
  54737. }
  54738. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  54739. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  54740. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54741. import { Scene } from "babylonjs/scene";
  54742. import { Vector3 } from "babylonjs/Maths/math.vector";
  54743. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54744. /**
  54745. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  54746. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54747. */
  54748. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  54749. /**
  54750. * Creates a new AnaglyphArcRotateCamera
  54751. * @param name defines camera name
  54752. * @param alpha defines alpha angle (in radians)
  54753. * @param beta defines beta angle (in radians)
  54754. * @param radius defines radius
  54755. * @param target defines camera target
  54756. * @param interaxialDistance defines distance between each color axis
  54757. * @param scene defines the hosting scene
  54758. */
  54759. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  54760. /**
  54761. * Gets camera class name
  54762. * @returns AnaglyphArcRotateCamera
  54763. */
  54764. getClassName(): string;
  54765. }
  54766. }
  54767. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  54768. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54769. import { Scene } from "babylonjs/scene";
  54770. import { Vector3 } from "babylonjs/Maths/math.vector";
  54771. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54772. /**
  54773. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  54774. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54775. */
  54776. export class AnaglyphFreeCamera extends FreeCamera {
  54777. /**
  54778. * Creates a new AnaglyphFreeCamera
  54779. * @param name defines camera name
  54780. * @param position defines initial position
  54781. * @param interaxialDistance defines distance between each color axis
  54782. * @param scene defines the hosting scene
  54783. */
  54784. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54785. /**
  54786. * Gets camera class name
  54787. * @returns AnaglyphFreeCamera
  54788. */
  54789. getClassName(): string;
  54790. }
  54791. }
  54792. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  54793. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54794. import { Scene } from "babylonjs/scene";
  54795. import { Vector3 } from "babylonjs/Maths/math.vector";
  54796. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54797. /**
  54798. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  54799. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54800. */
  54801. export class AnaglyphGamepadCamera extends GamepadCamera {
  54802. /**
  54803. * Creates a new AnaglyphGamepadCamera
  54804. * @param name defines camera name
  54805. * @param position defines initial position
  54806. * @param interaxialDistance defines distance between each color axis
  54807. * @param scene defines the hosting scene
  54808. */
  54809. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54810. /**
  54811. * Gets camera class name
  54812. * @returns AnaglyphGamepadCamera
  54813. */
  54814. getClassName(): string;
  54815. }
  54816. }
  54817. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  54818. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54819. import { Scene } from "babylonjs/scene";
  54820. import { Vector3 } from "babylonjs/Maths/math.vector";
  54821. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54822. /**
  54823. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  54824. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54825. */
  54826. export class AnaglyphUniversalCamera extends UniversalCamera {
  54827. /**
  54828. * Creates a new AnaglyphUniversalCamera
  54829. * @param name defines camera name
  54830. * @param position defines initial position
  54831. * @param interaxialDistance defines distance between each color axis
  54832. * @param scene defines the hosting scene
  54833. */
  54834. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54835. /**
  54836. * Gets camera class name
  54837. * @returns AnaglyphUniversalCamera
  54838. */
  54839. getClassName(): string;
  54840. }
  54841. }
  54842. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  54843. /** @hidden */
  54844. export var stereoscopicInterlacePixelShader: {
  54845. name: string;
  54846. shader: string;
  54847. };
  54848. }
  54849. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  54850. import { Camera } from "babylonjs/Cameras/camera";
  54851. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54852. import { Engine } from "babylonjs/Engines/engine";
  54853. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  54854. /**
  54855. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  54856. */
  54857. export class StereoscopicInterlacePostProcessI extends PostProcess {
  54858. private _stepSize;
  54859. private _passedProcess;
  54860. /**
  54861. * Gets a string identifying the name of the class
  54862. * @returns "StereoscopicInterlacePostProcessI" string
  54863. */
  54864. getClassName(): string;
  54865. /**
  54866. * Initializes a StereoscopicInterlacePostProcessI
  54867. * @param name The name of the effect.
  54868. * @param rigCameras The rig cameras to be appled to the post process
  54869. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  54870. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  54871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54872. * @param engine The engine which the post process will be applied. (default: current engine)
  54873. * @param reusable If the post process can be reused on the same frame. (default: false)
  54874. */
  54875. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54876. }
  54877. /**
  54878. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  54879. */
  54880. export class StereoscopicInterlacePostProcess extends PostProcess {
  54881. private _stepSize;
  54882. private _passedProcess;
  54883. /**
  54884. * Gets a string identifying the name of the class
  54885. * @returns "StereoscopicInterlacePostProcess" string
  54886. */
  54887. getClassName(): string;
  54888. /**
  54889. * Initializes a StereoscopicInterlacePostProcess
  54890. * @param name The name of the effect.
  54891. * @param rigCameras The rig cameras to be appled to the post process
  54892. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  54893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54894. * @param engine The engine which the post process will be applied. (default: current engine)
  54895. * @param reusable If the post process can be reused on the same frame. (default: false)
  54896. */
  54897. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54898. }
  54899. }
  54900. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  54901. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  54902. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54903. import { Scene } from "babylonjs/scene";
  54904. import { Vector3 } from "babylonjs/Maths/math.vector";
  54905. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54906. /**
  54907. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  54908. * @see https://doc.babylonjs.com/features/cameras
  54909. */
  54910. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  54911. /**
  54912. * Creates a new StereoscopicArcRotateCamera
  54913. * @param name defines camera name
  54914. * @param alpha defines alpha angle (in radians)
  54915. * @param beta defines beta angle (in radians)
  54916. * @param radius defines radius
  54917. * @param target defines camera target
  54918. * @param interaxialDistance defines distance between each color axis
  54919. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54920. * @param scene defines the hosting scene
  54921. */
  54922. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54923. /**
  54924. * Gets camera class name
  54925. * @returns StereoscopicArcRotateCamera
  54926. */
  54927. getClassName(): string;
  54928. }
  54929. }
  54930. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  54931. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54932. import { Scene } from "babylonjs/scene";
  54933. import { Vector3 } from "babylonjs/Maths/math.vector";
  54934. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54935. /**
  54936. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  54937. * @see https://doc.babylonjs.com/features/cameras
  54938. */
  54939. export class StereoscopicFreeCamera extends FreeCamera {
  54940. /**
  54941. * Creates a new StereoscopicFreeCamera
  54942. * @param name defines camera name
  54943. * @param position defines initial position
  54944. * @param interaxialDistance defines distance between each color axis
  54945. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54946. * @param scene defines the hosting scene
  54947. */
  54948. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54949. /**
  54950. * Gets camera class name
  54951. * @returns StereoscopicFreeCamera
  54952. */
  54953. getClassName(): string;
  54954. }
  54955. }
  54956. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  54957. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54958. import { Scene } from "babylonjs/scene";
  54959. import { Vector3 } from "babylonjs/Maths/math.vector";
  54960. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54961. /**
  54962. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  54963. * @see https://doc.babylonjs.com/features/cameras
  54964. */
  54965. export class StereoscopicGamepadCamera extends GamepadCamera {
  54966. /**
  54967. * Creates a new StereoscopicGamepadCamera
  54968. * @param name defines camera name
  54969. * @param position defines initial position
  54970. * @param interaxialDistance defines distance between each color axis
  54971. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54972. * @param scene defines the hosting scene
  54973. */
  54974. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54975. /**
  54976. * Gets camera class name
  54977. * @returns StereoscopicGamepadCamera
  54978. */
  54979. getClassName(): string;
  54980. }
  54981. }
  54982. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  54983. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54984. import { Scene } from "babylonjs/scene";
  54985. import { Vector3 } from "babylonjs/Maths/math.vector";
  54986. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54987. /**
  54988. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  54989. * @see https://doc.babylonjs.com/features/cameras
  54990. */
  54991. export class StereoscopicUniversalCamera extends UniversalCamera {
  54992. /**
  54993. * Creates a new StereoscopicUniversalCamera
  54994. * @param name defines camera name
  54995. * @param position defines initial position
  54996. * @param interaxialDistance defines distance between each color axis
  54997. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54998. * @param scene defines the hosting scene
  54999. */
  55000. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  55001. /**
  55002. * Gets camera class name
  55003. * @returns StereoscopicUniversalCamera
  55004. */
  55005. getClassName(): string;
  55006. }
  55007. }
  55008. declare module "babylonjs/Cameras/Stereoscopic/index" {
  55009. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  55010. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  55011. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  55012. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  55013. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  55014. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  55015. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  55016. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  55017. }
  55018. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  55019. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55020. import { Scene } from "babylonjs/scene";
  55021. import { Vector3 } from "babylonjs/Maths/math.vector";
  55022. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  55023. /**
  55024. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  55025. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  55026. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  55027. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  55028. */
  55029. export class VirtualJoysticksCamera extends FreeCamera {
  55030. /**
  55031. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  55032. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  55033. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  55034. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  55035. * @param name Define the name of the camera in the scene
  55036. * @param position Define the start position of the camera in the scene
  55037. * @param scene Define the scene the camera belongs to
  55038. */
  55039. constructor(name: string, position: Vector3, scene: Scene);
  55040. /**
  55041. * Gets the current object class name.
  55042. * @return the class name
  55043. */
  55044. getClassName(): string;
  55045. }
  55046. }
  55047. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  55048. import { Matrix } from "babylonjs/Maths/math.vector";
  55049. /**
  55050. * This represents all the required metrics to create a VR camera.
  55051. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  55052. */
  55053. export class VRCameraMetrics {
  55054. /**
  55055. * Define the horizontal resolution off the screen.
  55056. */
  55057. hResolution: number;
  55058. /**
  55059. * Define the vertical resolution off the screen.
  55060. */
  55061. vResolution: number;
  55062. /**
  55063. * Define the horizontal screen size.
  55064. */
  55065. hScreenSize: number;
  55066. /**
  55067. * Define the vertical screen size.
  55068. */
  55069. vScreenSize: number;
  55070. /**
  55071. * Define the vertical screen center position.
  55072. */
  55073. vScreenCenter: number;
  55074. /**
  55075. * Define the distance of the eyes to the screen.
  55076. */
  55077. eyeToScreenDistance: number;
  55078. /**
  55079. * Define the distance between both lenses
  55080. */
  55081. lensSeparationDistance: number;
  55082. /**
  55083. * Define the distance between both viewer's eyes.
  55084. */
  55085. interpupillaryDistance: number;
  55086. /**
  55087. * Define the distortion factor of the VR postprocess.
  55088. * Please, touch with care.
  55089. */
  55090. distortionK: number[];
  55091. /**
  55092. * Define the chromatic aberration correction factors for the VR post process.
  55093. */
  55094. chromaAbCorrection: number[];
  55095. /**
  55096. * Define the scale factor of the post process.
  55097. * The smaller the better but the slower.
  55098. */
  55099. postProcessScaleFactor: number;
  55100. /**
  55101. * Define an offset for the lens center.
  55102. */
  55103. lensCenterOffset: number;
  55104. /**
  55105. * Define if the current vr camera should compensate the distortion of the lense or not.
  55106. */
  55107. compensateDistortion: boolean;
  55108. /**
  55109. * Defines if multiview should be enabled when rendering (Default: false)
  55110. */
  55111. multiviewEnabled: boolean;
  55112. /**
  55113. * Gets the rendering aspect ratio based on the provided resolutions.
  55114. */
  55115. get aspectRatio(): number;
  55116. /**
  55117. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  55118. */
  55119. get aspectRatioFov(): number;
  55120. /**
  55121. * @hidden
  55122. */
  55123. get leftHMatrix(): Matrix;
  55124. /**
  55125. * @hidden
  55126. */
  55127. get rightHMatrix(): Matrix;
  55128. /**
  55129. * @hidden
  55130. */
  55131. get leftPreViewMatrix(): Matrix;
  55132. /**
  55133. * @hidden
  55134. */
  55135. get rightPreViewMatrix(): Matrix;
  55136. /**
  55137. * Get the default VRMetrics based on the most generic setup.
  55138. * @returns the default vr metrics
  55139. */
  55140. static GetDefault(): VRCameraMetrics;
  55141. }
  55142. }
  55143. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  55144. /** @hidden */
  55145. export var vrDistortionCorrectionPixelShader: {
  55146. name: string;
  55147. shader: string;
  55148. };
  55149. }
  55150. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  55151. import { Camera } from "babylonjs/Cameras/camera";
  55152. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55153. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55154. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  55155. /**
  55156. * VRDistortionCorrectionPostProcess used for mobile VR
  55157. */
  55158. export class VRDistortionCorrectionPostProcess extends PostProcess {
  55159. private _isRightEye;
  55160. private _distortionFactors;
  55161. private _postProcessScaleFactor;
  55162. private _lensCenterOffset;
  55163. private _scaleIn;
  55164. private _scaleFactor;
  55165. private _lensCenter;
  55166. /**
  55167. * Gets a string identifying the name of the class
  55168. * @returns "VRDistortionCorrectionPostProcess" string
  55169. */
  55170. getClassName(): string;
  55171. /**
  55172. * Initializes the VRDistortionCorrectionPostProcess
  55173. * @param name The name of the effect.
  55174. * @param camera The camera to apply the render pass to.
  55175. * @param isRightEye If this is for the right eye distortion
  55176. * @param vrMetrics All the required metrics for the VR camera
  55177. */
  55178. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  55179. }
  55180. }
  55181. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  55182. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  55183. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  55184. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55185. import { Scene } from "babylonjs/scene";
  55186. import { Vector3 } from "babylonjs/Maths/math.vector";
  55187. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  55188. import "babylonjs/Cameras/RigModes/vrRigMode";
  55189. /**
  55190. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  55191. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55192. */
  55193. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  55194. /**
  55195. * Creates a new VRDeviceOrientationArcRotateCamera
  55196. * @param name defines camera name
  55197. * @param alpha defines the camera rotation along the logitudinal axis
  55198. * @param beta defines the camera rotation along the latitudinal axis
  55199. * @param radius defines the camera distance from its target
  55200. * @param target defines the camera target
  55201. * @param scene defines the scene the camera belongs to
  55202. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  55203. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55204. */
  55205. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55206. /**
  55207. * Gets camera class name
  55208. * @returns VRDeviceOrientationArcRotateCamera
  55209. */
  55210. getClassName(): string;
  55211. }
  55212. }
  55213. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  55214. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55215. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55216. import { Scene } from "babylonjs/scene";
  55217. import { Vector3 } from "babylonjs/Maths/math.vector";
  55218. import "babylonjs/Cameras/RigModes/vrRigMode";
  55219. /**
  55220. * Camera used to simulate VR rendering (based on FreeCamera)
  55221. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55222. */
  55223. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  55224. /**
  55225. * Creates a new VRDeviceOrientationFreeCamera
  55226. * @param name defines camera name
  55227. * @param position defines the start position of the camera
  55228. * @param scene defines the scene the camera belongs to
  55229. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  55230. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55231. */
  55232. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55233. /**
  55234. * Gets camera class name
  55235. * @returns VRDeviceOrientationFreeCamera
  55236. */
  55237. getClassName(): string;
  55238. }
  55239. }
  55240. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  55241. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55242. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55243. import { Scene } from "babylonjs/scene";
  55244. import { Vector3 } from "babylonjs/Maths/math.vector";
  55245. import "babylonjs/Gamepads/gamepadSceneComponent";
  55246. /**
  55247. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  55248. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55249. */
  55250. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  55251. /**
  55252. * Creates a new VRDeviceOrientationGamepadCamera
  55253. * @param name defines camera name
  55254. * @param position defines the start position of the camera
  55255. * @param scene defines the scene the camera belongs to
  55256. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  55257. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55258. */
  55259. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55260. /**
  55261. * Gets camera class name
  55262. * @returns VRDeviceOrientationGamepadCamera
  55263. */
  55264. getClassName(): string;
  55265. }
  55266. }
  55267. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  55268. import { Scene } from "babylonjs/scene";
  55269. import { Texture } from "babylonjs/Materials/Textures/texture";
  55270. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55271. /**
  55272. * A class extending Texture allowing drawing on a texture
  55273. * @see https://doc.babylonjs.com/how_to/dynamictexture
  55274. */
  55275. export class DynamicTexture extends Texture {
  55276. private _generateMipMaps;
  55277. private _canvas;
  55278. private _context;
  55279. /**
  55280. * Creates a DynamicTexture
  55281. * @param name defines the name of the texture
  55282. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  55283. * @param scene defines the scene where you want the texture
  55284. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55285. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55286. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55287. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  55288. */
  55289. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  55290. /**
  55291. * Get the current class name of the texture useful for serialization or dynamic coding.
  55292. * @returns "DynamicTexture"
  55293. */
  55294. getClassName(): string;
  55295. /**
  55296. * Gets the current state of canRescale
  55297. */
  55298. get canRescale(): boolean;
  55299. private _recreate;
  55300. /**
  55301. * Scales the texture
  55302. * @param ratio the scale factor to apply to both width and height
  55303. */
  55304. scale(ratio: number): void;
  55305. /**
  55306. * Resizes the texture
  55307. * @param width the new width
  55308. * @param height the new height
  55309. */
  55310. scaleTo(width: number, height: number): void;
  55311. /**
  55312. * Gets the context of the canvas used by the texture
  55313. * @returns the canvas context of the dynamic texture
  55314. */
  55315. getContext(): CanvasRenderingContext2D;
  55316. /**
  55317. * Clears the texture
  55318. */
  55319. clear(): void;
  55320. /**
  55321. * Updates the texture
  55322. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55323. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55324. */
  55325. update(invertY?: boolean, premulAlpha?: boolean): void;
  55326. /**
  55327. * Draws text onto the texture
  55328. * @param text defines the text to be drawn
  55329. * @param x defines the placement of the text from the left
  55330. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55331. * @param font defines the font to be used with font-style, font-size, font-name
  55332. * @param color defines the color used for the text
  55333. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55334. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55335. * @param update defines whether texture is immediately update (default is true)
  55336. */
  55337. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  55338. /**
  55339. * Clones the texture
  55340. * @returns the clone of the texture.
  55341. */
  55342. clone(): DynamicTexture;
  55343. /**
  55344. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55345. * @returns a serialized dynamic texture object
  55346. */
  55347. serialize(): any;
  55348. private _IsCanvasElement;
  55349. /** @hidden */
  55350. _rebuild(): void;
  55351. }
  55352. }
  55353. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  55354. import { Scene } from "babylonjs/scene";
  55355. import { Color3 } from "babylonjs/Maths/math.color";
  55356. import { Mesh } from "babylonjs/Meshes/mesh";
  55357. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55358. import { Nullable } from "babylonjs/types";
  55359. /**
  55360. * Class containing static functions to help procedurally build meshes
  55361. */
  55362. export class GroundBuilder {
  55363. /**
  55364. * Creates a ground mesh
  55365. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55366. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55368. * @param name defines the name of the mesh
  55369. * @param options defines the options used to create the mesh
  55370. * @param scene defines the hosting scene
  55371. * @returns the ground mesh
  55372. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55373. */
  55374. static CreateGround(name: string, options: {
  55375. width?: number;
  55376. height?: number;
  55377. subdivisions?: number;
  55378. subdivisionsX?: number;
  55379. subdivisionsY?: number;
  55380. updatable?: boolean;
  55381. }, scene: any): Mesh;
  55382. /**
  55383. * Creates a tiled ground mesh
  55384. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55385. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55386. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  55387. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  55388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55389. * @param name defines the name of the mesh
  55390. * @param options defines the options used to create the mesh
  55391. * @param scene defines the hosting scene
  55392. * @returns the tiled ground mesh
  55393. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55394. */
  55395. static CreateTiledGround(name: string, options: {
  55396. xmin: number;
  55397. zmin: number;
  55398. xmax: number;
  55399. zmax: number;
  55400. subdivisions?: {
  55401. w: number;
  55402. h: number;
  55403. };
  55404. precision?: {
  55405. w: number;
  55406. h: number;
  55407. };
  55408. updatable?: boolean;
  55409. }, scene?: Nullable<Scene>): Mesh;
  55410. /**
  55411. * Creates a ground mesh from a height map
  55412. * * The parameter `url` sets the URL of the height map image resource.
  55413. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55414. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55415. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55416. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55417. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  55418. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  55419. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55421. * @param name defines the name of the mesh
  55422. * @param url defines the url to the height map
  55423. * @param options defines the options used to create the mesh
  55424. * @param scene defines the hosting scene
  55425. * @returns the ground mesh
  55426. * @see https://doc.babylonjs.com/babylon101/height_map
  55427. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55428. */
  55429. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55430. width?: number;
  55431. height?: number;
  55432. subdivisions?: number;
  55433. minHeight?: number;
  55434. maxHeight?: number;
  55435. colorFilter?: Color3;
  55436. alphaFilter?: number;
  55437. updatable?: boolean;
  55438. onReady?: (mesh: GroundMesh) => void;
  55439. }, scene?: Nullable<Scene>): GroundMesh;
  55440. }
  55441. }
  55442. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  55443. import { Vector4 } from "babylonjs/Maths/math.vector";
  55444. import { Mesh } from "babylonjs/Meshes/mesh";
  55445. /**
  55446. * Class containing static functions to help procedurally build meshes
  55447. */
  55448. export class TorusBuilder {
  55449. /**
  55450. * Creates a torus mesh
  55451. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55452. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55453. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55457. * @param name defines the name of the mesh
  55458. * @param options defines the options used to create the mesh
  55459. * @param scene defines the hosting scene
  55460. * @returns the torus mesh
  55461. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55462. */
  55463. static CreateTorus(name: string, options: {
  55464. diameter?: number;
  55465. thickness?: number;
  55466. tessellation?: number;
  55467. updatable?: boolean;
  55468. sideOrientation?: number;
  55469. frontUVs?: Vector4;
  55470. backUVs?: Vector4;
  55471. }, scene: any): Mesh;
  55472. }
  55473. }
  55474. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  55475. import { Vector4 } from "babylonjs/Maths/math.vector";
  55476. import { Color4 } from "babylonjs/Maths/math.color";
  55477. import { Mesh } from "babylonjs/Meshes/mesh";
  55478. /**
  55479. * Class containing static functions to help procedurally build meshes
  55480. */
  55481. export class CylinderBuilder {
  55482. /**
  55483. * Creates a cylinder or a cone mesh
  55484. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55485. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55486. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  55487. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55488. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55489. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55490. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55491. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55492. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55493. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  55494. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  55495. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55496. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  55497. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  55498. * * If `enclose` is false, a ring surface is one element.
  55499. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55500. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  55501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55504. * @param name defines the name of the mesh
  55505. * @param options defines the options used to create the mesh
  55506. * @param scene defines the hosting scene
  55507. * @returns the cylinder mesh
  55508. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55509. */
  55510. static CreateCylinder(name: string, options: {
  55511. height?: number;
  55512. diameterTop?: number;
  55513. diameterBottom?: number;
  55514. diameter?: number;
  55515. tessellation?: number;
  55516. subdivisions?: number;
  55517. arc?: number;
  55518. faceColors?: Color4[];
  55519. faceUV?: Vector4[];
  55520. updatable?: boolean;
  55521. hasRings?: boolean;
  55522. enclose?: boolean;
  55523. cap?: number;
  55524. sideOrientation?: number;
  55525. frontUVs?: Vector4;
  55526. backUVs?: Vector4;
  55527. }, scene: any): Mesh;
  55528. }
  55529. }
  55530. declare module "babylonjs/XR/webXRTypes" {
  55531. import { Nullable } from "babylonjs/types";
  55532. import { IDisposable } from "babylonjs/scene";
  55533. /**
  55534. * States of the webXR experience
  55535. */
  55536. export enum WebXRState {
  55537. /**
  55538. * Transitioning to being in XR mode
  55539. */
  55540. ENTERING_XR = 0,
  55541. /**
  55542. * Transitioning to non XR mode
  55543. */
  55544. EXITING_XR = 1,
  55545. /**
  55546. * In XR mode and presenting
  55547. */
  55548. IN_XR = 2,
  55549. /**
  55550. * Not entered XR mode
  55551. */
  55552. NOT_IN_XR = 3
  55553. }
  55554. /**
  55555. * The state of the XR camera's tracking
  55556. */
  55557. export enum WebXRTrackingState {
  55558. /**
  55559. * No transformation received, device is not being tracked
  55560. */
  55561. NOT_TRACKING = 0,
  55562. /**
  55563. * Tracking lost - using emulated position
  55564. */
  55565. TRACKING_LOST = 1,
  55566. /**
  55567. * Transformation tracking works normally
  55568. */
  55569. TRACKING = 2
  55570. }
  55571. /**
  55572. * Abstraction of the XR render target
  55573. */
  55574. export interface WebXRRenderTarget extends IDisposable {
  55575. /**
  55576. * xrpresent context of the canvas which can be used to display/mirror xr content
  55577. */
  55578. canvasContext: WebGLRenderingContext;
  55579. /**
  55580. * xr layer for the canvas
  55581. */
  55582. xrLayer: Nullable<XRWebGLLayer>;
  55583. /**
  55584. * Initializes the xr layer for the session
  55585. * @param xrSession xr session
  55586. * @returns a promise that will resolve once the XR Layer has been created
  55587. */
  55588. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55589. }
  55590. }
  55591. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  55592. import { Nullable } from "babylonjs/types";
  55593. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55594. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55595. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55596. import { Observable } from "babylonjs/Misc/observable";
  55597. /**
  55598. * COnfiguration object for WebXR output canvas
  55599. */
  55600. export class WebXRManagedOutputCanvasOptions {
  55601. /**
  55602. * An optional canvas in case you wish to create it yourself and provide it here.
  55603. * If not provided, a new canvas will be created
  55604. */
  55605. canvasElement?: HTMLCanvasElement;
  55606. /**
  55607. * Options for this XR Layer output
  55608. */
  55609. canvasOptions?: XRWebGLLayerInit;
  55610. /**
  55611. * CSS styling for a newly created canvas (if not provided)
  55612. */
  55613. newCanvasCssStyle?: string;
  55614. /**
  55615. * Get the default values of the configuration object
  55616. * @param engine defines the engine to use (can be null)
  55617. * @returns default values of this configuration object
  55618. */
  55619. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  55620. }
  55621. /**
  55622. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  55623. */
  55624. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  55625. private _options;
  55626. private _canvas;
  55627. private _engine;
  55628. private _originalCanvasSize;
  55629. /**
  55630. * Rendering context of the canvas which can be used to display/mirror xr content
  55631. */
  55632. canvasContext: WebGLRenderingContext;
  55633. /**
  55634. * xr layer for the canvas
  55635. */
  55636. xrLayer: Nullable<XRWebGLLayer>;
  55637. /**
  55638. * Obseervers registered here will be triggered when the xr layer was initialized
  55639. */
  55640. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  55641. /**
  55642. * Initializes the canvas to be added/removed upon entering/exiting xr
  55643. * @param _xrSessionManager The XR Session manager
  55644. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  55645. */
  55646. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  55647. /**
  55648. * Disposes of the object
  55649. */
  55650. dispose(): void;
  55651. /**
  55652. * Initializes the xr layer for the session
  55653. * @param xrSession xr session
  55654. * @returns a promise that will resolve once the XR Layer has been created
  55655. */
  55656. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55657. private _addCanvas;
  55658. private _removeCanvas;
  55659. private _setCanvasSize;
  55660. private _setManagedOutputCanvas;
  55661. }
  55662. }
  55663. declare module "babylonjs/XR/webXRSessionManager" {
  55664. import { Observable } from "babylonjs/Misc/observable";
  55665. import { Nullable } from "babylonjs/types";
  55666. import { IDisposable, Scene } from "babylonjs/scene";
  55667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55668. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55669. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55670. /**
  55671. * Manages an XRSession to work with Babylon's engine
  55672. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  55673. */
  55674. export class WebXRSessionManager implements IDisposable {
  55675. /** The scene which the session should be created for */
  55676. scene: Scene;
  55677. private _referenceSpace;
  55678. private _rttProvider;
  55679. private _sessionEnded;
  55680. private _xrNavigator;
  55681. private baseLayer;
  55682. /**
  55683. * The base reference space from which the session started. good if you want to reset your
  55684. * reference space
  55685. */
  55686. baseReferenceSpace: XRReferenceSpace;
  55687. /**
  55688. * Current XR frame
  55689. */
  55690. currentFrame: Nullable<XRFrame>;
  55691. /** WebXR timestamp updated every frame */
  55692. currentTimestamp: number;
  55693. /**
  55694. * Used just in case of a failure to initialize an immersive session.
  55695. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  55696. */
  55697. defaultHeightCompensation: number;
  55698. /**
  55699. * Fires every time a new xrFrame arrives which can be used to update the camera
  55700. */
  55701. onXRFrameObservable: Observable<XRFrame>;
  55702. /**
  55703. * Fires when the reference space changed
  55704. */
  55705. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  55706. /**
  55707. * Fires when the xr session is ended either by the device or manually done
  55708. */
  55709. onXRSessionEnded: Observable<any>;
  55710. /**
  55711. * Fires when the xr session is ended either by the device or manually done
  55712. */
  55713. onXRSessionInit: Observable<XRSession>;
  55714. /**
  55715. * Underlying xr session
  55716. */
  55717. session: XRSession;
  55718. /**
  55719. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  55720. * or get the offset the player is currently at.
  55721. */
  55722. viewerReferenceSpace: XRReferenceSpace;
  55723. /**
  55724. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  55725. * @param scene The scene which the session should be created for
  55726. */
  55727. constructor(
  55728. /** The scene which the session should be created for */
  55729. scene: Scene);
  55730. /**
  55731. * The current reference space used in this session. This reference space can constantly change!
  55732. * It is mainly used to offset the camera's position.
  55733. */
  55734. get referenceSpace(): XRReferenceSpace;
  55735. /**
  55736. * Set a new reference space and triggers the observable
  55737. */
  55738. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  55739. /**
  55740. * Disposes of the session manager
  55741. */
  55742. dispose(): void;
  55743. /**
  55744. * Stops the xrSession and restores the render loop
  55745. * @returns Promise which resolves after it exits XR
  55746. */
  55747. exitXRAsync(): Promise<void>;
  55748. /**
  55749. * Gets the correct render target texture to be rendered this frame for this eye
  55750. * @param eye the eye for which to get the render target
  55751. * @returns the render target for the specified eye
  55752. */
  55753. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  55754. /**
  55755. * Creates a WebXRRenderTarget object for the XR session
  55756. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  55757. * @param options optional options to provide when creating a new render target
  55758. * @returns a WebXR render target to which the session can render
  55759. */
  55760. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  55761. /**
  55762. * Initializes the manager
  55763. * After initialization enterXR can be called to start an XR session
  55764. * @returns Promise which resolves after it is initialized
  55765. */
  55766. initializeAsync(): Promise<void>;
  55767. /**
  55768. * Initializes an xr session
  55769. * @param xrSessionMode mode to initialize
  55770. * @param xrSessionInit defines optional and required values to pass to the session builder
  55771. * @returns a promise which will resolve once the session has been initialized
  55772. */
  55773. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  55774. /**
  55775. * Checks if a session would be supported for the creation options specified
  55776. * @param sessionMode session mode to check if supported eg. immersive-vr
  55777. * @returns A Promise that resolves to true if supported and false if not
  55778. */
  55779. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55780. /**
  55781. * Resets the reference space to the one started the session
  55782. */
  55783. resetReferenceSpace(): void;
  55784. /**
  55785. * Starts rendering to the xr layer
  55786. */
  55787. runXRRenderLoop(): void;
  55788. /**
  55789. * Sets the reference space on the xr session
  55790. * @param referenceSpaceType space to set
  55791. * @returns a promise that will resolve once the reference space has been set
  55792. */
  55793. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  55794. /**
  55795. * Updates the render state of the session
  55796. * @param state state to set
  55797. * @returns a promise that resolves once the render state has been updated
  55798. */
  55799. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  55800. /**
  55801. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  55802. * @param sessionMode defines the session to test
  55803. * @returns a promise with boolean as final value
  55804. */
  55805. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55806. /**
  55807. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  55808. */
  55809. get isNative(): boolean;
  55810. private _createRenderTargetTexture;
  55811. }
  55812. }
  55813. declare module "babylonjs/XR/webXRCamera" {
  55814. import { Vector3 } from "babylonjs/Maths/math.vector";
  55815. import { Scene } from "babylonjs/scene";
  55816. import { Camera } from "babylonjs/Cameras/camera";
  55817. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55818. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55819. import { Observable } from "babylonjs/Misc/observable";
  55820. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  55821. /**
  55822. * WebXR Camera which holds the views for the xrSession
  55823. * @see https://doc.babylonjs.com/how_to/webxr_camera
  55824. */
  55825. export class WebXRCamera extends FreeCamera {
  55826. private _xrSessionManager;
  55827. private _firstFrame;
  55828. private _referenceQuaternion;
  55829. private _referencedPosition;
  55830. private _xrInvPositionCache;
  55831. private _xrInvQuaternionCache;
  55832. private _trackingState;
  55833. /**
  55834. * Observable raised before camera teleportation
  55835. */
  55836. onBeforeCameraTeleport: Observable<Vector3>;
  55837. /**
  55838. * Observable raised after camera teleportation
  55839. */
  55840. onAfterCameraTeleport: Observable<Vector3>;
  55841. /**
  55842. * Notifies when the camera's tracking state has changed.
  55843. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  55844. */
  55845. onTrackingStateChanged: Observable<WebXRTrackingState>;
  55846. /**
  55847. * Should position compensation execute on first frame.
  55848. * This is used when copying the position from a native (non XR) camera
  55849. */
  55850. compensateOnFirstFrame: boolean;
  55851. /**
  55852. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  55853. * @param name the name of the camera
  55854. * @param scene the scene to add the camera to
  55855. * @param _xrSessionManager a constructed xr session manager
  55856. */
  55857. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  55858. /**
  55859. * Get the current XR tracking state of the camera
  55860. */
  55861. get trackingState(): WebXRTrackingState;
  55862. private _setTrackingState;
  55863. /**
  55864. * Return the user's height, unrelated to the current ground.
  55865. * This will be the y position of this camera, when ground level is 0.
  55866. */
  55867. get realWorldHeight(): number;
  55868. /** @hidden */
  55869. _updateForDualEyeDebugging(): void;
  55870. /**
  55871. * Sets this camera's transformation based on a non-vr camera
  55872. * @param otherCamera the non-vr camera to copy the transformation from
  55873. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  55874. */
  55875. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  55876. /**
  55877. * Gets the current instance class name ("WebXRCamera").
  55878. * @returns the class name
  55879. */
  55880. getClassName(): string;
  55881. private _rotate180;
  55882. private _updateFromXRSession;
  55883. private _updateNumberOfRigCameras;
  55884. private _updateReferenceSpace;
  55885. private _updateReferenceSpaceOffset;
  55886. }
  55887. }
  55888. declare module "babylonjs/XR/webXRFeaturesManager" {
  55889. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55890. import { IDisposable } from "babylonjs/scene";
  55891. /**
  55892. * Defining the interface required for a (webxr) feature
  55893. */
  55894. export interface IWebXRFeature extends IDisposable {
  55895. /**
  55896. * Is this feature attached
  55897. */
  55898. attached: boolean;
  55899. /**
  55900. * Should auto-attach be disabled?
  55901. */
  55902. disableAutoAttach: boolean;
  55903. /**
  55904. * Attach the feature to the session
  55905. * Will usually be called by the features manager
  55906. *
  55907. * @param force should attachment be forced (even when already attached)
  55908. * @returns true if successful.
  55909. */
  55910. attach(force?: boolean): boolean;
  55911. /**
  55912. * Detach the feature from the session
  55913. * Will usually be called by the features manager
  55914. *
  55915. * @returns true if successful.
  55916. */
  55917. detach(): boolean;
  55918. /**
  55919. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55920. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55921. *
  55922. * @returns whether or not the feature is compatible in this environment
  55923. */
  55924. isCompatible(): boolean;
  55925. /**
  55926. * Was this feature disposed;
  55927. */
  55928. isDisposed: boolean;
  55929. /**
  55930. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  55931. */
  55932. xrNativeFeatureName?: string;
  55933. /**
  55934. * A list of (Babylon WebXR) features this feature depends on
  55935. */
  55936. dependsOn?: string[];
  55937. /**
  55938. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  55939. */
  55940. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  55941. }
  55942. /**
  55943. * A list of the currently available features without referencing them
  55944. */
  55945. export class WebXRFeatureName {
  55946. /**
  55947. * The name of the anchor system feature
  55948. */
  55949. static readonly ANCHOR_SYSTEM: string;
  55950. /**
  55951. * The name of the background remover feature
  55952. */
  55953. static readonly BACKGROUND_REMOVER: string;
  55954. /**
  55955. * The name of the hit test feature
  55956. */
  55957. static readonly HIT_TEST: string;
  55958. /**
  55959. * The name of the mesh detection feature
  55960. */
  55961. static readonly MESH_DETECTION: string;
  55962. /**
  55963. * physics impostors for xr controllers feature
  55964. */
  55965. static readonly PHYSICS_CONTROLLERS: string;
  55966. /**
  55967. * The name of the plane detection feature
  55968. */
  55969. static readonly PLANE_DETECTION: string;
  55970. /**
  55971. * The name of the pointer selection feature
  55972. */
  55973. static readonly POINTER_SELECTION: string;
  55974. /**
  55975. * The name of the teleportation feature
  55976. */
  55977. static readonly TELEPORTATION: string;
  55978. /**
  55979. * The name of the feature points feature.
  55980. */
  55981. static readonly FEATURE_POINTS: string;
  55982. /**
  55983. * The name of the hand tracking feature.
  55984. */
  55985. static readonly HAND_TRACKING: string;
  55986. /**
  55987. * The name of the image tracking feature
  55988. */
  55989. static readonly IMAGE_TRACKING: string;
  55990. }
  55991. /**
  55992. * Defining the constructor of a feature. Used to register the modules.
  55993. */
  55994. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  55995. /**
  55996. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  55997. * It is mainly used in AR sessions.
  55998. *
  55999. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  56000. */
  56001. export class WebXRFeaturesManager implements IDisposable {
  56002. private _xrSessionManager;
  56003. private static readonly _AvailableFeatures;
  56004. private _features;
  56005. /**
  56006. * constructs a new features manages.
  56007. *
  56008. * @param _xrSessionManager an instance of WebXRSessionManager
  56009. */
  56010. constructor(_xrSessionManager: WebXRSessionManager);
  56011. /**
  56012. * Used to register a module. After calling this function a developer can use this feature in the scene.
  56013. * Mainly used internally.
  56014. *
  56015. * @param featureName the name of the feature to register
  56016. * @param constructorFunction the function used to construct the module
  56017. * @param version the (babylon) version of the module
  56018. * @param stable is that a stable version of this module
  56019. */
  56020. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  56021. /**
  56022. * Returns a constructor of a specific feature.
  56023. *
  56024. * @param featureName the name of the feature to construct
  56025. * @param version the version of the feature to load
  56026. * @param xrSessionManager the xrSessionManager. Used to construct the module
  56027. * @param options optional options provided to the module.
  56028. * @returns a function that, when called, will return a new instance of this feature
  56029. */
  56030. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  56031. /**
  56032. * Can be used to return the list of features currently registered
  56033. *
  56034. * @returns an Array of available features
  56035. */
  56036. static GetAvailableFeatures(): string[];
  56037. /**
  56038. * Gets the versions available for a specific feature
  56039. * @param featureName the name of the feature
  56040. * @returns an array with the available versions
  56041. */
  56042. static GetAvailableVersions(featureName: string): string[];
  56043. /**
  56044. * Return the latest unstable version of this feature
  56045. * @param featureName the name of the feature to search
  56046. * @returns the version number. if not found will return -1
  56047. */
  56048. static GetLatestVersionOfFeature(featureName: string): number;
  56049. /**
  56050. * Return the latest stable version of this feature
  56051. * @param featureName the name of the feature to search
  56052. * @returns the version number. if not found will return -1
  56053. */
  56054. static GetStableVersionOfFeature(featureName: string): number;
  56055. /**
  56056. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  56057. * Can be used during a session to start a feature
  56058. * @param featureName the name of feature to attach
  56059. */
  56060. attachFeature(featureName: string): void;
  56061. /**
  56062. * Can be used inside a session or when the session ends to detach a specific feature
  56063. * @param featureName the name of the feature to detach
  56064. */
  56065. detachFeature(featureName: string): void;
  56066. /**
  56067. * Used to disable an already-enabled feature
  56068. * The feature will be disposed and will be recreated once enabled.
  56069. * @param featureName the feature to disable
  56070. * @returns true if disable was successful
  56071. */
  56072. disableFeature(featureName: string | {
  56073. Name: string;
  56074. }): boolean;
  56075. /**
  56076. * dispose this features manager
  56077. */
  56078. dispose(): void;
  56079. /**
  56080. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  56081. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  56082. *
  56083. * @param featureName the name of the feature to load or the class of the feature
  56084. * @param version optional version to load. if not provided the latest version will be enabled
  56085. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  56086. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  56087. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  56088. * @returns a new constructed feature or throws an error if feature not found.
  56089. */
  56090. enableFeature(featureName: string | {
  56091. Name: string;
  56092. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  56093. /**
  56094. * get the implementation of an enabled feature.
  56095. * @param featureName the name of the feature to load
  56096. * @returns the feature class, if found
  56097. */
  56098. getEnabledFeature(featureName: string): IWebXRFeature;
  56099. /**
  56100. * Get the list of enabled features
  56101. * @returns an array of enabled features
  56102. */
  56103. getEnabledFeatures(): string[];
  56104. /**
  56105. * This function will extend the session creation configuration object with enabled features.
  56106. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  56107. * according to the defined "required" variable, provided during enableFeature call
  56108. * @param xrSessionInit the xr Session init object to extend
  56109. *
  56110. * @returns an extended XRSessionInit object
  56111. */
  56112. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  56113. }
  56114. }
  56115. declare module "babylonjs/XR/webXRExperienceHelper" {
  56116. import { Observable } from "babylonjs/Misc/observable";
  56117. import { IDisposable, Scene } from "babylonjs/scene";
  56118. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  56119. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  56120. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  56121. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  56122. /**
  56123. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  56124. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  56125. */
  56126. export class WebXRExperienceHelper implements IDisposable {
  56127. private scene;
  56128. private _nonVRCamera;
  56129. private _originalSceneAutoClear;
  56130. private _supported;
  56131. /**
  56132. * Camera used to render xr content
  56133. */
  56134. camera: WebXRCamera;
  56135. /** A features manager for this xr session */
  56136. featuresManager: WebXRFeaturesManager;
  56137. /**
  56138. * Observers registered here will be triggered after the camera's initial transformation is set
  56139. * This can be used to set a different ground level or an extra rotation.
  56140. *
  56141. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  56142. * to the position set after this observable is done executing.
  56143. */
  56144. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  56145. /**
  56146. * Fires when the state of the experience helper has changed
  56147. */
  56148. onStateChangedObservable: Observable<WebXRState>;
  56149. /** Session manager used to keep track of xr session */
  56150. sessionManager: WebXRSessionManager;
  56151. /**
  56152. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  56153. */
  56154. state: WebXRState;
  56155. /**
  56156. * Creates a WebXRExperienceHelper
  56157. * @param scene The scene the helper should be created in
  56158. */
  56159. private constructor();
  56160. /**
  56161. * Creates the experience helper
  56162. * @param scene the scene to attach the experience helper to
  56163. * @returns a promise for the experience helper
  56164. */
  56165. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  56166. /**
  56167. * Disposes of the experience helper
  56168. */
  56169. dispose(): void;
  56170. /**
  56171. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  56172. * @param sessionMode options for the XR session
  56173. * @param referenceSpaceType frame of reference of the XR session
  56174. * @param renderTarget the output canvas that will be used to enter XR mode
  56175. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  56176. * @returns promise that resolves after xr mode has entered
  56177. */
  56178. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  56179. /**
  56180. * Exits XR mode and returns the scene to its original state
  56181. * @returns promise that resolves after xr mode has exited
  56182. */
  56183. exitXRAsync(): Promise<void>;
  56184. private _nonXRToXRCamera;
  56185. private _setState;
  56186. }
  56187. }
  56188. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  56189. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56190. import { Observable } from "babylonjs/Misc/observable";
  56191. import { IDisposable } from "babylonjs/scene";
  56192. /**
  56193. * X-Y values for axes in WebXR
  56194. */
  56195. export interface IWebXRMotionControllerAxesValue {
  56196. /**
  56197. * The value of the x axis
  56198. */
  56199. x: number;
  56200. /**
  56201. * The value of the y-axis
  56202. */
  56203. y: number;
  56204. }
  56205. /**
  56206. * changed / previous values for the values of this component
  56207. */
  56208. export interface IWebXRMotionControllerComponentChangesValues<T> {
  56209. /**
  56210. * current (this frame) value
  56211. */
  56212. current: T;
  56213. /**
  56214. * previous (last change) value
  56215. */
  56216. previous: T;
  56217. }
  56218. /**
  56219. * Represents changes in the component between current frame and last values recorded
  56220. */
  56221. export interface IWebXRMotionControllerComponentChanges {
  56222. /**
  56223. * will be populated with previous and current values if axes changed
  56224. */
  56225. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  56226. /**
  56227. * will be populated with previous and current values if pressed changed
  56228. */
  56229. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  56230. /**
  56231. * will be populated with previous and current values if touched changed
  56232. */
  56233. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  56234. /**
  56235. * will be populated with previous and current values if value changed
  56236. */
  56237. value?: IWebXRMotionControllerComponentChangesValues<number>;
  56238. }
  56239. /**
  56240. * This class represents a single component (for example button or thumbstick) of a motion controller
  56241. */
  56242. export class WebXRControllerComponent implements IDisposable {
  56243. /**
  56244. * the id of this component
  56245. */
  56246. id: string;
  56247. /**
  56248. * the type of the component
  56249. */
  56250. type: MotionControllerComponentType;
  56251. private _buttonIndex;
  56252. private _axesIndices;
  56253. private _axes;
  56254. private _changes;
  56255. private _currentValue;
  56256. private _hasChanges;
  56257. private _pressed;
  56258. private _touched;
  56259. /**
  56260. * button component type
  56261. */
  56262. static BUTTON_TYPE: MotionControllerComponentType;
  56263. /**
  56264. * squeeze component type
  56265. */
  56266. static SQUEEZE_TYPE: MotionControllerComponentType;
  56267. /**
  56268. * Thumbstick component type
  56269. */
  56270. static THUMBSTICK_TYPE: MotionControllerComponentType;
  56271. /**
  56272. * Touchpad component type
  56273. */
  56274. static TOUCHPAD_TYPE: MotionControllerComponentType;
  56275. /**
  56276. * trigger component type
  56277. */
  56278. static TRIGGER_TYPE: MotionControllerComponentType;
  56279. /**
  56280. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  56281. * the axes data changes
  56282. */
  56283. onAxisValueChangedObservable: Observable<{
  56284. x: number;
  56285. y: number;
  56286. }>;
  56287. /**
  56288. * Observers registered here will be triggered when the state of a button changes
  56289. * State change is either pressed / touched / value
  56290. */
  56291. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  56292. /**
  56293. * Creates a new component for a motion controller.
  56294. * It is created by the motion controller itself
  56295. *
  56296. * @param id the id of this component
  56297. * @param type the type of the component
  56298. * @param _buttonIndex index in the buttons array of the gamepad
  56299. * @param _axesIndices indices of the values in the axes array of the gamepad
  56300. */
  56301. constructor(
  56302. /**
  56303. * the id of this component
  56304. */
  56305. id: string,
  56306. /**
  56307. * the type of the component
  56308. */
  56309. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  56310. /**
  56311. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  56312. */
  56313. get axes(): IWebXRMotionControllerAxesValue;
  56314. /**
  56315. * Get the changes. Elements will be populated only if they changed with their previous and current value
  56316. */
  56317. get changes(): IWebXRMotionControllerComponentChanges;
  56318. /**
  56319. * Return whether or not the component changed the last frame
  56320. */
  56321. get hasChanges(): boolean;
  56322. /**
  56323. * is the button currently pressed
  56324. */
  56325. get pressed(): boolean;
  56326. /**
  56327. * is the button currently touched
  56328. */
  56329. get touched(): boolean;
  56330. /**
  56331. * Get the current value of this component
  56332. */
  56333. get value(): number;
  56334. /**
  56335. * Dispose this component
  56336. */
  56337. dispose(): void;
  56338. /**
  56339. * Are there axes correlating to this component
  56340. * @return true is axes data is available
  56341. */
  56342. isAxes(): boolean;
  56343. /**
  56344. * Is this component a button (hence - pressable)
  56345. * @returns true if can be pressed
  56346. */
  56347. isButton(): boolean;
  56348. /**
  56349. * update this component using the gamepad object it is in. Called on every frame
  56350. * @param nativeController the native gamepad controller object
  56351. */
  56352. update(nativeController: IMinimalMotionControllerObject): void;
  56353. }
  56354. }
  56355. declare module "babylonjs/Loading/sceneLoader" {
  56356. import { Observable } from "babylonjs/Misc/observable";
  56357. import { Nullable } from "babylonjs/types";
  56358. import { Scene } from "babylonjs/scene";
  56359. import { Engine } from "babylonjs/Engines/engine";
  56360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56361. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56362. import { AssetContainer } from "babylonjs/assetContainer";
  56363. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56364. import { Skeleton } from "babylonjs/Bones/skeleton";
  56365. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  56366. import { WebRequest } from "babylonjs/Misc/webRequest";
  56367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56368. import { Geometry } from "babylonjs/Meshes/geometry";
  56369. import { Light } from "babylonjs/Lights/light";
  56370. /**
  56371. * Type used for the success callback of ImportMesh
  56372. */
  56373. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  56374. /**
  56375. * Interface used for the result of ImportMeshAsync
  56376. */
  56377. export interface ISceneLoaderAsyncResult {
  56378. /**
  56379. * The array of loaded meshes
  56380. */
  56381. readonly meshes: AbstractMesh[];
  56382. /**
  56383. * The array of loaded particle systems
  56384. */
  56385. readonly particleSystems: IParticleSystem[];
  56386. /**
  56387. * The array of loaded skeletons
  56388. */
  56389. readonly skeletons: Skeleton[];
  56390. /**
  56391. * The array of loaded animation groups
  56392. */
  56393. readonly animationGroups: AnimationGroup[];
  56394. /**
  56395. * The array of loaded transform nodes
  56396. */
  56397. readonly transformNodes: TransformNode[];
  56398. /**
  56399. * The array of loaded geometries
  56400. */
  56401. readonly geometries: Geometry[];
  56402. /**
  56403. * The array of loaded lights
  56404. */
  56405. readonly lights: Light[];
  56406. }
  56407. /**
  56408. * Interface used to represent data loading progression
  56409. */
  56410. export interface ISceneLoaderProgressEvent {
  56411. /**
  56412. * Defines if data length to load can be evaluated
  56413. */
  56414. readonly lengthComputable: boolean;
  56415. /**
  56416. * Defines the loaded data length
  56417. */
  56418. readonly loaded: number;
  56419. /**
  56420. * Defines the data length to load
  56421. */
  56422. readonly total: number;
  56423. }
  56424. /**
  56425. * Interface used by SceneLoader plugins to define supported file extensions
  56426. */
  56427. export interface ISceneLoaderPluginExtensions {
  56428. /**
  56429. * Defines the list of supported extensions
  56430. */
  56431. [extension: string]: {
  56432. isBinary: boolean;
  56433. };
  56434. }
  56435. /**
  56436. * Interface used by SceneLoader plugin factory
  56437. */
  56438. export interface ISceneLoaderPluginFactory {
  56439. /**
  56440. * Defines the name of the factory
  56441. */
  56442. name: string;
  56443. /**
  56444. * Function called to create a new plugin
  56445. * @return the new plugin
  56446. */
  56447. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56448. /**
  56449. * The callback that returns true if the data can be directly loaded.
  56450. * @param data string containing the file data
  56451. * @returns if the data can be loaded directly
  56452. */
  56453. canDirectLoad?(data: string): boolean;
  56454. }
  56455. /**
  56456. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  56457. */
  56458. export interface ISceneLoaderPluginBase {
  56459. /**
  56460. * The friendly name of this plugin.
  56461. */
  56462. name: string;
  56463. /**
  56464. * The file extensions supported by this plugin.
  56465. */
  56466. extensions: string | ISceneLoaderPluginExtensions;
  56467. /**
  56468. * The callback called when loading from a url.
  56469. * @param scene scene loading this url
  56470. * @param url url to load
  56471. * @param onSuccess callback called when the file successfully loads
  56472. * @param onProgress callback called while file is loading (if the server supports this mode)
  56473. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  56474. * @param onError callback called when the file fails to load
  56475. * @returns a file request object
  56476. */
  56477. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56478. /**
  56479. * The callback called when loading from a file object.
  56480. * @param scene scene loading this file
  56481. * @param file defines the file to load
  56482. * @param onSuccess defines the callback to call when data is loaded
  56483. * @param onProgress defines the callback to call during loading process
  56484. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  56485. * @param onError defines the callback to call when an error occurs
  56486. * @returns a file request object
  56487. */
  56488. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56489. /**
  56490. * The callback that returns true if the data can be directly loaded.
  56491. * @param data string containing the file data
  56492. * @returns if the data can be loaded directly
  56493. */
  56494. canDirectLoad?(data: string): boolean;
  56495. /**
  56496. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  56497. * @param scene scene loading this data
  56498. * @param data string containing the data
  56499. * @returns data to pass to the plugin
  56500. */
  56501. directLoad?(scene: Scene, data: string): any;
  56502. /**
  56503. * The callback that allows custom handling of the root url based on the response url.
  56504. * @param rootUrl the original root url
  56505. * @param responseURL the response url if available
  56506. * @returns the new root url
  56507. */
  56508. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  56509. }
  56510. /**
  56511. * Interface used to define a SceneLoader plugin
  56512. */
  56513. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  56514. /**
  56515. * Import meshes into a scene.
  56516. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56517. * @param scene The scene to import into
  56518. * @param data The data to import
  56519. * @param rootUrl The root url for scene and resources
  56520. * @param meshes The meshes array to import into
  56521. * @param particleSystems The particle systems array to import into
  56522. * @param skeletons The skeletons array to import into
  56523. * @param onError The callback when import fails
  56524. * @returns True if successful or false otherwise
  56525. */
  56526. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  56527. /**
  56528. * Load into a scene.
  56529. * @param scene The scene to load into
  56530. * @param data The data to import
  56531. * @param rootUrl The root url for scene and resources
  56532. * @param onError The callback when import fails
  56533. * @returns True if successful or false otherwise
  56534. */
  56535. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  56536. /**
  56537. * Load into an asset container.
  56538. * @param scene The scene to load into
  56539. * @param data The data to import
  56540. * @param rootUrl The root url for scene and resources
  56541. * @param onError The callback when import fails
  56542. * @returns The loaded asset container
  56543. */
  56544. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  56545. }
  56546. /**
  56547. * Interface used to define an async SceneLoader plugin
  56548. */
  56549. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  56550. /**
  56551. * Import meshes into a scene.
  56552. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56553. * @param scene The scene to import into
  56554. * @param data The data to import
  56555. * @param rootUrl The root url for scene and resources
  56556. * @param onProgress The callback when the load progresses
  56557. * @param fileName Defines the name of the file to load
  56558. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  56559. */
  56560. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  56561. /**
  56562. * Load into a scene.
  56563. * @param scene The scene to load into
  56564. * @param data The data to import
  56565. * @param rootUrl The root url for scene and resources
  56566. * @param onProgress The callback when the load progresses
  56567. * @param fileName Defines the name of the file to load
  56568. * @returns Nothing
  56569. */
  56570. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  56571. /**
  56572. * Load into an asset container.
  56573. * @param scene The scene to load into
  56574. * @param data The data to import
  56575. * @param rootUrl The root url for scene and resources
  56576. * @param onProgress The callback when the load progresses
  56577. * @param fileName Defines the name of the file to load
  56578. * @returns The loaded asset container
  56579. */
  56580. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  56581. }
  56582. /**
  56583. * Mode that determines how to handle old animation groups before loading new ones.
  56584. */
  56585. export enum SceneLoaderAnimationGroupLoadingMode {
  56586. /**
  56587. * Reset all old animations to initial state then dispose them.
  56588. */
  56589. Clean = 0,
  56590. /**
  56591. * Stop all old animations.
  56592. */
  56593. Stop = 1,
  56594. /**
  56595. * Restart old animations from first frame.
  56596. */
  56597. Sync = 2,
  56598. /**
  56599. * Old animations remains untouched.
  56600. */
  56601. NoSync = 3
  56602. }
  56603. /**
  56604. * Defines a plugin registered by the SceneLoader
  56605. */
  56606. interface IRegisteredPlugin {
  56607. /**
  56608. * Defines the plugin to use
  56609. */
  56610. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56611. /**
  56612. * Defines if the plugin supports binary data
  56613. */
  56614. isBinary: boolean;
  56615. }
  56616. /**
  56617. * Class used to load scene from various file formats using registered plugins
  56618. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  56619. */
  56620. export class SceneLoader {
  56621. /**
  56622. * No logging while loading
  56623. */
  56624. static readonly NO_LOGGING: number;
  56625. /**
  56626. * Minimal logging while loading
  56627. */
  56628. static readonly MINIMAL_LOGGING: number;
  56629. /**
  56630. * Summary logging while loading
  56631. */
  56632. static readonly SUMMARY_LOGGING: number;
  56633. /**
  56634. * Detailled logging while loading
  56635. */
  56636. static readonly DETAILED_LOGGING: number;
  56637. /**
  56638. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  56639. */
  56640. static get ForceFullSceneLoadingForIncremental(): boolean;
  56641. static set ForceFullSceneLoadingForIncremental(value: boolean);
  56642. /**
  56643. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  56644. */
  56645. static get ShowLoadingScreen(): boolean;
  56646. static set ShowLoadingScreen(value: boolean);
  56647. /**
  56648. * Defines the current logging level (while loading the scene)
  56649. * @ignorenaming
  56650. */
  56651. static get loggingLevel(): number;
  56652. static set loggingLevel(value: number);
  56653. /**
  56654. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  56655. */
  56656. static get CleanBoneMatrixWeights(): boolean;
  56657. static set CleanBoneMatrixWeights(value: boolean);
  56658. /**
  56659. * Event raised when a plugin is used to load a scene
  56660. */
  56661. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56662. private static _registeredPlugins;
  56663. private static _showingLoadingScreen;
  56664. /**
  56665. * Gets the default plugin (used to load Babylon files)
  56666. * @returns the .babylon plugin
  56667. */
  56668. static GetDefaultPlugin(): IRegisteredPlugin;
  56669. private static _GetPluginForExtension;
  56670. private static _GetPluginForDirectLoad;
  56671. private static _GetPluginForFilename;
  56672. private static _GetDirectLoad;
  56673. private static _LoadData;
  56674. private static _GetFileInfo;
  56675. /**
  56676. * Gets a plugin that can load the given extension
  56677. * @param extension defines the extension to load
  56678. * @returns a plugin or null if none works
  56679. */
  56680. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56681. /**
  56682. * Gets a boolean indicating that the given extension can be loaded
  56683. * @param extension defines the extension to load
  56684. * @returns true if the extension is supported
  56685. */
  56686. static IsPluginForExtensionAvailable(extension: string): boolean;
  56687. /**
  56688. * Adds a new plugin to the list of registered plugins
  56689. * @param plugin defines the plugin to add
  56690. */
  56691. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  56692. /**
  56693. * Import meshes into a scene
  56694. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56695. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56696. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56697. * @param scene the instance of BABYLON.Scene to append to
  56698. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  56699. * @param onProgress a callback with a progress event for each file being loaded
  56700. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56701. * @param pluginExtension the extension used to determine the plugin
  56702. * @returns The loaded plugin
  56703. */
  56704. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56705. /**
  56706. * Import meshes into a scene
  56707. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56708. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56709. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56710. * @param scene the instance of BABYLON.Scene to append to
  56711. * @param onProgress a callback with a progress event for each file being loaded
  56712. * @param pluginExtension the extension used to determine the plugin
  56713. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  56714. */
  56715. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  56716. /**
  56717. * Load a scene
  56718. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56719. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56720. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56721. * @param onSuccess a callback with the scene when import succeeds
  56722. * @param onProgress a callback with a progress event for each file being loaded
  56723. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56724. * @param pluginExtension the extension used to determine the plugin
  56725. * @returns The loaded plugin
  56726. */
  56727. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56728. /**
  56729. * Load a scene
  56730. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56731. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56732. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56733. * @param onProgress a callback with a progress event for each file being loaded
  56734. * @param pluginExtension the extension used to determine the plugin
  56735. * @returns The loaded scene
  56736. */
  56737. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56738. /**
  56739. * Append a scene
  56740. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56741. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56742. * @param scene is the instance of BABYLON.Scene to append to
  56743. * @param onSuccess a callback with the scene when import succeeds
  56744. * @param onProgress a callback with a progress event for each file being loaded
  56745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56746. * @param pluginExtension the extension used to determine the plugin
  56747. * @returns The loaded plugin
  56748. */
  56749. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56750. /**
  56751. * Append a scene
  56752. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56753. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56754. * @param scene is the instance of BABYLON.Scene to append to
  56755. * @param onProgress a callback with a progress event for each file being loaded
  56756. * @param pluginExtension the extension used to determine the plugin
  56757. * @returns The given scene
  56758. */
  56759. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56760. /**
  56761. * Load a scene into an asset container
  56762. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56763. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56764. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56765. * @param onSuccess a callback with the scene when import succeeds
  56766. * @param onProgress a callback with a progress event for each file being loaded
  56767. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56768. * @param pluginExtension the extension used to determine the plugin
  56769. * @returns The loaded plugin
  56770. */
  56771. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56772. /**
  56773. * Load a scene into an asset container
  56774. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56775. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  56776. * @param scene is the instance of Scene to append to
  56777. * @param onProgress a callback with a progress event for each file being loaded
  56778. * @param pluginExtension the extension used to determine the plugin
  56779. * @returns The loaded asset container
  56780. */
  56781. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  56782. /**
  56783. * Import animations from a file into a scene
  56784. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56785. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56786. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56787. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56788. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56789. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56790. * @param onSuccess a callback with the scene when import succeeds
  56791. * @param onProgress a callback with a progress event for each file being loaded
  56792. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56793. * @param pluginExtension the extension used to determine the plugin
  56794. */
  56795. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): void;
  56796. /**
  56797. * Import animations from a file into a scene
  56798. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  56799. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  56800. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56801. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56802. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56803. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56804. * @param onSuccess a callback with the scene when import succeeds
  56805. * @param onProgress a callback with a progress event for each file being loaded
  56806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56807. * @param pluginExtension the extension used to determine the plugin
  56808. * @returns the updated scene with imported animations
  56809. */
  56810. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56811. }
  56812. }
  56813. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  56814. import { IDisposable, Scene } from "babylonjs/scene";
  56815. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  56816. import { Observable } from "babylonjs/Misc/observable";
  56817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56818. import { Nullable } from "babylonjs/types";
  56819. /**
  56820. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  56821. */
  56822. export type MotionControllerHandedness = "none" | "left" | "right";
  56823. /**
  56824. * The type of components available in motion controllers.
  56825. * This is not the name of the component.
  56826. */
  56827. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  56828. /**
  56829. * The state of a controller component
  56830. */
  56831. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  56832. /**
  56833. * The schema of motion controller layout.
  56834. * No object will be initialized using this interface
  56835. * This is used just to define the profile.
  56836. */
  56837. export interface IMotionControllerLayout {
  56838. /**
  56839. * Path to load the assets. Usually relative to the base path
  56840. */
  56841. assetPath: string;
  56842. /**
  56843. * Available components (unsorted)
  56844. */
  56845. components: {
  56846. /**
  56847. * A map of component Ids
  56848. */
  56849. [componentId: string]: {
  56850. /**
  56851. * The type of input the component outputs
  56852. */
  56853. type: MotionControllerComponentType;
  56854. /**
  56855. * The indices of this component in the gamepad object
  56856. */
  56857. gamepadIndices: {
  56858. /**
  56859. * Index of button
  56860. */
  56861. button?: number;
  56862. /**
  56863. * If available, index of x-axis
  56864. */
  56865. xAxis?: number;
  56866. /**
  56867. * If available, index of y-axis
  56868. */
  56869. yAxis?: number;
  56870. };
  56871. /**
  56872. * The mesh's root node name
  56873. */
  56874. rootNodeName: string;
  56875. /**
  56876. * Animation definitions for this model
  56877. */
  56878. visualResponses: {
  56879. [stateKey: string]: {
  56880. /**
  56881. * What property will be animated
  56882. */
  56883. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  56884. /**
  56885. * What states influence this visual response
  56886. */
  56887. states: MotionControllerComponentStateType[];
  56888. /**
  56889. * Type of animation - movement or visibility
  56890. */
  56891. valueNodeProperty: "transform" | "visibility";
  56892. /**
  56893. * Base node name to move. Its position will be calculated according to the min and max nodes
  56894. */
  56895. valueNodeName?: string;
  56896. /**
  56897. * Minimum movement node
  56898. */
  56899. minNodeName?: string;
  56900. /**
  56901. * Max movement node
  56902. */
  56903. maxNodeName?: string;
  56904. };
  56905. };
  56906. /**
  56907. * If touch enabled, what is the name of node to display user feedback
  56908. */
  56909. touchPointNodeName?: string;
  56910. };
  56911. };
  56912. /**
  56913. * Is it xr standard mapping or not
  56914. */
  56915. gamepadMapping: "" | "xr-standard";
  56916. /**
  56917. * Base root node of this entire model
  56918. */
  56919. rootNodeName: string;
  56920. /**
  56921. * Defines the main button component id
  56922. */
  56923. selectComponentId: string;
  56924. }
  56925. /**
  56926. * A definition for the layout map in the input profile
  56927. */
  56928. export interface IMotionControllerLayoutMap {
  56929. /**
  56930. * Layouts with handedness type as a key
  56931. */
  56932. [handedness: string]: IMotionControllerLayout;
  56933. }
  56934. /**
  56935. * The XR Input profile schema
  56936. * Profiles can be found here:
  56937. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  56938. */
  56939. export interface IMotionControllerProfile {
  56940. /**
  56941. * fallback profiles for this profileId
  56942. */
  56943. fallbackProfileIds: string[];
  56944. /**
  56945. * The layout map, with handedness as key
  56946. */
  56947. layouts: IMotionControllerLayoutMap;
  56948. /**
  56949. * The id of this profile
  56950. * correlates to the profile(s) in the xrInput.profiles array
  56951. */
  56952. profileId: string;
  56953. }
  56954. /**
  56955. * A helper-interface for the 3 meshes needed for controller button animation
  56956. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  56957. */
  56958. export interface IMotionControllerButtonMeshMap {
  56959. /**
  56960. * the mesh that defines the pressed value mesh position.
  56961. * This is used to find the max-position of this button
  56962. */
  56963. pressedMesh: AbstractMesh;
  56964. /**
  56965. * the mesh that defines the unpressed value mesh position.
  56966. * This is used to find the min (or initial) position of this button
  56967. */
  56968. unpressedMesh: AbstractMesh;
  56969. /**
  56970. * The mesh that will be changed when value changes
  56971. */
  56972. valueMesh: AbstractMesh;
  56973. }
  56974. /**
  56975. * A helper-interface for the 3 meshes needed for controller axis animation.
  56976. * This will be expanded when touchpad animations are fully supported
  56977. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  56978. */
  56979. export interface IMotionControllerMeshMap {
  56980. /**
  56981. * the mesh that defines the maximum value mesh position.
  56982. */
  56983. maxMesh?: AbstractMesh;
  56984. /**
  56985. * the mesh that defines the minimum value mesh position.
  56986. */
  56987. minMesh?: AbstractMesh;
  56988. /**
  56989. * The mesh that will be changed when axis value changes
  56990. */
  56991. valueMesh?: AbstractMesh;
  56992. }
  56993. /**
  56994. * The elements needed for change-detection of the gamepad objects in motion controllers
  56995. */
  56996. export interface IMinimalMotionControllerObject {
  56997. /**
  56998. * Available axes of this controller
  56999. */
  57000. axes: number[];
  57001. /**
  57002. * An array of available buttons
  57003. */
  57004. buttons: Array<{
  57005. /**
  57006. * Value of the button/trigger
  57007. */
  57008. value: number;
  57009. /**
  57010. * If the button/trigger is currently touched
  57011. */
  57012. touched: boolean;
  57013. /**
  57014. * If the button/trigger is currently pressed
  57015. */
  57016. pressed: boolean;
  57017. }>;
  57018. /**
  57019. * EXPERIMENTAL haptic support.
  57020. */
  57021. hapticActuators?: Array<{
  57022. pulse: (value: number, duration: number) => Promise<boolean>;
  57023. }>;
  57024. }
  57025. /**
  57026. * An Abstract Motion controller
  57027. * This class receives an xrInput and a profile layout and uses those to initialize the components
  57028. * Each component has an observable to check for changes in value and state
  57029. */
  57030. export abstract class WebXRAbstractMotionController implements IDisposable {
  57031. protected scene: Scene;
  57032. protected layout: IMotionControllerLayout;
  57033. /**
  57034. * The gamepad object correlating to this controller
  57035. */
  57036. gamepadObject: IMinimalMotionControllerObject;
  57037. /**
  57038. * handedness (left/right/none) of this controller
  57039. */
  57040. handedness: MotionControllerHandedness;
  57041. private _initComponent;
  57042. private _modelReady;
  57043. /**
  57044. * A map of components (WebXRControllerComponent) in this motion controller
  57045. * Components have a ComponentType and can also have both button and axis definitions
  57046. */
  57047. readonly components: {
  57048. [id: string]: WebXRControllerComponent;
  57049. };
  57050. /**
  57051. * Disable the model's animation. Can be set at any time.
  57052. */
  57053. disableAnimation: boolean;
  57054. /**
  57055. * Observers registered here will be triggered when the model of this controller is done loading
  57056. */
  57057. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  57058. /**
  57059. * The profile id of this motion controller
  57060. */
  57061. abstract profileId: string;
  57062. /**
  57063. * The root mesh of the model. It is null if the model was not yet initialized
  57064. */
  57065. rootMesh: Nullable<AbstractMesh>;
  57066. /**
  57067. * constructs a new abstract motion controller
  57068. * @param scene the scene to which the model of the controller will be added
  57069. * @param layout The profile layout to load
  57070. * @param gamepadObject The gamepad object correlating to this controller
  57071. * @param handedness handedness (left/right/none) of this controller
  57072. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  57073. */
  57074. constructor(scene: Scene, layout: IMotionControllerLayout,
  57075. /**
  57076. * The gamepad object correlating to this controller
  57077. */
  57078. gamepadObject: IMinimalMotionControllerObject,
  57079. /**
  57080. * handedness (left/right/none) of this controller
  57081. */
  57082. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  57083. /**
  57084. * Dispose this controller, the model mesh and all its components
  57085. */
  57086. dispose(): void;
  57087. /**
  57088. * Returns all components of specific type
  57089. * @param type the type to search for
  57090. * @return an array of components with this type
  57091. */
  57092. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  57093. /**
  57094. * get a component based an its component id as defined in layout.components
  57095. * @param id the id of the component
  57096. * @returns the component correlates to the id or undefined if not found
  57097. */
  57098. getComponent(id: string): WebXRControllerComponent;
  57099. /**
  57100. * Get the list of components available in this motion controller
  57101. * @returns an array of strings correlating to available components
  57102. */
  57103. getComponentIds(): string[];
  57104. /**
  57105. * Get the first component of specific type
  57106. * @param type type of component to find
  57107. * @return a controller component or null if not found
  57108. */
  57109. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  57110. /**
  57111. * Get the main (Select) component of this controller as defined in the layout
  57112. * @returns the main component of this controller
  57113. */
  57114. getMainComponent(): WebXRControllerComponent;
  57115. /**
  57116. * Loads the model correlating to this controller
  57117. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  57118. * @returns A promise fulfilled with the result of the model loading
  57119. */
  57120. loadModel(): Promise<boolean>;
  57121. /**
  57122. * Update this model using the current XRFrame
  57123. * @param xrFrame the current xr frame to use and update the model
  57124. */
  57125. updateFromXRFrame(xrFrame: XRFrame): void;
  57126. /**
  57127. * Backwards compatibility due to a deeply-integrated typo
  57128. */
  57129. get handness(): XREye;
  57130. /**
  57131. * Pulse (vibrate) this controller
  57132. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  57133. * Consecutive calls to this function will cancel the last pulse call
  57134. *
  57135. * @param value the strength of the pulse in 0.0...1.0 range
  57136. * @param duration Duration of the pulse in milliseconds
  57137. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  57138. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  57139. */
  57140. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  57141. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  57142. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  57143. /**
  57144. * Moves the axis on the controller mesh based on its current state
  57145. * @param axis the index of the axis
  57146. * @param axisValue the value of the axis which determines the meshes new position
  57147. * @hidden
  57148. */
  57149. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  57150. /**
  57151. * Update the model itself with the current frame data
  57152. * @param xrFrame the frame to use for updating the model mesh
  57153. */
  57154. protected updateModel(xrFrame: XRFrame): void;
  57155. /**
  57156. * Get the filename and path for this controller's model
  57157. * @returns a map of filename and path
  57158. */
  57159. protected abstract _getFilenameAndPath(): {
  57160. filename: string;
  57161. path: string;
  57162. };
  57163. /**
  57164. * This function is called before the mesh is loaded. It checks for loading constraints.
  57165. * For example, this function can check if the GLB loader is available
  57166. * If this function returns false, the generic controller will be loaded instead
  57167. * @returns Is the client ready to load the mesh
  57168. */
  57169. protected abstract _getModelLoadingConstraints(): boolean;
  57170. /**
  57171. * This function will be called after the model was successfully loaded and can be used
  57172. * for mesh transformations before it is available for the user
  57173. * @param meshes the loaded meshes
  57174. */
  57175. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  57176. /**
  57177. * Set the root mesh for this controller. Important for the WebXR controller class
  57178. * @param meshes the loaded meshes
  57179. */
  57180. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  57181. /**
  57182. * A function executed each frame that updates the mesh (if needed)
  57183. * @param xrFrame the current xrFrame
  57184. */
  57185. protected abstract _updateModel(xrFrame: XRFrame): void;
  57186. private _getGenericFilenameAndPath;
  57187. private _getGenericParentMesh;
  57188. }
  57189. }
  57190. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  57191. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57193. import { Scene } from "babylonjs/scene";
  57194. /**
  57195. * A generic trigger-only motion controller for WebXR
  57196. */
  57197. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  57198. /**
  57199. * Static version of the profile id of this controller
  57200. */
  57201. static ProfileId: string;
  57202. profileId: string;
  57203. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  57204. protected _getFilenameAndPath(): {
  57205. filename: string;
  57206. path: string;
  57207. };
  57208. protected _getModelLoadingConstraints(): boolean;
  57209. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  57210. protected _setRootMesh(meshes: AbstractMesh[]): void;
  57211. protected _updateModel(): void;
  57212. }
  57213. }
  57214. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  57215. import { Vector4 } from "babylonjs/Maths/math.vector";
  57216. import { Mesh } from "babylonjs/Meshes/mesh";
  57217. import { Scene } from "babylonjs/scene";
  57218. import { Nullable } from "babylonjs/types";
  57219. /**
  57220. * Class containing static functions to help procedurally build meshes
  57221. */
  57222. export class SphereBuilder {
  57223. /**
  57224. * Creates a sphere mesh
  57225. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57226. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  57227. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57228. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  57229. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  57230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57233. * @param name defines the name of the mesh
  57234. * @param options defines the options used to create the mesh
  57235. * @param scene defines the hosting scene
  57236. * @returns the sphere mesh
  57237. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57238. */
  57239. static CreateSphere(name: string, options: {
  57240. segments?: number;
  57241. diameter?: number;
  57242. diameterX?: number;
  57243. diameterY?: number;
  57244. diameterZ?: number;
  57245. arc?: number;
  57246. slice?: number;
  57247. sideOrientation?: number;
  57248. frontUVs?: Vector4;
  57249. backUVs?: Vector4;
  57250. updatable?: boolean;
  57251. }, scene?: Nullable<Scene>): Mesh;
  57252. }
  57253. }
  57254. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  57255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57256. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57257. import { Scene } from "babylonjs/scene";
  57258. /**
  57259. * A profiled motion controller has its profile loaded from an online repository.
  57260. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  57261. */
  57262. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  57263. private _repositoryUrl;
  57264. private _buttonMeshMapping;
  57265. private _touchDots;
  57266. /**
  57267. * The profile ID of this controller. Will be populated when the controller initializes.
  57268. */
  57269. profileId: string;
  57270. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  57271. dispose(): void;
  57272. protected _getFilenameAndPath(): {
  57273. filename: string;
  57274. path: string;
  57275. };
  57276. protected _getModelLoadingConstraints(): boolean;
  57277. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  57278. protected _setRootMesh(meshes: AbstractMesh[]): void;
  57279. protected _updateModel(_xrFrame: XRFrame): void;
  57280. }
  57281. }
  57282. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  57283. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57284. import { Scene } from "babylonjs/scene";
  57285. /**
  57286. * A construction function type to create a new controller based on an xrInput object
  57287. */
  57288. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  57289. /**
  57290. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  57291. *
  57292. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  57293. * it should be replaced with auto-loaded controllers.
  57294. *
  57295. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  57296. */
  57297. export class WebXRMotionControllerManager {
  57298. private static _AvailableControllers;
  57299. private static _Fallbacks;
  57300. private static _ProfileLoadingPromises;
  57301. private static _ProfilesList;
  57302. /**
  57303. * The base URL of the online controller repository. Can be changed at any time.
  57304. */
  57305. static BaseRepositoryUrl: string;
  57306. /**
  57307. * Which repository gets priority - local or online
  57308. */
  57309. static PrioritizeOnlineRepository: boolean;
  57310. /**
  57311. * Use the online repository, or use only locally-defined controllers
  57312. */
  57313. static UseOnlineRepository: boolean;
  57314. /**
  57315. * Clear the cache used for profile loading and reload when requested again
  57316. */
  57317. static ClearProfilesCache(): void;
  57318. /**
  57319. * Register the default fallbacks.
  57320. * This function is called automatically when this file is imported.
  57321. */
  57322. static DefaultFallbacks(): void;
  57323. /**
  57324. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  57325. * @param profileId the profile to which a fallback needs to be found
  57326. * @return an array with corresponding fallback profiles
  57327. */
  57328. static FindFallbackWithProfileId(profileId: string): string[];
  57329. /**
  57330. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  57331. * The order of search:
  57332. *
  57333. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  57334. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  57335. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  57336. * 4) return the generic trigger controller if none were found
  57337. *
  57338. * @param xrInput the xrInput to which a new controller is initialized
  57339. * @param scene the scene to which the model will be added
  57340. * @param forceProfile force a certain profile for this controller
  57341. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  57342. */
  57343. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  57344. /**
  57345. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  57346. *
  57347. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  57348. *
  57349. * @param type the profile type to register
  57350. * @param constructFunction the function to be called when loading this profile
  57351. */
  57352. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  57353. /**
  57354. * Register a fallback to a specific profile.
  57355. * @param profileId the profileId that will receive the fallbacks
  57356. * @param fallbacks A list of fallback profiles
  57357. */
  57358. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  57359. /**
  57360. * Will update the list of profiles available in the repository
  57361. * @return a promise that resolves to a map of profiles available online
  57362. */
  57363. static UpdateProfilesList(): Promise<{
  57364. [profile: string]: string;
  57365. }>;
  57366. private static _LoadProfileFromRepository;
  57367. private static _LoadProfilesFromAvailableControllers;
  57368. }
  57369. }
  57370. declare module "babylonjs/XR/webXRInputSource" {
  57371. import { Observable } from "babylonjs/Misc/observable";
  57372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57373. import { Ray } from "babylonjs/Culling/ray";
  57374. import { Scene } from "babylonjs/scene";
  57375. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57376. /**
  57377. * Configuration options for the WebXR controller creation
  57378. */
  57379. export interface IWebXRControllerOptions {
  57380. /**
  57381. * Should the controller mesh be animated when a user interacts with it
  57382. * The pressed buttons / thumbstick and touchpad animations will be disabled
  57383. */
  57384. disableMotionControllerAnimation?: boolean;
  57385. /**
  57386. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  57387. */
  57388. doNotLoadControllerMesh?: boolean;
  57389. /**
  57390. * Force a specific controller type for this controller.
  57391. * This can be used when creating your own profile or when testing different controllers
  57392. */
  57393. forceControllerProfile?: string;
  57394. /**
  57395. * Defines a rendering group ID for meshes that will be loaded.
  57396. * This is for the default controllers only.
  57397. */
  57398. renderingGroupId?: number;
  57399. }
  57400. /**
  57401. * Represents an XR controller
  57402. */
  57403. export class WebXRInputSource {
  57404. private _scene;
  57405. /** The underlying input source for the controller */
  57406. inputSource: XRInputSource;
  57407. private _options;
  57408. private _tmpVector;
  57409. private _uniqueId;
  57410. private _disposed;
  57411. /**
  57412. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  57413. */
  57414. grip?: AbstractMesh;
  57415. /**
  57416. * If available, this is the gamepad object related to this controller.
  57417. * Using this object it is possible to get click events and trackpad changes of the
  57418. * webxr controller that is currently being used.
  57419. */
  57420. motionController?: WebXRAbstractMotionController;
  57421. /**
  57422. * Event that fires when the controller is removed/disposed.
  57423. * The object provided as event data is this controller, after associated assets were disposed.
  57424. * uniqueId is still available.
  57425. */
  57426. onDisposeObservable: Observable<WebXRInputSource>;
  57427. /**
  57428. * Will be triggered when the mesh associated with the motion controller is done loading.
  57429. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  57430. * A shortened version of controller -> motion controller -> on mesh loaded.
  57431. */
  57432. onMeshLoadedObservable: Observable<AbstractMesh>;
  57433. /**
  57434. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  57435. */
  57436. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  57437. /**
  57438. * Pointer which can be used to select objects or attach a visible laser to
  57439. */
  57440. pointer: AbstractMesh;
  57441. /**
  57442. * Creates the input source object
  57443. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  57444. * @param _scene the scene which the controller should be associated to
  57445. * @param inputSource the underlying input source for the controller
  57446. * @param _options options for this controller creation
  57447. */
  57448. constructor(_scene: Scene,
  57449. /** The underlying input source for the controller */
  57450. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  57451. /**
  57452. * Get this controllers unique id
  57453. */
  57454. get uniqueId(): string;
  57455. /**
  57456. * Disposes of the object
  57457. */
  57458. dispose(): void;
  57459. /**
  57460. * Gets a world space ray coming from the pointer or grip
  57461. * @param result the resulting ray
  57462. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  57463. */
  57464. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  57465. /**
  57466. * Updates the controller pose based on the given XRFrame
  57467. * @param xrFrame xr frame to update the pose with
  57468. * @param referenceSpace reference space to use
  57469. */
  57470. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  57471. }
  57472. }
  57473. declare module "babylonjs/XR/webXRInput" {
  57474. import { Observable } from "babylonjs/Misc/observable";
  57475. import { IDisposable } from "babylonjs/scene";
  57476. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  57477. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57478. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57479. /**
  57480. * The schema for initialization options of the XR Input class
  57481. */
  57482. export interface IWebXRInputOptions {
  57483. /**
  57484. * If set to true no model will be automatically loaded
  57485. */
  57486. doNotLoadControllerMeshes?: boolean;
  57487. /**
  57488. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  57489. * If not found, the xr input profile data will be used.
  57490. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  57491. */
  57492. forceInputProfile?: string;
  57493. /**
  57494. * Do not send a request to the controller repository to load the profile.
  57495. *
  57496. * Instead, use the controllers available in babylon itself.
  57497. */
  57498. disableOnlineControllerRepository?: boolean;
  57499. /**
  57500. * A custom URL for the controllers repository
  57501. */
  57502. customControllersRepositoryURL?: string;
  57503. /**
  57504. * Should the controller model's components not move according to the user input
  57505. */
  57506. disableControllerAnimation?: boolean;
  57507. /**
  57508. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  57509. */
  57510. controllerOptions?: IWebXRControllerOptions;
  57511. }
  57512. /**
  57513. * XR input used to track XR inputs such as controllers/rays
  57514. */
  57515. export class WebXRInput implements IDisposable {
  57516. /**
  57517. * the xr session manager for this session
  57518. */
  57519. xrSessionManager: WebXRSessionManager;
  57520. /**
  57521. * the WebXR camera for this session. Mainly used for teleportation
  57522. */
  57523. xrCamera: WebXRCamera;
  57524. private readonly options;
  57525. /**
  57526. * XR controllers being tracked
  57527. */
  57528. controllers: Array<WebXRInputSource>;
  57529. private _frameObserver;
  57530. private _sessionEndedObserver;
  57531. private _sessionInitObserver;
  57532. /**
  57533. * Event when a controller has been connected/added
  57534. */
  57535. onControllerAddedObservable: Observable<WebXRInputSource>;
  57536. /**
  57537. * Event when a controller has been removed/disconnected
  57538. */
  57539. onControllerRemovedObservable: Observable<WebXRInputSource>;
  57540. /**
  57541. * Initializes the WebXRInput
  57542. * @param xrSessionManager the xr session manager for this session
  57543. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  57544. * @param options = initialization options for this xr input
  57545. */
  57546. constructor(
  57547. /**
  57548. * the xr session manager for this session
  57549. */
  57550. xrSessionManager: WebXRSessionManager,
  57551. /**
  57552. * the WebXR camera for this session. Mainly used for teleportation
  57553. */
  57554. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  57555. private _onInputSourcesChange;
  57556. private _addAndRemoveControllers;
  57557. /**
  57558. * Disposes of the object
  57559. */
  57560. dispose(): void;
  57561. }
  57562. }
  57563. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  57564. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  57565. import { Observable, EventState } from "babylonjs/Misc/observable";
  57566. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57567. /**
  57568. * This is the base class for all WebXR features.
  57569. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  57570. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  57571. */
  57572. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  57573. protected _xrSessionManager: WebXRSessionManager;
  57574. private _attached;
  57575. private _removeOnDetach;
  57576. /**
  57577. * Is this feature disposed?
  57578. */
  57579. isDisposed: boolean;
  57580. /**
  57581. * Should auto-attach be disabled?
  57582. */
  57583. disableAutoAttach: boolean;
  57584. /**
  57585. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  57586. */
  57587. xrNativeFeatureName: string;
  57588. /**
  57589. * Construct a new (abstract) WebXR feature
  57590. * @param _xrSessionManager the xr session manager for this feature
  57591. */
  57592. constructor(_xrSessionManager: WebXRSessionManager);
  57593. /**
  57594. * Is this feature attached
  57595. */
  57596. get attached(): boolean;
  57597. /**
  57598. * attach this feature
  57599. *
  57600. * @param force should attachment be forced (even when already attached)
  57601. * @returns true if successful, false is failed or already attached
  57602. */
  57603. attach(force?: boolean): boolean;
  57604. /**
  57605. * detach this feature.
  57606. *
  57607. * @returns true if successful, false if failed or already detached
  57608. */
  57609. detach(): boolean;
  57610. /**
  57611. * Dispose this feature and all of the resources attached
  57612. */
  57613. dispose(): void;
  57614. /**
  57615. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  57616. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  57617. *
  57618. * @returns whether or not the feature is compatible in this environment
  57619. */
  57620. isCompatible(): boolean;
  57621. /**
  57622. * This is used to register callbacks that will automatically be removed when detach is called.
  57623. * @param observable the observable to which the observer will be attached
  57624. * @param callback the callback to register
  57625. */
  57626. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  57627. /**
  57628. * Code in this function will be executed on each xrFrame received from the browser.
  57629. * This function will not execute after the feature is detached.
  57630. * @param _xrFrame the current frame
  57631. */
  57632. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  57633. }
  57634. }
  57635. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  57636. import { IDisposable, Scene } from "babylonjs/scene";
  57637. import { Nullable } from "babylonjs/types";
  57638. import { Observable } from "babylonjs/Misc/observable";
  57639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57640. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  57641. import { Camera } from "babylonjs/Cameras/camera";
  57642. /**
  57643. * Renders a layer on top of an existing scene
  57644. */
  57645. export class UtilityLayerRenderer implements IDisposable {
  57646. /** the original scene that will be rendered on top of */
  57647. originalScene: Scene;
  57648. private _pointerCaptures;
  57649. private _lastPointerEvents;
  57650. private static _DefaultUtilityLayer;
  57651. private static _DefaultKeepDepthUtilityLayer;
  57652. private _sharedGizmoLight;
  57653. private _renderCamera;
  57654. /**
  57655. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  57656. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  57657. * @returns the camera that is used when rendering the utility layer
  57658. */
  57659. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  57660. /**
  57661. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  57662. * @param cam the camera that should be used when rendering the utility layer
  57663. */
  57664. setRenderCamera(cam: Nullable<Camera>): void;
  57665. /**
  57666. * @hidden
  57667. * Light which used by gizmos to get light shading
  57668. */
  57669. _getSharedGizmoLight(): HemisphericLight;
  57670. /**
  57671. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  57672. */
  57673. pickUtilitySceneFirst: boolean;
  57674. /**
  57675. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  57676. */
  57677. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  57678. /**
  57679. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  57680. */
  57681. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  57682. /**
  57683. * The scene that is rendered on top of the original scene
  57684. */
  57685. utilityLayerScene: Scene;
  57686. /**
  57687. * If the utility layer should automatically be rendered on top of existing scene
  57688. */
  57689. shouldRender: boolean;
  57690. /**
  57691. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  57692. */
  57693. onlyCheckPointerDownEvents: boolean;
  57694. /**
  57695. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  57696. */
  57697. processAllEvents: boolean;
  57698. /**
  57699. * Observable raised when the pointer move from the utility layer scene to the main scene
  57700. */
  57701. onPointerOutObservable: Observable<number>;
  57702. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  57703. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  57704. private _afterRenderObserver;
  57705. private _sceneDisposeObserver;
  57706. private _originalPointerObserver;
  57707. /**
  57708. * Instantiates a UtilityLayerRenderer
  57709. * @param originalScene the original scene that will be rendered on top of
  57710. * @param handleEvents boolean indicating if the utility layer should handle events
  57711. */
  57712. constructor(
  57713. /** the original scene that will be rendered on top of */
  57714. originalScene: Scene, handleEvents?: boolean);
  57715. private _notifyObservers;
  57716. /**
  57717. * Renders the utility layers scene on top of the original scene
  57718. */
  57719. render(): void;
  57720. /**
  57721. * Disposes of the renderer
  57722. */
  57723. dispose(): void;
  57724. private _updateCamera;
  57725. }
  57726. }
  57727. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  57728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57730. import { WebXRInput } from "babylonjs/XR/webXRInput";
  57731. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  57732. import { Scene } from "babylonjs/scene";
  57733. import { Nullable } from "babylonjs/types";
  57734. import { Color3 } from "babylonjs/Maths/math.color";
  57735. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  57736. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57737. /**
  57738. * Options interface for the pointer selection module
  57739. */
  57740. export interface IWebXRControllerPointerSelectionOptions {
  57741. /**
  57742. * if provided, this scene will be used to render meshes.
  57743. */
  57744. customUtilityLayerScene?: Scene;
  57745. /**
  57746. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  57747. * If not disabled, the last picked point will be used to execute a pointer up event
  57748. * If disabled, pointer up event will be triggered right after the pointer down event.
  57749. * Used in screen and gaze target ray mode only
  57750. */
  57751. disablePointerUpOnTouchOut: boolean;
  57752. /**
  57753. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  57754. */
  57755. forceGazeMode: boolean;
  57756. /**
  57757. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  57758. * to start a new countdown to the pointer down event.
  57759. * Defaults to 1.
  57760. */
  57761. gazeModePointerMovedFactor?: number;
  57762. /**
  57763. * Different button type to use instead of the main component
  57764. */
  57765. overrideButtonId?: string;
  57766. /**
  57767. * use this rendering group id for the meshes (optional)
  57768. */
  57769. renderingGroupId?: number;
  57770. /**
  57771. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  57772. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  57773. * 3000 means 3 seconds between pointing at something and selecting it
  57774. */
  57775. timeToSelect?: number;
  57776. /**
  57777. * Should meshes created here be added to a utility layer or the main scene
  57778. */
  57779. useUtilityLayer?: boolean;
  57780. /**
  57781. * Optional WebXR camera to be used for gaze selection
  57782. */
  57783. gazeCamera?: WebXRCamera;
  57784. /**
  57785. * the xr input to use with this pointer selection
  57786. */
  57787. xrInput: WebXRInput;
  57788. /**
  57789. * Should the scene pointerX and pointerY update be disabled
  57790. * This is required for fullscreen AR GUI, but might slow down other experiences.
  57791. * Disable in VR, if not needed.
  57792. * The first rig camera (left eye) will be used to calculate the projection
  57793. */
  57794. disableScenePointerVectorUpdate: boolean;
  57795. /**
  57796. * Enable pointer selection on all controllers instead of switching between them
  57797. */
  57798. enablePointerSelectionOnAllControllers?: boolean;
  57799. /**
  57800. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  57801. * If switch is enabled, it will still allow the user to switch between the different controllers
  57802. */
  57803. preferredHandedness?: XRHandedness;
  57804. /**
  57805. * Disable switching the pointer selection from one controller to the other.
  57806. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  57807. */
  57808. disableSwitchOnClick?: boolean;
  57809. /**
  57810. * The maximum distance of the pointer selection feature. Defaults to 100.
  57811. */
  57812. maxPointerDistance?: number;
  57813. }
  57814. /**
  57815. * A module that will enable pointer selection for motion controllers of XR Input Sources
  57816. */
  57817. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  57818. private readonly _options;
  57819. private static _idCounter;
  57820. private _attachController;
  57821. private _controllers;
  57822. private _scene;
  57823. private _tmpVectorForPickCompare;
  57824. private _attachedController;
  57825. /**
  57826. * The module's name
  57827. */
  57828. static readonly Name: string;
  57829. /**
  57830. * The (Babylon) version of this module.
  57831. * This is an integer representing the implementation version.
  57832. * This number does not correspond to the WebXR specs version
  57833. */
  57834. static readonly Version: number;
  57835. /**
  57836. * Disable lighting on the laser pointer (so it will always be visible)
  57837. */
  57838. disablePointerLighting: boolean;
  57839. /**
  57840. * Disable lighting on the selection mesh (so it will always be visible)
  57841. */
  57842. disableSelectionMeshLighting: boolean;
  57843. /**
  57844. * Should the laser pointer be displayed
  57845. */
  57846. displayLaserPointer: boolean;
  57847. /**
  57848. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  57849. */
  57850. displaySelectionMesh: boolean;
  57851. /**
  57852. * This color will be set to the laser pointer when selection is triggered
  57853. */
  57854. laserPointerPickedColor: Color3;
  57855. /**
  57856. * Default color of the laser pointer
  57857. */
  57858. laserPointerDefaultColor: Color3;
  57859. /**
  57860. * default color of the selection ring
  57861. */
  57862. selectionMeshDefaultColor: Color3;
  57863. /**
  57864. * This color will be applied to the selection ring when selection is triggered
  57865. */
  57866. selectionMeshPickedColor: Color3;
  57867. /**
  57868. * Optional filter to be used for ray selection. This predicate shares behavior with
  57869. * scene.pointerMovePredicate which takes priority if it is also assigned.
  57870. */
  57871. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57872. /**
  57873. * constructs a new background remover module
  57874. * @param _xrSessionManager the session manager for this module
  57875. * @param _options read-only options to be used in this module
  57876. */
  57877. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  57878. /**
  57879. * attach this feature
  57880. * Will usually be called by the features manager
  57881. *
  57882. * @returns true if successful.
  57883. */
  57884. attach(): boolean;
  57885. /**
  57886. * detach this feature.
  57887. * Will usually be called by the features manager
  57888. *
  57889. * @returns true if successful.
  57890. */
  57891. detach(): boolean;
  57892. /**
  57893. * Will get the mesh under a specific pointer.
  57894. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  57895. * @param controllerId the controllerId to check
  57896. * @returns The mesh under pointer or null if no mesh is under the pointer
  57897. */
  57898. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  57899. /**
  57900. * Get the xr controller that correlates to the pointer id in the pointer event
  57901. *
  57902. * @param id the pointer id to search for
  57903. * @returns the controller that correlates to this id or null if not found
  57904. */
  57905. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  57906. private _identityMatrix;
  57907. private _screenCoordinatesRef;
  57908. private _viewportRef;
  57909. protected _onXRFrame(_xrFrame: XRFrame): void;
  57910. private _attachGazeMode;
  57911. private _attachScreenRayMode;
  57912. private _attachTrackedPointerRayMode;
  57913. private _convertNormalToDirectionOfRay;
  57914. private _detachController;
  57915. private _generateNewMeshPair;
  57916. private _pickingMoved;
  57917. private _updatePointerDistance;
  57918. /** @hidden */
  57919. get lasterPointerDefaultColor(): Color3;
  57920. }
  57921. }
  57922. declare module "babylonjs/XR/webXREnterExitUI" {
  57923. import { Nullable } from "babylonjs/types";
  57924. import { Observable } from "babylonjs/Misc/observable";
  57925. import { IDisposable, Scene } from "babylonjs/scene";
  57926. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  57927. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  57928. /**
  57929. * Button which can be used to enter a different mode of XR
  57930. */
  57931. export class WebXREnterExitUIButton {
  57932. /** button element */
  57933. element: HTMLElement;
  57934. /** XR initialization options for the button */
  57935. sessionMode: XRSessionMode;
  57936. /** Reference space type */
  57937. referenceSpaceType: XRReferenceSpaceType;
  57938. /**
  57939. * Creates a WebXREnterExitUIButton
  57940. * @param element button element
  57941. * @param sessionMode XR initialization session mode
  57942. * @param referenceSpaceType the type of reference space to be used
  57943. */
  57944. constructor(
  57945. /** button element */
  57946. element: HTMLElement,
  57947. /** XR initialization options for the button */
  57948. sessionMode: XRSessionMode,
  57949. /** Reference space type */
  57950. referenceSpaceType: XRReferenceSpaceType);
  57951. /**
  57952. * Extendable function which can be used to update the button's visuals when the state changes
  57953. * @param activeButton the current active button in the UI
  57954. */
  57955. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  57956. }
  57957. /**
  57958. * Options to create the webXR UI
  57959. */
  57960. export class WebXREnterExitUIOptions {
  57961. /**
  57962. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  57963. */
  57964. customButtons?: Array<WebXREnterExitUIButton>;
  57965. /**
  57966. * A reference space type to use when creating the default button.
  57967. * Default is local-floor
  57968. */
  57969. referenceSpaceType?: XRReferenceSpaceType;
  57970. /**
  57971. * Context to enter xr with
  57972. */
  57973. renderTarget?: Nullable<WebXRRenderTarget>;
  57974. /**
  57975. * A session mode to use when creating the default button.
  57976. * Default is immersive-vr
  57977. */
  57978. sessionMode?: XRSessionMode;
  57979. /**
  57980. * A list of optional features to init the session with
  57981. */
  57982. optionalFeatures?: string[];
  57983. /**
  57984. * A list of optional features to init the session with
  57985. */
  57986. requiredFeatures?: string[];
  57987. /**
  57988. * If defined, this function will be executed if the UI encounters an error when entering XR
  57989. */
  57990. onError?: (error: any) => void;
  57991. }
  57992. /**
  57993. * UI to allow the user to enter/exit XR mode
  57994. */
  57995. export class WebXREnterExitUI implements IDisposable {
  57996. private scene;
  57997. /** version of the options passed to this UI */
  57998. options: WebXREnterExitUIOptions;
  57999. private _activeButton;
  58000. private _buttons;
  58001. /**
  58002. * The HTML Div Element to which buttons are added.
  58003. */
  58004. readonly overlay: HTMLDivElement;
  58005. /**
  58006. * Fired every time the active button is changed.
  58007. *
  58008. * When xr is entered via a button that launches xr that button will be the callback parameter
  58009. *
  58010. * When exiting xr the callback parameter will be null)
  58011. */
  58012. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  58013. /**
  58014. *
  58015. * @param scene babylon scene object to use
  58016. * @param options (read-only) version of the options passed to this UI
  58017. */
  58018. private constructor();
  58019. /**
  58020. * Creates UI to allow the user to enter/exit XR mode
  58021. * @param scene the scene to add the ui to
  58022. * @param helper the xr experience helper to enter/exit xr with
  58023. * @param options options to configure the UI
  58024. * @returns the created ui
  58025. */
  58026. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  58027. /**
  58028. * Disposes of the XR UI component
  58029. */
  58030. dispose(): void;
  58031. private _updateButtons;
  58032. }
  58033. }
  58034. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  58035. import { Vector3 } from "babylonjs/Maths/math.vector";
  58036. import { Color4 } from "babylonjs/Maths/math.color";
  58037. import { Nullable } from "babylonjs/types";
  58038. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58039. import { Scene } from "babylonjs/scene";
  58040. /**
  58041. * Class containing static functions to help procedurally build meshes
  58042. */
  58043. export class LinesBuilder {
  58044. /**
  58045. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58046. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  58047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58048. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58049. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58050. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58051. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58052. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  58053. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58056. * @param name defines the name of the new line system
  58057. * @param options defines the options used to create the line system
  58058. * @param scene defines the hosting scene
  58059. * @returns a new line system mesh
  58060. */
  58061. static CreateLineSystem(name: string, options: {
  58062. lines: Vector3[][];
  58063. updatable?: boolean;
  58064. instance?: Nullable<LinesMesh>;
  58065. colors?: Nullable<Color4[][]>;
  58066. useVertexAlpha?: boolean;
  58067. }, scene: Nullable<Scene>): LinesMesh;
  58068. /**
  58069. * Creates a line mesh
  58070. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  58071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58072. * * The parameter `points` is an array successive Vector3
  58073. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  58074. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58075. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58076. * * When updating an instance, remember that only point positions can change, not the number of points
  58077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58079. * @param name defines the name of the new line system
  58080. * @param options defines the options used to create the line system
  58081. * @param scene defines the hosting scene
  58082. * @returns a new line mesh
  58083. */
  58084. static CreateLines(name: string, options: {
  58085. points: Vector3[];
  58086. updatable?: boolean;
  58087. instance?: Nullable<LinesMesh>;
  58088. colors?: Color4[];
  58089. useVertexAlpha?: boolean;
  58090. }, scene?: Nullable<Scene>): LinesMesh;
  58091. /**
  58092. * Creates a dashed line mesh
  58093. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  58094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58095. * * The parameter `points` is an array successive Vector3
  58096. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58097. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58098. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58099. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  58100. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58101. * * When updating an instance, remember that only point positions can change, not the number of points
  58102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58103. * @param name defines the name of the mesh
  58104. * @param options defines the options used to create the mesh
  58105. * @param scene defines the hosting scene
  58106. * @returns the dashed line mesh
  58107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58108. */
  58109. static CreateDashedLines(name: string, options: {
  58110. points: Vector3[];
  58111. dashSize?: number;
  58112. gapSize?: number;
  58113. dashNb?: number;
  58114. updatable?: boolean;
  58115. instance?: LinesMesh;
  58116. useVertexAlpha?: boolean;
  58117. }, scene?: Nullable<Scene>): LinesMesh;
  58118. }
  58119. }
  58120. declare module "babylonjs/Misc/timer" {
  58121. import { Observable, Observer } from "babylonjs/Misc/observable";
  58122. import { Nullable } from "babylonjs/types";
  58123. import { IDisposable } from "babylonjs/scene";
  58124. /**
  58125. * Construction options for a timer
  58126. */
  58127. export interface ITimerOptions<T> {
  58128. /**
  58129. * Time-to-end
  58130. */
  58131. timeout: number;
  58132. /**
  58133. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  58134. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  58135. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  58136. */
  58137. contextObservable: Observable<T>;
  58138. /**
  58139. * Optional parameters when adding an observer to the observable
  58140. */
  58141. observableParameters?: {
  58142. mask?: number;
  58143. insertFirst?: boolean;
  58144. scope?: any;
  58145. };
  58146. /**
  58147. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  58148. */
  58149. breakCondition?: (data?: ITimerData<T>) => boolean;
  58150. /**
  58151. * Will be triggered when the time condition has met
  58152. */
  58153. onEnded?: (data: ITimerData<any>) => void;
  58154. /**
  58155. * Will be triggered when the break condition has met (prematurely ended)
  58156. */
  58157. onAborted?: (data: ITimerData<any>) => void;
  58158. /**
  58159. * Optional function to execute on each tick (or count)
  58160. */
  58161. onTick?: (data: ITimerData<any>) => void;
  58162. }
  58163. /**
  58164. * An interface defining the data sent by the timer
  58165. */
  58166. export interface ITimerData<T> {
  58167. /**
  58168. * When did it start
  58169. */
  58170. startTime: number;
  58171. /**
  58172. * Time now
  58173. */
  58174. currentTime: number;
  58175. /**
  58176. * Time passed since started
  58177. */
  58178. deltaTime: number;
  58179. /**
  58180. * How much is completed, in [0.0...1.0].
  58181. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  58182. */
  58183. completeRate: number;
  58184. /**
  58185. * What the registered observable sent in the last count
  58186. */
  58187. payload: T;
  58188. }
  58189. /**
  58190. * The current state of the timer
  58191. */
  58192. export enum TimerState {
  58193. /**
  58194. * Timer initialized, not yet started
  58195. */
  58196. INIT = 0,
  58197. /**
  58198. * Timer started and counting
  58199. */
  58200. STARTED = 1,
  58201. /**
  58202. * Timer ended (whether aborted or time reached)
  58203. */
  58204. ENDED = 2
  58205. }
  58206. /**
  58207. * A simple version of the timer. Will take options and start the timer immediately after calling it
  58208. *
  58209. * @param options options with which to initialize this timer
  58210. */
  58211. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  58212. /**
  58213. * An advanced implementation of a timer class
  58214. */
  58215. export class AdvancedTimer<T = any> implements IDisposable {
  58216. /**
  58217. * Will notify each time the timer calculates the remaining time
  58218. */
  58219. onEachCountObservable: Observable<ITimerData<T>>;
  58220. /**
  58221. * Will trigger when the timer was aborted due to the break condition
  58222. */
  58223. onTimerAbortedObservable: Observable<ITimerData<T>>;
  58224. /**
  58225. * Will trigger when the timer ended successfully
  58226. */
  58227. onTimerEndedObservable: Observable<ITimerData<T>>;
  58228. /**
  58229. * Will trigger when the timer state has changed
  58230. */
  58231. onStateChangedObservable: Observable<TimerState>;
  58232. private _observer;
  58233. private _contextObservable;
  58234. private _observableParameters;
  58235. private _startTime;
  58236. private _timer;
  58237. private _state;
  58238. private _breakCondition;
  58239. private _timeToEnd;
  58240. private _breakOnNextTick;
  58241. /**
  58242. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  58243. * @param options construction options for this advanced timer
  58244. */
  58245. constructor(options: ITimerOptions<T>);
  58246. /**
  58247. * set a breaking condition for this timer. Default is to never break during count
  58248. * @param predicate the new break condition. Returns true to break, false otherwise
  58249. */
  58250. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  58251. /**
  58252. * Reset ALL associated observables in this advanced timer
  58253. */
  58254. clearObservables(): void;
  58255. /**
  58256. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  58257. *
  58258. * @param timeToEnd how much time to measure until timer ended
  58259. */
  58260. start(timeToEnd?: number): void;
  58261. /**
  58262. * Will force a stop on the next tick.
  58263. */
  58264. stop(): void;
  58265. /**
  58266. * Dispose this timer, clearing all resources
  58267. */
  58268. dispose(): void;
  58269. private _setState;
  58270. private _tick;
  58271. private _stop;
  58272. }
  58273. }
  58274. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  58275. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  58276. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  58277. import { Nullable } from "babylonjs/types";
  58278. import { WebXRInput } from "babylonjs/XR/webXRInput";
  58279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58280. import { Vector3 } from "babylonjs/Maths/math.vector";
  58281. import { Material } from "babylonjs/Materials/material";
  58282. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  58283. import { Scene } from "babylonjs/scene";
  58284. /**
  58285. * The options container for the teleportation module
  58286. */
  58287. export interface IWebXRTeleportationOptions {
  58288. /**
  58289. * if provided, this scene will be used to render meshes.
  58290. */
  58291. customUtilityLayerScene?: Scene;
  58292. /**
  58293. * Values to configure the default target mesh
  58294. */
  58295. defaultTargetMeshOptions?: {
  58296. /**
  58297. * Fill color of the teleportation area
  58298. */
  58299. teleportationFillColor?: string;
  58300. /**
  58301. * Border color for the teleportation area
  58302. */
  58303. teleportationBorderColor?: string;
  58304. /**
  58305. * Disable the mesh's animation sequence
  58306. */
  58307. disableAnimation?: boolean;
  58308. /**
  58309. * Disable lighting on the material or the ring and arrow
  58310. */
  58311. disableLighting?: boolean;
  58312. /**
  58313. * Override the default material of the torus and arrow
  58314. */
  58315. torusArrowMaterial?: Material;
  58316. };
  58317. /**
  58318. * A list of meshes to use as floor meshes.
  58319. * Meshes can be added and removed after initializing the feature using the
  58320. * addFloorMesh and removeFloorMesh functions
  58321. * If empty, rotation will still work
  58322. */
  58323. floorMeshes?: AbstractMesh[];
  58324. /**
  58325. * use this rendering group id for the meshes (optional)
  58326. */
  58327. renderingGroupId?: number;
  58328. /**
  58329. * Should teleportation move only to snap points
  58330. */
  58331. snapPointsOnly?: boolean;
  58332. /**
  58333. * An array of points to which the teleportation will snap to.
  58334. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  58335. */
  58336. snapPositions?: Vector3[];
  58337. /**
  58338. * How close should the teleportation ray be in order to snap to position.
  58339. * Default to 0.8 units (meters)
  58340. */
  58341. snapToPositionRadius?: number;
  58342. /**
  58343. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  58344. * If you want to support rotation, make sure your mesh has a direction indicator.
  58345. *
  58346. * When left untouched, the default mesh will be initialized.
  58347. */
  58348. teleportationTargetMesh?: AbstractMesh;
  58349. /**
  58350. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  58351. */
  58352. timeToTeleport?: number;
  58353. /**
  58354. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  58355. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  58356. */
  58357. useMainComponentOnly?: boolean;
  58358. /**
  58359. * Should meshes created here be added to a utility layer or the main scene
  58360. */
  58361. useUtilityLayer?: boolean;
  58362. /**
  58363. * Babylon XR Input class for controller
  58364. */
  58365. xrInput: WebXRInput;
  58366. /**
  58367. * Meshes that the teleportation ray cannot go through
  58368. */
  58369. pickBlockerMeshes?: AbstractMesh[];
  58370. /**
  58371. * Should teleport work only on a specific hand?
  58372. */
  58373. forceHandedness?: XRHandedness;
  58374. /**
  58375. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  58376. */
  58377. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  58378. }
  58379. /**
  58380. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  58381. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  58382. * the input of the attached controllers.
  58383. */
  58384. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  58385. private _options;
  58386. private _controllers;
  58387. private _currentTeleportationControllerId;
  58388. private _floorMeshes;
  58389. private _quadraticBezierCurve;
  58390. private _selectionFeature;
  58391. private _snapToPositions;
  58392. private _snappedToPoint;
  58393. private _teleportationRingMaterial?;
  58394. private _tmpRay;
  58395. private _tmpVector;
  58396. private _tmpQuaternion;
  58397. /**
  58398. * The module's name
  58399. */
  58400. static readonly Name: string;
  58401. /**
  58402. * The (Babylon) version of this module.
  58403. * This is an integer representing the implementation version.
  58404. * This number does not correspond to the webxr specs version
  58405. */
  58406. static readonly Version: number;
  58407. /**
  58408. * Is movement backwards enabled
  58409. */
  58410. backwardsMovementEnabled: boolean;
  58411. /**
  58412. * Distance to travel when moving backwards
  58413. */
  58414. backwardsTeleportationDistance: number;
  58415. /**
  58416. * The distance from the user to the inspection point in the direction of the controller
  58417. * A higher number will allow the user to move further
  58418. * defaults to 5 (meters, in xr units)
  58419. */
  58420. parabolicCheckRadius: number;
  58421. /**
  58422. * Should the module support parabolic ray on top of direct ray
  58423. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  58424. * Very helpful when moving between floors / different heights
  58425. */
  58426. parabolicRayEnabled: boolean;
  58427. /**
  58428. * The second type of ray - straight line.
  58429. * Should it be enabled or should the parabolic line be the only one.
  58430. */
  58431. straightRayEnabled: boolean;
  58432. /**
  58433. * How much rotation should be applied when rotating right and left
  58434. */
  58435. rotationAngle: number;
  58436. private _rotationEnabled;
  58437. /**
  58438. * Is rotation enabled when moving forward?
  58439. * Disabling this feature will prevent the user from deciding the direction when teleporting
  58440. */
  58441. get rotationEnabled(): boolean;
  58442. /**
  58443. * Sets wether rotation is enabled or not
  58444. * @param enabled is rotation enabled when teleportation is shown
  58445. */
  58446. set rotationEnabled(enabled: boolean);
  58447. /**
  58448. * Exposes the currently set teleportation target mesh.
  58449. */
  58450. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  58451. /**
  58452. * constructs a new anchor system
  58453. * @param _xrSessionManager an instance of WebXRSessionManager
  58454. * @param _options configuration object for this feature
  58455. */
  58456. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  58457. /**
  58458. * Get the snapPointsOnly flag
  58459. */
  58460. get snapPointsOnly(): boolean;
  58461. /**
  58462. * Sets the snapPointsOnly flag
  58463. * @param snapToPoints should teleportation be exclusively to snap points
  58464. */
  58465. set snapPointsOnly(snapToPoints: boolean);
  58466. /**
  58467. * Add a new mesh to the floor meshes array
  58468. * @param mesh the mesh to use as floor mesh
  58469. */
  58470. addFloorMesh(mesh: AbstractMesh): void;
  58471. /**
  58472. * Add a new snap-to point to fix teleportation to this position
  58473. * @param newSnapPoint The new Snap-To point
  58474. */
  58475. addSnapPoint(newSnapPoint: Vector3): void;
  58476. attach(): boolean;
  58477. detach(): boolean;
  58478. dispose(): void;
  58479. /**
  58480. * Remove a mesh from the floor meshes array
  58481. * @param mesh the mesh to remove
  58482. */
  58483. removeFloorMesh(mesh: AbstractMesh): void;
  58484. /**
  58485. * Remove a mesh from the floor meshes array using its name
  58486. * @param name the mesh name to remove
  58487. */
  58488. removeFloorMeshByName(name: string): void;
  58489. /**
  58490. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  58491. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  58492. * @returns was the point found and removed or not
  58493. */
  58494. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  58495. /**
  58496. * This function sets a selection feature that will be disabled when
  58497. * the forward ray is shown and will be reattached when hidden.
  58498. * This is used to remove the selection rays when moving.
  58499. * @param selectionFeature the feature to disable when forward movement is enabled
  58500. */
  58501. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  58502. protected _onXRFrame(_xrFrame: XRFrame): void;
  58503. private _attachController;
  58504. private _createDefaultTargetMesh;
  58505. private _detachController;
  58506. private _findClosestSnapPointWithRadius;
  58507. private _setTargetMeshPosition;
  58508. private _setTargetMeshVisibility;
  58509. private _showParabolicPath;
  58510. private _teleportForward;
  58511. }
  58512. }
  58513. declare module "babylonjs/XR/webXRDefaultExperience" {
  58514. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  58515. import { Scene } from "babylonjs/scene";
  58516. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  58517. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  58518. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  58519. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  58520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58521. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  58522. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  58523. /**
  58524. * Options for the default xr helper
  58525. */
  58526. export class WebXRDefaultExperienceOptions {
  58527. /**
  58528. * Enable or disable default UI to enter XR
  58529. */
  58530. disableDefaultUI?: boolean;
  58531. /**
  58532. * Should teleportation not initialize. defaults to false.
  58533. */
  58534. disableTeleportation?: boolean;
  58535. /**
  58536. * Floor meshes that will be used for teleport
  58537. */
  58538. floorMeshes?: Array<AbstractMesh>;
  58539. /**
  58540. * If set to true, the first frame will not be used to reset position
  58541. * The first frame is mainly used when copying transformation from the old camera
  58542. * Mainly used in AR
  58543. */
  58544. ignoreNativeCameraTransformation?: boolean;
  58545. /**
  58546. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  58547. */
  58548. inputOptions?: IWebXRInputOptions;
  58549. /**
  58550. * optional configuration for the output canvas
  58551. */
  58552. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  58553. /**
  58554. * optional UI options. This can be used among other to change session mode and reference space type
  58555. */
  58556. uiOptions?: WebXREnterExitUIOptions;
  58557. /**
  58558. * When loading teleportation and pointer select, use stable versions instead of latest.
  58559. */
  58560. useStablePlugins?: boolean;
  58561. /**
  58562. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  58563. */
  58564. renderingGroupId?: number;
  58565. /**
  58566. * A list of optional features to init the session with
  58567. * If set to true, all features we support will be added
  58568. */
  58569. optionalFeatures?: boolean | string[];
  58570. }
  58571. /**
  58572. * Default experience which provides a similar setup to the previous webVRExperience
  58573. */
  58574. export class WebXRDefaultExperience {
  58575. /**
  58576. * Base experience
  58577. */
  58578. baseExperience: WebXRExperienceHelper;
  58579. /**
  58580. * Enables ui for entering/exiting xr
  58581. */
  58582. enterExitUI: WebXREnterExitUI;
  58583. /**
  58584. * Input experience extension
  58585. */
  58586. input: WebXRInput;
  58587. /**
  58588. * Enables laser pointer and selection
  58589. */
  58590. pointerSelection: WebXRControllerPointerSelection;
  58591. /**
  58592. * Default target xr should render to
  58593. */
  58594. renderTarget: WebXRRenderTarget;
  58595. /**
  58596. * Enables teleportation
  58597. */
  58598. teleportation: WebXRMotionControllerTeleportation;
  58599. private constructor();
  58600. /**
  58601. * Creates the default xr experience
  58602. * @param scene scene
  58603. * @param options options for basic configuration
  58604. * @returns resulting WebXRDefaultExperience
  58605. */
  58606. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58607. /**
  58608. * DIsposes of the experience helper
  58609. */
  58610. dispose(): void;
  58611. }
  58612. }
  58613. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  58614. import { Observable } from "babylonjs/Misc/observable";
  58615. import { Nullable } from "babylonjs/types";
  58616. import { Camera } from "babylonjs/Cameras/camera";
  58617. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  58618. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  58619. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  58620. import { Scene } from "babylonjs/scene";
  58621. import { Vector3 } from "babylonjs/Maths/math.vector";
  58622. import { Color3 } from "babylonjs/Maths/math.color";
  58623. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58625. import { Mesh } from "babylonjs/Meshes/mesh";
  58626. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  58627. import { EasingFunction } from "babylonjs/Animations/easing";
  58628. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  58629. import "babylonjs/Meshes/Builders/groundBuilder";
  58630. import "babylonjs/Meshes/Builders/torusBuilder";
  58631. import "babylonjs/Meshes/Builders/cylinderBuilder";
  58632. import "babylonjs/Gamepads/gamepadSceneComponent";
  58633. import "babylonjs/Animations/animatable";
  58634. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  58635. /**
  58636. * Options to modify the vr teleportation behavior.
  58637. */
  58638. export interface VRTeleportationOptions {
  58639. /**
  58640. * The name of the mesh which should be used as the teleportation floor. (default: null)
  58641. */
  58642. floorMeshName?: string;
  58643. /**
  58644. * A list of meshes to be used as the teleportation floor. (default: empty)
  58645. */
  58646. floorMeshes?: Mesh[];
  58647. /**
  58648. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  58649. */
  58650. teleportationMode?: number;
  58651. /**
  58652. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  58653. */
  58654. teleportationTime?: number;
  58655. /**
  58656. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  58657. */
  58658. teleportationSpeed?: number;
  58659. /**
  58660. * The easing function used in the animation or null for Linear. (default CircleEase)
  58661. */
  58662. easingFunction?: EasingFunction;
  58663. }
  58664. /**
  58665. * Options to modify the vr experience helper's behavior.
  58666. */
  58667. export interface VRExperienceHelperOptions extends WebVROptions {
  58668. /**
  58669. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  58670. */
  58671. createDeviceOrientationCamera?: boolean;
  58672. /**
  58673. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  58674. */
  58675. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  58676. /**
  58677. * Uses the main button on the controller to toggle the laser casted. (default: true)
  58678. */
  58679. laserToggle?: boolean;
  58680. /**
  58681. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  58682. */
  58683. floorMeshes?: Mesh[];
  58684. /**
  58685. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  58686. */
  58687. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  58688. /**
  58689. * Defines if WebXR should be used instead of WebVR (if available)
  58690. */
  58691. useXR?: boolean;
  58692. }
  58693. /**
  58694. * Event containing information after VR has been entered
  58695. */
  58696. export class OnAfterEnteringVRObservableEvent {
  58697. /**
  58698. * If entering vr was successful
  58699. */
  58700. success: boolean;
  58701. }
  58702. /**
  58703. * Helps to quickly add VR support to an existing scene.
  58704. * See https://doc.babylonjs.com/how_to/webvr_helper
  58705. */
  58706. export class VRExperienceHelper {
  58707. /** Options to modify the vr experience helper's behavior. */
  58708. webVROptions: VRExperienceHelperOptions;
  58709. private _scene;
  58710. private _position;
  58711. private _btnVR;
  58712. private _btnVRDisplayed;
  58713. private _webVRsupported;
  58714. private _webVRready;
  58715. private _webVRrequesting;
  58716. private _webVRpresenting;
  58717. private _hasEnteredVR;
  58718. private _fullscreenVRpresenting;
  58719. private _inputElement;
  58720. private _webVRCamera;
  58721. private _vrDeviceOrientationCamera;
  58722. private _deviceOrientationCamera;
  58723. private _existingCamera;
  58724. private _onKeyDown;
  58725. private _onVrDisplayPresentChange;
  58726. private _onVRDisplayChanged;
  58727. private _onVRRequestPresentStart;
  58728. private _onVRRequestPresentComplete;
  58729. /**
  58730. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  58731. */
  58732. enableGazeEvenWhenNoPointerLock: boolean;
  58733. /**
  58734. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  58735. */
  58736. exitVROnDoubleTap: boolean;
  58737. /**
  58738. * Observable raised right before entering VR.
  58739. */
  58740. onEnteringVRObservable: Observable<VRExperienceHelper>;
  58741. /**
  58742. * Observable raised when entering VR has completed.
  58743. */
  58744. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  58745. /**
  58746. * Observable raised when exiting VR.
  58747. */
  58748. onExitingVRObservable: Observable<VRExperienceHelper>;
  58749. /**
  58750. * Observable raised when controller mesh is loaded.
  58751. */
  58752. onControllerMeshLoadedObservable: Observable<WebVRController>;
  58753. /** Return this.onEnteringVRObservable
  58754. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  58755. */
  58756. get onEnteringVR(): Observable<VRExperienceHelper>;
  58757. /** Return this.onExitingVRObservable
  58758. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  58759. */
  58760. get onExitingVR(): Observable<VRExperienceHelper>;
  58761. /** Return this.onControllerMeshLoadedObservable
  58762. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  58763. */
  58764. get onControllerMeshLoaded(): Observable<WebVRController>;
  58765. private _rayLength;
  58766. private _useCustomVRButton;
  58767. private _teleportationRequested;
  58768. private _teleportActive;
  58769. private _floorMeshName;
  58770. private _floorMeshesCollection;
  58771. private _teleportationMode;
  58772. private _teleportationTime;
  58773. private _teleportationSpeed;
  58774. private _teleportationEasing;
  58775. private _rotationAllowed;
  58776. private _teleportBackwardsVector;
  58777. private _teleportationTarget;
  58778. private _isDefaultTeleportationTarget;
  58779. private _postProcessMove;
  58780. private _teleportationFillColor;
  58781. private _teleportationBorderColor;
  58782. private _rotationAngle;
  58783. private _haloCenter;
  58784. private _cameraGazer;
  58785. private _padSensibilityUp;
  58786. private _padSensibilityDown;
  58787. private _leftController;
  58788. private _rightController;
  58789. private _gazeColor;
  58790. private _laserColor;
  58791. private _pickedLaserColor;
  58792. private _pickedGazeColor;
  58793. /**
  58794. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  58795. */
  58796. onNewMeshSelected: Observable<AbstractMesh>;
  58797. /**
  58798. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  58799. * This observable will provide the mesh and the controller used to select the mesh
  58800. */
  58801. onMeshSelectedWithController: Observable<{
  58802. mesh: AbstractMesh;
  58803. controller: WebVRController;
  58804. }>;
  58805. /**
  58806. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  58807. */
  58808. onNewMeshPicked: Observable<PickingInfo>;
  58809. private _circleEase;
  58810. /**
  58811. * Observable raised before camera teleportation
  58812. */
  58813. onBeforeCameraTeleport: Observable<Vector3>;
  58814. /**
  58815. * Observable raised after camera teleportation
  58816. */
  58817. onAfterCameraTeleport: Observable<Vector3>;
  58818. /**
  58819. * Observable raised when current selected mesh gets unselected
  58820. */
  58821. onSelectedMeshUnselected: Observable<AbstractMesh>;
  58822. private _raySelectionPredicate;
  58823. /**
  58824. * To be optionaly changed by user to define custom ray selection
  58825. */
  58826. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  58827. /**
  58828. * To be optionaly changed by user to define custom selection logic (after ray selection)
  58829. */
  58830. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58831. /**
  58832. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  58833. */
  58834. teleportationEnabled: boolean;
  58835. private _defaultHeight;
  58836. private _teleportationInitialized;
  58837. private _interactionsEnabled;
  58838. private _interactionsRequested;
  58839. private _displayGaze;
  58840. private _displayLaserPointer;
  58841. /**
  58842. * The mesh used to display where the user is going to teleport.
  58843. */
  58844. get teleportationTarget(): Mesh;
  58845. /**
  58846. * Sets the mesh to be used to display where the user is going to teleport.
  58847. */
  58848. set teleportationTarget(value: Mesh);
  58849. /**
  58850. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  58851. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  58852. * See https://doc.babylonjs.com/resources/baking_transformations
  58853. */
  58854. get gazeTrackerMesh(): Mesh;
  58855. set gazeTrackerMesh(value: Mesh);
  58856. /**
  58857. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  58858. */
  58859. updateGazeTrackerScale: boolean;
  58860. /**
  58861. * If the gaze trackers color should be updated when selecting meshes
  58862. */
  58863. updateGazeTrackerColor: boolean;
  58864. /**
  58865. * If the controller laser color should be updated when selecting meshes
  58866. */
  58867. updateControllerLaserColor: boolean;
  58868. /**
  58869. * The gaze tracking mesh corresponding to the left controller
  58870. */
  58871. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  58872. /**
  58873. * The gaze tracking mesh corresponding to the right controller
  58874. */
  58875. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  58876. /**
  58877. * If the ray of the gaze should be displayed.
  58878. */
  58879. get displayGaze(): boolean;
  58880. /**
  58881. * Sets if the ray of the gaze should be displayed.
  58882. */
  58883. set displayGaze(value: boolean);
  58884. /**
  58885. * If the ray of the LaserPointer should be displayed.
  58886. */
  58887. get displayLaserPointer(): boolean;
  58888. /**
  58889. * Sets if the ray of the LaserPointer should be displayed.
  58890. */
  58891. set displayLaserPointer(value: boolean);
  58892. /**
  58893. * The deviceOrientationCamera used as the camera when not in VR.
  58894. */
  58895. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  58896. /**
  58897. * Based on the current WebVR support, returns the current VR camera used.
  58898. */
  58899. get currentVRCamera(): Nullable<Camera>;
  58900. /**
  58901. * The webVRCamera which is used when in VR.
  58902. */
  58903. get webVRCamera(): WebVRFreeCamera;
  58904. /**
  58905. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  58906. */
  58907. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  58908. /**
  58909. * The html button that is used to trigger entering into VR.
  58910. */
  58911. get vrButton(): Nullable<HTMLButtonElement>;
  58912. private get _teleportationRequestInitiated();
  58913. /**
  58914. * Defines whether or not Pointer lock should be requested when switching to
  58915. * full screen.
  58916. */
  58917. requestPointerLockOnFullScreen: boolean;
  58918. /**
  58919. * If asking to force XR, this will be populated with the default xr experience
  58920. */
  58921. xr: WebXRDefaultExperience;
  58922. /**
  58923. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  58924. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  58925. */
  58926. xrTestDone: boolean;
  58927. /**
  58928. * Instantiates a VRExperienceHelper.
  58929. * Helps to quickly add VR support to an existing scene.
  58930. * @param scene The scene the VRExperienceHelper belongs to.
  58931. * @param webVROptions Options to modify the vr experience helper's behavior.
  58932. */
  58933. constructor(scene: Scene,
  58934. /** Options to modify the vr experience helper's behavior. */
  58935. webVROptions?: VRExperienceHelperOptions);
  58936. private completeVRInit;
  58937. private _onDefaultMeshLoaded;
  58938. private _onResize;
  58939. private _onFullscreenChange;
  58940. /**
  58941. * Gets a value indicating if we are currently in VR mode.
  58942. */
  58943. get isInVRMode(): boolean;
  58944. private onVrDisplayPresentChange;
  58945. private onVRDisplayChanged;
  58946. private moveButtonToBottomRight;
  58947. private displayVRButton;
  58948. private updateButtonVisibility;
  58949. private _cachedAngularSensibility;
  58950. /**
  58951. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  58952. * Otherwise, will use the fullscreen API.
  58953. */
  58954. enterVR(): void;
  58955. /**
  58956. * Attempt to exit VR, or fullscreen.
  58957. */
  58958. exitVR(): void;
  58959. /**
  58960. * The position of the vr experience helper.
  58961. */
  58962. get position(): Vector3;
  58963. /**
  58964. * Sets the position of the vr experience helper.
  58965. */
  58966. set position(value: Vector3);
  58967. /**
  58968. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  58969. */
  58970. enableInteractions(): void;
  58971. private get _noControllerIsActive();
  58972. private beforeRender;
  58973. private _isTeleportationFloor;
  58974. /**
  58975. * Adds a floor mesh to be used for teleportation.
  58976. * @param floorMesh the mesh to be used for teleportation.
  58977. */
  58978. addFloorMesh(floorMesh: Mesh): void;
  58979. /**
  58980. * Removes a floor mesh from being used for teleportation.
  58981. * @param floorMesh the mesh to be removed.
  58982. */
  58983. removeFloorMesh(floorMesh: Mesh): void;
  58984. /**
  58985. * Enables interactions and teleportation using the VR controllers and gaze.
  58986. * @param vrTeleportationOptions options to modify teleportation behavior.
  58987. */
  58988. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  58989. private _onNewGamepadConnected;
  58990. private _tryEnableInteractionOnController;
  58991. private _onNewGamepadDisconnected;
  58992. private _enableInteractionOnController;
  58993. private _checkTeleportWithRay;
  58994. private _checkRotate;
  58995. private _checkTeleportBackwards;
  58996. private _enableTeleportationOnController;
  58997. private _createTeleportationCircles;
  58998. private _displayTeleportationTarget;
  58999. private _hideTeleportationTarget;
  59000. private _rotateCamera;
  59001. private _moveTeleportationSelectorTo;
  59002. private _workingVector;
  59003. private _workingQuaternion;
  59004. private _workingMatrix;
  59005. /**
  59006. * Time Constant Teleportation Mode
  59007. */
  59008. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  59009. /**
  59010. * Speed Constant Teleportation Mode
  59011. */
  59012. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  59013. /**
  59014. * Teleports the users feet to the desired location
  59015. * @param location The location where the user's feet should be placed
  59016. */
  59017. teleportCamera(location: Vector3): void;
  59018. private _convertNormalToDirectionOfRay;
  59019. private _castRayAndSelectObject;
  59020. private _notifySelectedMeshUnselected;
  59021. /**
  59022. * Permanently set new colors for the laser pointer
  59023. * @param color the new laser color
  59024. * @param pickedColor the new laser color when picked mesh detected
  59025. */
  59026. setLaserColor(color: Color3, pickedColor?: Color3): void;
  59027. /**
  59028. * Set lighting enabled / disabled on the laser pointer of both controllers
  59029. * @param enabled should the lighting be enabled on the laser pointer
  59030. */
  59031. setLaserLightingState(enabled?: boolean): void;
  59032. /**
  59033. * Permanently set new colors for the gaze pointer
  59034. * @param color the new gaze color
  59035. * @param pickedColor the new gaze color when picked mesh detected
  59036. */
  59037. setGazeColor(color: Color3, pickedColor?: Color3): void;
  59038. /**
  59039. * Sets the color of the laser ray from the vr controllers.
  59040. * @param color new color for the ray.
  59041. */
  59042. changeLaserColor(color: Color3): void;
  59043. /**
  59044. * Sets the color of the ray from the vr headsets gaze.
  59045. * @param color new color for the ray.
  59046. */
  59047. changeGazeColor(color: Color3): void;
  59048. /**
  59049. * Exits VR and disposes of the vr experience helper
  59050. */
  59051. dispose(): void;
  59052. /**
  59053. * Gets the name of the VRExperienceHelper class
  59054. * @returns "VRExperienceHelper"
  59055. */
  59056. getClassName(): string;
  59057. }
  59058. }
  59059. declare module "babylonjs/Cameras/VR/index" {
  59060. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  59061. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  59062. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  59063. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  59064. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  59065. export * from "babylonjs/Cameras/VR/webVRCamera";
  59066. }
  59067. declare module "babylonjs/Cameras/RigModes/index" {
  59068. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  59069. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  59070. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  59071. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  59072. }
  59073. declare module "babylonjs/Cameras/index" {
  59074. export * from "babylonjs/Cameras/Inputs/index";
  59075. export * from "babylonjs/Cameras/cameraInputsManager";
  59076. export * from "babylonjs/Cameras/camera";
  59077. export * from "babylonjs/Cameras/targetCamera";
  59078. export * from "babylonjs/Cameras/freeCamera";
  59079. export * from "babylonjs/Cameras/freeCameraInputsManager";
  59080. export * from "babylonjs/Cameras/touchCamera";
  59081. export * from "babylonjs/Cameras/arcRotateCamera";
  59082. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  59083. export * from "babylonjs/Cameras/deviceOrientationCamera";
  59084. export * from "babylonjs/Cameras/flyCamera";
  59085. export * from "babylonjs/Cameras/flyCameraInputsManager";
  59086. export * from "babylonjs/Cameras/followCamera";
  59087. export * from "babylonjs/Cameras/followCameraInputsManager";
  59088. export * from "babylonjs/Cameras/gamepadCamera";
  59089. export * from "babylonjs/Cameras/Stereoscopic/index";
  59090. export * from "babylonjs/Cameras/universalCamera";
  59091. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  59092. export * from "babylonjs/Cameras/VR/index";
  59093. export * from "babylonjs/Cameras/RigModes/index";
  59094. }
  59095. declare module "babylonjs/Collisions/index" {
  59096. export * from "babylonjs/Collisions/collider";
  59097. export * from "babylonjs/Collisions/collisionCoordinator";
  59098. export * from "babylonjs/Collisions/pickingInfo";
  59099. export * from "babylonjs/Collisions/intersectionInfo";
  59100. export * from "babylonjs/Collisions/meshCollisionData";
  59101. }
  59102. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  59103. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  59104. import { Vector3 } from "babylonjs/Maths/math.vector";
  59105. import { Ray } from "babylonjs/Culling/ray";
  59106. import { Plane } from "babylonjs/Maths/math.plane";
  59107. /**
  59108. * Contains an array of blocks representing the octree
  59109. */
  59110. export interface IOctreeContainer<T> {
  59111. /**
  59112. * Blocks within the octree
  59113. */
  59114. blocks: Array<OctreeBlock<T>>;
  59115. }
  59116. /**
  59117. * Class used to store a cell in an octree
  59118. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59119. */
  59120. export class OctreeBlock<T> {
  59121. /**
  59122. * Gets the content of the current block
  59123. */
  59124. entries: T[];
  59125. /**
  59126. * Gets the list of block children
  59127. */
  59128. blocks: Array<OctreeBlock<T>>;
  59129. private _depth;
  59130. private _maxDepth;
  59131. private _capacity;
  59132. private _minPoint;
  59133. private _maxPoint;
  59134. private _boundingVectors;
  59135. private _creationFunc;
  59136. /**
  59137. * Creates a new block
  59138. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  59139. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  59140. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  59141. * @param depth defines the current depth of this block in the octree
  59142. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  59143. * @param creationFunc defines a callback to call when an element is added to the block
  59144. */
  59145. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  59146. /**
  59147. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  59148. */
  59149. get capacity(): number;
  59150. /**
  59151. * Gets the minimum vector (in world space) of the block's bounding box
  59152. */
  59153. get minPoint(): Vector3;
  59154. /**
  59155. * Gets the maximum vector (in world space) of the block's bounding box
  59156. */
  59157. get maxPoint(): Vector3;
  59158. /**
  59159. * Add a new element to this block
  59160. * @param entry defines the element to add
  59161. */
  59162. addEntry(entry: T): void;
  59163. /**
  59164. * Remove an element from this block
  59165. * @param entry defines the element to remove
  59166. */
  59167. removeEntry(entry: T): void;
  59168. /**
  59169. * Add an array of elements to this block
  59170. * @param entries defines the array of elements to add
  59171. */
  59172. addEntries(entries: T[]): void;
  59173. /**
  59174. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  59175. * @param frustumPlanes defines the frustum planes to test
  59176. * @param selection defines the array to store current content if selection is positive
  59177. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59178. */
  59179. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  59180. /**
  59181. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  59182. * @param sphereCenter defines the bounding sphere center
  59183. * @param sphereRadius defines the bounding sphere radius
  59184. * @param selection defines the array to store current content if selection is positive
  59185. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59186. */
  59187. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  59188. /**
  59189. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  59190. * @param ray defines the ray to test with
  59191. * @param selection defines the array to store current content if selection is positive
  59192. */
  59193. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  59194. /**
  59195. * Subdivide the content into child blocks (this block will then be empty)
  59196. */
  59197. createInnerBlocks(): void;
  59198. /**
  59199. * @hidden
  59200. */
  59201. static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  59202. }
  59203. }
  59204. declare module "babylonjs/Culling/Octrees/octree" {
  59205. import { SmartArray } from "babylonjs/Misc/smartArray";
  59206. import { Vector3 } from "babylonjs/Maths/math.vector";
  59207. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59209. import { Ray } from "babylonjs/Culling/ray";
  59210. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  59211. import { Plane } from "babylonjs/Maths/math.plane";
  59212. /**
  59213. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  59214. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59215. */
  59216. export class Octree<T> {
  59217. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  59218. maxDepth: number;
  59219. /**
  59220. * Blocks within the octree containing objects
  59221. */
  59222. blocks: Array<OctreeBlock<T>>;
  59223. /**
  59224. * Content stored in the octree
  59225. */
  59226. dynamicContent: T[];
  59227. private _maxBlockCapacity;
  59228. private _selectionContent;
  59229. private _creationFunc;
  59230. /**
  59231. * Creates a octree
  59232. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59233. * @param creationFunc function to be used to instatiate the octree
  59234. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  59235. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  59236. */
  59237. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  59238. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  59239. maxDepth?: number);
  59240. /**
  59241. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  59242. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  59243. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  59244. * @param entries meshes to be added to the octree blocks
  59245. */
  59246. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  59247. /**
  59248. * Adds a mesh to the octree
  59249. * @param entry Mesh to add to the octree
  59250. */
  59251. addMesh(entry: T): void;
  59252. /**
  59253. * Remove an element from the octree
  59254. * @param entry defines the element to remove
  59255. */
  59256. removeMesh(entry: T): void;
  59257. /**
  59258. * Selects an array of meshes within the frustum
  59259. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  59260. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  59261. * @returns array of meshes within the frustum
  59262. */
  59263. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  59264. /**
  59265. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  59266. * @param sphereCenter defines the bounding sphere center
  59267. * @param sphereRadius defines the bounding sphere radius
  59268. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59269. * @returns an array of objects that intersect the sphere
  59270. */
  59271. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  59272. /**
  59273. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  59274. * @param ray defines the ray to test with
  59275. * @returns array of intersected objects
  59276. */
  59277. intersectsRay(ray: Ray): SmartArray<T>;
  59278. /**
  59279. * Adds a mesh into the octree block if it intersects the block
  59280. */
  59281. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  59282. /**
  59283. * Adds a submesh into the octree block if it intersects the block
  59284. */
  59285. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  59286. }
  59287. }
  59288. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  59289. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  59290. import { Scene } from "babylonjs/scene";
  59291. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59293. import { Ray } from "babylonjs/Culling/ray";
  59294. import { Octree } from "babylonjs/Culling/Octrees/octree";
  59295. import { Collider } from "babylonjs/Collisions/collider";
  59296. module "babylonjs/scene" {
  59297. interface Scene {
  59298. /**
  59299. * @hidden
  59300. * Backing Filed
  59301. */
  59302. _selectionOctree: Octree<AbstractMesh>;
  59303. /**
  59304. * Gets the octree used to boost mesh selection (picking)
  59305. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59306. */
  59307. selectionOctree: Octree<AbstractMesh>;
  59308. /**
  59309. * Creates or updates the octree used to boost selection (picking)
  59310. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59311. * @param maxCapacity defines the maximum capacity per leaf
  59312. * @param maxDepth defines the maximum depth of the octree
  59313. * @returns an octree of AbstractMesh
  59314. */
  59315. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  59316. }
  59317. }
  59318. module "babylonjs/Meshes/abstractMesh" {
  59319. interface AbstractMesh {
  59320. /**
  59321. * @hidden
  59322. * Backing Field
  59323. */
  59324. _submeshesOctree: Octree<SubMesh>;
  59325. /**
  59326. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  59327. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  59328. * @param maxCapacity defines the maximum size of each block (64 by default)
  59329. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  59330. * @returns the new octree
  59331. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  59332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59333. */
  59334. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  59335. }
  59336. }
  59337. /**
  59338. * Defines the octree scene component responsible to manage any octrees
  59339. * in a given scene.
  59340. */
  59341. export class OctreeSceneComponent {
  59342. /**
  59343. * The component name help to identify the component in the list of scene components.
  59344. */
  59345. readonly name: string;
  59346. /**
  59347. * The scene the component belongs to.
  59348. */
  59349. scene: Scene;
  59350. /**
  59351. * Indicates if the meshes have been checked to make sure they are isEnabled()
  59352. */
  59353. readonly checksIsEnabled: boolean;
  59354. /**
  59355. * Creates a new instance of the component for the given scene
  59356. * @param scene Defines the scene to register the component in
  59357. */
  59358. constructor(scene: Scene);
  59359. /**
  59360. * Registers the component in a given scene
  59361. */
  59362. register(): void;
  59363. /**
  59364. * Return the list of active meshes
  59365. * @returns the list of active meshes
  59366. */
  59367. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  59368. /**
  59369. * Return the list of active sub meshes
  59370. * @param mesh The mesh to get the candidates sub meshes from
  59371. * @returns the list of active sub meshes
  59372. */
  59373. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  59374. private _tempRay;
  59375. /**
  59376. * Return the list of sub meshes intersecting with a given local ray
  59377. * @param mesh defines the mesh to find the submesh for
  59378. * @param localRay defines the ray in local space
  59379. * @returns the list of intersecting sub meshes
  59380. */
  59381. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  59382. /**
  59383. * Return the list of sub meshes colliding with a collider
  59384. * @param mesh defines the mesh to find the submesh for
  59385. * @param collider defines the collider to evaluate the collision against
  59386. * @returns the list of colliding sub meshes
  59387. */
  59388. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  59389. /**
  59390. * Rebuilds the elements related to this component in case of
  59391. * context lost for instance.
  59392. */
  59393. rebuild(): void;
  59394. /**
  59395. * Disposes the component and the associated ressources.
  59396. */
  59397. dispose(): void;
  59398. }
  59399. }
  59400. declare module "babylonjs/Culling/Octrees/index" {
  59401. export * from "babylonjs/Culling/Octrees/octree";
  59402. export * from "babylonjs/Culling/Octrees/octreeBlock";
  59403. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  59404. }
  59405. declare module "babylonjs/Culling/index" {
  59406. export * from "babylonjs/Culling/boundingBox";
  59407. export * from "babylonjs/Culling/boundingInfo";
  59408. export * from "babylonjs/Culling/boundingSphere";
  59409. export * from "babylonjs/Culling/Octrees/index";
  59410. export * from "babylonjs/Culling/ray";
  59411. }
  59412. declare module "babylonjs/Gizmos/gizmo" {
  59413. import { Observer } from "babylonjs/Misc/observable";
  59414. import { Nullable } from "babylonjs/types";
  59415. import { IDisposable } from "babylonjs/scene";
  59416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59417. import { Mesh } from "babylonjs/Meshes/mesh";
  59418. import { Node } from "babylonjs/node";
  59419. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59420. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59421. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  59422. /**
  59423. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  59424. */
  59425. export interface GizmoAxisCache {
  59426. /** Mesh used to runder the Gizmo */
  59427. gizmoMeshes: Mesh[];
  59428. /** Mesh used to detect user interaction with Gizmo */
  59429. colliderMeshes: Mesh[];
  59430. /** Material used to inicate color of gizmo mesh */
  59431. material: StandardMaterial;
  59432. /** Material used to inicate hover state of the Gizmo */
  59433. hoverMaterial: StandardMaterial;
  59434. /** Material used to inicate disabled state of the Gizmo */
  59435. disableMaterial: StandardMaterial;
  59436. /** Used to indicate Active state of the Gizmo */
  59437. active: boolean;
  59438. }
  59439. /**
  59440. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  59441. */
  59442. export class Gizmo implements IDisposable {
  59443. /** The utility layer the gizmo will be added to */
  59444. gizmoLayer: UtilityLayerRenderer;
  59445. /**
  59446. * The root mesh of the gizmo
  59447. */
  59448. _rootMesh: Mesh;
  59449. private _attachedMesh;
  59450. private _attachedNode;
  59451. /**
  59452. * Ratio for the scale of the gizmo (Default: 1)
  59453. */
  59454. protected _scaleRatio: number;
  59455. /**
  59456. * boolean updated by pointermove when a gizmo mesh is hovered
  59457. */
  59458. protected _isHovered: boolean;
  59459. /**
  59460. * Ratio for the scale of the gizmo (Default: 1)
  59461. */
  59462. set scaleRatio(value: number);
  59463. get scaleRatio(): number;
  59464. /**
  59465. * True when the mouse pointer is hovered a gizmo mesh
  59466. */
  59467. get isHovered(): boolean;
  59468. /**
  59469. * If a custom mesh has been set (Default: false)
  59470. */
  59471. protected _customMeshSet: boolean;
  59472. /**
  59473. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  59474. * * When set, interactions will be enabled
  59475. */
  59476. get attachedMesh(): Nullable<AbstractMesh>;
  59477. set attachedMesh(value: Nullable<AbstractMesh>);
  59478. /**
  59479. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  59480. * * When set, interactions will be enabled
  59481. */
  59482. get attachedNode(): Nullable<Node>;
  59483. set attachedNode(value: Nullable<Node>);
  59484. /**
  59485. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59486. * @param mesh The mesh to replace the default mesh of the gizmo
  59487. */
  59488. setCustomMesh(mesh: Mesh): void;
  59489. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  59490. /**
  59491. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  59492. */
  59493. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59494. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59495. /**
  59496. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  59497. */
  59498. updateGizmoPositionToMatchAttachedMesh: boolean;
  59499. /**
  59500. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  59501. */
  59502. updateScale: boolean;
  59503. protected _interactionsEnabled: boolean;
  59504. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59505. private _beforeRenderObserver;
  59506. private _tempQuaternion;
  59507. private _tempVector;
  59508. private _tempVector2;
  59509. private _tempMatrix1;
  59510. private _tempMatrix2;
  59511. private _rightHandtoLeftHandMatrix;
  59512. /**
  59513. * Creates a gizmo
  59514. * @param gizmoLayer The utility layer the gizmo will be added to
  59515. */
  59516. constructor(
  59517. /** The utility layer the gizmo will be added to */
  59518. gizmoLayer?: UtilityLayerRenderer);
  59519. /**
  59520. * Updates the gizmo to match the attached mesh's position/rotation
  59521. */
  59522. protected _update(): void;
  59523. /**
  59524. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  59525. * @param value Node, TransformNode or mesh
  59526. */
  59527. protected _matrixChanged(): void;
  59528. /**
  59529. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  59530. * @param gizmoLayer The utility layer the gizmo will be added to
  59531. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  59532. * @returns {Observer<PointerInfo>} pointerObserver
  59533. */
  59534. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  59535. /**
  59536. * Disposes of the gizmo
  59537. */
  59538. dispose(): void;
  59539. }
  59540. }
  59541. declare module "babylonjs/Gizmos/planeDragGizmo" {
  59542. import { Observable } from "babylonjs/Misc/observable";
  59543. import { Nullable } from "babylonjs/types";
  59544. import { Vector3 } from "babylonjs/Maths/math.vector";
  59545. import { Color3 } from "babylonjs/Maths/math.color";
  59546. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59547. import { Node } from "babylonjs/node";
  59548. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59549. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59550. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59551. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59552. import { Scene } from "babylonjs/scene";
  59553. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59554. /**
  59555. * Single plane drag gizmo
  59556. */
  59557. export class PlaneDragGizmo extends Gizmo {
  59558. /**
  59559. * Drag behavior responsible for the gizmos dragging interactions
  59560. */
  59561. dragBehavior: PointerDragBehavior;
  59562. private _pointerObserver;
  59563. /**
  59564. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59565. */
  59566. snapDistance: number;
  59567. /**
  59568. * Event that fires each time the gizmo snaps to a new location.
  59569. * * snapDistance is the the change in distance
  59570. */
  59571. onSnapObservable: Observable<{
  59572. snapDistance: number;
  59573. }>;
  59574. private _gizmoMesh;
  59575. private _coloredMaterial;
  59576. private _hoverMaterial;
  59577. private _disableMaterial;
  59578. private _isEnabled;
  59579. private _parent;
  59580. private _dragging;
  59581. /** @hidden */
  59582. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  59583. /**
  59584. * Creates a PlaneDragGizmo
  59585. * @param gizmoLayer The utility layer the gizmo will be added to
  59586. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  59587. * @param color The color of the gizmo
  59588. */
  59589. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  59590. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59591. /**
  59592. * If the gizmo is enabled
  59593. */
  59594. set isEnabled(value: boolean);
  59595. get isEnabled(): boolean;
  59596. /**
  59597. * Disposes of the gizmo
  59598. */
  59599. dispose(): void;
  59600. }
  59601. }
  59602. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59603. import { Observable } from "babylonjs/Misc/observable";
  59604. import { Nullable } from "babylonjs/types";
  59605. import { Vector3 } from "babylonjs/Maths/math.vector";
  59606. import { Color3 } from "babylonjs/Maths/math.color";
  59607. import "babylonjs/Meshes/Builders/linesBuilder";
  59608. import { Node } from "babylonjs/node";
  59609. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59610. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59611. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59612. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59613. /**
  59614. * Single plane rotation gizmo
  59615. */
  59616. export class PlaneRotationGizmo extends Gizmo {
  59617. /**
  59618. * Drag behavior responsible for the gizmos dragging interactions
  59619. */
  59620. dragBehavior: PointerDragBehavior;
  59621. private _pointerObserver;
  59622. /**
  59623. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59624. */
  59625. snapDistance: number;
  59626. /**
  59627. * Event that fires each time the gizmo snaps to a new location.
  59628. * * snapDistance is the the change in distance
  59629. */
  59630. onSnapObservable: Observable<{
  59631. snapDistance: number;
  59632. }>;
  59633. private _isEnabled;
  59634. private _parent;
  59635. private _coloredMaterial;
  59636. private _hoverMaterial;
  59637. private _disableMaterial;
  59638. private _gizmoMesh;
  59639. private _rotationCircle;
  59640. private _dragging;
  59641. private static _CircleConstants;
  59642. /**
  59643. * Creates a PlaneRotationGizmo
  59644. * @param gizmoLayer The utility layer the gizmo will be added to
  59645. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59646. * @param color The color of the gizmo
  59647. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59648. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59649. * @param thickness display gizmo axis thickness
  59650. */
  59651. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59652. /** Create Geometry for Gizmo */
  59653. private _createGizmoMesh;
  59654. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59655. private setupRotationCircle;
  59656. private updateRotationPath;
  59657. private updateRotationCircle;
  59658. /**
  59659. * If the gizmo is enabled
  59660. */
  59661. set isEnabled(value: boolean);
  59662. get isEnabled(): boolean;
  59663. /**
  59664. * Disposes of the gizmo
  59665. */
  59666. dispose(): void;
  59667. }
  59668. }
  59669. declare module "babylonjs/Gizmos/rotationGizmo" {
  59670. import { Observable } from "babylonjs/Misc/observable";
  59671. import { Nullable } from "babylonjs/types";
  59672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59673. import { Mesh } from "babylonjs/Meshes/mesh";
  59674. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59675. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59676. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59677. import { Node } from "babylonjs/node";
  59678. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59679. /**
  59680. * Gizmo that enables rotating a mesh along 3 axis
  59681. */
  59682. export class RotationGizmo extends Gizmo {
  59683. /**
  59684. * Internal gizmo used for interactions on the x axis
  59685. */
  59686. xGizmo: PlaneRotationGizmo;
  59687. /**
  59688. * Internal gizmo used for interactions on the y axis
  59689. */
  59690. yGizmo: PlaneRotationGizmo;
  59691. /**
  59692. * Internal gizmo used for interactions on the z axis
  59693. */
  59694. zGizmo: PlaneRotationGizmo;
  59695. /** Fires an event when any of it's sub gizmos are dragged */
  59696. onDragStartObservable: Observable<unknown>;
  59697. /** Fires an event when any of it's sub gizmos are released from dragging */
  59698. onDragEndObservable: Observable<unknown>;
  59699. private _meshAttached;
  59700. private _nodeAttached;
  59701. private _observables;
  59702. /** Node Caching for quick lookup */
  59703. private _gizmoAxisCache;
  59704. get attachedMesh(): Nullable<AbstractMesh>;
  59705. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59706. get attachedNode(): Nullable<Node>;
  59707. set attachedNode(node: Nullable<Node>);
  59708. protected _checkBillboardTransform(): void;
  59709. /**
  59710. * True when the mouse pointer is hovering a gizmo mesh
  59711. */
  59712. get isHovered(): boolean;
  59713. /**
  59714. * Creates a RotationGizmo
  59715. * @param gizmoLayer The utility layer the gizmo will be added to
  59716. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59717. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59718. * @param thickness display gizmo axis thickness
  59719. */
  59720. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  59721. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59722. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59723. /**
  59724. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59725. */
  59726. set snapDistance(value: number);
  59727. get snapDistance(): number;
  59728. /**
  59729. * Ratio for the scale of the gizmo (Default: 1)
  59730. */
  59731. set scaleRatio(value: number);
  59732. get scaleRatio(): number;
  59733. /**
  59734. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59735. * @param mesh Axis gizmo mesh
  59736. * @param cache Gizmo axis definition used for reactive gizmo UI
  59737. */
  59738. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59739. /**
  59740. * Disposes of the gizmo
  59741. */
  59742. dispose(): void;
  59743. /**
  59744. * CustomMeshes are not supported by this gizmo
  59745. * @param mesh The mesh to replace the default mesh of the gizmo
  59746. */
  59747. setCustomMesh(mesh: Mesh): void;
  59748. }
  59749. }
  59750. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59751. import { Scene } from "babylonjs/scene";
  59752. import { Vector4 } from "babylonjs/Maths/math.vector";
  59753. import { Color4 } from "babylonjs/Maths/math.color";
  59754. import { Mesh } from "babylonjs/Meshes/mesh";
  59755. import { Nullable } from "babylonjs/types";
  59756. /**
  59757. * Class containing static functions to help procedurally build meshes
  59758. */
  59759. export class PolyhedronBuilder {
  59760. /**
  59761. * Creates a polyhedron mesh
  59762. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  59763. * * The parameter `size` (positive float, default 1) sets the polygon size
  59764. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59765. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  59766. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  59767. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  59768. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59769. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  59770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59773. * @param name defines the name of the mesh
  59774. * @param options defines the options used to create the mesh
  59775. * @param scene defines the hosting scene
  59776. * @returns the polyhedron mesh
  59777. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59778. */
  59779. static CreatePolyhedron(name: string, options: {
  59780. type?: number;
  59781. size?: number;
  59782. sizeX?: number;
  59783. sizeY?: number;
  59784. sizeZ?: number;
  59785. custom?: any;
  59786. faceUV?: Vector4[];
  59787. faceColors?: Color4[];
  59788. flat?: boolean;
  59789. updatable?: boolean;
  59790. sideOrientation?: number;
  59791. frontUVs?: Vector4;
  59792. backUVs?: Vector4;
  59793. }, scene?: Nullable<Scene>): Mesh;
  59794. }
  59795. }
  59796. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  59797. import { Nullable } from "babylonjs/types";
  59798. import { Scene } from "babylonjs/scene";
  59799. import { Vector4 } from "babylonjs/Maths/math.vector";
  59800. import { Color4 } from "babylonjs/Maths/math.color";
  59801. import { Mesh } from "babylonjs/Meshes/mesh";
  59802. /**
  59803. * Class containing static functions to help procedurally build meshes
  59804. */
  59805. export class BoxBuilder {
  59806. /**
  59807. * Creates a box mesh
  59808. * * The parameter `size` sets the size (float) of each box side (default 1)
  59809. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59810. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  59811. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59815. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59816. * @param name defines the name of the mesh
  59817. * @param options defines the options used to create the mesh
  59818. * @param scene defines the hosting scene
  59819. * @returns the box mesh
  59820. */
  59821. static CreateBox(name: string, options: {
  59822. size?: number;
  59823. width?: number;
  59824. height?: number;
  59825. depth?: number;
  59826. faceUV?: Vector4[];
  59827. faceColors?: Color4[];
  59828. sideOrientation?: number;
  59829. frontUVs?: Vector4;
  59830. backUVs?: Vector4;
  59831. wrap?: boolean;
  59832. topBaseAt?: number;
  59833. bottomBaseAt?: number;
  59834. updatable?: boolean;
  59835. }, scene?: Nullable<Scene>): Mesh;
  59836. }
  59837. }
  59838. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59839. import { Observable } from "babylonjs/Misc/observable";
  59840. import { Nullable } from "babylonjs/types";
  59841. import { Vector3 } from "babylonjs/Maths/math.vector";
  59842. import { Node } from "babylonjs/node";
  59843. import { Mesh } from "babylonjs/Meshes/mesh";
  59844. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59845. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59846. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59847. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59848. import { Color3 } from "babylonjs/Maths/math.color";
  59849. /**
  59850. * Single axis scale gizmo
  59851. */
  59852. export class AxisScaleGizmo extends Gizmo {
  59853. /**
  59854. * Drag behavior responsible for the gizmos dragging interactions
  59855. */
  59856. dragBehavior: PointerDragBehavior;
  59857. private _pointerObserver;
  59858. /**
  59859. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59860. */
  59861. snapDistance: number;
  59862. /**
  59863. * Event that fires each time the gizmo snaps to a new location.
  59864. * * snapDistance is the the change in distance
  59865. */
  59866. onSnapObservable: Observable<{
  59867. snapDistance: number;
  59868. }>;
  59869. /**
  59870. * If the scaling operation should be done on all axis (default: false)
  59871. */
  59872. uniformScaling: boolean;
  59873. /**
  59874. * Custom sensitivity value for the drag strength
  59875. */
  59876. sensitivity: number;
  59877. private _isEnabled;
  59878. private _parent;
  59879. private _gizmoMesh;
  59880. private _coloredMaterial;
  59881. private _hoverMaterial;
  59882. private _disableMaterial;
  59883. private _dragging;
  59884. private _tmpVector;
  59885. private _tmpMatrix;
  59886. private _tmpMatrix2;
  59887. /**
  59888. * Creates an AxisScaleGizmo
  59889. * @param gizmoLayer The utility layer the gizmo will be added to
  59890. * @param dragAxis The axis which the gizmo will be able to scale on
  59891. * @param color The color of the gizmo
  59892. * @param thickness display gizmo axis thickness
  59893. */
  59894. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59895. /** Create Geometry for Gizmo */
  59896. private _createGizmoMesh;
  59897. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59898. /**
  59899. * If the gizmo is enabled
  59900. */
  59901. set isEnabled(value: boolean);
  59902. get isEnabled(): boolean;
  59903. /**
  59904. * Disposes of the gizmo
  59905. */
  59906. dispose(): void;
  59907. /**
  59908. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59909. * @param mesh The mesh to replace the default mesh of the gizmo
  59910. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59911. */
  59912. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59913. }
  59914. }
  59915. declare module "babylonjs/Gizmos/scaleGizmo" {
  59916. import { Observable } from "babylonjs/Misc/observable";
  59917. import { Nullable } from "babylonjs/types";
  59918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59919. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59920. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59921. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59922. import { Mesh } from "babylonjs/Meshes/mesh";
  59923. import { Node } from "babylonjs/node";
  59924. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59925. /**
  59926. * Gizmo that enables scaling a mesh along 3 axis
  59927. */
  59928. export class ScaleGizmo extends Gizmo {
  59929. /**
  59930. * Internal gizmo used for interactions on the x axis
  59931. */
  59932. xGizmo: AxisScaleGizmo;
  59933. /**
  59934. * Internal gizmo used for interactions on the y axis
  59935. */
  59936. yGizmo: AxisScaleGizmo;
  59937. /**
  59938. * Internal gizmo used for interactions on the z axis
  59939. */
  59940. zGizmo: AxisScaleGizmo;
  59941. /**
  59942. * Internal gizmo used to scale all axis equally
  59943. */
  59944. uniformScaleGizmo: AxisScaleGizmo;
  59945. private _meshAttached;
  59946. private _nodeAttached;
  59947. private _snapDistance;
  59948. private _uniformScalingMesh;
  59949. private _octahedron;
  59950. private _sensitivity;
  59951. private _coloredMaterial;
  59952. private _hoverMaterial;
  59953. private _disableMaterial;
  59954. private _observables;
  59955. /** Node Caching for quick lookup */
  59956. private _gizmoAxisCache;
  59957. /** Fires an event when any of it's sub gizmos are dragged */
  59958. onDragStartObservable: Observable<unknown>;
  59959. /** Fires an event when any of it's sub gizmos are released from dragging */
  59960. onDragEndObservable: Observable<unknown>;
  59961. get attachedMesh(): Nullable<AbstractMesh>;
  59962. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59963. get attachedNode(): Nullable<Node>;
  59964. set attachedNode(node: Nullable<Node>);
  59965. /**
  59966. * True when the mouse pointer is hovering a gizmo mesh
  59967. */
  59968. get isHovered(): boolean;
  59969. /**
  59970. * Creates a ScaleGizmo
  59971. * @param gizmoLayer The utility layer the gizmo will be added to
  59972. * @param thickness display gizmo axis thickness
  59973. */
  59974. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59975. /** Create Geometry for Gizmo */
  59976. private _createUniformScaleMesh;
  59977. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59978. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59979. /**
  59980. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59981. */
  59982. set snapDistance(value: number);
  59983. get snapDistance(): number;
  59984. /**
  59985. * Ratio for the scale of the gizmo (Default: 1)
  59986. */
  59987. set scaleRatio(value: number);
  59988. get scaleRatio(): number;
  59989. /**
  59990. * Sensitivity factor for dragging (Default: 1)
  59991. */
  59992. set sensitivity(value: number);
  59993. get sensitivity(): number;
  59994. /**
  59995. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59996. * @param mesh Axis gizmo mesh
  59997. * @param cache Gizmo axis definition used for reactive gizmo UI
  59998. */
  59999. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60000. /**
  60001. * Disposes of the gizmo
  60002. */
  60003. dispose(): void;
  60004. }
  60005. }
  60006. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  60007. import { Observable } from "babylonjs/Misc/observable";
  60008. import { Nullable } from "babylonjs/types";
  60009. import { Vector3 } from "babylonjs/Maths/math.vector";
  60010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60011. import { Mesh } from "babylonjs/Meshes/mesh";
  60012. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60013. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60014. import { Color3 } from "babylonjs/Maths/math.color";
  60015. import "babylonjs/Meshes/Builders/boxBuilder";
  60016. /**
  60017. * Bounding box gizmo
  60018. */
  60019. export class BoundingBoxGizmo extends Gizmo {
  60020. private _lineBoundingBox;
  60021. private _rotateSpheresParent;
  60022. private _scaleBoxesParent;
  60023. private _boundingDimensions;
  60024. private _renderObserver;
  60025. private _pointerObserver;
  60026. private _scaleDragSpeed;
  60027. private _tmpQuaternion;
  60028. private _tmpVector;
  60029. private _tmpRotationMatrix;
  60030. /**
  60031. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  60032. */
  60033. ignoreChildren: boolean;
  60034. /**
  60035. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  60036. */
  60037. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  60038. /**
  60039. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  60040. */
  60041. rotationSphereSize: number;
  60042. /**
  60043. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  60044. */
  60045. scaleBoxSize: number;
  60046. /**
  60047. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  60048. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  60049. */
  60050. fixedDragMeshScreenSize: boolean;
  60051. /**
  60052. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  60053. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  60054. */
  60055. fixedDragMeshBoundsSize: boolean;
  60056. /**
  60057. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  60058. */
  60059. fixedDragMeshScreenSizeDistanceFactor: number;
  60060. /**
  60061. * Fired when a rotation sphere or scale box is dragged
  60062. */
  60063. onDragStartObservable: Observable<{}>;
  60064. /**
  60065. * Fired when a scale box is dragged
  60066. */
  60067. onScaleBoxDragObservable: Observable<{}>;
  60068. /**
  60069. * Fired when a scale box drag is ended
  60070. */
  60071. onScaleBoxDragEndObservable: Observable<{}>;
  60072. /**
  60073. * Fired when a rotation sphere is dragged
  60074. */
  60075. onRotationSphereDragObservable: Observable<{}>;
  60076. /**
  60077. * Fired when a rotation sphere drag is ended
  60078. */
  60079. onRotationSphereDragEndObservable: Observable<{}>;
  60080. /**
  60081. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  60082. */
  60083. scalePivot: Nullable<Vector3>;
  60084. /**
  60085. * Mesh used as a pivot to rotate the attached node
  60086. */
  60087. private _anchorMesh;
  60088. private _existingMeshScale;
  60089. private _dragMesh;
  60090. private pointerDragBehavior;
  60091. private coloredMaterial;
  60092. private hoverColoredMaterial;
  60093. /**
  60094. * Sets the color of the bounding box gizmo
  60095. * @param color the color to set
  60096. */
  60097. setColor(color: Color3): void;
  60098. /**
  60099. * Creates an BoundingBoxGizmo
  60100. * @param gizmoLayer The utility layer the gizmo will be added to
  60101. * @param color The color of the gizmo
  60102. */
  60103. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  60104. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  60105. private _selectNode;
  60106. /**
  60107. * Updates the bounding box information for the Gizmo
  60108. */
  60109. updateBoundingBox(): void;
  60110. private _updateRotationSpheres;
  60111. private _updateScaleBoxes;
  60112. /**
  60113. * Enables rotation on the specified axis and disables rotation on the others
  60114. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  60115. */
  60116. setEnabledRotationAxis(axis: string): void;
  60117. /**
  60118. * Enables/disables scaling
  60119. * @param enable if scaling should be enabled
  60120. * @param homogeneousScaling defines if scaling should only be homogeneous
  60121. */
  60122. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  60123. private _updateDummy;
  60124. /**
  60125. * Enables a pointer drag behavior on the bounding box of the gizmo
  60126. */
  60127. enableDragBehavior(): void;
  60128. /**
  60129. * Disposes of the gizmo
  60130. */
  60131. dispose(): void;
  60132. /**
  60133. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  60134. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  60135. * @returns the bounding box mesh with the passed in mesh as a child
  60136. */
  60137. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  60138. /**
  60139. * CustomMeshes are not supported by this gizmo
  60140. * @param mesh The mesh to replace the default mesh of the gizmo
  60141. */
  60142. setCustomMesh(mesh: Mesh): void;
  60143. }
  60144. }
  60145. declare module "babylonjs/Gizmos/gizmoManager" {
  60146. import { Observable } from "babylonjs/Misc/observable";
  60147. import { Nullable } from "babylonjs/types";
  60148. import { Scene, IDisposable } from "babylonjs/scene";
  60149. import { Node } from "babylonjs/node";
  60150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60151. import { Mesh } from "babylonjs/Meshes/mesh";
  60152. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60153. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  60154. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60155. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  60156. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60157. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  60158. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  60159. /**
  60160. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  60161. */
  60162. export class GizmoManager implements IDisposable {
  60163. private scene;
  60164. /**
  60165. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  60166. */
  60167. gizmos: {
  60168. positionGizmo: Nullable<PositionGizmo>;
  60169. rotationGizmo: Nullable<RotationGizmo>;
  60170. scaleGizmo: Nullable<ScaleGizmo>;
  60171. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  60172. };
  60173. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  60174. clearGizmoOnEmptyPointerEvent: boolean;
  60175. /** Fires an event when the manager is attached to a mesh */
  60176. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  60177. /** Fires an event when the manager is attached to a node */
  60178. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  60179. private _gizmosEnabled;
  60180. private _pointerObservers;
  60181. private _attachedMesh;
  60182. private _attachedNode;
  60183. private _boundingBoxColor;
  60184. private _defaultUtilityLayer;
  60185. private _defaultKeepDepthUtilityLayer;
  60186. private _thickness;
  60187. /** Node Caching for quick lookup */
  60188. private _gizmoAxisCache;
  60189. /**
  60190. * When bounding box gizmo is enabled, this can be used to track drag/end events
  60191. */
  60192. boundingBoxDragBehavior: SixDofDragBehavior;
  60193. /**
  60194. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  60195. */
  60196. attachableMeshes: Nullable<Array<AbstractMesh>>;
  60197. /**
  60198. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  60199. */
  60200. attachableNodes: Nullable<Array<Node>>;
  60201. /**
  60202. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  60203. */
  60204. usePointerToAttachGizmos: boolean;
  60205. /**
  60206. * Utility layer that the bounding box gizmo belongs to
  60207. */
  60208. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  60209. /**
  60210. * Utility layer that all gizmos besides bounding box belong to
  60211. */
  60212. get utilityLayer(): UtilityLayerRenderer;
  60213. /**
  60214. * True when the mouse pointer is hovering a gizmo mesh
  60215. */
  60216. get isHovered(): boolean;
  60217. /**
  60218. * Instatiates a gizmo manager
  60219. * @param scene the scene to overlay the gizmos on top of
  60220. * @param thickness display gizmo axis thickness
  60221. * @param utilityLayer the layer where gizmos are rendered
  60222. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  60223. */
  60224. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  60225. /**
  60226. * Subscribes to pointer down events, for attaching and detaching mesh
  60227. * @param scene The sceme layer the observer will be added to
  60228. */
  60229. private _attachToMeshPointerObserver;
  60230. /**
  60231. * Attaches a set of gizmos to the specified mesh
  60232. * @param mesh The mesh the gizmo's should be attached to
  60233. */
  60234. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60235. /**
  60236. * Attaches a set of gizmos to the specified node
  60237. * @param node The node the gizmo's should be attached to
  60238. */
  60239. attachToNode(node: Nullable<Node>): void;
  60240. /**
  60241. * If the position gizmo is enabled
  60242. */
  60243. set positionGizmoEnabled(value: boolean);
  60244. get positionGizmoEnabled(): boolean;
  60245. /**
  60246. * If the rotation gizmo is enabled
  60247. */
  60248. set rotationGizmoEnabled(value: boolean);
  60249. get rotationGizmoEnabled(): boolean;
  60250. /**
  60251. * If the scale gizmo is enabled
  60252. */
  60253. set scaleGizmoEnabled(value: boolean);
  60254. get scaleGizmoEnabled(): boolean;
  60255. /**
  60256. * If the boundingBox gizmo is enabled
  60257. */
  60258. set boundingBoxGizmoEnabled(value: boolean);
  60259. get boundingBoxGizmoEnabled(): boolean;
  60260. /**
  60261. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60262. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  60263. */
  60264. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  60265. /**
  60266. * Disposes of the gizmo manager
  60267. */
  60268. dispose(): void;
  60269. }
  60270. }
  60271. declare module "babylonjs/Gizmos/positionGizmo" {
  60272. import { Observable } from "babylonjs/Misc/observable";
  60273. import { Nullable } from "babylonjs/types";
  60274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60275. import { Node } from "babylonjs/node";
  60276. import { Mesh } from "babylonjs/Meshes/mesh";
  60277. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60278. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  60279. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  60280. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60281. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  60282. /**
  60283. * Gizmo that enables dragging a mesh along 3 axis
  60284. */
  60285. export class PositionGizmo extends Gizmo {
  60286. /**
  60287. * Internal gizmo used for interactions on the x axis
  60288. */
  60289. xGizmo: AxisDragGizmo;
  60290. /**
  60291. * Internal gizmo used for interactions on the y axis
  60292. */
  60293. yGizmo: AxisDragGizmo;
  60294. /**
  60295. * Internal gizmo used for interactions on the z axis
  60296. */
  60297. zGizmo: AxisDragGizmo;
  60298. /**
  60299. * Internal gizmo used for interactions on the yz plane
  60300. */
  60301. xPlaneGizmo: PlaneDragGizmo;
  60302. /**
  60303. * Internal gizmo used for interactions on the xz plane
  60304. */
  60305. yPlaneGizmo: PlaneDragGizmo;
  60306. /**
  60307. * Internal gizmo used for interactions on the xy plane
  60308. */
  60309. zPlaneGizmo: PlaneDragGizmo;
  60310. /**
  60311. * private variables
  60312. */
  60313. private _meshAttached;
  60314. private _nodeAttached;
  60315. private _snapDistance;
  60316. private _observables;
  60317. /** Node Caching for quick lookup */
  60318. private _gizmoAxisCache;
  60319. /** Fires an event when any of it's sub gizmos are dragged */
  60320. onDragStartObservable: Observable<unknown>;
  60321. /** Fires an event when any of it's sub gizmos are released from dragging */
  60322. onDragEndObservable: Observable<unknown>;
  60323. /**
  60324. * If set to true, planar drag is enabled
  60325. */
  60326. private _planarGizmoEnabled;
  60327. get attachedMesh(): Nullable<AbstractMesh>;
  60328. set attachedMesh(mesh: Nullable<AbstractMesh>);
  60329. get attachedNode(): Nullable<Node>;
  60330. set attachedNode(node: Nullable<Node>);
  60331. /**
  60332. * True when the mouse pointer is hovering a gizmo mesh
  60333. */
  60334. get isHovered(): boolean;
  60335. /**
  60336. * Creates a PositionGizmo
  60337. * @param gizmoLayer The utility layer the gizmo will be added to
  60338. @param thickness display gizmo axis thickness
  60339. */
  60340. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  60341. /**
  60342. * If the planar drag gizmo is enabled
  60343. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  60344. */
  60345. set planarGizmoEnabled(value: boolean);
  60346. get planarGizmoEnabled(): boolean;
  60347. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  60348. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  60349. /**
  60350. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60351. */
  60352. set snapDistance(value: number);
  60353. get snapDistance(): number;
  60354. /**
  60355. * Ratio for the scale of the gizmo (Default: 1)
  60356. */
  60357. set scaleRatio(value: number);
  60358. get scaleRatio(): number;
  60359. /**
  60360. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60361. * @param mesh Axis gizmo mesh
  60362. * @param cache Gizmo axis definition used for reactive gizmo UI
  60363. */
  60364. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60365. /**
  60366. * Disposes of the gizmo
  60367. */
  60368. dispose(): void;
  60369. /**
  60370. * CustomMeshes are not supported by this gizmo
  60371. * @param mesh The mesh to replace the default mesh of the gizmo
  60372. */
  60373. setCustomMesh(mesh: Mesh): void;
  60374. }
  60375. }
  60376. declare module "babylonjs/Gizmos/axisDragGizmo" {
  60377. import { Observable } from "babylonjs/Misc/observable";
  60378. import { Nullable } from "babylonjs/types";
  60379. import { Vector3 } from "babylonjs/Maths/math.vector";
  60380. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60381. import { Node } from "babylonjs/node";
  60382. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60383. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60384. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60385. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60386. import { Scene } from "babylonjs/scene";
  60387. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60388. import { Color3 } from "babylonjs/Maths/math.color";
  60389. /**
  60390. * Single axis drag gizmo
  60391. */
  60392. export class AxisDragGizmo extends Gizmo {
  60393. /**
  60394. * Drag behavior responsible for the gizmos dragging interactions
  60395. */
  60396. dragBehavior: PointerDragBehavior;
  60397. private _pointerObserver;
  60398. /**
  60399. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60400. */
  60401. snapDistance: number;
  60402. /**
  60403. * Event that fires each time the gizmo snaps to a new location.
  60404. * * snapDistance is the the change in distance
  60405. */
  60406. onSnapObservable: Observable<{
  60407. snapDistance: number;
  60408. }>;
  60409. private _isEnabled;
  60410. private _parent;
  60411. private _gizmoMesh;
  60412. private _coloredMaterial;
  60413. private _hoverMaterial;
  60414. private _disableMaterial;
  60415. private _dragging;
  60416. /** @hidden */
  60417. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  60418. /** @hidden */
  60419. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  60420. /**
  60421. * Creates an AxisDragGizmo
  60422. * @param gizmoLayer The utility layer the gizmo will be added to
  60423. * @param dragAxis The axis which the gizmo will be able to drag on
  60424. * @param color The color of the gizmo
  60425. * @param thickness display gizmo axis thickness
  60426. */
  60427. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  60428. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60429. /**
  60430. * If the gizmo is enabled
  60431. */
  60432. set isEnabled(value: boolean);
  60433. get isEnabled(): boolean;
  60434. /**
  60435. * Disposes of the gizmo
  60436. */
  60437. dispose(): void;
  60438. }
  60439. }
  60440. declare module "babylonjs/Debug/axesViewer" {
  60441. import { Vector3 } from "babylonjs/Maths/math.vector";
  60442. import { Nullable } from "babylonjs/types";
  60443. import { Scene } from "babylonjs/scene";
  60444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60445. /**
  60446. * The Axes viewer will show 3 axes in a specific point in space
  60447. */
  60448. export class AxesViewer {
  60449. private _xAxis;
  60450. private _yAxis;
  60451. private _zAxis;
  60452. private _scaleLinesFactor;
  60453. private _instanced;
  60454. /**
  60455. * Gets the hosting scene
  60456. */
  60457. scene: Nullable<Scene>;
  60458. /**
  60459. * Gets or sets a number used to scale line length
  60460. */
  60461. scaleLines: number;
  60462. /** Gets the node hierarchy used to render x-axis */
  60463. get xAxis(): TransformNode;
  60464. /** Gets the node hierarchy used to render y-axis */
  60465. get yAxis(): TransformNode;
  60466. /** Gets the node hierarchy used to render z-axis */
  60467. get zAxis(): TransformNode;
  60468. /**
  60469. * Creates a new AxesViewer
  60470. * @param scene defines the hosting scene
  60471. * @param scaleLines defines a number used to scale line length (1 by default)
  60472. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  60473. * @param xAxis defines the node hierarchy used to render the x-axis
  60474. * @param yAxis defines the node hierarchy used to render the y-axis
  60475. * @param zAxis defines the node hierarchy used to render the z-axis
  60476. */
  60477. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  60478. /**
  60479. * Force the viewer to update
  60480. * @param position defines the position of the viewer
  60481. * @param xaxis defines the x axis of the viewer
  60482. * @param yaxis defines the y axis of the viewer
  60483. * @param zaxis defines the z axis of the viewer
  60484. */
  60485. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  60486. /**
  60487. * Creates an instance of this axes viewer.
  60488. * @returns a new axes viewer with instanced meshes
  60489. */
  60490. createInstance(): AxesViewer;
  60491. /** Releases resources */
  60492. dispose(): void;
  60493. private static _SetRenderingGroupId;
  60494. }
  60495. }
  60496. declare module "babylonjs/Debug/boneAxesViewer" {
  60497. import { Nullable } from "babylonjs/types";
  60498. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  60499. import { Vector3 } from "babylonjs/Maths/math.vector";
  60500. import { Mesh } from "babylonjs/Meshes/mesh";
  60501. import { Bone } from "babylonjs/Bones/bone";
  60502. import { Scene } from "babylonjs/scene";
  60503. /**
  60504. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  60505. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  60506. */
  60507. export class BoneAxesViewer extends AxesViewer {
  60508. /**
  60509. * Gets or sets the target mesh where to display the axes viewer
  60510. */
  60511. mesh: Nullable<Mesh>;
  60512. /**
  60513. * Gets or sets the target bone where to display the axes viewer
  60514. */
  60515. bone: Nullable<Bone>;
  60516. /** Gets current position */
  60517. pos: Vector3;
  60518. /** Gets direction of X axis */
  60519. xaxis: Vector3;
  60520. /** Gets direction of Y axis */
  60521. yaxis: Vector3;
  60522. /** Gets direction of Z axis */
  60523. zaxis: Vector3;
  60524. /**
  60525. * Creates a new BoneAxesViewer
  60526. * @param scene defines the hosting scene
  60527. * @param bone defines the target bone
  60528. * @param mesh defines the target mesh
  60529. * @param scaleLines defines a scaling factor for line length (1 by default)
  60530. */
  60531. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  60532. /**
  60533. * Force the viewer to update
  60534. */
  60535. update(): void;
  60536. /** Releases resources */
  60537. dispose(): void;
  60538. }
  60539. }
  60540. declare module "babylonjs/Debug/debugLayer" {
  60541. import { Scene } from "babylonjs/scene";
  60542. /**
  60543. * Interface used to define scene explorer extensibility option
  60544. */
  60545. export interface IExplorerExtensibilityOption {
  60546. /**
  60547. * Define the option label
  60548. */
  60549. label: string;
  60550. /**
  60551. * Defines the action to execute on click
  60552. */
  60553. action: (entity: any) => void;
  60554. }
  60555. /**
  60556. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  60557. */
  60558. export interface IExplorerExtensibilityGroup {
  60559. /**
  60560. * Defines a predicate to test if a given type mut be extended
  60561. */
  60562. predicate: (entity: any) => boolean;
  60563. /**
  60564. * Gets the list of options added to a type
  60565. */
  60566. entries: IExplorerExtensibilityOption[];
  60567. }
  60568. /**
  60569. * Interface used to define the options to use to create the Inspector
  60570. */
  60571. export interface IInspectorOptions {
  60572. /**
  60573. * Display in overlay mode (default: false)
  60574. */
  60575. overlay?: boolean;
  60576. /**
  60577. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  60578. */
  60579. globalRoot?: HTMLElement;
  60580. /**
  60581. * Display the Scene explorer
  60582. */
  60583. showExplorer?: boolean;
  60584. /**
  60585. * Display the property inspector
  60586. */
  60587. showInspector?: boolean;
  60588. /**
  60589. * Display in embed mode (both panes on the right)
  60590. */
  60591. embedMode?: boolean;
  60592. /**
  60593. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  60594. */
  60595. handleResize?: boolean;
  60596. /**
  60597. * Allow the panes to popup (default: true)
  60598. */
  60599. enablePopup?: boolean;
  60600. /**
  60601. * Allow the panes to be closed by users (default: true)
  60602. */
  60603. enableClose?: boolean;
  60604. /**
  60605. * Optional list of extensibility entries
  60606. */
  60607. explorerExtensibility?: IExplorerExtensibilityGroup[];
  60608. /**
  60609. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  60610. */
  60611. inspectorURL?: string;
  60612. /**
  60613. * Optional initial tab (default to DebugLayerTab.Properties)
  60614. */
  60615. initialTab?: DebugLayerTab;
  60616. }
  60617. module "babylonjs/scene" {
  60618. interface Scene {
  60619. /**
  60620. * @hidden
  60621. * Backing field
  60622. */
  60623. _debugLayer: DebugLayer;
  60624. /**
  60625. * Gets the debug layer (aka Inspector) associated with the scene
  60626. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60627. */
  60628. debugLayer: DebugLayer;
  60629. }
  60630. }
  60631. /**
  60632. * Enum of inspector action tab
  60633. */
  60634. export enum DebugLayerTab {
  60635. /**
  60636. * Properties tag (default)
  60637. */
  60638. Properties = 0,
  60639. /**
  60640. * Debug tab
  60641. */
  60642. Debug = 1,
  60643. /**
  60644. * Statistics tab
  60645. */
  60646. Statistics = 2,
  60647. /**
  60648. * Tools tab
  60649. */
  60650. Tools = 3,
  60651. /**
  60652. * Settings tab
  60653. */
  60654. Settings = 4
  60655. }
  60656. /**
  60657. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60658. * what is happening in your scene
  60659. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60660. */
  60661. export class DebugLayer {
  60662. /**
  60663. * Define the url to get the inspector script from.
  60664. * By default it uses the babylonjs CDN.
  60665. * @ignoreNaming
  60666. */
  60667. static InspectorURL: string;
  60668. private _scene;
  60669. private BJSINSPECTOR;
  60670. private _onPropertyChangedObservable?;
  60671. /**
  60672. * Observable triggered when a property is changed through the inspector.
  60673. */
  60674. get onPropertyChangedObservable(): any;
  60675. /**
  60676. * Instantiates a new debug layer.
  60677. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60678. * what is happening in your scene
  60679. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60680. * @param scene Defines the scene to inspect
  60681. */
  60682. constructor(scene: Scene);
  60683. /** Creates the inspector window. */
  60684. private _createInspector;
  60685. /**
  60686. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  60687. * @param entity defines the entity to select
  60688. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  60689. */
  60690. select(entity: any, lineContainerTitles?: string | string[]): void;
  60691. /** Get the inspector from bundle or global */
  60692. private _getGlobalInspector;
  60693. /**
  60694. * Get if the inspector is visible or not.
  60695. * @returns true if visible otherwise, false
  60696. */
  60697. isVisible(): boolean;
  60698. /**
  60699. * Hide the inspector and close its window.
  60700. */
  60701. hide(): void;
  60702. /**
  60703. * Update the scene in the inspector
  60704. */
  60705. setAsActiveScene(): void;
  60706. /**
  60707. * Launch the debugLayer.
  60708. * @param config Define the configuration of the inspector
  60709. * @return a promise fulfilled when the debug layer is visible
  60710. */
  60711. show(config?: IInspectorOptions): Promise<DebugLayer>;
  60712. }
  60713. }
  60714. declare module "babylonjs/Debug/physicsViewer" {
  60715. import { Nullable } from "babylonjs/types";
  60716. import { Scene } from "babylonjs/scene";
  60717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60718. import { Mesh } from "babylonjs/Meshes/mesh";
  60719. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60721. /**
  60722. * Used to show the physics impostor around the specific mesh
  60723. */
  60724. export class PhysicsViewer {
  60725. /** @hidden */
  60726. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  60727. /** @hidden */
  60728. protected _meshes: Array<Nullable<AbstractMesh>>;
  60729. /** @hidden */
  60730. protected _scene: Nullable<Scene>;
  60731. /** @hidden */
  60732. protected _numMeshes: number;
  60733. /** @hidden */
  60734. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  60735. private _renderFunction;
  60736. private _utilityLayer;
  60737. private _debugBoxMesh;
  60738. private _debugSphereMesh;
  60739. private _debugCylinderMesh;
  60740. private _debugMaterial;
  60741. private _debugMeshMeshes;
  60742. /**
  60743. * Creates a new PhysicsViewer
  60744. * @param scene defines the hosting scene
  60745. */
  60746. constructor(scene: Scene);
  60747. /** @hidden */
  60748. protected _updateDebugMeshes(): void;
  60749. /**
  60750. * Renders a specified physic impostor
  60751. * @param impostor defines the impostor to render
  60752. * @param targetMesh defines the mesh represented by the impostor
  60753. * @returns the new debug mesh used to render the impostor
  60754. */
  60755. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  60756. /**
  60757. * Hides a specified physic impostor
  60758. * @param impostor defines the impostor to hide
  60759. */
  60760. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  60761. private _getDebugMaterial;
  60762. private _getDebugBoxMesh;
  60763. private _getDebugSphereMesh;
  60764. private _getDebugCylinderMesh;
  60765. private _getDebugMeshMesh;
  60766. private _getDebugMesh;
  60767. /** Releases all resources */
  60768. dispose(): void;
  60769. }
  60770. }
  60771. declare module "babylonjs/Debug/rayHelper" {
  60772. import { Nullable } from "babylonjs/types";
  60773. import { Ray } from "babylonjs/Culling/ray";
  60774. import { Vector3 } from "babylonjs/Maths/math.vector";
  60775. import { Color3 } from "babylonjs/Maths/math.color";
  60776. import { Scene } from "babylonjs/scene";
  60777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60778. import "babylonjs/Meshes/Builders/linesBuilder";
  60779. /**
  60780. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60781. * in order to better appreciate the issue one might have.
  60782. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60783. */
  60784. export class RayHelper {
  60785. /**
  60786. * Defines the ray we are currently tryin to visualize.
  60787. */
  60788. ray: Nullable<Ray>;
  60789. private _renderPoints;
  60790. private _renderLine;
  60791. private _renderFunction;
  60792. private _scene;
  60793. private _onAfterRenderObserver;
  60794. private _onAfterStepObserver;
  60795. private _attachedToMesh;
  60796. private _meshSpaceDirection;
  60797. private _meshSpaceOrigin;
  60798. /**
  60799. * Helper function to create a colored helper in a scene in one line.
  60800. * @param ray Defines the ray we are currently tryin to visualize
  60801. * @param scene Defines the scene the ray is used in
  60802. * @param color Defines the color we want to see the ray in
  60803. * @returns The newly created ray helper.
  60804. */
  60805. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  60806. /**
  60807. * Instantiate a new ray helper.
  60808. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60809. * in order to better appreciate the issue one might have.
  60810. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60811. * @param ray Defines the ray we are currently tryin to visualize
  60812. */
  60813. constructor(ray: Ray);
  60814. /**
  60815. * Shows the ray we are willing to debug.
  60816. * @param scene Defines the scene the ray needs to be rendered in
  60817. * @param color Defines the color the ray needs to be rendered in
  60818. */
  60819. show(scene: Scene, color?: Color3): void;
  60820. /**
  60821. * Hides the ray we are debugging.
  60822. */
  60823. hide(): void;
  60824. private _render;
  60825. /**
  60826. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  60827. * @param mesh Defines the mesh we want the helper attached to
  60828. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  60829. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  60830. * @param length Defines the length of the ray
  60831. */
  60832. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  60833. /**
  60834. * Detach the ray helper from the mesh it has previously been attached to.
  60835. */
  60836. detachFromMesh(): void;
  60837. private _updateToMesh;
  60838. /**
  60839. * Dispose the helper and release its associated resources.
  60840. */
  60841. dispose(): void;
  60842. }
  60843. }
  60844. declare module "babylonjs/Debug/ISkeletonViewer" {
  60845. import { Skeleton } from "babylonjs/Bones/skeleton";
  60846. import { Color3 } from "babylonjs/Maths/math.color";
  60847. /**
  60848. * Defines the options associated with the creation of a SkeletonViewer.
  60849. */
  60850. export interface ISkeletonViewerOptions {
  60851. /** Should the system pause animations before building the Viewer? */
  60852. pauseAnimations: boolean;
  60853. /** Should the system return the skeleton to rest before building? */
  60854. returnToRest: boolean;
  60855. /** public Display Mode of the Viewer */
  60856. displayMode: number;
  60857. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60858. displayOptions: ISkeletonViewerDisplayOptions;
  60859. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60860. computeBonesUsingShaders: boolean;
  60861. /** Flag ignore non weighted bones */
  60862. useAllBones: boolean;
  60863. }
  60864. /**
  60865. * Defines how to display the various bone meshes for the viewer.
  60866. */
  60867. export interface ISkeletonViewerDisplayOptions {
  60868. /** How far down to start tapering the bone spurs */
  60869. midStep?: number;
  60870. /** How big is the midStep? */
  60871. midStepFactor?: number;
  60872. /** Base for the Sphere Size */
  60873. sphereBaseSize?: number;
  60874. /** The ratio of the sphere to the longest bone in units */
  60875. sphereScaleUnit?: number;
  60876. /** Ratio for the Sphere Size */
  60877. sphereFactor?: number;
  60878. /** Whether a spur should attach its far end to the child bone position */
  60879. spurFollowsChild?: boolean;
  60880. /** Whether to show local axes or not */
  60881. showLocalAxes?: boolean;
  60882. /** Length of each local axis */
  60883. localAxesSize?: number;
  60884. }
  60885. /**
  60886. * Defines the constructor options for the BoneWeight Shader.
  60887. */
  60888. export interface IBoneWeightShaderOptions {
  60889. /** Skeleton to Map */
  60890. skeleton: Skeleton;
  60891. /** Colors for Uninfluenced bones */
  60892. colorBase?: Color3;
  60893. /** Colors for 0.0-0.25 Weight bones */
  60894. colorZero?: Color3;
  60895. /** Color for 0.25-0.5 Weight Influence */
  60896. colorQuarter?: Color3;
  60897. /** Color for 0.5-0.75 Weight Influence */
  60898. colorHalf?: Color3;
  60899. /** Color for 0.75-1 Weight Influence */
  60900. colorFull?: Color3;
  60901. /** Color for Zero Weight Influence */
  60902. targetBoneIndex?: number;
  60903. }
  60904. /**
  60905. * Simple structure of the gradient steps for the Color Map.
  60906. */
  60907. export interface ISkeletonMapShaderColorMapKnot {
  60908. /** Color of the Knot */
  60909. color: Color3;
  60910. /** Location of the Knot */
  60911. location: number;
  60912. }
  60913. /**
  60914. * Defines the constructor options for the SkeletonMap Shader.
  60915. */
  60916. export interface ISkeletonMapShaderOptions {
  60917. /** Skeleton to Map */
  60918. skeleton: Skeleton;
  60919. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  60920. colorMap?: ISkeletonMapShaderColorMapKnot[];
  60921. }
  60922. }
  60923. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  60924. import { Nullable } from "babylonjs/types";
  60925. import { Scene } from "babylonjs/scene";
  60926. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  60927. import { Color4 } from "babylonjs/Maths/math.color";
  60928. import { Mesh } from "babylonjs/Meshes/mesh";
  60929. /**
  60930. * Class containing static functions to help procedurally build meshes
  60931. */
  60932. export class RibbonBuilder {
  60933. /**
  60934. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60935. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60936. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60937. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60938. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  60939. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  60940. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  60941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60944. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  60945. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60946. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  60947. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60949. * @param name defines the name of the mesh
  60950. * @param options defines the options used to create the mesh
  60951. * @param scene defines the hosting scene
  60952. * @returns the ribbon mesh
  60953. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60955. */
  60956. static CreateRibbon(name: string, options: {
  60957. pathArray: Vector3[][];
  60958. closeArray?: boolean;
  60959. closePath?: boolean;
  60960. offset?: number;
  60961. updatable?: boolean;
  60962. sideOrientation?: number;
  60963. frontUVs?: Vector4;
  60964. backUVs?: Vector4;
  60965. instance?: Mesh;
  60966. invertUV?: boolean;
  60967. uvs?: Vector2[];
  60968. colors?: Color4[];
  60969. }, scene?: Nullable<Scene>): Mesh;
  60970. }
  60971. }
  60972. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  60973. import { Nullable } from "babylonjs/types";
  60974. import { Scene } from "babylonjs/scene";
  60975. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60976. import { Mesh } from "babylonjs/Meshes/mesh";
  60977. /**
  60978. * Class containing static functions to help procedurally build meshes
  60979. */
  60980. export class ShapeBuilder {
  60981. /**
  60982. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60983. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  60984. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60985. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  60986. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60987. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  60988. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  60989. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60994. * @param name defines the name of the mesh
  60995. * @param options defines the options used to create the mesh
  60996. * @param scene defines the hosting scene
  60997. * @returns the extruded shape mesh
  60998. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61000. */
  61001. static ExtrudeShape(name: string, options: {
  61002. shape: Vector3[];
  61003. path: Vector3[];
  61004. scale?: number;
  61005. rotation?: number;
  61006. cap?: number;
  61007. updatable?: boolean;
  61008. sideOrientation?: number;
  61009. frontUVs?: Vector4;
  61010. backUVs?: Vector4;
  61011. instance?: Mesh;
  61012. invertUV?: boolean;
  61013. }, scene?: Nullable<Scene>): Mesh;
  61014. /**
  61015. * Creates an custom extruded shape mesh.
  61016. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61017. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  61018. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61019. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  61020. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61021. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  61022. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61023. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61024. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61025. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  61026. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  61027. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61032. * @param name defines the name of the mesh
  61033. * @param options defines the options used to create the mesh
  61034. * @param scene defines the hosting scene
  61035. * @returns the custom extruded shape mesh
  61036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61037. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61039. */
  61040. static ExtrudeShapeCustom(name: string, options: {
  61041. shape: Vector3[];
  61042. path: Vector3[];
  61043. scaleFunction?: any;
  61044. rotationFunction?: any;
  61045. ribbonCloseArray?: boolean;
  61046. ribbonClosePath?: boolean;
  61047. cap?: number;
  61048. updatable?: boolean;
  61049. sideOrientation?: number;
  61050. frontUVs?: Vector4;
  61051. backUVs?: Vector4;
  61052. instance?: Mesh;
  61053. invertUV?: boolean;
  61054. }, scene?: Nullable<Scene>): Mesh;
  61055. private static _ExtrudeShapeGeneric;
  61056. }
  61057. }
  61058. declare module "babylonjs/Debug/skeletonViewer" {
  61059. import { Color3 } from "babylonjs/Maths/math.color";
  61060. import { Scene } from "babylonjs/scene";
  61061. import { Nullable } from "babylonjs/types";
  61062. import { Skeleton } from "babylonjs/Bones/skeleton";
  61063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61064. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  61065. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  61066. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  61067. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  61068. /**
  61069. * Class used to render a debug view of a given skeleton
  61070. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  61071. */
  61072. export class SkeletonViewer {
  61073. /** defines the skeleton to render */
  61074. skeleton: Skeleton;
  61075. /** defines the mesh attached to the skeleton */
  61076. mesh: AbstractMesh;
  61077. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  61078. autoUpdateBonesMatrices: boolean;
  61079. /** defines the rendering group id to use with the viewer */
  61080. renderingGroupId: number;
  61081. /** is the options for the viewer */
  61082. options: Partial<ISkeletonViewerOptions>;
  61083. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  61084. static readonly DISPLAY_LINES: number;
  61085. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  61086. static readonly DISPLAY_SPHERES: number;
  61087. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  61088. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  61089. /** public static method to create a BoneWeight Shader
  61090. * @param options The constructor options
  61091. * @param scene The scene that the shader is scoped to
  61092. * @returns The created ShaderMaterial
  61093. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  61094. */
  61095. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  61096. /** public static method to create a BoneWeight Shader
  61097. * @param options The constructor options
  61098. * @param scene The scene that the shader is scoped to
  61099. * @returns The created ShaderMaterial
  61100. */
  61101. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  61102. /** private static method to create a BoneWeight Shader
  61103. * @param size The size of the buffer to create (usually the bone count)
  61104. * @param colorMap The gradient data to generate
  61105. * @param scene The scene that the shader is scoped to
  61106. * @returns an Array of floats from the color gradient values
  61107. */
  61108. private static _CreateBoneMapColorBuffer;
  61109. /** If SkeletonViewer scene scope. */
  61110. private _scene;
  61111. /** Gets or sets the color used to render the skeleton */
  61112. color: Color3;
  61113. /** Array of the points of the skeleton fo the line view. */
  61114. private _debugLines;
  61115. /** The SkeletonViewers Mesh. */
  61116. private _debugMesh;
  61117. /** The local axes Meshes. */
  61118. private _localAxes;
  61119. /** If SkeletonViewer is enabled. */
  61120. private _isEnabled;
  61121. /** If SkeletonViewer is ready. */
  61122. private _ready;
  61123. /** SkeletonViewer render observable. */
  61124. private _obs;
  61125. /** The Utility Layer to render the gizmos in. */
  61126. private _utilityLayer;
  61127. private _boneIndices;
  61128. /** Gets the Scene. */
  61129. get scene(): Scene;
  61130. /** Gets the utilityLayer. */
  61131. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  61132. /** Checks Ready Status. */
  61133. get isReady(): Boolean;
  61134. /** Sets Ready Status. */
  61135. set ready(value: boolean);
  61136. /** Gets the debugMesh */
  61137. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  61138. /** Sets the debugMesh */
  61139. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  61140. /** Gets the displayMode */
  61141. get displayMode(): number;
  61142. /** Sets the displayMode */
  61143. set displayMode(value: number);
  61144. /**
  61145. * Creates a new SkeletonViewer
  61146. * @param skeleton defines the skeleton to render
  61147. * @param mesh defines the mesh attached to the skeleton
  61148. * @param scene defines the hosting scene
  61149. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  61150. * @param renderingGroupId defines the rendering group id to use with the viewer
  61151. * @param options All of the extra constructor options for the SkeletonViewer
  61152. */
  61153. constructor(
  61154. /** defines the skeleton to render */
  61155. skeleton: Skeleton,
  61156. /** defines the mesh attached to the skeleton */
  61157. mesh: AbstractMesh,
  61158. /** The Scene scope*/
  61159. scene: Scene,
  61160. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  61161. autoUpdateBonesMatrices?: boolean,
  61162. /** defines the rendering group id to use with the viewer */
  61163. renderingGroupId?: number,
  61164. /** is the options for the viewer */
  61165. options?: Partial<ISkeletonViewerOptions>);
  61166. /** The Dynamic bindings for the update functions */
  61167. private _bindObs;
  61168. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  61169. update(): void;
  61170. /** Gets or sets a boolean indicating if the viewer is enabled */
  61171. set isEnabled(value: boolean);
  61172. get isEnabled(): boolean;
  61173. private _getBonePosition;
  61174. private _getLinesForBonesWithLength;
  61175. private _getLinesForBonesNoLength;
  61176. /** function to revert the mesh and scene back to the initial state. */
  61177. private _revert;
  61178. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  61179. private _getAbsoluteBindPoseToRef;
  61180. /** function to build and bind sphere joint points and spur bone representations. */
  61181. private _buildSpheresAndSpurs;
  61182. private _buildLocalAxes;
  61183. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  61184. private _displayLinesUpdate;
  61185. /** Changes the displayMode of the skeleton viewer
  61186. * @param mode The displayMode numerical value
  61187. */
  61188. changeDisplayMode(mode: number): void;
  61189. /** Sets a display option of the skeleton viewer
  61190. *
  61191. * | Option | Type | Default | Description |
  61192. * | ---------------- | ------- | ------- | ----------- |
  61193. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  61194. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  61195. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  61196. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  61197. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  61198. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  61199. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  61200. *
  61201. * @param option String of the option name
  61202. * @param value The numerical option value
  61203. */
  61204. changeDisplayOptions(option: string, value: number): void;
  61205. /** Release associated resources */
  61206. dispose(): void;
  61207. }
  61208. }
  61209. declare module "babylonjs/Debug/index" {
  61210. export * from "babylonjs/Debug/axesViewer";
  61211. export * from "babylonjs/Debug/boneAxesViewer";
  61212. export * from "babylonjs/Debug/debugLayer";
  61213. export * from "babylonjs/Debug/physicsViewer";
  61214. export * from "babylonjs/Debug/rayHelper";
  61215. export * from "babylonjs/Debug/skeletonViewer";
  61216. export * from "babylonjs/Debug/ISkeletonViewer";
  61217. }
  61218. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  61219. /**
  61220. * Enum for Device Types
  61221. */
  61222. export enum DeviceType {
  61223. /** Generic */
  61224. Generic = 0,
  61225. /** Keyboard */
  61226. Keyboard = 1,
  61227. /** Mouse */
  61228. Mouse = 2,
  61229. /** Touch Pointers */
  61230. Touch = 3,
  61231. /** PS4 Dual Shock */
  61232. DualShock = 4,
  61233. /** Xbox */
  61234. Xbox = 5,
  61235. /** Switch Controller */
  61236. Switch = 6
  61237. }
  61238. /**
  61239. * Enum for All Pointers (Touch/Mouse)
  61240. */
  61241. export enum PointerInput {
  61242. /** Horizontal Axis */
  61243. Horizontal = 0,
  61244. /** Vertical Axis */
  61245. Vertical = 1,
  61246. /** Left Click or Touch */
  61247. LeftClick = 2,
  61248. /** Middle Click */
  61249. MiddleClick = 3,
  61250. /** Right Click */
  61251. RightClick = 4,
  61252. /** Browser Back */
  61253. BrowserBack = 5,
  61254. /** Browser Forward */
  61255. BrowserForward = 6
  61256. }
  61257. /**
  61258. * Enum for Dual Shock Gamepad
  61259. */
  61260. export enum DualShockInput {
  61261. /** Cross */
  61262. Cross = 0,
  61263. /** Circle */
  61264. Circle = 1,
  61265. /** Square */
  61266. Square = 2,
  61267. /** Triangle */
  61268. Triangle = 3,
  61269. /** L1 */
  61270. L1 = 4,
  61271. /** R1 */
  61272. R1 = 5,
  61273. /** L2 */
  61274. L2 = 6,
  61275. /** R2 */
  61276. R2 = 7,
  61277. /** Share */
  61278. Share = 8,
  61279. /** Options */
  61280. Options = 9,
  61281. /** L3 */
  61282. L3 = 10,
  61283. /** R3 */
  61284. R3 = 11,
  61285. /** DPadUp */
  61286. DPadUp = 12,
  61287. /** DPadDown */
  61288. DPadDown = 13,
  61289. /** DPadLeft */
  61290. DPadLeft = 14,
  61291. /** DRight */
  61292. DPadRight = 15,
  61293. /** Home */
  61294. Home = 16,
  61295. /** TouchPad */
  61296. TouchPad = 17,
  61297. /** LStickXAxis */
  61298. LStickXAxis = 18,
  61299. /** LStickYAxis */
  61300. LStickYAxis = 19,
  61301. /** RStickXAxis */
  61302. RStickXAxis = 20,
  61303. /** RStickYAxis */
  61304. RStickYAxis = 21
  61305. }
  61306. /**
  61307. * Enum for Xbox Gamepad
  61308. */
  61309. export enum XboxInput {
  61310. /** A */
  61311. A = 0,
  61312. /** B */
  61313. B = 1,
  61314. /** X */
  61315. X = 2,
  61316. /** Y */
  61317. Y = 3,
  61318. /** LB */
  61319. LB = 4,
  61320. /** RB */
  61321. RB = 5,
  61322. /** LT */
  61323. LT = 6,
  61324. /** RT */
  61325. RT = 7,
  61326. /** Back */
  61327. Back = 8,
  61328. /** Start */
  61329. Start = 9,
  61330. /** LS */
  61331. LS = 10,
  61332. /** RS */
  61333. RS = 11,
  61334. /** DPadUp */
  61335. DPadUp = 12,
  61336. /** DPadDown */
  61337. DPadDown = 13,
  61338. /** DPadLeft */
  61339. DPadLeft = 14,
  61340. /** DRight */
  61341. DPadRight = 15,
  61342. /** Home */
  61343. Home = 16,
  61344. /** LStickXAxis */
  61345. LStickXAxis = 17,
  61346. /** LStickYAxis */
  61347. LStickYAxis = 18,
  61348. /** RStickXAxis */
  61349. RStickXAxis = 19,
  61350. /** RStickYAxis */
  61351. RStickYAxis = 20
  61352. }
  61353. /**
  61354. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  61355. */
  61356. export enum SwitchInput {
  61357. /** B */
  61358. B = 0,
  61359. /** A */
  61360. A = 1,
  61361. /** Y */
  61362. Y = 2,
  61363. /** X */
  61364. X = 3,
  61365. /** L */
  61366. L = 4,
  61367. /** R */
  61368. R = 5,
  61369. /** ZL */
  61370. ZL = 6,
  61371. /** ZR */
  61372. ZR = 7,
  61373. /** Minus */
  61374. Minus = 8,
  61375. /** Plus */
  61376. Plus = 9,
  61377. /** LS */
  61378. LS = 10,
  61379. /** RS */
  61380. RS = 11,
  61381. /** DPadUp */
  61382. DPadUp = 12,
  61383. /** DPadDown */
  61384. DPadDown = 13,
  61385. /** DPadLeft */
  61386. DPadLeft = 14,
  61387. /** DRight */
  61388. DPadRight = 15,
  61389. /** Home */
  61390. Home = 16,
  61391. /** Capture */
  61392. Capture = 17,
  61393. /** LStickXAxis */
  61394. LStickXAxis = 18,
  61395. /** LStickYAxis */
  61396. LStickYAxis = 19,
  61397. /** RStickXAxis */
  61398. RStickXAxis = 20,
  61399. /** RStickYAxis */
  61400. RStickYAxis = 21
  61401. }
  61402. }
  61403. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  61404. import { Engine } from "babylonjs/Engines/engine";
  61405. import { IDisposable } from "babylonjs/scene";
  61406. import { Nullable } from "babylonjs/types";
  61407. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61408. /**
  61409. * This class will take all inputs from Keyboard, Pointer, and
  61410. * any Gamepads and provide a polling system that all devices
  61411. * will use. This class assumes that there will only be one
  61412. * pointer device and one keyboard.
  61413. */
  61414. export class DeviceInputSystem implements IDisposable {
  61415. /**
  61416. * Returns onDeviceConnected callback property
  61417. * @returns Callback with function to execute when a device is connected
  61418. */
  61419. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  61420. /**
  61421. * Sets callback function when a device is connected and executes against all connected devices
  61422. * @param callback Function to execute when a device is connected
  61423. */
  61424. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  61425. /**
  61426. * Callback to be triggered when a device is disconnected
  61427. */
  61428. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  61429. /**
  61430. * Callback to be triggered when event driven input is updated
  61431. */
  61432. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  61433. private _inputs;
  61434. private _gamepads;
  61435. private _keyboardActive;
  61436. private _pointerActive;
  61437. private _elementToAttachTo;
  61438. private _keyboardDownEvent;
  61439. private _keyboardUpEvent;
  61440. private _pointerMoveEvent;
  61441. private _pointerDownEvent;
  61442. private _pointerUpEvent;
  61443. private _gamepadConnectedEvent;
  61444. private _gamepadDisconnectedEvent;
  61445. private _onDeviceConnected;
  61446. private static _MAX_KEYCODES;
  61447. private static _MAX_POINTER_INPUTS;
  61448. private constructor();
  61449. /**
  61450. * Creates a new DeviceInputSystem instance
  61451. * @param engine Engine to pull input element from
  61452. * @returns The new instance
  61453. */
  61454. static Create(engine: Engine): DeviceInputSystem;
  61455. /**
  61456. * Checks for current device input value, given an id and input index
  61457. * @param deviceName Id of connected device
  61458. * @param inputIndex Index of device input
  61459. * @returns Current value of input
  61460. */
  61461. /**
  61462. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  61463. * @param deviceType Enum specifiying device type
  61464. * @param deviceSlot "Slot" or index that device is referenced in
  61465. * @param inputIndex Id of input to be checked
  61466. * @returns Current value of input
  61467. */
  61468. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  61469. /**
  61470. * Dispose of all the eventlisteners
  61471. */
  61472. dispose(): void;
  61473. /**
  61474. * Checks for existing connections to devices and register them, if necessary
  61475. * Currently handles gamepads and mouse
  61476. */
  61477. private _checkForConnectedDevices;
  61478. /**
  61479. * Add a gamepad to the DeviceInputSystem
  61480. * @param gamepad A single DOM Gamepad object
  61481. */
  61482. private _addGamePad;
  61483. /**
  61484. * Add pointer device to DeviceInputSystem
  61485. * @param deviceType Type of Pointer to add
  61486. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  61487. * @param currentX Current X at point of adding
  61488. * @param currentY Current Y at point of adding
  61489. */
  61490. private _addPointerDevice;
  61491. /**
  61492. * Add device and inputs to device array
  61493. * @param deviceType Enum specifiying device type
  61494. * @param deviceSlot "Slot" or index that device is referenced in
  61495. * @param numberOfInputs Number of input entries to create for given device
  61496. */
  61497. private _registerDevice;
  61498. /**
  61499. * Given a specific device name, remove that device from the device map
  61500. * @param deviceType Enum specifiying device type
  61501. * @param deviceSlot "Slot" or index that device is referenced in
  61502. */
  61503. private _unregisterDevice;
  61504. /**
  61505. * Handle all actions that come from keyboard interaction
  61506. */
  61507. private _handleKeyActions;
  61508. /**
  61509. * Handle all actions that come from pointer interaction
  61510. */
  61511. private _handlePointerActions;
  61512. /**
  61513. * Handle all actions that come from gamepad interaction
  61514. */
  61515. private _handleGamepadActions;
  61516. /**
  61517. * Update all non-event based devices with each frame
  61518. * @param deviceType Enum specifiying device type
  61519. * @param deviceSlot "Slot" or index that device is referenced in
  61520. * @param inputIndex Id of input to be checked
  61521. */
  61522. private _updateDevice;
  61523. /**
  61524. * Gets DeviceType from the device name
  61525. * @param deviceName Name of Device from DeviceInputSystem
  61526. * @returns DeviceType enum value
  61527. */
  61528. private _getGamepadDeviceType;
  61529. }
  61530. }
  61531. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  61532. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61533. /**
  61534. * Type to handle enforcement of inputs
  61535. */
  61536. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  61537. }
  61538. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  61539. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  61540. import { Engine } from "babylonjs/Engines/engine";
  61541. import { IDisposable } from "babylonjs/scene";
  61542. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61543. import { Nullable } from "babylonjs/types";
  61544. import { Observable } from "babylonjs/Misc/observable";
  61545. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61546. /**
  61547. * Class that handles all input for a specific device
  61548. */
  61549. export class DeviceSource<T extends DeviceType> {
  61550. /** Type of device */
  61551. readonly deviceType: DeviceType;
  61552. /** "Slot" or index that device is referenced in */
  61553. readonly deviceSlot: number;
  61554. /**
  61555. * Observable to handle device input changes per device
  61556. */
  61557. readonly onInputChangedObservable: Observable<{
  61558. inputIndex: DeviceInput<T>;
  61559. previousState: Nullable<number>;
  61560. currentState: Nullable<number>;
  61561. }>;
  61562. private readonly _deviceInputSystem;
  61563. /**
  61564. * Default Constructor
  61565. * @param deviceInputSystem Reference to DeviceInputSystem
  61566. * @param deviceType Type of device
  61567. * @param deviceSlot "Slot" or index that device is referenced in
  61568. */
  61569. constructor(deviceInputSystem: DeviceInputSystem,
  61570. /** Type of device */
  61571. deviceType: DeviceType,
  61572. /** "Slot" or index that device is referenced in */
  61573. deviceSlot?: number);
  61574. /**
  61575. * Get input for specific input
  61576. * @param inputIndex index of specific input on device
  61577. * @returns Input value from DeviceInputSystem
  61578. */
  61579. getInput(inputIndex: DeviceInput<T>): number;
  61580. }
  61581. /**
  61582. * Class to keep track of devices
  61583. */
  61584. export class DeviceSourceManager implements IDisposable {
  61585. /**
  61586. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  61587. */
  61588. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  61589. /**
  61590. * Observable to be triggered when after a device is disconnected
  61591. */
  61592. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  61593. private readonly _devices;
  61594. private readonly _firstDevice;
  61595. private readonly _deviceInputSystem;
  61596. /**
  61597. * Default Constructor
  61598. * @param engine engine to pull input element from
  61599. */
  61600. constructor(engine: Engine);
  61601. /**
  61602. * Gets a DeviceSource, given a type and slot
  61603. * @param deviceType Enum specifying device type
  61604. * @param deviceSlot "Slot" or index that device is referenced in
  61605. * @returns DeviceSource object
  61606. */
  61607. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  61608. /**
  61609. * Gets an array of DeviceSource objects for a given device type
  61610. * @param deviceType Enum specifying device type
  61611. * @returns Array of DeviceSource objects
  61612. */
  61613. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  61614. /**
  61615. * Returns a read-only list of all available devices
  61616. * @returns Read-only array with active devices
  61617. */
  61618. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  61619. /**
  61620. * Dispose of DeviceInputSystem and other parts
  61621. */
  61622. dispose(): void;
  61623. /**
  61624. * Function to add device name to device list
  61625. * @param deviceType Enum specifying device type
  61626. * @param deviceSlot "Slot" or index that device is referenced in
  61627. */
  61628. private _addDevice;
  61629. /**
  61630. * Function to remove device name to device list
  61631. * @param deviceType Enum specifying device type
  61632. * @param deviceSlot "Slot" or index that device is referenced in
  61633. */
  61634. private _removeDevice;
  61635. /**
  61636. * Updates array storing first connected device of each type
  61637. * @param type Type of Device
  61638. */
  61639. private _updateFirstDevices;
  61640. }
  61641. }
  61642. declare module "babylonjs/DeviceInput/index" {
  61643. export * from "babylonjs/DeviceInput/deviceInputSystem";
  61644. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61645. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61646. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61647. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61648. }
  61649. declare module "babylonjs/Engines/nullEngine" {
  61650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  61651. import { Engine } from "babylonjs/Engines/engine";
  61652. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  61653. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  61654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61655. import { Effect } from "babylonjs/Materials/effect";
  61656. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  61657. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  61658. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  61659. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  61660. /**
  61661. * Options to create the null engine
  61662. */
  61663. export class NullEngineOptions {
  61664. /**
  61665. * Render width (Default: 512)
  61666. */
  61667. renderWidth: number;
  61668. /**
  61669. * Render height (Default: 256)
  61670. */
  61671. renderHeight: number;
  61672. /**
  61673. * Texture size (Default: 512)
  61674. */
  61675. textureSize: number;
  61676. /**
  61677. * If delta time between frames should be constant
  61678. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61679. */
  61680. deterministicLockstep: boolean;
  61681. /**
  61682. * Maximum about of steps between frames (Default: 4)
  61683. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61684. */
  61685. lockstepMaxSteps: number;
  61686. /**
  61687. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  61688. */
  61689. useHighPrecisionMatrix?: boolean;
  61690. }
  61691. /**
  61692. * The null engine class provides support for headless version of babylon.js.
  61693. * This can be used in server side scenario or for testing purposes
  61694. */
  61695. export class NullEngine extends Engine {
  61696. private _options;
  61697. /**
  61698. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  61699. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61700. * @returns true if engine is in deterministic lock step mode
  61701. */
  61702. isDeterministicLockStep(): boolean;
  61703. /**
  61704. * Gets the max steps when engine is running in deterministic lock step
  61705. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61706. * @returns the max steps
  61707. */
  61708. getLockstepMaxSteps(): number;
  61709. /**
  61710. * Gets the current hardware scaling level.
  61711. * By default the hardware scaling level is computed from the window device ratio.
  61712. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  61713. * @returns a number indicating the current hardware scaling level
  61714. */
  61715. getHardwareScalingLevel(): number;
  61716. constructor(options?: NullEngineOptions);
  61717. /**
  61718. * Creates a vertex buffer
  61719. * @param vertices the data for the vertex buffer
  61720. * @returns the new WebGL static buffer
  61721. */
  61722. createVertexBuffer(vertices: FloatArray): DataBuffer;
  61723. /**
  61724. * Creates a new index buffer
  61725. * @param indices defines the content of the index buffer
  61726. * @param updatable defines if the index buffer must be updatable
  61727. * @returns a new webGL buffer
  61728. */
  61729. createIndexBuffer(indices: IndicesArray): DataBuffer;
  61730. /**
  61731. * Clear the current render buffer or the current render target (if any is set up)
  61732. * @param color defines the color to use
  61733. * @param backBuffer defines if the back buffer must be cleared
  61734. * @param depth defines if the depth buffer must be cleared
  61735. * @param stencil defines if the stencil buffer must be cleared
  61736. */
  61737. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  61738. /**
  61739. * Gets the current render width
  61740. * @param useScreen defines if screen size must be used (or the current render target if any)
  61741. * @returns a number defining the current render width
  61742. */
  61743. getRenderWidth(useScreen?: boolean): number;
  61744. /**
  61745. * Gets the current render height
  61746. * @param useScreen defines if screen size must be used (or the current render target if any)
  61747. * @returns a number defining the current render height
  61748. */
  61749. getRenderHeight(useScreen?: boolean): number;
  61750. /**
  61751. * Set the WebGL's viewport
  61752. * @param viewport defines the viewport element to be used
  61753. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  61754. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  61755. */
  61756. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  61757. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  61758. /**
  61759. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  61760. * @param pipelineContext defines the pipeline context to use
  61761. * @param uniformsNames defines the list of uniform names
  61762. * @returns an array of webGL uniform locations
  61763. */
  61764. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  61765. /**
  61766. * Gets the lsit of active attributes for a given webGL program
  61767. * @param pipelineContext defines the pipeline context to use
  61768. * @param attributesNames defines the list of attribute names to get
  61769. * @returns an array of indices indicating the offset of each attribute
  61770. */
  61771. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  61772. /**
  61773. * Binds an effect to the webGL context
  61774. * @param effect defines the effect to bind
  61775. */
  61776. bindSamplers(effect: Effect): void;
  61777. /**
  61778. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  61779. * @param effect defines the effect to activate
  61780. */
  61781. enableEffect(effect: Effect): void;
  61782. /**
  61783. * Set various states to the webGL context
  61784. * @param culling defines backface culling state
  61785. * @param zOffset defines the value to apply to zOffset (0 by default)
  61786. * @param force defines if states must be applied even if cache is up to date
  61787. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  61788. */
  61789. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  61790. /**
  61791. * Set the value of an uniform to an array of int32
  61792. * @param uniform defines the webGL uniform location where to store the value
  61793. * @param array defines the array of int32 to store
  61794. * @returns true if value was set
  61795. */
  61796. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61797. /**
  61798. * Set the value of an uniform to an array of int32 (stored as vec2)
  61799. * @param uniform defines the webGL uniform location where to store the value
  61800. * @param array defines the array of int32 to store
  61801. * @returns true if value was set
  61802. */
  61803. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61804. /**
  61805. * Set the value of an uniform to an array of int32 (stored as vec3)
  61806. * @param uniform defines the webGL uniform location where to store the value
  61807. * @param array defines the array of int32 to store
  61808. * @returns true if value was set
  61809. */
  61810. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61811. /**
  61812. * Set the value of an uniform to an array of int32 (stored as vec4)
  61813. * @param uniform defines the webGL uniform location where to store the value
  61814. * @param array defines the array of int32 to store
  61815. * @returns true if value was set
  61816. */
  61817. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61818. /**
  61819. * Set the value of an uniform to an array of float32
  61820. * @param uniform defines the webGL uniform location where to store the value
  61821. * @param array defines the array of float32 to store
  61822. * @returns true if value was set
  61823. */
  61824. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61825. /**
  61826. * Set the value of an uniform to an array of float32 (stored as vec2)
  61827. * @param uniform defines the webGL uniform location where to store the value
  61828. * @param array defines the array of float32 to store
  61829. * @returns true if value was set
  61830. */
  61831. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61832. /**
  61833. * Set the value of an uniform to an array of float32 (stored as vec3)
  61834. * @param uniform defines the webGL uniform location where to store the value
  61835. * @param array defines the array of float32 to store
  61836. * @returns true if value was set
  61837. */
  61838. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61839. /**
  61840. * Set the value of an uniform to an array of float32 (stored as vec4)
  61841. * @param uniform defines the webGL uniform location where to store the value
  61842. * @param array defines the array of float32 to store
  61843. * @returns true if value was set
  61844. */
  61845. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61846. /**
  61847. * Set the value of an uniform to an array of number
  61848. * @param uniform defines the webGL uniform location where to store the value
  61849. * @param array defines the array of number to store
  61850. * @returns true if value was set
  61851. */
  61852. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  61853. /**
  61854. * Set the value of an uniform to an array of number (stored as vec2)
  61855. * @param uniform defines the webGL uniform location where to store the value
  61856. * @param array defines the array of number to store
  61857. * @returns true if value was set
  61858. */
  61859. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  61860. /**
  61861. * Set the value of an uniform to an array of number (stored as vec3)
  61862. * @param uniform defines the webGL uniform location where to store the value
  61863. * @param array defines the array of number to store
  61864. * @returns true if value was set
  61865. */
  61866. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  61867. /**
  61868. * Set the value of an uniform to an array of number (stored as vec4)
  61869. * @param uniform defines the webGL uniform location where to store the value
  61870. * @param array defines the array of number to store
  61871. * @returns true if value was set
  61872. */
  61873. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  61874. /**
  61875. * Set the value of an uniform to an array of float32 (stored as matrices)
  61876. * @param uniform defines the webGL uniform location where to store the value
  61877. * @param matrices defines the array of float32 to store
  61878. * @returns true if value was set
  61879. */
  61880. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  61881. /**
  61882. * Set the value of an uniform to a matrix (3x3)
  61883. * @param uniform defines the webGL uniform location where to store the value
  61884. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  61885. * @returns true if value was set
  61886. */
  61887. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61888. /**
  61889. * Set the value of an uniform to a matrix (2x2)
  61890. * @param uniform defines the webGL uniform location where to store the value
  61891. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  61892. * @returns true if value was set
  61893. */
  61894. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61895. /**
  61896. * Set the value of an uniform to a number (float)
  61897. * @param uniform defines the webGL uniform location where to store the value
  61898. * @param value defines the float number to store
  61899. * @returns true if value was set
  61900. */
  61901. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  61902. /**
  61903. * Set the value of an uniform to a vec2
  61904. * @param uniform defines the webGL uniform location where to store the value
  61905. * @param x defines the 1st component of the value
  61906. * @param y defines the 2nd component of the value
  61907. * @returns true if value was set
  61908. */
  61909. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  61910. /**
  61911. * Set the value of an uniform to a vec3
  61912. * @param uniform defines the webGL uniform location where to store the value
  61913. * @param x defines the 1st component of the value
  61914. * @param y defines the 2nd component of the value
  61915. * @param z defines the 3rd component of the value
  61916. * @returns true if value was set
  61917. */
  61918. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  61919. /**
  61920. * Set the value of an uniform to a boolean
  61921. * @param uniform defines the webGL uniform location where to store the value
  61922. * @param bool defines the boolean to store
  61923. * @returns true if value was set
  61924. */
  61925. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  61926. /**
  61927. * Set the value of an uniform to a vec4
  61928. * @param uniform defines the webGL uniform location where to store the value
  61929. * @param x defines the 1st component of the value
  61930. * @param y defines the 2nd component of the value
  61931. * @param z defines the 3rd component of the value
  61932. * @param w defines the 4th component of the value
  61933. * @returns true if value was set
  61934. */
  61935. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  61936. /**
  61937. * Sets the current alpha mode
  61938. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  61939. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  61940. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61941. */
  61942. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  61943. /**
  61944. * Bind webGl buffers directly to the webGL context
  61945. * @param vertexBuffers defines the vertex buffer to bind
  61946. * @param indexBuffer defines the index buffer to bind
  61947. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  61948. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  61949. * @param effect defines the effect associated with the vertex buffer
  61950. */
  61951. bindBuffers(vertexBuffers: {
  61952. [key: string]: VertexBuffer;
  61953. }, indexBuffer: DataBuffer, effect: Effect): void;
  61954. /**
  61955. * Force the entire cache to be cleared
  61956. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  61957. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  61958. */
  61959. wipeCaches(bruteForce?: boolean): void;
  61960. /**
  61961. * Send a draw order
  61962. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  61963. * @param indexStart defines the starting index
  61964. * @param indexCount defines the number of index to draw
  61965. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61966. */
  61967. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  61968. /**
  61969. * Draw a list of indexed primitives
  61970. * @param fillMode defines the primitive to use
  61971. * @param indexStart defines the starting index
  61972. * @param indexCount defines the number of index to draw
  61973. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61974. */
  61975. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  61976. /**
  61977. * Draw a list of unindexed primitives
  61978. * @param fillMode defines the primitive to use
  61979. * @param verticesStart defines the index of first vertex to draw
  61980. * @param verticesCount defines the count of vertices to draw
  61981. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61982. */
  61983. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  61984. /** @hidden */
  61985. protected _createTexture(): WebGLTexture;
  61986. /** @hidden */
  61987. _releaseTexture(texture: InternalTexture): void;
  61988. /**
  61989. * Usually called from Texture.ts.
  61990. * Passed information to create a WebGLTexture
  61991. * @param urlArg defines a value which contains one of the following:
  61992. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  61993. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  61994. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  61995. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  61996. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  61997. * @param scene needed for loading to the correct scene
  61998. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  61999. * @param onLoad optional callback to be called upon successful completion
  62000. * @param onError optional callback to be called upon failure
  62001. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  62002. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  62003. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  62004. * @param forcedExtension defines the extension to use to pick the right loader
  62005. * @param mimeType defines an optional mime type
  62006. * @returns a InternalTexture for assignment back into BABYLON.Texture
  62007. */
  62008. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  62009. /**
  62010. * Creates a new render target texture
  62011. * @param size defines the size of the texture
  62012. * @param options defines the options used to create the texture
  62013. * @returns a new render target texture stored in an InternalTexture
  62014. */
  62015. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  62016. /**
  62017. * Update the sampling mode of a given texture
  62018. * @param samplingMode defines the required sampling mode
  62019. * @param texture defines the texture to update
  62020. */
  62021. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  62022. /**
  62023. * Binds the frame buffer to the specified texture.
  62024. * @param texture The texture to render to or null for the default canvas
  62025. * @param faceIndex The face of the texture to render to in case of cube texture
  62026. * @param requiredWidth The width of the target to render to
  62027. * @param requiredHeight The height of the target to render to
  62028. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  62029. * @param lodLevel defines le lod level to bind to the frame buffer
  62030. */
  62031. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  62032. /**
  62033. * Unbind the current render target texture from the webGL context
  62034. * @param texture defines the render target texture to unbind
  62035. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  62036. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  62037. */
  62038. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  62039. /**
  62040. * Creates a dynamic vertex buffer
  62041. * @param vertices the data for the dynamic vertex buffer
  62042. * @returns the new WebGL dynamic buffer
  62043. */
  62044. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  62045. /**
  62046. * Update the content of a dynamic texture
  62047. * @param texture defines the texture to update
  62048. * @param canvas defines the canvas containing the source
  62049. * @param invertY defines if data must be stored with Y axis inverted
  62050. * @param premulAlpha defines if alpha is stored as premultiplied
  62051. * @param format defines the format of the data
  62052. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  62053. */
  62054. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  62055. /**
  62056. * Gets a boolean indicating if all created effects are ready
  62057. * @returns true if all effects are ready
  62058. */
  62059. areAllEffectsReady(): boolean;
  62060. /**
  62061. * @hidden
  62062. * Get the current error code of the webGL context
  62063. * @returns the error code
  62064. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  62065. */
  62066. getError(): number;
  62067. /** @hidden */
  62068. _getUnpackAlignement(): number;
  62069. /** @hidden */
  62070. _unpackFlipY(value: boolean): void;
  62071. /**
  62072. * Update a dynamic index buffer
  62073. * @param indexBuffer defines the target index buffer
  62074. * @param indices defines the data to update
  62075. * @param offset defines the offset in the target index buffer where update should start
  62076. */
  62077. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  62078. /**
  62079. * Updates a dynamic vertex buffer.
  62080. * @param vertexBuffer the vertex buffer to update
  62081. * @param vertices the data used to update the vertex buffer
  62082. * @param byteOffset the byte offset of the data (optional)
  62083. * @param byteLength the byte length of the data (optional)
  62084. */
  62085. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  62086. /** @hidden */
  62087. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  62088. /** @hidden */
  62089. _bindTexture(channel: number, texture: InternalTexture): void;
  62090. protected _deleteBuffer(buffer: WebGLBuffer): void;
  62091. /**
  62092. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  62093. */
  62094. releaseEffects(): void;
  62095. displayLoadingUI(): void;
  62096. hideLoadingUI(): void;
  62097. /** @hidden */
  62098. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62099. /** @hidden */
  62100. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62101. /** @hidden */
  62102. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62103. /** @hidden */
  62104. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  62105. }
  62106. }
  62107. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  62108. import { Nullable, int } from "babylonjs/types";
  62109. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  62110. /** @hidden */
  62111. export class _OcclusionDataStorage {
  62112. /** @hidden */
  62113. occlusionInternalRetryCounter: number;
  62114. /** @hidden */
  62115. isOcclusionQueryInProgress: boolean;
  62116. /** @hidden */
  62117. isOccluded: boolean;
  62118. /** @hidden */
  62119. occlusionRetryCount: number;
  62120. /** @hidden */
  62121. occlusionType: number;
  62122. /** @hidden */
  62123. occlusionQueryAlgorithmType: number;
  62124. }
  62125. module "babylonjs/Engines/engine" {
  62126. interface Engine {
  62127. /**
  62128. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  62129. * @return the new query
  62130. */
  62131. createQuery(): WebGLQuery;
  62132. /**
  62133. * Delete and release a webGL query
  62134. * @param query defines the query to delete
  62135. * @return the current engine
  62136. */
  62137. deleteQuery(query: WebGLQuery): Engine;
  62138. /**
  62139. * Check if a given query has resolved and got its value
  62140. * @param query defines the query to check
  62141. * @returns true if the query got its value
  62142. */
  62143. isQueryResultAvailable(query: WebGLQuery): boolean;
  62144. /**
  62145. * Gets the value of a given query
  62146. * @param query defines the query to check
  62147. * @returns the value of the query
  62148. */
  62149. getQueryResult(query: WebGLQuery): number;
  62150. /**
  62151. * Initiates an occlusion query
  62152. * @param algorithmType defines the algorithm to use
  62153. * @param query defines the query to use
  62154. * @returns the current engine
  62155. * @see https://doc.babylonjs.com/features/occlusionquery
  62156. */
  62157. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  62158. /**
  62159. * Ends an occlusion query
  62160. * @see https://doc.babylonjs.com/features/occlusionquery
  62161. * @param algorithmType defines the algorithm to use
  62162. * @returns the current engine
  62163. */
  62164. endOcclusionQuery(algorithmType: number): Engine;
  62165. /**
  62166. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  62167. * Please note that only one query can be issued at a time
  62168. * @returns a time token used to track the time span
  62169. */
  62170. startTimeQuery(): Nullable<_TimeToken>;
  62171. /**
  62172. * Ends a time query
  62173. * @param token defines the token used to measure the time span
  62174. * @returns the time spent (in ns)
  62175. */
  62176. endTimeQuery(token: _TimeToken): int;
  62177. /** @hidden */
  62178. _currentNonTimestampToken: Nullable<_TimeToken>;
  62179. /** @hidden */
  62180. _createTimeQuery(): WebGLQuery;
  62181. /** @hidden */
  62182. _deleteTimeQuery(query: WebGLQuery): void;
  62183. /** @hidden */
  62184. _getGlAlgorithmType(algorithmType: number): number;
  62185. /** @hidden */
  62186. _getTimeQueryResult(query: WebGLQuery): any;
  62187. /** @hidden */
  62188. _getTimeQueryAvailability(query: WebGLQuery): any;
  62189. }
  62190. }
  62191. module "babylonjs/Meshes/abstractMesh" {
  62192. interface AbstractMesh {
  62193. /**
  62194. * Backing filed
  62195. * @hidden
  62196. */
  62197. __occlusionDataStorage: _OcclusionDataStorage;
  62198. /**
  62199. * Access property
  62200. * @hidden
  62201. */
  62202. _occlusionDataStorage: _OcclusionDataStorage;
  62203. /**
  62204. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  62205. * The default value is -1 which means don't break the query and wait till the result
  62206. * @see https://doc.babylonjs.com/features/occlusionquery
  62207. */
  62208. occlusionRetryCount: number;
  62209. /**
  62210. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  62211. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  62212. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  62213. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  62214. * @see https://doc.babylonjs.com/features/occlusionquery
  62215. */
  62216. occlusionType: number;
  62217. /**
  62218. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  62219. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  62220. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  62221. * @see https://doc.babylonjs.com/features/occlusionquery
  62222. */
  62223. occlusionQueryAlgorithmType: number;
  62224. /**
  62225. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  62226. * @see https://doc.babylonjs.com/features/occlusionquery
  62227. */
  62228. isOccluded: boolean;
  62229. /**
  62230. * Flag to check the progress status of the query
  62231. * @see https://doc.babylonjs.com/features/occlusionquery
  62232. */
  62233. isOcclusionQueryInProgress: boolean;
  62234. }
  62235. }
  62236. }
  62237. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  62238. import { Nullable } from "babylonjs/types";
  62239. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62240. /** @hidden */
  62241. export var _forceTransformFeedbackToBundle: boolean;
  62242. module "babylonjs/Engines/engine" {
  62243. interface Engine {
  62244. /**
  62245. * Creates a webGL transform feedback object
  62246. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  62247. * @returns the webGL transform feedback object
  62248. */
  62249. createTransformFeedback(): WebGLTransformFeedback;
  62250. /**
  62251. * Delete a webGL transform feedback object
  62252. * @param value defines the webGL transform feedback object to delete
  62253. */
  62254. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  62255. /**
  62256. * Bind a webGL transform feedback object to the webgl context
  62257. * @param value defines the webGL transform feedback object to bind
  62258. */
  62259. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  62260. /**
  62261. * Begins a transform feedback operation
  62262. * @param usePoints defines if points or triangles must be used
  62263. */
  62264. beginTransformFeedback(usePoints: boolean): void;
  62265. /**
  62266. * Ends a transform feedback operation
  62267. */
  62268. endTransformFeedback(): void;
  62269. /**
  62270. * Specify the varyings to use with transform feedback
  62271. * @param program defines the associated webGL program
  62272. * @param value defines the list of strings representing the varying names
  62273. */
  62274. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  62275. /**
  62276. * Bind a webGL buffer for a transform feedback operation
  62277. * @param value defines the webGL buffer to bind
  62278. */
  62279. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  62280. }
  62281. }
  62282. }
  62283. declare module "babylonjs/Engines/Extensions/engine.views" {
  62284. import { Camera } from "babylonjs/Cameras/camera";
  62285. import { Nullable } from "babylonjs/types";
  62286. /**
  62287. * Class used to define an additional view for the engine
  62288. * @see https://doc.babylonjs.com/how_to/multi_canvases
  62289. */
  62290. export class EngineView {
  62291. /** Defines the canvas where to render the view */
  62292. target: HTMLCanvasElement;
  62293. /** Defines an optional camera used to render the view (will use active camera else) */
  62294. camera?: Camera;
  62295. }
  62296. module "babylonjs/Engines/engine" {
  62297. interface Engine {
  62298. /**
  62299. * Gets or sets the HTML element to use for attaching events
  62300. */
  62301. inputElement: Nullable<HTMLElement>;
  62302. /**
  62303. * Gets the current engine view
  62304. * @see https://doc.babylonjs.com/how_to/multi_canvases
  62305. */
  62306. activeView: Nullable<EngineView>;
  62307. /** Gets or sets the list of views */
  62308. views: EngineView[];
  62309. /**
  62310. * Register a new child canvas
  62311. * @param canvas defines the canvas to register
  62312. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  62313. * @returns the associated view
  62314. */
  62315. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  62316. /**
  62317. * Remove a registered child canvas
  62318. * @param canvas defines the canvas to remove
  62319. * @returns the current engine
  62320. */
  62321. unRegisterView(canvas: HTMLCanvasElement): Engine;
  62322. }
  62323. }
  62324. }
  62325. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  62326. import { Nullable } from "babylonjs/types";
  62327. module "babylonjs/Engines/engine" {
  62328. interface Engine {
  62329. /** @hidden */
  62330. _excludedCompressedTextures: string[];
  62331. /** @hidden */
  62332. _textureFormatInUse: string;
  62333. /**
  62334. * Gets the list of texture formats supported
  62335. */
  62336. readonly texturesSupported: Array<string>;
  62337. /**
  62338. * Gets the texture format in use
  62339. */
  62340. readonly textureFormatInUse: Nullable<string>;
  62341. /**
  62342. * Set the compressed texture extensions or file names to skip.
  62343. *
  62344. * @param skippedFiles defines the list of those texture files you want to skip
  62345. * Example: [".dds", ".env", "myfile.png"]
  62346. */
  62347. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  62348. /**
  62349. * Set the compressed texture format to use, based on the formats you have, and the formats
  62350. * supported by the hardware / browser.
  62351. *
  62352. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  62353. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  62354. * to API arguments needed to compressed textures. This puts the burden on the container
  62355. * generator to house the arcane code for determining these for current & future formats.
  62356. *
  62357. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62358. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62359. *
  62360. * Note: The result of this call is not taken into account when a texture is base64.
  62361. *
  62362. * @param formatsAvailable defines the list of those format families you have created
  62363. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  62364. *
  62365. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  62366. * @returns The extension selected.
  62367. */
  62368. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  62369. }
  62370. }
  62371. }
  62372. declare module "babylonjs/Engines/Extensions/index" {
  62373. export * from "babylonjs/Engines/Extensions/engine.alpha";
  62374. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  62375. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  62376. export * from "babylonjs/Engines/Extensions/engine.multiview";
  62377. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  62378. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62379. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  62380. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  62381. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  62382. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  62383. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62384. export * from "babylonjs/Engines/Extensions/engine.webVR";
  62385. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  62386. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  62387. export * from "babylonjs/Engines/Extensions/engine.views";
  62388. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  62389. import "babylonjs/Engines/Extensions/engine.textureSelector";
  62390. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  62391. }
  62392. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  62393. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62394. /** @hidden */
  62395. export var rgbdEncodePixelShader: {
  62396. name: string;
  62397. shader: string;
  62398. };
  62399. }
  62400. declare module "babylonjs/Misc/environmentTextureTools" {
  62401. import { Nullable } from "babylonjs/types";
  62402. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  62403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62405. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62406. import "babylonjs/Engines/Extensions/engine.readTexture";
  62407. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62408. import "babylonjs/Shaders/rgbdEncode.fragment";
  62409. import "babylonjs/Shaders/rgbdDecode.fragment";
  62410. /**
  62411. * Raw texture data and descriptor sufficient for WebGL texture upload
  62412. */
  62413. export interface EnvironmentTextureInfo {
  62414. /**
  62415. * Version of the environment map
  62416. */
  62417. version: number;
  62418. /**
  62419. * Width of image
  62420. */
  62421. width: number;
  62422. /**
  62423. * Irradiance information stored in the file.
  62424. */
  62425. irradiance: any;
  62426. /**
  62427. * Specular information stored in the file.
  62428. */
  62429. specular: any;
  62430. }
  62431. /**
  62432. * Defines One Image in the file. It requires only the position in the file
  62433. * as well as the length.
  62434. */
  62435. interface BufferImageData {
  62436. /**
  62437. * Length of the image data.
  62438. */
  62439. length: number;
  62440. /**
  62441. * Position of the data from the null terminator delimiting the end of the JSON.
  62442. */
  62443. position: number;
  62444. }
  62445. /**
  62446. * Defines the specular data enclosed in the file.
  62447. * This corresponds to the version 1 of the data.
  62448. */
  62449. export interface EnvironmentTextureSpecularInfoV1 {
  62450. /**
  62451. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  62452. */
  62453. specularDataPosition?: number;
  62454. /**
  62455. * This contains all the images data needed to reconstruct the cubemap.
  62456. */
  62457. mipmaps: Array<BufferImageData>;
  62458. /**
  62459. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  62460. */
  62461. lodGenerationScale: number;
  62462. }
  62463. /**
  62464. * Sets of helpers addressing the serialization and deserialization of environment texture
  62465. * stored in a BabylonJS env file.
  62466. * Those files are usually stored as .env files.
  62467. */
  62468. export class EnvironmentTextureTools {
  62469. /**
  62470. * Magic number identifying the env file.
  62471. */
  62472. private static _MagicBytes;
  62473. /**
  62474. * Gets the environment info from an env file.
  62475. * @param data The array buffer containing the .env bytes.
  62476. * @returns the environment file info (the json header) if successfully parsed.
  62477. */
  62478. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  62479. /**
  62480. * Creates an environment texture from a loaded cube texture.
  62481. * @param texture defines the cube texture to convert in env file
  62482. * @return a promise containing the environment data if succesfull.
  62483. */
  62484. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  62485. /**
  62486. * Creates a JSON representation of the spherical data.
  62487. * @param texture defines the texture containing the polynomials
  62488. * @return the JSON representation of the spherical info
  62489. */
  62490. private static _CreateEnvTextureIrradiance;
  62491. /**
  62492. * Creates the ArrayBufferViews used for initializing environment texture image data.
  62493. * @param data the image data
  62494. * @param info parameters that determine what views will be created for accessing the underlying buffer
  62495. * @return the views described by info providing access to the underlying buffer
  62496. */
  62497. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  62498. /**
  62499. * Uploads the texture info contained in the env file to the GPU.
  62500. * @param texture defines the internal texture to upload to
  62501. * @param data defines the data to load
  62502. * @param info defines the texture info retrieved through the GetEnvInfo method
  62503. * @returns a promise
  62504. */
  62505. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  62506. private static _OnImageReadyAsync;
  62507. /**
  62508. * Uploads the levels of image data to the GPU.
  62509. * @param texture defines the internal texture to upload to
  62510. * @param imageData defines the array buffer views of image data [mipmap][face]
  62511. * @returns a promise
  62512. */
  62513. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  62514. /**
  62515. * Uploads spherical polynomials information to the texture.
  62516. * @param texture defines the texture we are trying to upload the information to
  62517. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  62518. */
  62519. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  62520. /** @hidden */
  62521. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62522. }
  62523. }
  62524. declare module "babylonjs/Engines/nativeEngine" {
  62525. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  62526. import { Engine } from "babylonjs/Engines/engine";
  62527. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  62528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62530. import { Effect } from "babylonjs/Materials/effect";
  62531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62532. import { Scene } from "babylonjs/scene";
  62533. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  62534. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  62535. import { IMatrixLike, IColor3Like, IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  62536. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  62537. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  62538. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  62539. /**
  62540. * Container for accessors for natively-stored mesh data buffers.
  62541. */
  62542. class NativeDataBuffer extends DataBuffer {
  62543. /**
  62544. * Accessor value used to identify/retrieve a natively-stored index buffer.
  62545. */
  62546. nativeIndexBuffer?: any;
  62547. /**
  62548. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  62549. */
  62550. nativeVertexBuffer?: any;
  62551. }
  62552. /** @hidden */
  62553. class NativeTexture extends InternalTexture {
  62554. getInternalTexture(): InternalTexture;
  62555. getViewCount(): number;
  62556. }
  62557. /** @hidden */
  62558. export class NativeEngine extends Engine {
  62559. private readonly _native;
  62560. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  62561. private readonly INVALID_HANDLE;
  62562. private _boundBuffersVertexArray;
  62563. private _currentDepthTest;
  62564. getHardwareScalingLevel(): number;
  62565. constructor();
  62566. dispose(): void;
  62567. /**
  62568. * Can be used to override the current requestAnimationFrame requester.
  62569. * @hidden
  62570. */
  62571. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  62572. /**
  62573. * Override default engine behavior.
  62574. * @param color
  62575. * @param backBuffer
  62576. * @param depth
  62577. * @param stencil
  62578. */
  62579. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  62580. /**
  62581. * Gets host document
  62582. * @returns the host document object
  62583. */
  62584. getHostDocument(): Nullable<Document>;
  62585. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  62586. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  62587. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  62588. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  62589. [key: string]: VertexBuffer;
  62590. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62591. bindBuffers(vertexBuffers: {
  62592. [key: string]: VertexBuffer;
  62593. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62594. recordVertexArrayObject(vertexBuffers: {
  62595. [key: string]: VertexBuffer;
  62596. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  62597. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62598. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62599. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  62600. /**
  62601. * Draw a list of indexed primitives
  62602. * @param fillMode defines the primitive to use
  62603. * @param indexStart defines the starting index
  62604. * @param indexCount defines the number of index to draw
  62605. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62606. */
  62607. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  62608. /**
  62609. * Draw a list of unindexed primitives
  62610. * @param fillMode defines the primitive to use
  62611. * @param verticesStart defines the index of first vertex to draw
  62612. * @param verticesCount defines the count of vertices to draw
  62613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62614. */
  62615. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  62616. createPipelineContext(): IPipelineContext;
  62617. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  62618. /** @hidden */
  62619. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  62620. /** @hidden */
  62621. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  62622. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62623. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62624. protected _setProgram(program: WebGLProgram): void;
  62625. _releaseEffect(effect: Effect): void;
  62626. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  62627. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  62628. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  62629. bindSamplers(effect: Effect): void;
  62630. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  62631. getRenderWidth(useScreen?: boolean): number;
  62632. getRenderHeight(useScreen?: boolean): number;
  62633. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  62634. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  62635. /**
  62636. * Set the z offset to apply to current rendering
  62637. * @param value defines the offset to apply
  62638. */
  62639. setZOffset(value: number): void;
  62640. /**
  62641. * Gets the current value of the zOffset
  62642. * @returns the current zOffset state
  62643. */
  62644. getZOffset(): number;
  62645. /**
  62646. * Enable or disable depth buffering
  62647. * @param enable defines the state to set
  62648. */
  62649. setDepthBuffer(enable: boolean): void;
  62650. /**
  62651. * Gets a boolean indicating if depth writing is enabled
  62652. * @returns the current depth writing state
  62653. */
  62654. getDepthWrite(): boolean;
  62655. setDepthFunctionToGreater(): void;
  62656. setDepthFunctionToGreaterOrEqual(): void;
  62657. setDepthFunctionToLess(): void;
  62658. setDepthFunctionToLessOrEqual(): void;
  62659. /**
  62660. * Enable or disable depth writing
  62661. * @param enable defines the state to set
  62662. */
  62663. setDepthWrite(enable: boolean): void;
  62664. /**
  62665. * Enable or disable color writing
  62666. * @param enable defines the state to set
  62667. */
  62668. setColorWrite(enable: boolean): void;
  62669. /**
  62670. * Gets a boolean indicating if color writing is enabled
  62671. * @returns the current color writing state
  62672. */
  62673. getColorWrite(): boolean;
  62674. /**
  62675. * Sets alpha constants used by some alpha blending modes
  62676. * @param r defines the red component
  62677. * @param g defines the green component
  62678. * @param b defines the blue component
  62679. * @param a defines the alpha component
  62680. */
  62681. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  62682. /**
  62683. * Sets the current alpha mode
  62684. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  62685. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  62686. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62687. */
  62688. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  62689. /**
  62690. * Gets the current alpha mode
  62691. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62692. * @returns the current alpha mode
  62693. */
  62694. getAlphaMode(): number;
  62695. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  62696. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62697. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62698. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62699. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62700. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62701. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62702. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62703. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62704. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  62705. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  62706. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  62707. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  62708. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  62709. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62710. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62711. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  62712. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  62713. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  62714. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  62715. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  62716. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  62717. wipeCaches(bruteForce?: boolean): void;
  62718. protected _createTexture(): WebGLTexture;
  62719. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  62720. /**
  62721. * Update the content of a dynamic texture
  62722. * @param texture defines the texture to update
  62723. * @param canvas defines the canvas containing the source
  62724. * @param invertY defines if data must be stored with Y axis inverted
  62725. * @param premulAlpha defines if alpha is stored as premultiplied
  62726. * @param format defines the format of the data
  62727. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  62728. */
  62729. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  62730. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  62731. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  62732. /**
  62733. * Usually called from Texture.ts.
  62734. * Passed information to create a WebGLTexture
  62735. * @param url defines a value which contains one of the following:
  62736. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  62737. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  62738. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  62739. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  62740. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  62741. * @param scene needed for loading to the correct scene
  62742. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  62743. * @param onLoad optional callback to be called upon successful completion
  62744. * @param onError optional callback to be called upon failure
  62745. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  62746. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  62747. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  62748. * @param forcedExtension defines the extension to use to pick the right loader
  62749. * @param mimeType defines an optional mime type
  62750. * @param loaderOptions options to be passed to the loader
  62751. * @returns a InternalTexture for assignment back into BABYLON.Texture
  62752. */
  62753. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  62754. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  62755. _releaseFramebufferObjects(texture: InternalTexture): void;
  62756. /**
  62757. * Creates a cube texture
  62758. * @param rootUrl defines the url where the files to load is located
  62759. * @param scene defines the current scene
  62760. * @param files defines the list of files to load (1 per face)
  62761. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  62762. * @param onLoad defines an optional callback raised when the texture is loaded
  62763. * @param onError defines an optional callback raised if there is an issue to load the texture
  62764. * @param format defines the format of the data
  62765. * @param forcedExtension defines the extension to use to pick the right loader
  62766. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  62767. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62768. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62769. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  62770. * @returns the cube texture as an InternalTexture
  62771. */
  62772. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  62773. createRenderTargetTexture(size: number | {
  62774. width: number;
  62775. height: number;
  62776. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  62777. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  62778. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  62779. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  62780. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  62781. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  62782. /**
  62783. * Updates a dynamic vertex buffer.
  62784. * @param vertexBuffer the vertex buffer to update
  62785. * @param data the data used to update the vertex buffer
  62786. * @param byteOffset the byte offset of the data (optional)
  62787. * @param byteLength the byte length of the data (optional)
  62788. */
  62789. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  62790. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  62791. private _updateAnisotropicLevel;
  62792. private _getAddressMode;
  62793. /** @hidden */
  62794. _bindTexture(channel: number, texture: InternalTexture): void;
  62795. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  62796. releaseEffects(): void;
  62797. /** @hidden */
  62798. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62799. /** @hidden */
  62800. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62801. /** @hidden */
  62802. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62803. /** @hidden */
  62804. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  62805. private _getNativeSamplingMode;
  62806. private _getNativeTextureFormat;
  62807. private _getNativeAlphaMode;
  62808. private _getNativeAttribType;
  62809. }
  62810. }
  62811. declare module "babylonjs/Engines/engineFactory" {
  62812. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62813. /**
  62814. * Helper class to create the best engine depending on the current hardware
  62815. */
  62816. export class EngineFactory {
  62817. /**
  62818. * Creates an engine based on the capabilities of the underlying hardware
  62819. * @param canvas Defines the canvas to use to display the result
  62820. * @param options Defines the options passed to the engine to create the context dependencies
  62821. * @returns a promise that resolves with the created engine
  62822. */
  62823. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  62824. }
  62825. }
  62826. declare module "babylonjs/Engines/index" {
  62827. export * from "babylonjs/Engines/constants";
  62828. export * from "babylonjs/Engines/engineCapabilities";
  62829. export * from "babylonjs/Engines/instancingAttributeInfo";
  62830. export * from "babylonjs/Engines/thinEngine";
  62831. export * from "babylonjs/Engines/engine";
  62832. export * from "babylonjs/Engines/engineStore";
  62833. export * from "babylonjs/Engines/nullEngine";
  62834. export * from "babylonjs/Engines/Extensions/index";
  62835. export * from "babylonjs/Engines/IPipelineContext";
  62836. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  62837. export * from "babylonjs/Engines/WebGPU/webgpuConstants";
  62838. export * from "babylonjs/Engines/webgpuEngine";
  62839. export * from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline";
  62840. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  62841. export * from "babylonjs/Engines/nativeEngine";
  62842. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  62843. export * from "babylonjs/Engines/performanceConfigurator";
  62844. export * from "babylonjs/Engines/engineFeatures";
  62845. export * from "babylonjs/Engines/engineFactory";
  62846. }
  62847. declare module "babylonjs/Events/clipboardEvents" {
  62848. /**
  62849. * Gather the list of clipboard event types as constants.
  62850. */
  62851. export class ClipboardEventTypes {
  62852. /**
  62853. * The clipboard event is fired when a copy command is active (pressed).
  62854. */
  62855. static readonly COPY: number;
  62856. /**
  62857. * The clipboard event is fired when a cut command is active (pressed).
  62858. */
  62859. static readonly CUT: number;
  62860. /**
  62861. * The clipboard event is fired when a paste command is active (pressed).
  62862. */
  62863. static readonly PASTE: number;
  62864. }
  62865. /**
  62866. * This class is used to store clipboard related info for the onClipboardObservable event.
  62867. */
  62868. export class ClipboardInfo {
  62869. /**
  62870. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62871. */
  62872. type: number;
  62873. /**
  62874. * Defines the related dom event
  62875. */
  62876. event: ClipboardEvent;
  62877. /**
  62878. *Creates an instance of ClipboardInfo.
  62879. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  62880. * @param event Defines the related dom event
  62881. */
  62882. constructor(
  62883. /**
  62884. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62885. */
  62886. type: number,
  62887. /**
  62888. * Defines the related dom event
  62889. */
  62890. event: ClipboardEvent);
  62891. /**
  62892. * Get the clipboard event's type from the keycode.
  62893. * @param keyCode Defines the keyCode for the current keyboard event.
  62894. * @return {number}
  62895. */
  62896. static GetTypeFromCharacter(keyCode: number): number;
  62897. }
  62898. }
  62899. declare module "babylonjs/Events/index" {
  62900. export * from "babylonjs/Events/keyboardEvents";
  62901. export * from "babylonjs/Events/pointerEvents";
  62902. export * from "babylonjs/Events/clipboardEvents";
  62903. }
  62904. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  62905. import { Scene } from "babylonjs/scene";
  62906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62907. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62908. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62909. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62910. /**
  62911. * Google Daydream controller
  62912. */
  62913. export class DaydreamController extends WebVRController {
  62914. /**
  62915. * Base Url for the controller model.
  62916. */
  62917. static MODEL_BASE_URL: string;
  62918. /**
  62919. * File name for the controller model.
  62920. */
  62921. static MODEL_FILENAME: string;
  62922. /**
  62923. * Gamepad Id prefix used to identify Daydream Controller.
  62924. */
  62925. static readonly GAMEPAD_ID_PREFIX: string;
  62926. /**
  62927. * Creates a new DaydreamController from a gamepad
  62928. * @param vrGamepad the gamepad that the controller should be created from
  62929. */
  62930. constructor(vrGamepad: any);
  62931. /**
  62932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62933. * @param scene scene in which to add meshes
  62934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62935. */
  62936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62937. /**
  62938. * Called once for each button that changed state since the last frame
  62939. * @param buttonIdx Which button index changed
  62940. * @param state New state of the button
  62941. * @param changes Which properties on the state changed since last frame
  62942. */
  62943. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62944. }
  62945. }
  62946. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  62947. import { Scene } from "babylonjs/scene";
  62948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62949. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62951. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62952. /**
  62953. * Gear VR Controller
  62954. */
  62955. export class GearVRController extends WebVRController {
  62956. /**
  62957. * Base Url for the controller model.
  62958. */
  62959. static MODEL_BASE_URL: string;
  62960. /**
  62961. * File name for the controller model.
  62962. */
  62963. static MODEL_FILENAME: string;
  62964. /**
  62965. * Gamepad Id prefix used to identify this controller.
  62966. */
  62967. static readonly GAMEPAD_ID_PREFIX: string;
  62968. private readonly _buttonIndexToObservableNameMap;
  62969. /**
  62970. * Creates a new GearVRController from a gamepad
  62971. * @param vrGamepad the gamepad that the controller should be created from
  62972. */
  62973. constructor(vrGamepad: any);
  62974. /**
  62975. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62976. * @param scene scene in which to add meshes
  62977. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62978. */
  62979. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62980. /**
  62981. * Called once for each button that changed state since the last frame
  62982. * @param buttonIdx Which button index changed
  62983. * @param state New state of the button
  62984. * @param changes Which properties on the state changed since last frame
  62985. */
  62986. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62987. }
  62988. }
  62989. declare module "babylonjs/Gamepads/Controllers/genericController" {
  62990. import { Scene } from "babylonjs/scene";
  62991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62992. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62993. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62994. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62995. /**
  62996. * Generic Controller
  62997. */
  62998. export class GenericController extends WebVRController {
  62999. /**
  63000. * Base Url for the controller model.
  63001. */
  63002. static readonly MODEL_BASE_URL: string;
  63003. /**
  63004. * File name for the controller model.
  63005. */
  63006. static readonly MODEL_FILENAME: string;
  63007. /**
  63008. * Creates a new GenericController from a gamepad
  63009. * @param vrGamepad the gamepad that the controller should be created from
  63010. */
  63011. constructor(vrGamepad: any);
  63012. /**
  63013. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63014. * @param scene scene in which to add meshes
  63015. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63016. */
  63017. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63018. /**
  63019. * Called once for each button that changed state since the last frame
  63020. * @param buttonIdx Which button index changed
  63021. * @param state New state of the button
  63022. * @param changes Which properties on the state changed since last frame
  63023. */
  63024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63025. }
  63026. }
  63027. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  63028. import { Observable } from "babylonjs/Misc/observable";
  63029. import { Scene } from "babylonjs/scene";
  63030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63031. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63032. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63033. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63034. /**
  63035. * Oculus Touch Controller
  63036. */
  63037. export class OculusTouchController extends WebVRController {
  63038. /**
  63039. * Base Url for the controller model.
  63040. */
  63041. static MODEL_BASE_URL: string;
  63042. /**
  63043. * File name for the left controller model.
  63044. */
  63045. static MODEL_LEFT_FILENAME: string;
  63046. /**
  63047. * File name for the right controller model.
  63048. */
  63049. static MODEL_RIGHT_FILENAME: string;
  63050. /**
  63051. * Base Url for the Quest controller model.
  63052. */
  63053. static QUEST_MODEL_BASE_URL: string;
  63054. /**
  63055. * @hidden
  63056. * If the controllers are running on a device that needs the updated Quest controller models
  63057. */
  63058. static _IsQuest: boolean;
  63059. /**
  63060. * Fired when the secondary trigger on this controller is modified
  63061. */
  63062. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  63063. /**
  63064. * Fired when the thumb rest on this controller is modified
  63065. */
  63066. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  63067. /**
  63068. * Creates a new OculusTouchController from a gamepad
  63069. * @param vrGamepad the gamepad that the controller should be created from
  63070. */
  63071. constructor(vrGamepad: any);
  63072. /**
  63073. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63074. * @param scene scene in which to add meshes
  63075. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63076. */
  63077. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63078. /**
  63079. * Fired when the A button on this controller is modified
  63080. */
  63081. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63082. /**
  63083. * Fired when the B button on this controller is modified
  63084. */
  63085. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63086. /**
  63087. * Fired when the X button on this controller is modified
  63088. */
  63089. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63090. /**
  63091. * Fired when the Y button on this controller is modified
  63092. */
  63093. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63094. /**
  63095. * Called once for each button that changed state since the last frame
  63096. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  63097. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  63098. * 2) secondary trigger (same)
  63099. * 3) A (right) X (left), touch, pressed = value
  63100. * 4) B / Y
  63101. * 5) thumb rest
  63102. * @param buttonIdx Which button index changed
  63103. * @param state New state of the button
  63104. * @param changes Which properties on the state changed since last frame
  63105. */
  63106. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63107. }
  63108. }
  63109. declare module "babylonjs/Gamepads/Controllers/viveController" {
  63110. import { Scene } from "babylonjs/scene";
  63111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63112. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63113. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63114. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63115. import { Observable } from "babylonjs/Misc/observable";
  63116. /**
  63117. * Vive Controller
  63118. */
  63119. export class ViveController extends WebVRController {
  63120. /**
  63121. * Base Url for the controller model.
  63122. */
  63123. static MODEL_BASE_URL: string;
  63124. /**
  63125. * File name for the controller model.
  63126. */
  63127. static MODEL_FILENAME: string;
  63128. /**
  63129. * Creates a new ViveController from a gamepad
  63130. * @param vrGamepad the gamepad that the controller should be created from
  63131. */
  63132. constructor(vrGamepad: any);
  63133. /**
  63134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63135. * @param scene scene in which to add meshes
  63136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63137. */
  63138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63139. /**
  63140. * Fired when the left button on this controller is modified
  63141. */
  63142. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63143. /**
  63144. * Fired when the right button on this controller is modified
  63145. */
  63146. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63147. /**
  63148. * Fired when the menu button on this controller is modified
  63149. */
  63150. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63151. /**
  63152. * Called once for each button that changed state since the last frame
  63153. * Vive mapping:
  63154. * 0: touchpad
  63155. * 1: trigger
  63156. * 2: left AND right buttons
  63157. * 3: menu button
  63158. * @param buttonIdx Which button index changed
  63159. * @param state New state of the button
  63160. * @param changes Which properties on the state changed since last frame
  63161. */
  63162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63163. }
  63164. }
  63165. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  63166. import { Observable } from "babylonjs/Misc/observable";
  63167. import { Scene } from "babylonjs/scene";
  63168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63169. import { Ray } from "babylonjs/Culling/ray";
  63170. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63171. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63172. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63173. /**
  63174. * Defines the WindowsMotionController object that the state of the windows motion controller
  63175. */
  63176. export class WindowsMotionController extends WebVRController {
  63177. /**
  63178. * The base url used to load the left and right controller models
  63179. */
  63180. static MODEL_BASE_URL: string;
  63181. /**
  63182. * The name of the left controller model file
  63183. */
  63184. static MODEL_LEFT_FILENAME: string;
  63185. /**
  63186. * The name of the right controller model file
  63187. */
  63188. static MODEL_RIGHT_FILENAME: string;
  63189. /**
  63190. * The controller name prefix for this controller type
  63191. */
  63192. static readonly GAMEPAD_ID_PREFIX: string;
  63193. /**
  63194. * The controller id pattern for this controller type
  63195. */
  63196. private static readonly GAMEPAD_ID_PATTERN;
  63197. private _loadedMeshInfo;
  63198. protected readonly _mapping: {
  63199. buttons: string[];
  63200. buttonMeshNames: {
  63201. trigger: string;
  63202. menu: string;
  63203. grip: string;
  63204. thumbstick: string;
  63205. trackpad: string;
  63206. };
  63207. buttonObservableNames: {
  63208. trigger: string;
  63209. menu: string;
  63210. grip: string;
  63211. thumbstick: string;
  63212. trackpad: string;
  63213. };
  63214. axisMeshNames: string[];
  63215. pointingPoseMeshName: string;
  63216. };
  63217. /**
  63218. * Fired when the trackpad on this controller is clicked
  63219. */
  63220. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  63221. /**
  63222. * Fired when the trackpad on this controller is modified
  63223. */
  63224. onTrackpadValuesChangedObservable: Observable<StickValues>;
  63225. /**
  63226. * The current x and y values of this controller's trackpad
  63227. */
  63228. trackpad: StickValues;
  63229. /**
  63230. * Creates a new WindowsMotionController from a gamepad
  63231. * @param vrGamepad the gamepad that the controller should be created from
  63232. */
  63233. constructor(vrGamepad: any);
  63234. /**
  63235. * Fired when the trigger on this controller is modified
  63236. */
  63237. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63238. /**
  63239. * Fired when the menu button on this controller is modified
  63240. */
  63241. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63242. /**
  63243. * Fired when the grip button on this controller is modified
  63244. */
  63245. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63246. /**
  63247. * Fired when the thumbstick button on this controller is modified
  63248. */
  63249. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63250. /**
  63251. * Fired when the touchpad button on this controller is modified
  63252. */
  63253. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63254. /**
  63255. * Fired when the touchpad values on this controller are modified
  63256. */
  63257. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  63258. protected _updateTrackpad(): void;
  63259. /**
  63260. * Called once per frame by the engine.
  63261. */
  63262. update(): void;
  63263. /**
  63264. * Called once for each button that changed state since the last frame
  63265. * @param buttonIdx Which button index changed
  63266. * @param state New state of the button
  63267. * @param changes Which properties on the state changed since last frame
  63268. */
  63269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63270. /**
  63271. * Moves the buttons on the controller mesh based on their current state
  63272. * @param buttonName the name of the button to move
  63273. * @param buttonValue the value of the button which determines the buttons new position
  63274. */
  63275. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  63276. /**
  63277. * Moves the axis on the controller mesh based on its current state
  63278. * @param axis the index of the axis
  63279. * @param axisValue the value of the axis which determines the meshes new position
  63280. * @hidden
  63281. */
  63282. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  63283. /**
  63284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63285. * @param scene scene in which to add meshes
  63286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63287. */
  63288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  63289. /**
  63290. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  63291. * can be transformed by button presses and axes values, based on this._mapping.
  63292. *
  63293. * @param scene scene in which the meshes exist
  63294. * @param meshes list of meshes that make up the controller model to process
  63295. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  63296. */
  63297. private processModel;
  63298. private createMeshInfo;
  63299. /**
  63300. * Gets the ray of the controller in the direction the controller is pointing
  63301. * @param length the length the resulting ray should be
  63302. * @returns a ray in the direction the controller is pointing
  63303. */
  63304. getForwardRay(length?: number): Ray;
  63305. /**
  63306. * Disposes of the controller
  63307. */
  63308. dispose(): void;
  63309. }
  63310. /**
  63311. * This class represents a new windows motion controller in XR.
  63312. */
  63313. export class XRWindowsMotionController extends WindowsMotionController {
  63314. /**
  63315. * Changing the original WIndowsMotionController mapping to fir the new mapping
  63316. */
  63317. protected readonly _mapping: {
  63318. buttons: string[];
  63319. buttonMeshNames: {
  63320. trigger: string;
  63321. menu: string;
  63322. grip: string;
  63323. thumbstick: string;
  63324. trackpad: string;
  63325. };
  63326. buttonObservableNames: {
  63327. trigger: string;
  63328. menu: string;
  63329. grip: string;
  63330. thumbstick: string;
  63331. trackpad: string;
  63332. };
  63333. axisMeshNames: string[];
  63334. pointingPoseMeshName: string;
  63335. };
  63336. /**
  63337. * Construct a new XR-Based windows motion controller
  63338. *
  63339. * @param gamepadInfo the gamepad object from the browser
  63340. */
  63341. constructor(gamepadInfo: any);
  63342. /**
  63343. * holds the thumbstick values (X,Y)
  63344. */
  63345. thumbstickValues: StickValues;
  63346. /**
  63347. * Fired when the thumbstick on this controller is clicked
  63348. */
  63349. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  63350. /**
  63351. * Fired when the thumbstick on this controller is modified
  63352. */
  63353. onThumbstickValuesChangedObservable: Observable<StickValues>;
  63354. /**
  63355. * Fired when the touchpad button on this controller is modified
  63356. */
  63357. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  63358. /**
  63359. * Fired when the touchpad values on this controller are modified
  63360. */
  63361. onTrackpadValuesChangedObservable: Observable<StickValues>;
  63362. /**
  63363. * Fired when the thumbstick button on this controller is modified
  63364. * here to prevent breaking changes
  63365. */
  63366. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63367. /**
  63368. * updating the thumbstick(!) and not the trackpad.
  63369. * This is named this way due to the difference between WebVR and XR and to avoid
  63370. * changing the parent class.
  63371. */
  63372. protected _updateTrackpad(): void;
  63373. /**
  63374. * Disposes the class with joy
  63375. */
  63376. dispose(): void;
  63377. }
  63378. }
  63379. declare module "babylonjs/Gamepads/Controllers/index" {
  63380. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  63381. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  63382. export * from "babylonjs/Gamepads/Controllers/genericController";
  63383. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  63384. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63385. export * from "babylonjs/Gamepads/Controllers/viveController";
  63386. export * from "babylonjs/Gamepads/Controllers/webVRController";
  63387. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  63388. }
  63389. declare module "babylonjs/Gamepads/index" {
  63390. export * from "babylonjs/Gamepads/Controllers/index";
  63391. export * from "babylonjs/Gamepads/gamepad";
  63392. export * from "babylonjs/Gamepads/gamepadManager";
  63393. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  63394. export * from "babylonjs/Gamepads/xboxGamepad";
  63395. export * from "babylonjs/Gamepads/dualShockGamepad";
  63396. }
  63397. declare module "babylonjs/Lights/directionalLight" {
  63398. import { Camera } from "babylonjs/Cameras/camera";
  63399. import { Scene } from "babylonjs/scene";
  63400. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63402. import { Light } from "babylonjs/Lights/light";
  63403. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63404. import { Effect } from "babylonjs/Materials/effect";
  63405. /**
  63406. * A directional light is defined by a direction (what a surprise!).
  63407. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  63408. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  63409. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63410. */
  63411. export class DirectionalLight extends ShadowLight {
  63412. private _shadowFrustumSize;
  63413. /**
  63414. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  63415. */
  63416. get shadowFrustumSize(): number;
  63417. /**
  63418. * Specifies a fix frustum size for the shadow generation.
  63419. */
  63420. set shadowFrustumSize(value: number);
  63421. private _shadowOrthoScale;
  63422. /**
  63423. * Gets the shadow projection scale against the optimal computed one.
  63424. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63425. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63426. */
  63427. get shadowOrthoScale(): number;
  63428. /**
  63429. * Sets the shadow projection scale against the optimal computed one.
  63430. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63431. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63432. */
  63433. set shadowOrthoScale(value: number);
  63434. /**
  63435. * Automatically compute the projection matrix to best fit (including all the casters)
  63436. * on each frame.
  63437. */
  63438. autoUpdateExtends: boolean;
  63439. /**
  63440. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  63441. * on each frame. autoUpdateExtends must be set to true for this to work
  63442. */
  63443. autoCalcShadowZBounds: boolean;
  63444. private _orthoLeft;
  63445. private _orthoRight;
  63446. private _orthoTop;
  63447. private _orthoBottom;
  63448. /**
  63449. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  63450. * The directional light is emitted from everywhere in the given direction.
  63451. * It can cast shadows.
  63452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63453. * @param name The friendly name of the light
  63454. * @param direction The direction of the light
  63455. * @param scene The scene the light belongs to
  63456. */
  63457. constructor(name: string, direction: Vector3, scene: Scene);
  63458. /**
  63459. * Returns the string "DirectionalLight".
  63460. * @return The class name
  63461. */
  63462. getClassName(): string;
  63463. /**
  63464. * Returns the integer 1.
  63465. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63466. */
  63467. getTypeID(): number;
  63468. /**
  63469. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  63470. * Returns the DirectionalLight Shadow projection matrix.
  63471. */
  63472. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63473. /**
  63474. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  63475. * Returns the DirectionalLight Shadow projection matrix.
  63476. */
  63477. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  63478. /**
  63479. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  63480. * Returns the DirectionalLight Shadow projection matrix.
  63481. */
  63482. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63483. protected _buildUniformLayout(): void;
  63484. /**
  63485. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  63486. * @param effect The effect to update
  63487. * @param lightIndex The index of the light in the effect to update
  63488. * @returns The directional light
  63489. */
  63490. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  63491. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  63492. /**
  63493. * Gets the minZ used for shadow according to both the scene and the light.
  63494. *
  63495. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63496. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63497. * @param activeCamera The camera we are returning the min for
  63498. * @returns the depth min z
  63499. */
  63500. getDepthMinZ(activeCamera: Camera): number;
  63501. /**
  63502. * Gets the maxZ used for shadow according to both the scene and the light.
  63503. *
  63504. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63505. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63506. * @param activeCamera The camera we are returning the max for
  63507. * @returns the depth max z
  63508. */
  63509. getDepthMaxZ(activeCamera: Camera): number;
  63510. /**
  63511. * Prepares the list of defines specific to the light type.
  63512. * @param defines the list of defines
  63513. * @param lightIndex defines the index of the light for the effect
  63514. */
  63515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63516. }
  63517. }
  63518. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  63519. import { Mesh } from "babylonjs/Meshes/mesh";
  63520. /**
  63521. * Class containing static functions to help procedurally build meshes
  63522. */
  63523. export class HemisphereBuilder {
  63524. /**
  63525. * Creates a hemisphere mesh
  63526. * @param name defines the name of the mesh
  63527. * @param options defines the options used to create the mesh
  63528. * @param scene defines the hosting scene
  63529. * @returns the hemisphere mesh
  63530. */
  63531. static CreateHemisphere(name: string, options: {
  63532. segments?: number;
  63533. diameter?: number;
  63534. sideOrientation?: number;
  63535. }, scene: any): Mesh;
  63536. }
  63537. }
  63538. declare module "babylonjs/Lights/spotLight" {
  63539. import { Nullable } from "babylonjs/types";
  63540. import { Scene } from "babylonjs/scene";
  63541. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63543. import { Effect } from "babylonjs/Materials/effect";
  63544. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63545. import { Light } from "babylonjs/Lights/light";
  63546. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63547. /**
  63548. * A spot light is defined by a position, a direction, an angle, and an exponent.
  63549. * These values define a cone of light starting from the position, emitting toward the direction.
  63550. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  63551. * and the exponent defines the speed of the decay of the light with distance (reach).
  63552. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63553. */
  63554. export class SpotLight extends ShadowLight {
  63555. private _angle;
  63556. private _innerAngle;
  63557. private _cosHalfAngle;
  63558. private _lightAngleScale;
  63559. private _lightAngleOffset;
  63560. /**
  63561. * Gets the cone angle of the spot light in Radians.
  63562. */
  63563. get angle(): number;
  63564. /**
  63565. * Sets the cone angle of the spot light in Radians.
  63566. */
  63567. set angle(value: number);
  63568. /**
  63569. * Only used in gltf falloff mode, this defines the angle where
  63570. * the directional falloff will start before cutting at angle which could be seen
  63571. * as outer angle.
  63572. */
  63573. get innerAngle(): number;
  63574. /**
  63575. * Only used in gltf falloff mode, this defines the angle where
  63576. * the directional falloff will start before cutting at angle which could be seen
  63577. * as outer angle.
  63578. */
  63579. set innerAngle(value: number);
  63580. private _shadowAngleScale;
  63581. /**
  63582. * Allows scaling the angle of the light for shadow generation only.
  63583. */
  63584. get shadowAngleScale(): number;
  63585. /**
  63586. * Allows scaling the angle of the light for shadow generation only.
  63587. */
  63588. set shadowAngleScale(value: number);
  63589. /**
  63590. * The light decay speed with the distance from the emission spot.
  63591. */
  63592. exponent: number;
  63593. private _projectionTextureMatrix;
  63594. /**
  63595. * Allows reading the projecton texture
  63596. */
  63597. get projectionTextureMatrix(): Matrix;
  63598. protected _projectionTextureLightNear: number;
  63599. /**
  63600. * Gets the near clip of the Spotlight for texture projection.
  63601. */
  63602. get projectionTextureLightNear(): number;
  63603. /**
  63604. * Sets the near clip of the Spotlight for texture projection.
  63605. */
  63606. set projectionTextureLightNear(value: number);
  63607. protected _projectionTextureLightFar: number;
  63608. /**
  63609. * Gets the far clip of the Spotlight for texture projection.
  63610. */
  63611. get projectionTextureLightFar(): number;
  63612. /**
  63613. * Sets the far clip of the Spotlight for texture projection.
  63614. */
  63615. set projectionTextureLightFar(value: number);
  63616. protected _projectionTextureUpDirection: Vector3;
  63617. /**
  63618. * Gets the Up vector of the Spotlight for texture projection.
  63619. */
  63620. get projectionTextureUpDirection(): Vector3;
  63621. /**
  63622. * Sets the Up vector of the Spotlight for texture projection.
  63623. */
  63624. set projectionTextureUpDirection(value: Vector3);
  63625. private _projectionTexture;
  63626. /**
  63627. * Gets the projection texture of the light.
  63628. */
  63629. get projectionTexture(): Nullable<BaseTexture>;
  63630. /**
  63631. * Sets the projection texture of the light.
  63632. */
  63633. set projectionTexture(value: Nullable<BaseTexture>);
  63634. private static _IsProceduralTexture;
  63635. private static _IsTexture;
  63636. private _projectionTextureViewLightDirty;
  63637. private _projectionTextureProjectionLightDirty;
  63638. private _projectionTextureDirty;
  63639. private _projectionTextureViewTargetVector;
  63640. private _projectionTextureViewLightMatrix;
  63641. private _projectionTextureProjectionLightMatrix;
  63642. private _projectionTextureScalingMatrix;
  63643. /**
  63644. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  63645. * It can cast shadows.
  63646. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63647. * @param name The light friendly name
  63648. * @param position The position of the spot light in the scene
  63649. * @param direction The direction of the light in the scene
  63650. * @param angle The cone angle of the light in Radians
  63651. * @param exponent The light decay speed with the distance from the emission spot
  63652. * @param scene The scene the lights belongs to
  63653. */
  63654. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  63655. /**
  63656. * Returns the string "SpotLight".
  63657. * @returns the class name
  63658. */
  63659. getClassName(): string;
  63660. /**
  63661. * Returns the integer 2.
  63662. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63663. */
  63664. getTypeID(): number;
  63665. /**
  63666. * Overrides the direction setter to recompute the projection texture view light Matrix.
  63667. */
  63668. protected _setDirection(value: Vector3): void;
  63669. /**
  63670. * Overrides the position setter to recompute the projection texture view light Matrix.
  63671. */
  63672. protected _setPosition(value: Vector3): void;
  63673. /**
  63674. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  63675. * Returns the SpotLight.
  63676. */
  63677. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63678. protected _computeProjectionTextureViewLightMatrix(): void;
  63679. protected _computeProjectionTextureProjectionLightMatrix(): void;
  63680. /**
  63681. * Main function for light texture projection matrix computing.
  63682. */
  63683. protected _computeProjectionTextureMatrix(): void;
  63684. protected _buildUniformLayout(): void;
  63685. private _computeAngleValues;
  63686. /**
  63687. * Sets the passed Effect "effect" with the Light textures.
  63688. * @param effect The effect to update
  63689. * @param lightIndex The index of the light in the effect to update
  63690. * @returns The light
  63691. */
  63692. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  63693. /**
  63694. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  63695. * @param effect The effect to update
  63696. * @param lightIndex The index of the light in the effect to update
  63697. * @returns The spot light
  63698. */
  63699. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  63700. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63701. /**
  63702. * Disposes the light and the associated resources.
  63703. */
  63704. dispose(): void;
  63705. /**
  63706. * Prepares the list of defines specific to the light type.
  63707. * @param defines the list of defines
  63708. * @param lightIndex defines the index of the light for the effect
  63709. */
  63710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63711. }
  63712. }
  63713. declare module "babylonjs/Gizmos/lightGizmo" {
  63714. import { Nullable } from "babylonjs/types";
  63715. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63716. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63717. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63718. import { Light } from "babylonjs/Lights/light";
  63719. import { Observable } from "babylonjs/Misc/observable";
  63720. /**
  63721. * Gizmo that enables viewing a light
  63722. */
  63723. export class LightGizmo extends Gizmo {
  63724. private _lightMesh;
  63725. private _material;
  63726. private _cachedPosition;
  63727. private _cachedForward;
  63728. private _attachedMeshParent;
  63729. private _pointerObserver;
  63730. /**
  63731. * Event that fires each time the gizmo is clicked
  63732. */
  63733. onClickedObservable: Observable<Light>;
  63734. /**
  63735. * Creates a LightGizmo
  63736. * @param gizmoLayer The utility layer the gizmo will be added to
  63737. */
  63738. constructor(gizmoLayer?: UtilityLayerRenderer);
  63739. private _light;
  63740. /**
  63741. * The light that the gizmo is attached to
  63742. */
  63743. set light(light: Nullable<Light>);
  63744. get light(): Nullable<Light>;
  63745. /**
  63746. * Gets the material used to render the light gizmo
  63747. */
  63748. get material(): StandardMaterial;
  63749. /**
  63750. * @hidden
  63751. * Updates the gizmo to match the attached mesh's position/rotation
  63752. */
  63753. protected _update(): void;
  63754. private static _Scale;
  63755. /**
  63756. * Creates the lines for a light mesh
  63757. */
  63758. private static _CreateLightLines;
  63759. /**
  63760. * Disposes of the light gizmo
  63761. */
  63762. dispose(): void;
  63763. private static _CreateHemisphericLightMesh;
  63764. private static _CreatePointLightMesh;
  63765. private static _CreateSpotLightMesh;
  63766. private static _CreateDirectionalLightMesh;
  63767. }
  63768. }
  63769. declare module "babylonjs/Gizmos/cameraGizmo" {
  63770. import { Nullable } from "babylonjs/types";
  63771. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63772. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63773. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63774. import { Camera } from "babylonjs/Cameras/camera";
  63775. import { Observable } from "babylonjs/Misc/observable";
  63776. /**
  63777. * Gizmo that enables viewing a camera
  63778. */
  63779. export class CameraGizmo extends Gizmo {
  63780. private _cameraMesh;
  63781. private _cameraLinesMesh;
  63782. private _material;
  63783. private _pointerObserver;
  63784. /**
  63785. * Event that fires each time the gizmo is clicked
  63786. */
  63787. onClickedObservable: Observable<Camera>;
  63788. /**
  63789. * Creates a CameraGizmo
  63790. * @param gizmoLayer The utility layer the gizmo will be added to
  63791. */
  63792. constructor(gizmoLayer?: UtilityLayerRenderer);
  63793. private _camera;
  63794. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  63795. get displayFrustum(): boolean;
  63796. set displayFrustum(value: boolean);
  63797. /**
  63798. * The camera that the gizmo is attached to
  63799. */
  63800. set camera(camera: Nullable<Camera>);
  63801. get camera(): Nullable<Camera>;
  63802. /**
  63803. * Gets the material used to render the camera gizmo
  63804. */
  63805. get material(): StandardMaterial;
  63806. /**
  63807. * @hidden
  63808. * Updates the gizmo to match the attached mesh's position/rotation
  63809. */
  63810. protected _update(): void;
  63811. private static _Scale;
  63812. private _invProjection;
  63813. /**
  63814. * Disposes of the camera gizmo
  63815. */
  63816. dispose(): void;
  63817. private static _CreateCameraMesh;
  63818. private static _CreateCameraFrustum;
  63819. }
  63820. }
  63821. declare module "babylonjs/Gizmos/index" {
  63822. export * from "babylonjs/Gizmos/axisDragGizmo";
  63823. export * from "babylonjs/Gizmos/axisScaleGizmo";
  63824. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  63825. export * from "babylonjs/Gizmos/gizmo";
  63826. export * from "babylonjs/Gizmos/gizmoManager";
  63827. export * from "babylonjs/Gizmos/planeRotationGizmo";
  63828. export * from "babylonjs/Gizmos/positionGizmo";
  63829. export * from "babylonjs/Gizmos/rotationGizmo";
  63830. export * from "babylonjs/Gizmos/scaleGizmo";
  63831. export * from "babylonjs/Gizmos/lightGizmo";
  63832. export * from "babylonjs/Gizmos/cameraGizmo";
  63833. export * from "babylonjs/Gizmos/planeDragGizmo";
  63834. }
  63835. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  63836. /** @hidden */
  63837. export var backgroundFragmentDeclaration: {
  63838. name: string;
  63839. shader: string;
  63840. };
  63841. }
  63842. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  63843. /** @hidden */
  63844. export var backgroundUboDeclaration: {
  63845. name: string;
  63846. shader: string;
  63847. };
  63848. }
  63849. declare module "babylonjs/Shaders/background.fragment" {
  63850. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  63851. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63852. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  63853. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63854. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63855. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63856. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63857. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  63858. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  63859. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63860. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  63861. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63862. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63863. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  63864. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  63865. /** @hidden */
  63866. export var backgroundPixelShader: {
  63867. name: string;
  63868. shader: string;
  63869. };
  63870. }
  63871. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  63872. /** @hidden */
  63873. export var backgroundVertexDeclaration: {
  63874. name: string;
  63875. shader: string;
  63876. };
  63877. }
  63878. declare module "babylonjs/Shaders/background.vertex" {
  63879. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  63880. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63882. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63883. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63884. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  63885. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  63886. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63887. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63888. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63889. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63890. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63891. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  63892. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  63893. /** @hidden */
  63894. export var backgroundVertexShader: {
  63895. name: string;
  63896. shader: string;
  63897. };
  63898. }
  63899. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  63900. import { Nullable, int, float } from "babylonjs/types";
  63901. import { Scene } from "babylonjs/scene";
  63902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63903. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63905. import { Mesh } from "babylonjs/Meshes/mesh";
  63906. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  63907. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  63908. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  63909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63910. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  63911. import { Color3 } from "babylonjs/Maths/math.color";
  63912. import "babylonjs/Shaders/background.fragment";
  63913. import "babylonjs/Shaders/background.vertex";
  63914. /**
  63915. * Background material used to create an efficient environement around your scene.
  63916. */
  63917. export class BackgroundMaterial extends PushMaterial {
  63918. /**
  63919. * Standard reflectance value at parallel view angle.
  63920. */
  63921. static StandardReflectance0: number;
  63922. /**
  63923. * Standard reflectance value at grazing angle.
  63924. */
  63925. static StandardReflectance90: number;
  63926. protected _primaryColor: Color3;
  63927. /**
  63928. * Key light Color (multiply against the environement texture)
  63929. */
  63930. primaryColor: Color3;
  63931. protected __perceptualColor: Nullable<Color3>;
  63932. /**
  63933. * Experimental Internal Use Only.
  63934. *
  63935. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  63936. * This acts as a helper to set the primary color to a more "human friendly" value.
  63937. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  63938. * output color as close as possible from the chosen value.
  63939. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  63940. * part of lighting setup.)
  63941. */
  63942. get _perceptualColor(): Nullable<Color3>;
  63943. set _perceptualColor(value: Nullable<Color3>);
  63944. protected _primaryColorShadowLevel: float;
  63945. /**
  63946. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  63947. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  63948. */
  63949. get primaryColorShadowLevel(): float;
  63950. set primaryColorShadowLevel(value: float);
  63951. protected _primaryColorHighlightLevel: float;
  63952. /**
  63953. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  63954. * The primary color is used at the level chosen to define what the white area would look.
  63955. */
  63956. get primaryColorHighlightLevel(): float;
  63957. set primaryColorHighlightLevel(value: float);
  63958. protected _reflectionTexture: Nullable<BaseTexture>;
  63959. /**
  63960. * Reflection Texture used in the material.
  63961. * Should be author in a specific way for the best result (refer to the documentation).
  63962. */
  63963. reflectionTexture: Nullable<BaseTexture>;
  63964. protected _reflectionBlur: float;
  63965. /**
  63966. * Reflection Texture level of blur.
  63967. *
  63968. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  63969. * texture twice.
  63970. */
  63971. reflectionBlur: float;
  63972. protected _diffuseTexture: Nullable<BaseTexture>;
  63973. /**
  63974. * Diffuse Texture used in the material.
  63975. * Should be author in a specific way for the best result (refer to the documentation).
  63976. */
  63977. diffuseTexture: Nullable<BaseTexture>;
  63978. protected _shadowLights: Nullable<IShadowLight[]>;
  63979. /**
  63980. * Specify the list of lights casting shadow on the material.
  63981. * All scene shadow lights will be included if null.
  63982. */
  63983. shadowLights: Nullable<IShadowLight[]>;
  63984. protected _shadowLevel: float;
  63985. /**
  63986. * Helps adjusting the shadow to a softer level if required.
  63987. * 0 means black shadows and 1 means no shadows.
  63988. */
  63989. shadowLevel: float;
  63990. protected _sceneCenter: Vector3;
  63991. /**
  63992. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  63993. * It is usually zero but might be interesting to modify according to your setup.
  63994. */
  63995. sceneCenter: Vector3;
  63996. protected _opacityFresnel: boolean;
  63997. /**
  63998. * This helps specifying that the material is falling off to the sky box at grazing angle.
  63999. * This helps ensuring a nice transition when the camera goes under the ground.
  64000. */
  64001. opacityFresnel: boolean;
  64002. protected _reflectionFresnel: boolean;
  64003. /**
  64004. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  64005. * This helps adding a mirror texture on the ground.
  64006. */
  64007. reflectionFresnel: boolean;
  64008. protected _reflectionFalloffDistance: number;
  64009. /**
  64010. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  64011. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  64012. */
  64013. reflectionFalloffDistance: number;
  64014. protected _reflectionAmount: number;
  64015. /**
  64016. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  64017. */
  64018. reflectionAmount: number;
  64019. protected _reflectionReflectance0: number;
  64020. /**
  64021. * This specifies the weight of the reflection at grazing angle.
  64022. */
  64023. reflectionReflectance0: number;
  64024. protected _reflectionReflectance90: number;
  64025. /**
  64026. * This specifies the weight of the reflection at a perpendicular point of view.
  64027. */
  64028. reflectionReflectance90: number;
  64029. /**
  64030. * Sets the reflection reflectance fresnel values according to the default standard
  64031. * empirically know to work well :-)
  64032. */
  64033. set reflectionStandardFresnelWeight(value: number);
  64034. protected _useRGBColor: boolean;
  64035. /**
  64036. * Helps to directly use the maps channels instead of their level.
  64037. */
  64038. useRGBColor: boolean;
  64039. protected _enableNoise: boolean;
  64040. /**
  64041. * This helps reducing the banding effect that could occur on the background.
  64042. */
  64043. enableNoise: boolean;
  64044. /**
  64045. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  64046. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  64047. * Recommended to be keep at 1.0 except for special cases.
  64048. */
  64049. get fovMultiplier(): number;
  64050. set fovMultiplier(value: number);
  64051. private _fovMultiplier;
  64052. /**
  64053. * Enable the FOV adjustment feature controlled by fovMultiplier.
  64054. */
  64055. useEquirectangularFOV: boolean;
  64056. private _maxSimultaneousLights;
  64057. /**
  64058. * Number of Simultaneous lights allowed on the material.
  64059. */
  64060. maxSimultaneousLights: int;
  64061. private _shadowOnly;
  64062. /**
  64063. * Make the material only render shadows
  64064. */
  64065. shadowOnly: boolean;
  64066. /**
  64067. * Default configuration related to image processing available in the Background Material.
  64068. */
  64069. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  64070. /**
  64071. * Keep track of the image processing observer to allow dispose and replace.
  64072. */
  64073. private _imageProcessingObserver;
  64074. /**
  64075. * Attaches a new image processing configuration to the PBR Material.
  64076. * @param configuration (if null the scene configuration will be use)
  64077. */
  64078. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  64079. /**
  64080. * Gets the image processing configuration used either in this material.
  64081. */
  64082. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  64083. /**
  64084. * Sets the Default image processing configuration used either in the this material.
  64085. *
  64086. * If sets to null, the scene one is in use.
  64087. */
  64088. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  64089. /**
  64090. * Gets wether the color curves effect is enabled.
  64091. */
  64092. get cameraColorCurvesEnabled(): boolean;
  64093. /**
  64094. * Sets wether the color curves effect is enabled.
  64095. */
  64096. set cameraColorCurvesEnabled(value: boolean);
  64097. /**
  64098. * Gets wether the color grading effect is enabled.
  64099. */
  64100. get cameraColorGradingEnabled(): boolean;
  64101. /**
  64102. * Gets wether the color grading effect is enabled.
  64103. */
  64104. set cameraColorGradingEnabled(value: boolean);
  64105. /**
  64106. * Gets wether tonemapping is enabled or not.
  64107. */
  64108. get cameraToneMappingEnabled(): boolean;
  64109. /**
  64110. * Sets wether tonemapping is enabled or not
  64111. */
  64112. set cameraToneMappingEnabled(value: boolean);
  64113. /**
  64114. * The camera exposure used on this material.
  64115. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64116. * This corresponds to a photographic exposure.
  64117. */
  64118. get cameraExposure(): float;
  64119. /**
  64120. * The camera exposure used on this material.
  64121. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64122. * This corresponds to a photographic exposure.
  64123. */
  64124. set cameraExposure(value: float);
  64125. /**
  64126. * Gets The camera contrast used on this material.
  64127. */
  64128. get cameraContrast(): float;
  64129. /**
  64130. * Sets The camera contrast used on this material.
  64131. */
  64132. set cameraContrast(value: float);
  64133. /**
  64134. * Gets the Color Grading 2D Lookup Texture.
  64135. */
  64136. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  64137. /**
  64138. * Sets the Color Grading 2D Lookup Texture.
  64139. */
  64140. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  64141. /**
  64142. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64143. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64144. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  64145. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64146. */
  64147. get cameraColorCurves(): Nullable<ColorCurves>;
  64148. /**
  64149. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64150. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64151. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  64152. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64153. */
  64154. set cameraColorCurves(value: Nullable<ColorCurves>);
  64155. /**
  64156. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  64157. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  64158. */
  64159. switchToBGR: boolean;
  64160. private _renderTargets;
  64161. private _reflectionControls;
  64162. private _white;
  64163. private _primaryShadowColor;
  64164. private _primaryHighlightColor;
  64165. /**
  64166. * Instantiates a Background Material in the given scene
  64167. * @param name The friendly name of the material
  64168. * @param scene The scene to add the material to
  64169. */
  64170. constructor(name: string, scene: Scene);
  64171. /**
  64172. * Gets a boolean indicating that current material needs to register RTT
  64173. */
  64174. get hasRenderTargetTextures(): boolean;
  64175. /**
  64176. * The entire material has been created in order to prevent overdraw.
  64177. * @returns false
  64178. */
  64179. needAlphaTesting(): boolean;
  64180. /**
  64181. * The entire material has been created in order to prevent overdraw.
  64182. * @returns true if blending is enable
  64183. */
  64184. needAlphaBlending(): boolean;
  64185. /**
  64186. * Checks wether the material is ready to be rendered for a given mesh.
  64187. * @param mesh The mesh to render
  64188. * @param subMesh The submesh to check against
  64189. * @param useInstances Specify wether or not the material is used with instances
  64190. * @returns true if all the dependencies are ready (Textures, Effects...)
  64191. */
  64192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  64193. /**
  64194. * Compute the primary color according to the chosen perceptual color.
  64195. */
  64196. private _computePrimaryColorFromPerceptualColor;
  64197. /**
  64198. * Compute the highlights and shadow colors according to their chosen levels.
  64199. */
  64200. private _computePrimaryColors;
  64201. /**
  64202. * Build the uniform buffer used in the material.
  64203. */
  64204. buildUniformLayout(): void;
  64205. /**
  64206. * Unbind the material.
  64207. */
  64208. unbind(): void;
  64209. /**
  64210. * Bind only the world matrix to the material.
  64211. * @param world The world matrix to bind.
  64212. */
  64213. bindOnlyWorldMatrix(world: Matrix): void;
  64214. /**
  64215. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  64216. * @param world The world matrix to bind.
  64217. * @param subMesh The submesh to bind for.
  64218. */
  64219. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  64220. /**
  64221. * Checks to see if a texture is used in the material.
  64222. * @param texture - Base texture to use.
  64223. * @returns - Boolean specifying if a texture is used in the material.
  64224. */
  64225. hasTexture(texture: BaseTexture): boolean;
  64226. /**
  64227. * Dispose the material.
  64228. * @param forceDisposeEffect Force disposal of the associated effect.
  64229. * @param forceDisposeTextures Force disposal of the associated textures.
  64230. */
  64231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  64232. /**
  64233. * Clones the material.
  64234. * @param name The cloned name.
  64235. * @returns The cloned material.
  64236. */
  64237. clone(name: string): BackgroundMaterial;
  64238. /**
  64239. * Serializes the current material to its JSON representation.
  64240. * @returns The JSON representation.
  64241. */
  64242. serialize(): any;
  64243. /**
  64244. * Gets the class name of the material
  64245. * @returns "BackgroundMaterial"
  64246. */
  64247. getClassName(): string;
  64248. /**
  64249. * Parse a JSON input to create back a background material.
  64250. * @param source The JSON data to parse
  64251. * @param scene The scene to create the parsed material in
  64252. * @param rootUrl The root url of the assets the material depends upon
  64253. * @returns the instantiated BackgroundMaterial.
  64254. */
  64255. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  64256. }
  64257. }
  64258. declare module "babylonjs/Helpers/environmentHelper" {
  64259. import { Observable } from "babylonjs/Misc/observable";
  64260. import { Nullable } from "babylonjs/types";
  64261. import { Scene } from "babylonjs/scene";
  64262. import { Vector3 } from "babylonjs/Maths/math.vector";
  64263. import { Color3 } from "babylonjs/Maths/math.color";
  64264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64265. import { Mesh } from "babylonjs/Meshes/mesh";
  64266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64267. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  64268. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  64269. import "babylonjs/Meshes/Builders/planeBuilder";
  64270. import "babylonjs/Meshes/Builders/boxBuilder";
  64271. /**
  64272. * Represents the different options available during the creation of
  64273. * a Environment helper.
  64274. *
  64275. * This can control the default ground, skybox and image processing setup of your scene.
  64276. */
  64277. export interface IEnvironmentHelperOptions {
  64278. /**
  64279. * Specifies whether or not to create a ground.
  64280. * True by default.
  64281. */
  64282. createGround: boolean;
  64283. /**
  64284. * Specifies the ground size.
  64285. * 15 by default.
  64286. */
  64287. groundSize: number;
  64288. /**
  64289. * The texture used on the ground for the main color.
  64290. * Comes from the BabylonJS CDN by default.
  64291. *
  64292. * Remarks: Can be either a texture or a url.
  64293. */
  64294. groundTexture: string | BaseTexture;
  64295. /**
  64296. * The color mixed in the ground texture by default.
  64297. * BabylonJS clearColor by default.
  64298. */
  64299. groundColor: Color3;
  64300. /**
  64301. * Specifies the ground opacity.
  64302. * 1 by default.
  64303. */
  64304. groundOpacity: number;
  64305. /**
  64306. * Enables the ground to receive shadows.
  64307. * True by default.
  64308. */
  64309. enableGroundShadow: boolean;
  64310. /**
  64311. * Helps preventing the shadow to be fully black on the ground.
  64312. * 0.5 by default.
  64313. */
  64314. groundShadowLevel: number;
  64315. /**
  64316. * Creates a mirror texture attach to the ground.
  64317. * false by default.
  64318. */
  64319. enableGroundMirror: boolean;
  64320. /**
  64321. * Specifies the ground mirror size ratio.
  64322. * 0.3 by default as the default kernel is 64.
  64323. */
  64324. groundMirrorSizeRatio: number;
  64325. /**
  64326. * Specifies the ground mirror blur kernel size.
  64327. * 64 by default.
  64328. */
  64329. groundMirrorBlurKernel: number;
  64330. /**
  64331. * Specifies the ground mirror visibility amount.
  64332. * 1 by default
  64333. */
  64334. groundMirrorAmount: number;
  64335. /**
  64336. * Specifies the ground mirror reflectance weight.
  64337. * This uses the standard weight of the background material to setup the fresnel effect
  64338. * of the mirror.
  64339. * 1 by default.
  64340. */
  64341. groundMirrorFresnelWeight: number;
  64342. /**
  64343. * Specifies the ground mirror Falloff distance.
  64344. * This can helps reducing the size of the reflection.
  64345. * 0 by Default.
  64346. */
  64347. groundMirrorFallOffDistance: number;
  64348. /**
  64349. * Specifies the ground mirror texture type.
  64350. * Unsigned Int by Default.
  64351. */
  64352. groundMirrorTextureType: number;
  64353. /**
  64354. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  64355. * the shown objects.
  64356. */
  64357. groundYBias: number;
  64358. /**
  64359. * Specifies whether or not to create a skybox.
  64360. * True by default.
  64361. */
  64362. createSkybox: boolean;
  64363. /**
  64364. * Specifies the skybox size.
  64365. * 20 by default.
  64366. */
  64367. skyboxSize: number;
  64368. /**
  64369. * The texture used on the skybox for the main color.
  64370. * Comes from the BabylonJS CDN by default.
  64371. *
  64372. * Remarks: Can be either a texture or a url.
  64373. */
  64374. skyboxTexture: string | BaseTexture;
  64375. /**
  64376. * The color mixed in the skybox texture by default.
  64377. * BabylonJS clearColor by default.
  64378. */
  64379. skyboxColor: Color3;
  64380. /**
  64381. * The background rotation around the Y axis of the scene.
  64382. * This helps aligning the key lights of your scene with the background.
  64383. * 0 by default.
  64384. */
  64385. backgroundYRotation: number;
  64386. /**
  64387. * Compute automatically the size of the elements to best fit with the scene.
  64388. */
  64389. sizeAuto: boolean;
  64390. /**
  64391. * Default position of the rootMesh if autoSize is not true.
  64392. */
  64393. rootPosition: Vector3;
  64394. /**
  64395. * Sets up the image processing in the scene.
  64396. * true by default.
  64397. */
  64398. setupImageProcessing: boolean;
  64399. /**
  64400. * The texture used as your environment texture in the scene.
  64401. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  64402. *
  64403. * Remarks: Can be either a texture or a url.
  64404. */
  64405. environmentTexture: string | BaseTexture;
  64406. /**
  64407. * The value of the exposure to apply to the scene.
  64408. * 0.6 by default if setupImageProcessing is true.
  64409. */
  64410. cameraExposure: number;
  64411. /**
  64412. * The value of the contrast to apply to the scene.
  64413. * 1.6 by default if setupImageProcessing is true.
  64414. */
  64415. cameraContrast: number;
  64416. /**
  64417. * Specifies whether or not tonemapping should be enabled in the scene.
  64418. * true by default if setupImageProcessing is true.
  64419. */
  64420. toneMappingEnabled: boolean;
  64421. }
  64422. /**
  64423. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  64424. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  64425. * It also helps with the default setup of your imageProcessing configuration.
  64426. */
  64427. export class EnvironmentHelper {
  64428. /**
  64429. * Default ground texture URL.
  64430. */
  64431. private static _groundTextureCDNUrl;
  64432. /**
  64433. * Default skybox texture URL.
  64434. */
  64435. private static _skyboxTextureCDNUrl;
  64436. /**
  64437. * Default environment texture URL.
  64438. */
  64439. private static _environmentTextureCDNUrl;
  64440. /**
  64441. * Creates the default options for the helper.
  64442. */
  64443. private static _getDefaultOptions;
  64444. private _rootMesh;
  64445. /**
  64446. * Gets the root mesh created by the helper.
  64447. */
  64448. get rootMesh(): Mesh;
  64449. private _skybox;
  64450. /**
  64451. * Gets the skybox created by the helper.
  64452. */
  64453. get skybox(): Nullable<Mesh>;
  64454. private _skyboxTexture;
  64455. /**
  64456. * Gets the skybox texture created by the helper.
  64457. */
  64458. get skyboxTexture(): Nullable<BaseTexture>;
  64459. private _skyboxMaterial;
  64460. /**
  64461. * Gets the skybox material created by the helper.
  64462. */
  64463. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  64464. private _ground;
  64465. /**
  64466. * Gets the ground mesh created by the helper.
  64467. */
  64468. get ground(): Nullable<Mesh>;
  64469. private _groundTexture;
  64470. /**
  64471. * Gets the ground texture created by the helper.
  64472. */
  64473. get groundTexture(): Nullable<BaseTexture>;
  64474. private _groundMirror;
  64475. /**
  64476. * Gets the ground mirror created by the helper.
  64477. */
  64478. get groundMirror(): Nullable<MirrorTexture>;
  64479. /**
  64480. * Gets the ground mirror render list to helps pushing the meshes
  64481. * you wish in the ground reflection.
  64482. */
  64483. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  64484. private _groundMaterial;
  64485. /**
  64486. * Gets the ground material created by the helper.
  64487. */
  64488. get groundMaterial(): Nullable<BackgroundMaterial>;
  64489. /**
  64490. * Stores the creation options.
  64491. */
  64492. private readonly _scene;
  64493. private _options;
  64494. /**
  64495. * This observable will be notified with any error during the creation of the environment,
  64496. * mainly texture creation errors.
  64497. */
  64498. onErrorObservable: Observable<{
  64499. message?: string;
  64500. exception?: any;
  64501. }>;
  64502. /**
  64503. * constructor
  64504. * @param options Defines the options we want to customize the helper
  64505. * @param scene The scene to add the material to
  64506. */
  64507. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  64508. /**
  64509. * Updates the background according to the new options
  64510. * @param options
  64511. */
  64512. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  64513. /**
  64514. * Sets the primary color of all the available elements.
  64515. * @param color the main color to affect to the ground and the background
  64516. */
  64517. setMainColor(color: Color3): void;
  64518. /**
  64519. * Setup the image processing according to the specified options.
  64520. */
  64521. private _setupImageProcessing;
  64522. /**
  64523. * Setup the environment texture according to the specified options.
  64524. */
  64525. private _setupEnvironmentTexture;
  64526. /**
  64527. * Setup the background according to the specified options.
  64528. */
  64529. private _setupBackground;
  64530. /**
  64531. * Get the scene sizes according to the setup.
  64532. */
  64533. private _getSceneSize;
  64534. /**
  64535. * Setup the ground according to the specified options.
  64536. */
  64537. private _setupGround;
  64538. /**
  64539. * Setup the ground material according to the specified options.
  64540. */
  64541. private _setupGroundMaterial;
  64542. /**
  64543. * Setup the ground diffuse texture according to the specified options.
  64544. */
  64545. private _setupGroundDiffuseTexture;
  64546. /**
  64547. * Setup the ground mirror texture according to the specified options.
  64548. */
  64549. private _setupGroundMirrorTexture;
  64550. /**
  64551. * Setup the ground to receive the mirror texture.
  64552. */
  64553. private _setupMirrorInGroundMaterial;
  64554. /**
  64555. * Setup the skybox according to the specified options.
  64556. */
  64557. private _setupSkybox;
  64558. /**
  64559. * Setup the skybox material according to the specified options.
  64560. */
  64561. private _setupSkyboxMaterial;
  64562. /**
  64563. * Setup the skybox reflection texture according to the specified options.
  64564. */
  64565. private _setupSkyboxReflectionTexture;
  64566. private _errorHandler;
  64567. /**
  64568. * Dispose all the elements created by the Helper.
  64569. */
  64570. dispose(): void;
  64571. }
  64572. }
  64573. declare module "babylonjs/Helpers/textureDome" {
  64574. import { Scene } from "babylonjs/scene";
  64575. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64576. import { Mesh } from "babylonjs/Meshes/mesh";
  64577. import { Texture } from "babylonjs/Materials/Textures/texture";
  64578. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  64579. import "babylonjs/Meshes/Builders/sphereBuilder";
  64580. import { Nullable } from "babylonjs/types";
  64581. import { Observable } from "babylonjs/Misc/observable";
  64582. /**
  64583. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  64584. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  64585. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64586. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64587. */
  64588. export abstract class TextureDome<T extends Texture> extends TransformNode {
  64589. protected onError: Nullable<(message?: string, exception?: any) => void>;
  64590. /**
  64591. * Define the source as a Monoscopic panoramic 360/180.
  64592. */
  64593. static readonly MODE_MONOSCOPIC: number;
  64594. /**
  64595. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  64596. */
  64597. static readonly MODE_TOPBOTTOM: number;
  64598. /**
  64599. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  64600. */
  64601. static readonly MODE_SIDEBYSIDE: number;
  64602. private _halfDome;
  64603. private _crossEye;
  64604. protected _useDirectMapping: boolean;
  64605. /**
  64606. * The texture being displayed on the sphere
  64607. */
  64608. protected _texture: T;
  64609. /**
  64610. * Gets the texture being displayed on the sphere
  64611. */
  64612. get texture(): T;
  64613. /**
  64614. * Sets the texture being displayed on the sphere
  64615. */
  64616. set texture(newTexture: T);
  64617. /**
  64618. * The skybox material
  64619. */
  64620. protected _material: BackgroundMaterial;
  64621. /**
  64622. * The surface used for the dome
  64623. */
  64624. protected _mesh: Mesh;
  64625. /**
  64626. * Gets the mesh used for the dome.
  64627. */
  64628. get mesh(): Mesh;
  64629. /**
  64630. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  64631. */
  64632. private _halfDomeMask;
  64633. /**
  64634. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  64635. * Also see the options.resolution property.
  64636. */
  64637. get fovMultiplier(): number;
  64638. set fovMultiplier(value: number);
  64639. protected _textureMode: number;
  64640. /**
  64641. * Gets or set the current texture mode for the texture. It can be:
  64642. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64643. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64644. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64645. */
  64646. get textureMode(): number;
  64647. /**
  64648. * Sets the current texture mode for the texture. It can be:
  64649. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64650. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64651. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64652. */
  64653. set textureMode(value: number);
  64654. /**
  64655. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  64656. */
  64657. get halfDome(): boolean;
  64658. /**
  64659. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  64660. */
  64661. set halfDome(enabled: boolean);
  64662. /**
  64663. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  64664. */
  64665. set crossEye(enabled: boolean);
  64666. /**
  64667. * Is it a cross-eye texture?
  64668. */
  64669. get crossEye(): boolean;
  64670. /**
  64671. * The background material of this dome.
  64672. */
  64673. get material(): BackgroundMaterial;
  64674. /**
  64675. * Oberserver used in Stereoscopic VR Mode.
  64676. */
  64677. private _onBeforeCameraRenderObserver;
  64678. /**
  64679. * Observable raised when an error occured while loading the 360 image
  64680. */
  64681. onLoadErrorObservable: Observable<string>;
  64682. /**
  64683. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  64684. * @param name Element's name, child elements will append suffixes for their own names.
  64685. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  64686. * @param options An object containing optional or exposed sub element properties
  64687. */
  64688. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  64689. resolution?: number;
  64690. clickToPlay?: boolean;
  64691. autoPlay?: boolean;
  64692. loop?: boolean;
  64693. size?: number;
  64694. poster?: string;
  64695. faceForward?: boolean;
  64696. useDirectMapping?: boolean;
  64697. halfDomeMode?: boolean;
  64698. crossEyeMode?: boolean;
  64699. generateMipMaps?: boolean;
  64700. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  64701. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  64702. protected _changeTextureMode(value: number): void;
  64703. /**
  64704. * Releases resources associated with this node.
  64705. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  64706. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  64707. */
  64708. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64709. }
  64710. }
  64711. declare module "babylonjs/Helpers/photoDome" {
  64712. import { Scene } from "babylonjs/scene";
  64713. import { Texture } from "babylonjs/Materials/Textures/texture";
  64714. import { TextureDome } from "babylonjs/Helpers/textureDome";
  64715. /**
  64716. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  64717. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  64718. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64719. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64720. */
  64721. export class PhotoDome extends TextureDome<Texture> {
  64722. /**
  64723. * Define the image as a Monoscopic panoramic 360 image.
  64724. */
  64725. static readonly MODE_MONOSCOPIC: number;
  64726. /**
  64727. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  64728. */
  64729. static readonly MODE_TOPBOTTOM: number;
  64730. /**
  64731. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  64732. */
  64733. static readonly MODE_SIDEBYSIDE: number;
  64734. /**
  64735. * Gets or sets the texture being displayed on the sphere
  64736. */
  64737. get photoTexture(): Texture;
  64738. /**
  64739. * sets the texture being displayed on the sphere
  64740. */
  64741. set photoTexture(value: Texture);
  64742. /**
  64743. * Gets the current video mode for the video. It can be:
  64744. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64745. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64746. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64747. */
  64748. get imageMode(): number;
  64749. /**
  64750. * Sets the current video mode for the video. It can be:
  64751. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64752. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64753. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64754. */
  64755. set imageMode(value: number);
  64756. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  64757. }
  64758. }
  64759. declare module "babylonjs/Misc/dds" {
  64760. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64762. import { Nullable } from "babylonjs/types";
  64763. import { Scene } from "babylonjs/scene";
  64764. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  64765. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64766. /**
  64767. * Direct draw surface info
  64768. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  64769. */
  64770. export interface DDSInfo {
  64771. /**
  64772. * Width of the texture
  64773. */
  64774. width: number;
  64775. /**
  64776. * Width of the texture
  64777. */
  64778. height: number;
  64779. /**
  64780. * Number of Mipmaps for the texture
  64781. * @see https://en.wikipedia.org/wiki/Mipmap
  64782. */
  64783. mipmapCount: number;
  64784. /**
  64785. * If the textures format is a known fourCC format
  64786. * @see https://www.fourcc.org/
  64787. */
  64788. isFourCC: boolean;
  64789. /**
  64790. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  64791. */
  64792. isRGB: boolean;
  64793. /**
  64794. * If the texture is a lumincance format
  64795. */
  64796. isLuminance: boolean;
  64797. /**
  64798. * If this is a cube texture
  64799. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  64800. */
  64801. isCube: boolean;
  64802. /**
  64803. * If the texture is a compressed format eg. FOURCC_DXT1
  64804. */
  64805. isCompressed: boolean;
  64806. /**
  64807. * The dxgiFormat of the texture
  64808. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  64809. */
  64810. dxgiFormat: number;
  64811. /**
  64812. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  64813. */
  64814. textureType: number;
  64815. /**
  64816. * Sphericle polynomial created for the dds texture
  64817. */
  64818. sphericalPolynomial?: SphericalPolynomial;
  64819. }
  64820. /**
  64821. * Class used to provide DDS decompression tools
  64822. */
  64823. export class DDSTools {
  64824. /**
  64825. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  64826. */
  64827. static StoreLODInAlphaChannel: boolean;
  64828. /**
  64829. * Gets DDS information from an array buffer
  64830. * @param data defines the array buffer view to read data from
  64831. * @returns the DDS information
  64832. */
  64833. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  64834. private static _FloatView;
  64835. private static _Int32View;
  64836. private static _ToHalfFloat;
  64837. private static _FromHalfFloat;
  64838. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  64839. private static _GetHalfFloatRGBAArrayBuffer;
  64840. private static _GetFloatRGBAArrayBuffer;
  64841. private static _GetFloatAsUIntRGBAArrayBuffer;
  64842. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  64843. private static _GetRGBAArrayBuffer;
  64844. private static _ExtractLongWordOrder;
  64845. private static _GetRGBArrayBuffer;
  64846. private static _GetLuminanceArrayBuffer;
  64847. /**
  64848. * Uploads DDS Levels to a Babylon Texture
  64849. * @hidden
  64850. */
  64851. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  64852. }
  64853. module "babylonjs/Engines/thinEngine" {
  64854. interface ThinEngine {
  64855. /**
  64856. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  64857. * @param rootUrl defines the url where the file to load is located
  64858. * @param scene defines the current scene
  64859. * @param lodScale defines scale to apply to the mip map selection
  64860. * @param lodOffset defines offset to apply to the mip map selection
  64861. * @param onLoad defines an optional callback raised when the texture is loaded
  64862. * @param onError defines an optional callback raised if there is an issue to load the texture
  64863. * @param format defines the format of the data
  64864. * @param forcedExtension defines the extension to use to pick the right loader
  64865. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  64866. * @returns the cube texture as an InternalTexture
  64867. */
  64868. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  64869. }
  64870. }
  64871. }
  64872. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  64873. import { Nullable } from "babylonjs/types";
  64874. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64875. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64876. /**
  64877. * Implementation of the DDS Texture Loader.
  64878. * @hidden
  64879. */
  64880. export class _DDSTextureLoader implements IInternalTextureLoader {
  64881. /**
  64882. * Defines wether the loader supports cascade loading the different faces.
  64883. */
  64884. readonly supportCascades: boolean;
  64885. /**
  64886. * This returns if the loader support the current file information.
  64887. * @param extension defines the file extension of the file being loaded
  64888. * @returns true if the loader can load the specified file
  64889. */
  64890. canLoad(extension: string): boolean;
  64891. /**
  64892. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64893. * @param data contains the texture data
  64894. * @param texture defines the BabylonJS internal texture
  64895. * @param createPolynomials will be true if polynomials have been requested
  64896. * @param onLoad defines the callback to trigger once the texture is ready
  64897. * @param onError defines the callback to trigger in case of error
  64898. */
  64899. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64900. /**
  64901. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64902. * @param data contains the texture data
  64903. * @param texture defines the BabylonJS internal texture
  64904. * @param callback defines the method to call once ready to upload
  64905. */
  64906. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64907. }
  64908. }
  64909. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  64910. import { Nullable } from "babylonjs/types";
  64911. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64912. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64913. /**
  64914. * Implementation of the ENV Texture Loader.
  64915. * @hidden
  64916. */
  64917. export class _ENVTextureLoader implements IInternalTextureLoader {
  64918. /**
  64919. * Defines wether the loader supports cascade loading the different faces.
  64920. */
  64921. readonly supportCascades: boolean;
  64922. /**
  64923. * This returns if the loader support the current file information.
  64924. * @param extension defines the file extension of the file being loaded
  64925. * @returns true if the loader can load the specified file
  64926. */
  64927. canLoad(extension: string): boolean;
  64928. /**
  64929. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64930. * @param data contains the texture data
  64931. * @param texture defines the BabylonJS internal texture
  64932. * @param createPolynomials will be true if polynomials have been requested
  64933. * @param onLoad defines the callback to trigger once the texture is ready
  64934. * @param onError defines the callback to trigger in case of error
  64935. */
  64936. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64937. /**
  64938. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64939. * @param data contains the texture data
  64940. * @param texture defines the BabylonJS internal texture
  64941. * @param callback defines the method to call once ready to upload
  64942. */
  64943. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64944. }
  64945. }
  64946. declare module "babylonjs/Misc/khronosTextureContainer" {
  64947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64948. /**
  64949. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  64950. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  64951. */
  64952. export class KhronosTextureContainer {
  64953. /** contents of the KTX container file */
  64954. data: ArrayBufferView;
  64955. private static HEADER_LEN;
  64956. private static COMPRESSED_2D;
  64957. private static COMPRESSED_3D;
  64958. private static TEX_2D;
  64959. private static TEX_3D;
  64960. /**
  64961. * Gets the openGL type
  64962. */
  64963. glType: number;
  64964. /**
  64965. * Gets the openGL type size
  64966. */
  64967. glTypeSize: number;
  64968. /**
  64969. * Gets the openGL format
  64970. */
  64971. glFormat: number;
  64972. /**
  64973. * Gets the openGL internal format
  64974. */
  64975. glInternalFormat: number;
  64976. /**
  64977. * Gets the base internal format
  64978. */
  64979. glBaseInternalFormat: number;
  64980. /**
  64981. * Gets image width in pixel
  64982. */
  64983. pixelWidth: number;
  64984. /**
  64985. * Gets image height in pixel
  64986. */
  64987. pixelHeight: number;
  64988. /**
  64989. * Gets image depth in pixels
  64990. */
  64991. pixelDepth: number;
  64992. /**
  64993. * Gets the number of array elements
  64994. */
  64995. numberOfArrayElements: number;
  64996. /**
  64997. * Gets the number of faces
  64998. */
  64999. numberOfFaces: number;
  65000. /**
  65001. * Gets the number of mipmap levels
  65002. */
  65003. numberOfMipmapLevels: number;
  65004. /**
  65005. * Gets the bytes of key value data
  65006. */
  65007. bytesOfKeyValueData: number;
  65008. /**
  65009. * Gets the load type
  65010. */
  65011. loadType: number;
  65012. /**
  65013. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  65014. */
  65015. isInvalid: boolean;
  65016. /**
  65017. * Creates a new KhronosTextureContainer
  65018. * @param data contents of the KTX container file
  65019. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  65020. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  65021. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  65022. */
  65023. constructor(
  65024. /** contents of the KTX container file */
  65025. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  65026. /**
  65027. * Uploads KTX content to a Babylon Texture.
  65028. * It is assumed that the texture has already been created & is currently bound
  65029. * @hidden
  65030. */
  65031. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  65032. private _upload2DCompressedLevels;
  65033. /**
  65034. * Checks if the given data starts with a KTX file identifier.
  65035. * @param data the data to check
  65036. * @returns true if the data is a KTX file or false otherwise
  65037. */
  65038. static IsValid(data: ArrayBufferView): boolean;
  65039. }
  65040. }
  65041. declare module "babylonjs/Misc/workerPool" {
  65042. import { IDisposable } from "babylonjs/scene";
  65043. /**
  65044. * Helper class to push actions to a pool of workers.
  65045. */
  65046. export class WorkerPool implements IDisposable {
  65047. private _workerInfos;
  65048. private _pendingActions;
  65049. /**
  65050. * Constructor
  65051. * @param workers Array of workers to use for actions
  65052. */
  65053. constructor(workers: Array<Worker>);
  65054. /**
  65055. * Terminates all workers and clears any pending actions.
  65056. */
  65057. dispose(): void;
  65058. /**
  65059. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65060. * pended until a worker has completed its action.
  65061. * @param action The action to perform. Call onComplete when the action is complete.
  65062. */
  65063. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65064. private _execute;
  65065. }
  65066. }
  65067. declare module "babylonjs/Misc/khronosTextureContainer2" {
  65068. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65069. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65070. /**
  65071. * Class for loading KTX2 files
  65072. */
  65073. export class KhronosTextureContainer2 {
  65074. private static _WorkerPoolPromise?;
  65075. private static _Initialized;
  65076. private static _Ktx2Decoder;
  65077. /**
  65078. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  65079. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  65080. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  65081. * Urls you can change:
  65082. * URLConfig.jsDecoderModule
  65083. * URLConfig.wasmUASTCToASTC
  65084. * URLConfig.wasmUASTCToBC7
  65085. * URLConfig.wasmUASTCToRGBA_UNORM
  65086. * URLConfig.wasmUASTCToRGBA_SRGB
  65087. * URLConfig.jsMSCTranscoder
  65088. * URLConfig.wasmMSCTranscoder
  65089. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  65090. */
  65091. static URLConfig: {
  65092. jsDecoderModule: string;
  65093. wasmUASTCToASTC: null;
  65094. wasmUASTCToBC7: null;
  65095. wasmUASTCToRGBA_UNORM: null;
  65096. wasmUASTCToRGBA_SRGB: null;
  65097. jsMSCTranscoder: null;
  65098. wasmMSCTranscoder: null;
  65099. };
  65100. /**
  65101. * Default number of workers used to handle data decoding
  65102. */
  65103. static DefaultNumWorkers: number;
  65104. private static GetDefaultNumWorkers;
  65105. private _engine;
  65106. private static _CreateWorkerPool;
  65107. /**
  65108. * Constructor
  65109. * @param engine The engine to use
  65110. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65111. */
  65112. constructor(engine: ThinEngine, numWorkers?: number);
  65113. /** @hidden */
  65114. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  65115. /**
  65116. * Stop all async operations and release resources.
  65117. */
  65118. dispose(): void;
  65119. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  65120. /**
  65121. * Checks if the given data starts with a KTX2 file identifier.
  65122. * @param data the data to check
  65123. * @returns true if the data is a KTX2 file or false otherwise
  65124. */
  65125. static IsValid(data: ArrayBufferView): boolean;
  65126. }
  65127. }
  65128. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  65129. import { Nullable } from "babylonjs/types";
  65130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65131. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65132. /**
  65133. * Implementation of the KTX Texture Loader.
  65134. * @hidden
  65135. */
  65136. export class _KTXTextureLoader implements IInternalTextureLoader {
  65137. /**
  65138. * Defines wether the loader supports cascade loading the different faces.
  65139. */
  65140. readonly supportCascades: boolean;
  65141. /**
  65142. * This returns if the loader support the current file information.
  65143. * @param extension defines the file extension of the file being loaded
  65144. * @param mimeType defines the optional mime type of the file being loaded
  65145. * @returns true if the loader can load the specified file
  65146. */
  65147. canLoad(extension: string, mimeType?: string): boolean;
  65148. /**
  65149. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65150. * @param data contains the texture data
  65151. * @param texture defines the BabylonJS internal texture
  65152. * @param createPolynomials will be true if polynomials have been requested
  65153. * @param onLoad defines the callback to trigger once the texture is ready
  65154. * @param onError defines the callback to trigger in case of error
  65155. */
  65156. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65157. /**
  65158. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65159. * @param data contains the texture data
  65160. * @param texture defines the BabylonJS internal texture
  65161. * @param callback defines the method to call once ready to upload
  65162. */
  65163. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  65164. }
  65165. }
  65166. declare module "babylonjs/Helpers/sceneHelpers" {
  65167. import { Nullable } from "babylonjs/types";
  65168. import { Mesh } from "babylonjs/Meshes/mesh";
  65169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65170. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  65171. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  65172. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65173. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65174. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65175. import "babylonjs/Meshes/Builders/boxBuilder";
  65176. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  65177. /** @hidden */
  65178. export var _forceSceneHelpersToBundle: boolean;
  65179. module "babylonjs/scene" {
  65180. interface Scene {
  65181. /**
  65182. * Creates a default light for the scene.
  65183. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  65184. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  65185. */
  65186. createDefaultLight(replace?: boolean): void;
  65187. /**
  65188. * Creates a default camera for the scene.
  65189. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  65190. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  65191. * @param replace has default false, when true replaces the active camera in the scene
  65192. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  65193. */
  65194. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  65195. /**
  65196. * Creates a default camera and a default light.
  65197. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  65198. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  65199. * @param replace has the default false, when true replaces the active camera/light in the scene
  65200. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  65201. */
  65202. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  65203. /**
  65204. * Creates a new sky box
  65205. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  65206. * @param environmentTexture defines the texture to use as environment texture
  65207. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  65208. * @param scale defines the overall scale of the skybox
  65209. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  65210. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  65211. * @returns a new mesh holding the sky box
  65212. */
  65213. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  65214. /**
  65215. * Creates a new environment
  65216. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  65217. * @param options defines the options you can use to configure the environment
  65218. * @returns the new EnvironmentHelper
  65219. */
  65220. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  65221. /**
  65222. * Creates a new VREXperienceHelper
  65223. * @see https://doc.babylonjs.com/how_to/webvr_helper
  65224. * @param webVROptions defines the options used to create the new VREXperienceHelper
  65225. * @returns a new VREXperienceHelper
  65226. */
  65227. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  65228. /**
  65229. * Creates a new WebXRDefaultExperience
  65230. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  65231. * @param options experience options
  65232. * @returns a promise for a new WebXRDefaultExperience
  65233. */
  65234. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  65235. }
  65236. }
  65237. }
  65238. declare module "babylonjs/Helpers/videoDome" {
  65239. import { Scene } from "babylonjs/scene";
  65240. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  65241. import { TextureDome } from "babylonjs/Helpers/textureDome";
  65242. /**
  65243. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  65244. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  65245. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  65246. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  65247. */
  65248. export class VideoDome extends TextureDome<VideoTexture> {
  65249. /**
  65250. * Define the video source as a Monoscopic panoramic 360 video.
  65251. */
  65252. static readonly MODE_MONOSCOPIC: number;
  65253. /**
  65254. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  65255. */
  65256. static readonly MODE_TOPBOTTOM: number;
  65257. /**
  65258. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  65259. */
  65260. static readonly MODE_SIDEBYSIDE: number;
  65261. /**
  65262. * Get the video texture associated with this video dome
  65263. */
  65264. get videoTexture(): VideoTexture;
  65265. /**
  65266. * Get the video mode of this dome
  65267. */
  65268. get videoMode(): number;
  65269. /**
  65270. * Set the video mode of this dome.
  65271. * @see textureMode
  65272. */
  65273. set videoMode(value: number);
  65274. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  65275. }
  65276. }
  65277. declare module "babylonjs/Helpers/index" {
  65278. export * from "babylonjs/Helpers/environmentHelper";
  65279. export * from "babylonjs/Helpers/photoDome";
  65280. export * from "babylonjs/Helpers/sceneHelpers";
  65281. export * from "babylonjs/Helpers/videoDome";
  65282. }
  65283. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  65284. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  65285. import { IDisposable } from "babylonjs/scene";
  65286. import { Engine } from "babylonjs/Engines/engine";
  65287. /**
  65288. * This class can be used to get instrumentation data from a Babylon engine
  65289. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  65290. */
  65291. export class EngineInstrumentation implements IDisposable {
  65292. /**
  65293. * Define the instrumented engine.
  65294. */
  65295. engine: Engine;
  65296. private _captureGPUFrameTime;
  65297. private _gpuFrameTimeToken;
  65298. private _gpuFrameTime;
  65299. private _captureShaderCompilationTime;
  65300. private _shaderCompilationTime;
  65301. private _onBeginFrameObserver;
  65302. private _onEndFrameObserver;
  65303. private _onBeforeShaderCompilationObserver;
  65304. private _onAfterShaderCompilationObserver;
  65305. /**
  65306. * Gets the perf counter used for GPU frame time
  65307. */
  65308. get gpuFrameTimeCounter(): PerfCounter;
  65309. /**
  65310. * Gets the GPU frame time capture status
  65311. */
  65312. get captureGPUFrameTime(): boolean;
  65313. /**
  65314. * Enable or disable the GPU frame time capture
  65315. */
  65316. set captureGPUFrameTime(value: boolean);
  65317. /**
  65318. * Gets the perf counter used for shader compilation time
  65319. */
  65320. get shaderCompilationTimeCounter(): PerfCounter;
  65321. /**
  65322. * Gets the shader compilation time capture status
  65323. */
  65324. get captureShaderCompilationTime(): boolean;
  65325. /**
  65326. * Enable or disable the shader compilation time capture
  65327. */
  65328. set captureShaderCompilationTime(value: boolean);
  65329. /**
  65330. * Instantiates a new engine instrumentation.
  65331. * This class can be used to get instrumentation data from a Babylon engine
  65332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  65333. * @param engine Defines the engine to instrument
  65334. */
  65335. constructor(
  65336. /**
  65337. * Define the instrumented engine.
  65338. */
  65339. engine: Engine);
  65340. /**
  65341. * Dispose and release associated resources.
  65342. */
  65343. dispose(): void;
  65344. }
  65345. }
  65346. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  65347. import { Scene, IDisposable } from "babylonjs/scene";
  65348. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  65349. /**
  65350. * This class can be used to get instrumentation data from a Babylon engine
  65351. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  65352. */
  65353. export class SceneInstrumentation implements IDisposable {
  65354. /**
  65355. * Defines the scene to instrument
  65356. */
  65357. scene: Scene;
  65358. private _captureActiveMeshesEvaluationTime;
  65359. private _activeMeshesEvaluationTime;
  65360. private _captureRenderTargetsRenderTime;
  65361. private _renderTargetsRenderTime;
  65362. private _captureFrameTime;
  65363. private _frameTime;
  65364. private _captureRenderTime;
  65365. private _renderTime;
  65366. private _captureInterFrameTime;
  65367. private _interFrameTime;
  65368. private _captureParticlesRenderTime;
  65369. private _particlesRenderTime;
  65370. private _captureSpritesRenderTime;
  65371. private _spritesRenderTime;
  65372. private _capturePhysicsTime;
  65373. private _physicsTime;
  65374. private _captureAnimationsTime;
  65375. private _animationsTime;
  65376. private _captureCameraRenderTime;
  65377. private _cameraRenderTime;
  65378. private _onBeforeActiveMeshesEvaluationObserver;
  65379. private _onAfterActiveMeshesEvaluationObserver;
  65380. private _onBeforeRenderTargetsRenderObserver;
  65381. private _onAfterRenderTargetsRenderObserver;
  65382. private _onAfterRenderObserver;
  65383. private _onBeforeDrawPhaseObserver;
  65384. private _onAfterDrawPhaseObserver;
  65385. private _onBeforeAnimationsObserver;
  65386. private _onBeforeParticlesRenderingObserver;
  65387. private _onAfterParticlesRenderingObserver;
  65388. private _onBeforeSpritesRenderingObserver;
  65389. private _onAfterSpritesRenderingObserver;
  65390. private _onBeforePhysicsObserver;
  65391. private _onAfterPhysicsObserver;
  65392. private _onAfterAnimationsObserver;
  65393. private _onBeforeCameraRenderObserver;
  65394. private _onAfterCameraRenderObserver;
  65395. /**
  65396. * Gets the perf counter used for active meshes evaluation time
  65397. */
  65398. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  65399. /**
  65400. * Gets the active meshes evaluation time capture status
  65401. */
  65402. get captureActiveMeshesEvaluationTime(): boolean;
  65403. /**
  65404. * Enable or disable the active meshes evaluation time capture
  65405. */
  65406. set captureActiveMeshesEvaluationTime(value: boolean);
  65407. /**
  65408. * Gets the perf counter used for render targets render time
  65409. */
  65410. get renderTargetsRenderTimeCounter(): PerfCounter;
  65411. /**
  65412. * Gets the render targets render time capture status
  65413. */
  65414. get captureRenderTargetsRenderTime(): boolean;
  65415. /**
  65416. * Enable or disable the render targets render time capture
  65417. */
  65418. set captureRenderTargetsRenderTime(value: boolean);
  65419. /**
  65420. * Gets the perf counter used for particles render time
  65421. */
  65422. get particlesRenderTimeCounter(): PerfCounter;
  65423. /**
  65424. * Gets the particles render time capture status
  65425. */
  65426. get captureParticlesRenderTime(): boolean;
  65427. /**
  65428. * Enable or disable the particles render time capture
  65429. */
  65430. set captureParticlesRenderTime(value: boolean);
  65431. /**
  65432. * Gets the perf counter used for sprites render time
  65433. */
  65434. get spritesRenderTimeCounter(): PerfCounter;
  65435. /**
  65436. * Gets the sprites render time capture status
  65437. */
  65438. get captureSpritesRenderTime(): boolean;
  65439. /**
  65440. * Enable or disable the sprites render time capture
  65441. */
  65442. set captureSpritesRenderTime(value: boolean);
  65443. /**
  65444. * Gets the perf counter used for physics time
  65445. */
  65446. get physicsTimeCounter(): PerfCounter;
  65447. /**
  65448. * Gets the physics time capture status
  65449. */
  65450. get capturePhysicsTime(): boolean;
  65451. /**
  65452. * Enable or disable the physics time capture
  65453. */
  65454. set capturePhysicsTime(value: boolean);
  65455. /**
  65456. * Gets the perf counter used for animations time
  65457. */
  65458. get animationsTimeCounter(): PerfCounter;
  65459. /**
  65460. * Gets the animations time capture status
  65461. */
  65462. get captureAnimationsTime(): boolean;
  65463. /**
  65464. * Enable or disable the animations time capture
  65465. */
  65466. set captureAnimationsTime(value: boolean);
  65467. /**
  65468. * Gets the perf counter used for frame time capture
  65469. */
  65470. get frameTimeCounter(): PerfCounter;
  65471. /**
  65472. * Gets the frame time capture status
  65473. */
  65474. get captureFrameTime(): boolean;
  65475. /**
  65476. * Enable or disable the frame time capture
  65477. */
  65478. set captureFrameTime(value: boolean);
  65479. /**
  65480. * Gets the perf counter used for inter-frames time capture
  65481. */
  65482. get interFrameTimeCounter(): PerfCounter;
  65483. /**
  65484. * Gets the inter-frames time capture status
  65485. */
  65486. get captureInterFrameTime(): boolean;
  65487. /**
  65488. * Enable or disable the inter-frames time capture
  65489. */
  65490. set captureInterFrameTime(value: boolean);
  65491. /**
  65492. * Gets the perf counter used for render time capture
  65493. */
  65494. get renderTimeCounter(): PerfCounter;
  65495. /**
  65496. * Gets the render time capture status
  65497. */
  65498. get captureRenderTime(): boolean;
  65499. /**
  65500. * Enable or disable the render time capture
  65501. */
  65502. set captureRenderTime(value: boolean);
  65503. /**
  65504. * Gets the perf counter used for camera render time capture
  65505. */
  65506. get cameraRenderTimeCounter(): PerfCounter;
  65507. /**
  65508. * Gets the camera render time capture status
  65509. */
  65510. get captureCameraRenderTime(): boolean;
  65511. /**
  65512. * Enable or disable the camera render time capture
  65513. */
  65514. set captureCameraRenderTime(value: boolean);
  65515. /**
  65516. * Gets the perf counter used for draw calls
  65517. */
  65518. get drawCallsCounter(): PerfCounter;
  65519. /**
  65520. * Instantiates a new scene instrumentation.
  65521. * This class can be used to get instrumentation data from a Babylon engine
  65522. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  65523. * @param scene Defines the scene to instrument
  65524. */
  65525. constructor(
  65526. /**
  65527. * Defines the scene to instrument
  65528. */
  65529. scene: Scene);
  65530. /**
  65531. * Dispose and release associated resources.
  65532. */
  65533. dispose(): void;
  65534. }
  65535. }
  65536. declare module "babylonjs/Instrumentation/index" {
  65537. export * from "babylonjs/Instrumentation/engineInstrumentation";
  65538. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  65539. export * from "babylonjs/Instrumentation/timeToken";
  65540. }
  65541. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  65542. /** @hidden */
  65543. export var glowMapGenerationPixelShader: {
  65544. name: string;
  65545. shader: string;
  65546. };
  65547. }
  65548. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  65549. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65552. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65553. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65554. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65555. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65556. /** @hidden */
  65557. export var glowMapGenerationVertexShader: {
  65558. name: string;
  65559. shader: string;
  65560. };
  65561. }
  65562. declare module "babylonjs/Layers/effectLayer" {
  65563. import { Observable } from "babylonjs/Misc/observable";
  65564. import { Nullable } from "babylonjs/types";
  65565. import { Camera } from "babylonjs/Cameras/camera";
  65566. import { Scene } from "babylonjs/scene";
  65567. import { ISize } from "babylonjs/Maths/math.size";
  65568. import { Color4 } from "babylonjs/Maths/math.color";
  65569. import { Engine } from "babylonjs/Engines/engine";
  65570. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65572. import { Mesh } from "babylonjs/Meshes/mesh";
  65573. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65575. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65576. import { Effect } from "babylonjs/Materials/effect";
  65577. import { Material } from "babylonjs/Materials/material";
  65578. import "babylonjs/Shaders/glowMapGeneration.fragment";
  65579. import "babylonjs/Shaders/glowMapGeneration.vertex";
  65580. /**
  65581. * Effect layer options. This helps customizing the behaviour
  65582. * of the effect layer.
  65583. */
  65584. export interface IEffectLayerOptions {
  65585. /**
  65586. * Multiplication factor apply to the canvas size to compute the render target size
  65587. * used to generated the objects (the smaller the faster).
  65588. */
  65589. mainTextureRatio: number;
  65590. /**
  65591. * Enforces a fixed size texture to ensure effect stability across devices.
  65592. */
  65593. mainTextureFixedSize?: number;
  65594. /**
  65595. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  65596. */
  65597. alphaBlendingMode: number;
  65598. /**
  65599. * The camera attached to the layer.
  65600. */
  65601. camera: Nullable<Camera>;
  65602. /**
  65603. * The rendering group to draw the layer in.
  65604. */
  65605. renderingGroupId: number;
  65606. }
  65607. /**
  65608. * The effect layer Helps adding post process effect blended with the main pass.
  65609. *
  65610. * This can be for instance use to generate glow or higlight effects on the scene.
  65611. *
  65612. * The effect layer class can not be used directly and is intented to inherited from to be
  65613. * customized per effects.
  65614. */
  65615. export abstract class EffectLayer {
  65616. private _vertexBuffers;
  65617. private _indexBuffer;
  65618. private _cachedDefines;
  65619. private _effectLayerMapGenerationEffect;
  65620. private _effectLayerOptions;
  65621. private _mergeEffect;
  65622. protected _scene: Scene;
  65623. protected _engine: Engine;
  65624. protected _maxSize: number;
  65625. protected _mainTextureDesiredSize: ISize;
  65626. protected _mainTexture: RenderTargetTexture;
  65627. protected _shouldRender: boolean;
  65628. protected _postProcesses: PostProcess[];
  65629. protected _textures: BaseTexture[];
  65630. protected _emissiveTextureAndColor: {
  65631. texture: Nullable<BaseTexture>;
  65632. color: Color4;
  65633. };
  65634. /**
  65635. * The name of the layer
  65636. */
  65637. name: string;
  65638. /**
  65639. * The clear color of the texture used to generate the glow map.
  65640. */
  65641. neutralColor: Color4;
  65642. /**
  65643. * Specifies whether the highlight layer is enabled or not.
  65644. */
  65645. isEnabled: boolean;
  65646. /**
  65647. * Gets the camera attached to the layer.
  65648. */
  65649. get camera(): Nullable<Camera>;
  65650. /**
  65651. * Gets the rendering group id the layer should render in.
  65652. */
  65653. get renderingGroupId(): number;
  65654. set renderingGroupId(renderingGroupId: number);
  65655. /**
  65656. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  65657. */
  65658. disableBoundingBoxesFromEffectLayer: boolean;
  65659. /**
  65660. * An event triggered when the effect layer has been disposed.
  65661. */
  65662. onDisposeObservable: Observable<EffectLayer>;
  65663. /**
  65664. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  65665. */
  65666. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  65667. /**
  65668. * An event triggered when the generated texture is being merged in the scene.
  65669. */
  65670. onBeforeComposeObservable: Observable<EffectLayer>;
  65671. /**
  65672. * An event triggered when the mesh is rendered into the effect render target.
  65673. */
  65674. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  65675. /**
  65676. * An event triggered after the mesh has been rendered into the effect render target.
  65677. */
  65678. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  65679. /**
  65680. * An event triggered when the generated texture has been merged in the scene.
  65681. */
  65682. onAfterComposeObservable: Observable<EffectLayer>;
  65683. /**
  65684. * An event triggered when the efffect layer changes its size.
  65685. */
  65686. onSizeChangedObservable: Observable<EffectLayer>;
  65687. /** @hidden */
  65688. static _SceneComponentInitialization: (scene: Scene) => void;
  65689. /**
  65690. * Instantiates a new effect Layer and references it in the scene.
  65691. * @param name The name of the layer
  65692. * @param scene The scene to use the layer in
  65693. */
  65694. constructor(
  65695. /** The Friendly of the effect in the scene */
  65696. name: string, scene: Scene);
  65697. /**
  65698. * Get the effect name of the layer.
  65699. * @return The effect name
  65700. */
  65701. abstract getEffectName(): string;
  65702. /**
  65703. * Checks for the readiness of the element composing the layer.
  65704. * @param subMesh the mesh to check for
  65705. * @param useInstances specify whether or not to use instances to render the mesh
  65706. * @return true if ready otherwise, false
  65707. */
  65708. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65709. /**
  65710. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  65711. * @returns true if the effect requires stencil during the main canvas render pass.
  65712. */
  65713. abstract needStencil(): boolean;
  65714. /**
  65715. * Create the merge effect. This is the shader use to blit the information back
  65716. * to the main canvas at the end of the scene rendering.
  65717. * @returns The effect containing the shader used to merge the effect on the main canvas
  65718. */
  65719. protected abstract _createMergeEffect(): Effect;
  65720. /**
  65721. * Creates the render target textures and post processes used in the effect layer.
  65722. */
  65723. protected abstract _createTextureAndPostProcesses(): void;
  65724. /**
  65725. * Implementation specific of rendering the generating effect on the main canvas.
  65726. * @param effect The effect used to render through
  65727. */
  65728. protected abstract _internalRender(effect: Effect): void;
  65729. /**
  65730. * Sets the required values for both the emissive texture and and the main color.
  65731. */
  65732. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  65733. /**
  65734. * Free any resources and references associated to a mesh.
  65735. * Internal use
  65736. * @param mesh The mesh to free.
  65737. */
  65738. abstract _disposeMesh(mesh: Mesh): void;
  65739. /**
  65740. * Serializes this layer (Glow or Highlight for example)
  65741. * @returns a serialized layer object
  65742. */
  65743. abstract serialize?(): any;
  65744. /**
  65745. * Initializes the effect layer with the required options.
  65746. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  65747. */
  65748. protected _init(options: Partial<IEffectLayerOptions>): void;
  65749. /**
  65750. * Generates the index buffer of the full screen quad blending to the main canvas.
  65751. */
  65752. private _generateIndexBuffer;
  65753. /**
  65754. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  65755. */
  65756. private _generateVertexBuffer;
  65757. /**
  65758. * Sets the main texture desired size which is the closest power of two
  65759. * of the engine canvas size.
  65760. */
  65761. private _setMainTextureSize;
  65762. /**
  65763. * Creates the main texture for the effect layer.
  65764. */
  65765. protected _createMainTexture(): void;
  65766. /**
  65767. * Adds specific effects defines.
  65768. * @param defines The defines to add specifics to.
  65769. */
  65770. protected _addCustomEffectDefines(defines: string[]): void;
  65771. /**
  65772. * Checks for the readiness of the element composing the layer.
  65773. * @param subMesh the mesh to check for
  65774. * @param useInstances specify whether or not to use instances to render the mesh
  65775. * @param emissiveTexture the associated emissive texture used to generate the glow
  65776. * @return true if ready otherwise, false
  65777. */
  65778. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  65779. /**
  65780. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  65781. */
  65782. render(): void;
  65783. /**
  65784. * Determine if a given mesh will be used in the current effect.
  65785. * @param mesh mesh to test
  65786. * @returns true if the mesh will be used
  65787. */
  65788. hasMesh(mesh: AbstractMesh): boolean;
  65789. /**
  65790. * Returns true if the layer contains information to display, otherwise false.
  65791. * @returns true if the glow layer should be rendered
  65792. */
  65793. shouldRender(): boolean;
  65794. /**
  65795. * Returns true if the mesh should render, otherwise false.
  65796. * @param mesh The mesh to render
  65797. * @returns true if it should render otherwise false
  65798. */
  65799. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  65800. /**
  65801. * Returns true if the mesh can be rendered, otherwise false.
  65802. * @param mesh The mesh to render
  65803. * @param material The material used on the mesh
  65804. * @returns true if it can be rendered otherwise false
  65805. */
  65806. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  65807. /**
  65808. * Returns true if the mesh should render, otherwise false.
  65809. * @param mesh The mesh to render
  65810. * @returns true if it should render otherwise false
  65811. */
  65812. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  65813. /**
  65814. * Renders the submesh passed in parameter to the generation map.
  65815. */
  65816. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  65817. /**
  65818. * Defines whether the current material of the mesh should be use to render the effect.
  65819. * @param mesh defines the current mesh to render
  65820. */
  65821. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  65822. /**
  65823. * Rebuild the required buffers.
  65824. * @hidden Internal use only.
  65825. */
  65826. _rebuild(): void;
  65827. /**
  65828. * Dispose only the render target textures and post process.
  65829. */
  65830. private _disposeTextureAndPostProcesses;
  65831. /**
  65832. * Dispose the highlight layer and free resources.
  65833. */
  65834. dispose(): void;
  65835. /**
  65836. * Gets the class name of the effect layer
  65837. * @returns the string with the class name of the effect layer
  65838. */
  65839. getClassName(): string;
  65840. /**
  65841. * Creates an effect layer from parsed effect layer data
  65842. * @param parsedEffectLayer defines effect layer data
  65843. * @param scene defines the current scene
  65844. * @param rootUrl defines the root URL containing the effect layer information
  65845. * @returns a parsed effect Layer
  65846. */
  65847. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  65848. }
  65849. }
  65850. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  65851. import { Scene } from "babylonjs/scene";
  65852. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  65853. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65854. import { AbstractScene } from "babylonjs/abstractScene";
  65855. module "babylonjs/abstractScene" {
  65856. interface AbstractScene {
  65857. /**
  65858. * The list of effect layers (highlights/glow) added to the scene
  65859. * @see https://doc.babylonjs.com/how_to/highlight_layer
  65860. * @see https://doc.babylonjs.com/how_to/glow_layer
  65861. */
  65862. effectLayers: Array<EffectLayer>;
  65863. /**
  65864. * Removes the given effect layer from this scene.
  65865. * @param toRemove defines the effect layer to remove
  65866. * @returns the index of the removed effect layer
  65867. */
  65868. removeEffectLayer(toRemove: EffectLayer): number;
  65869. /**
  65870. * Adds the given effect layer to this scene
  65871. * @param newEffectLayer defines the effect layer to add
  65872. */
  65873. addEffectLayer(newEffectLayer: EffectLayer): void;
  65874. }
  65875. }
  65876. /**
  65877. * Defines the layer scene component responsible to manage any effect layers
  65878. * in a given scene.
  65879. */
  65880. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  65881. /**
  65882. * The component name helpfull to identify the component in the list of scene components.
  65883. */
  65884. readonly name: string;
  65885. /**
  65886. * The scene the component belongs to.
  65887. */
  65888. scene: Scene;
  65889. private _engine;
  65890. private _renderEffects;
  65891. private _needStencil;
  65892. private _previousStencilState;
  65893. /**
  65894. * Creates a new instance of the component for the given scene
  65895. * @param scene Defines the scene to register the component in
  65896. */
  65897. constructor(scene: Scene);
  65898. /**
  65899. * Registers the component in a given scene
  65900. */
  65901. register(): void;
  65902. /**
  65903. * Rebuilds the elements related to this component in case of
  65904. * context lost for instance.
  65905. */
  65906. rebuild(): void;
  65907. /**
  65908. * Serializes the component data to the specified json object
  65909. * @param serializationObject The object to serialize to
  65910. */
  65911. serialize(serializationObject: any): void;
  65912. /**
  65913. * Adds all the elements from the container to the scene
  65914. * @param container the container holding the elements
  65915. */
  65916. addFromContainer(container: AbstractScene): void;
  65917. /**
  65918. * Removes all the elements in the container from the scene
  65919. * @param container contains the elements to remove
  65920. * @param dispose if the removed element should be disposed (default: false)
  65921. */
  65922. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65923. /**
  65924. * Disposes the component and the associated ressources.
  65925. */
  65926. dispose(): void;
  65927. private _isReadyForMesh;
  65928. private _renderMainTexture;
  65929. private _setStencil;
  65930. private _setStencilBack;
  65931. private _draw;
  65932. private _drawCamera;
  65933. private _drawRenderingGroup;
  65934. }
  65935. }
  65936. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  65937. /** @hidden */
  65938. export var glowMapMergePixelShader: {
  65939. name: string;
  65940. shader: string;
  65941. };
  65942. }
  65943. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  65944. /** @hidden */
  65945. export var glowMapMergeVertexShader: {
  65946. name: string;
  65947. shader: string;
  65948. };
  65949. }
  65950. declare module "babylonjs/Layers/glowLayer" {
  65951. import { Nullable } from "babylonjs/types";
  65952. import { Camera } from "babylonjs/Cameras/camera";
  65953. import { Scene } from "babylonjs/scene";
  65954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65956. import { Mesh } from "babylonjs/Meshes/mesh";
  65957. import { Texture } from "babylonjs/Materials/Textures/texture";
  65958. import { Effect } from "babylonjs/Materials/effect";
  65959. import { Material } from "babylonjs/Materials/material";
  65960. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65961. import { Color4 } from "babylonjs/Maths/math.color";
  65962. import "babylonjs/Shaders/glowMapMerge.fragment";
  65963. import "babylonjs/Shaders/glowMapMerge.vertex";
  65964. import "babylonjs/Layers/effectLayerSceneComponent";
  65965. module "babylonjs/abstractScene" {
  65966. interface AbstractScene {
  65967. /**
  65968. * Return a the first highlight layer of the scene with a given name.
  65969. * @param name The name of the highlight layer to look for.
  65970. * @return The highlight layer if found otherwise null.
  65971. */
  65972. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  65973. }
  65974. }
  65975. /**
  65976. * Glow layer options. This helps customizing the behaviour
  65977. * of the glow layer.
  65978. */
  65979. export interface IGlowLayerOptions {
  65980. /**
  65981. * Multiplication factor apply to the canvas size to compute the render target size
  65982. * used to generated the glowing objects (the smaller the faster).
  65983. */
  65984. mainTextureRatio: number;
  65985. /**
  65986. * Enforces a fixed size texture to ensure resize independant blur.
  65987. */
  65988. mainTextureFixedSize?: number;
  65989. /**
  65990. * How big is the kernel of the blur texture.
  65991. */
  65992. blurKernelSize: number;
  65993. /**
  65994. * The camera attached to the layer.
  65995. */
  65996. camera: Nullable<Camera>;
  65997. /**
  65998. * Enable MSAA by chosing the number of samples.
  65999. */
  66000. mainTextureSamples?: number;
  66001. /**
  66002. * The rendering group to draw the layer in.
  66003. */
  66004. renderingGroupId: number;
  66005. }
  66006. /**
  66007. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  66008. *
  66009. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  66010. *
  66011. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  66012. */
  66013. export class GlowLayer extends EffectLayer {
  66014. /**
  66015. * Effect Name of the layer.
  66016. */
  66017. static readonly EffectName: string;
  66018. /**
  66019. * The default blur kernel size used for the glow.
  66020. */
  66021. static DefaultBlurKernelSize: number;
  66022. /**
  66023. * The default texture size ratio used for the glow.
  66024. */
  66025. static DefaultTextureRatio: number;
  66026. /**
  66027. * Sets the kernel size of the blur.
  66028. */
  66029. set blurKernelSize(value: number);
  66030. /**
  66031. * Gets the kernel size of the blur.
  66032. */
  66033. get blurKernelSize(): number;
  66034. /**
  66035. * Sets the glow intensity.
  66036. */
  66037. set intensity(value: number);
  66038. /**
  66039. * Gets the glow intensity.
  66040. */
  66041. get intensity(): number;
  66042. private _options;
  66043. private _intensity;
  66044. private _horizontalBlurPostprocess1;
  66045. private _verticalBlurPostprocess1;
  66046. private _horizontalBlurPostprocess2;
  66047. private _verticalBlurPostprocess2;
  66048. private _blurTexture1;
  66049. private _blurTexture2;
  66050. private _postProcesses1;
  66051. private _postProcesses2;
  66052. private _includedOnlyMeshes;
  66053. private _excludedMeshes;
  66054. private _meshesUsingTheirOwnMaterials;
  66055. /**
  66056. * Callback used to let the user override the color selection on a per mesh basis
  66057. */
  66058. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  66059. /**
  66060. * Callback used to let the user override the texture selection on a per mesh basis
  66061. */
  66062. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  66063. /**
  66064. * Instantiates a new glow Layer and references it to the scene.
  66065. * @param name The name of the layer
  66066. * @param scene The scene to use the layer in
  66067. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  66068. */
  66069. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  66070. /**
  66071. * Get the effect name of the layer.
  66072. * @return The effect name
  66073. */
  66074. getEffectName(): string;
  66075. /**
  66076. * Create the merge effect. This is the shader use to blit the information back
  66077. * to the main canvas at the end of the scene rendering.
  66078. */
  66079. protected _createMergeEffect(): Effect;
  66080. /**
  66081. * Creates the render target textures and post processes used in the glow layer.
  66082. */
  66083. protected _createTextureAndPostProcesses(): void;
  66084. /**
  66085. * Checks for the readiness of the element composing the layer.
  66086. * @param subMesh the mesh to check for
  66087. * @param useInstances specify wether or not to use instances to render the mesh
  66088. * @param emissiveTexture the associated emissive texture used to generate the glow
  66089. * @return true if ready otherwise, false
  66090. */
  66091. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66092. /**
  66093. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  66094. */
  66095. needStencil(): boolean;
  66096. /**
  66097. * Returns true if the mesh can be rendered, otherwise false.
  66098. * @param mesh The mesh to render
  66099. * @param material The material used on the mesh
  66100. * @returns true if it can be rendered otherwise false
  66101. */
  66102. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66103. /**
  66104. * Implementation specific of rendering the generating effect on the main canvas.
  66105. * @param effect The effect used to render through
  66106. */
  66107. protected _internalRender(effect: Effect): void;
  66108. /**
  66109. * Sets the required values for both the emissive texture and and the main color.
  66110. */
  66111. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66112. /**
  66113. * Returns true if the mesh should render, otherwise false.
  66114. * @param mesh The mesh to render
  66115. * @returns true if it should render otherwise false
  66116. */
  66117. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66118. /**
  66119. * Adds specific effects defines.
  66120. * @param defines The defines to add specifics to.
  66121. */
  66122. protected _addCustomEffectDefines(defines: string[]): void;
  66123. /**
  66124. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  66125. * @param mesh The mesh to exclude from the glow layer
  66126. */
  66127. addExcludedMesh(mesh: Mesh): void;
  66128. /**
  66129. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  66130. * @param mesh The mesh to remove
  66131. */
  66132. removeExcludedMesh(mesh: Mesh): void;
  66133. /**
  66134. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  66135. * @param mesh The mesh to include in the glow layer
  66136. */
  66137. addIncludedOnlyMesh(mesh: Mesh): void;
  66138. /**
  66139. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  66140. * @param mesh The mesh to remove
  66141. */
  66142. removeIncludedOnlyMesh(mesh: Mesh): void;
  66143. /**
  66144. * Determine if a given mesh will be used in the glow layer
  66145. * @param mesh The mesh to test
  66146. * @returns true if the mesh will be highlighted by the current glow layer
  66147. */
  66148. hasMesh(mesh: AbstractMesh): boolean;
  66149. /**
  66150. * Defines whether the current material of the mesh should be use to render the effect.
  66151. * @param mesh defines the current mesh to render
  66152. */
  66153. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  66154. /**
  66155. * Add a mesh to be rendered through its own material and not with emissive only.
  66156. * @param mesh The mesh for which we need to use its material
  66157. */
  66158. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  66159. /**
  66160. * Remove a mesh from being rendered through its own material and not with emissive only.
  66161. * @param mesh The mesh for which we need to not use its material
  66162. */
  66163. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  66164. /**
  66165. * Free any resources and references associated to a mesh.
  66166. * Internal use
  66167. * @param mesh The mesh to free.
  66168. * @hidden
  66169. */
  66170. _disposeMesh(mesh: Mesh): void;
  66171. /**
  66172. * Gets the class name of the effect layer
  66173. * @returns the string with the class name of the effect layer
  66174. */
  66175. getClassName(): string;
  66176. /**
  66177. * Serializes this glow layer
  66178. * @returns a serialized glow layer object
  66179. */
  66180. serialize(): any;
  66181. /**
  66182. * Creates a Glow Layer from parsed glow layer data
  66183. * @param parsedGlowLayer defines glow layer data
  66184. * @param scene defines the current scene
  66185. * @param rootUrl defines the root URL containing the glow layer information
  66186. * @returns a parsed Glow Layer
  66187. */
  66188. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  66189. }
  66190. }
  66191. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  66192. /** @hidden */
  66193. export var glowBlurPostProcessPixelShader: {
  66194. name: string;
  66195. shader: string;
  66196. };
  66197. }
  66198. declare module "babylonjs/Layers/highlightLayer" {
  66199. import { Observable } from "babylonjs/Misc/observable";
  66200. import { Nullable } from "babylonjs/types";
  66201. import { Camera } from "babylonjs/Cameras/camera";
  66202. import { Scene } from "babylonjs/scene";
  66203. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66205. import { Mesh } from "babylonjs/Meshes/mesh";
  66206. import { Effect } from "babylonjs/Materials/effect";
  66207. import { Material } from "babylonjs/Materials/material";
  66208. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  66209. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66210. import "babylonjs/Shaders/glowMapMerge.fragment";
  66211. import "babylonjs/Shaders/glowMapMerge.vertex";
  66212. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  66213. module "babylonjs/abstractScene" {
  66214. interface AbstractScene {
  66215. /**
  66216. * Return a the first highlight layer of the scene with a given name.
  66217. * @param name The name of the highlight layer to look for.
  66218. * @return The highlight layer if found otherwise null.
  66219. */
  66220. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  66221. }
  66222. }
  66223. /**
  66224. * Highlight layer options. This helps customizing the behaviour
  66225. * of the highlight layer.
  66226. */
  66227. export interface IHighlightLayerOptions {
  66228. /**
  66229. * Multiplication factor apply to the canvas size to compute the render target size
  66230. * used to generated the glowing objects (the smaller the faster).
  66231. */
  66232. mainTextureRatio: number;
  66233. /**
  66234. * Enforces a fixed size texture to ensure resize independant blur.
  66235. */
  66236. mainTextureFixedSize?: number;
  66237. /**
  66238. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  66239. * of the picture to blur (the smaller the faster).
  66240. */
  66241. blurTextureSizeRatio: number;
  66242. /**
  66243. * How big in texel of the blur texture is the vertical blur.
  66244. */
  66245. blurVerticalSize: number;
  66246. /**
  66247. * How big in texel of the blur texture is the horizontal blur.
  66248. */
  66249. blurHorizontalSize: number;
  66250. /**
  66251. * Alpha blending mode used to apply the blur. Default is combine.
  66252. */
  66253. alphaBlendingMode: number;
  66254. /**
  66255. * The camera attached to the layer.
  66256. */
  66257. camera: Nullable<Camera>;
  66258. /**
  66259. * Should we display highlight as a solid stroke?
  66260. */
  66261. isStroke?: boolean;
  66262. /**
  66263. * The rendering group to draw the layer in.
  66264. */
  66265. renderingGroupId: number;
  66266. }
  66267. /**
  66268. * The highlight layer Helps adding a glow effect around a mesh.
  66269. *
  66270. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  66271. * glowy meshes to your scene.
  66272. *
  66273. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  66274. */
  66275. export class HighlightLayer extends EffectLayer {
  66276. name: string;
  66277. /**
  66278. * Effect Name of the highlight layer.
  66279. */
  66280. static readonly EffectName: string;
  66281. /**
  66282. * The neutral color used during the preparation of the glow effect.
  66283. * This is black by default as the blend operation is a blend operation.
  66284. */
  66285. static NeutralColor: Color4;
  66286. /**
  66287. * Stencil value used for glowing meshes.
  66288. */
  66289. static GlowingMeshStencilReference: number;
  66290. /**
  66291. * Stencil value used for the other meshes in the scene.
  66292. */
  66293. static NormalMeshStencilReference: number;
  66294. /**
  66295. * Specifies whether or not the inner glow is ACTIVE in the layer.
  66296. */
  66297. innerGlow: boolean;
  66298. /**
  66299. * Specifies whether or not the outer glow is ACTIVE in the layer.
  66300. */
  66301. outerGlow: boolean;
  66302. /**
  66303. * Specifies the horizontal size of the blur.
  66304. */
  66305. set blurHorizontalSize(value: number);
  66306. /**
  66307. * Specifies the vertical size of the blur.
  66308. */
  66309. set blurVerticalSize(value: number);
  66310. /**
  66311. * Gets the horizontal size of the blur.
  66312. */
  66313. get blurHorizontalSize(): number;
  66314. /**
  66315. * Gets the vertical size of the blur.
  66316. */
  66317. get blurVerticalSize(): number;
  66318. /**
  66319. * An event triggered when the highlight layer is being blurred.
  66320. */
  66321. onBeforeBlurObservable: Observable<HighlightLayer>;
  66322. /**
  66323. * An event triggered when the highlight layer has been blurred.
  66324. */
  66325. onAfterBlurObservable: Observable<HighlightLayer>;
  66326. private _instanceGlowingMeshStencilReference;
  66327. private _options;
  66328. private _downSamplePostprocess;
  66329. private _horizontalBlurPostprocess;
  66330. private _verticalBlurPostprocess;
  66331. private _blurTexture;
  66332. private _meshes;
  66333. private _excludedMeshes;
  66334. /**
  66335. * Instantiates a new highlight Layer and references it to the scene..
  66336. * @param name The name of the layer
  66337. * @param scene The scene to use the layer in
  66338. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  66339. */
  66340. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  66341. /**
  66342. * Get the effect name of the layer.
  66343. * @return The effect name
  66344. */
  66345. getEffectName(): string;
  66346. /**
  66347. * Create the merge effect. This is the shader use to blit the information back
  66348. * to the main canvas at the end of the scene rendering.
  66349. */
  66350. protected _createMergeEffect(): Effect;
  66351. /**
  66352. * Creates the render target textures and post processes used in the highlight layer.
  66353. */
  66354. protected _createTextureAndPostProcesses(): void;
  66355. /**
  66356. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  66357. */
  66358. needStencil(): boolean;
  66359. /**
  66360. * Checks for the readiness of the element composing the layer.
  66361. * @param subMesh the mesh to check for
  66362. * @param useInstances specify wether or not to use instances to render the mesh
  66363. * @param emissiveTexture the associated emissive texture used to generate the glow
  66364. * @return true if ready otherwise, false
  66365. */
  66366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66367. /**
  66368. * Implementation specific of rendering the generating effect on the main canvas.
  66369. * @param effect The effect used to render through
  66370. */
  66371. protected _internalRender(effect: Effect): void;
  66372. /**
  66373. * Returns true if the layer contains information to display, otherwise false.
  66374. */
  66375. shouldRender(): boolean;
  66376. /**
  66377. * Returns true if the mesh should render, otherwise false.
  66378. * @param mesh The mesh to render
  66379. * @returns true if it should render otherwise false
  66380. */
  66381. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66382. /**
  66383. * Returns true if the mesh can be rendered, otherwise false.
  66384. * @param mesh The mesh to render
  66385. * @param material The material used on the mesh
  66386. * @returns true if it can be rendered otherwise false
  66387. */
  66388. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66389. /**
  66390. * Adds specific effects defines.
  66391. * @param defines The defines to add specifics to.
  66392. */
  66393. protected _addCustomEffectDefines(defines: string[]): void;
  66394. /**
  66395. * Sets the required values for both the emissive texture and and the main color.
  66396. */
  66397. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66398. /**
  66399. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  66400. * @param mesh The mesh to exclude from the highlight layer
  66401. */
  66402. addExcludedMesh(mesh: Mesh): void;
  66403. /**
  66404. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  66405. * @param mesh The mesh to highlight
  66406. */
  66407. removeExcludedMesh(mesh: Mesh): void;
  66408. /**
  66409. * Determine if a given mesh will be highlighted by the current HighlightLayer
  66410. * @param mesh mesh to test
  66411. * @returns true if the mesh will be highlighted by the current HighlightLayer
  66412. */
  66413. hasMesh(mesh: AbstractMesh): boolean;
  66414. /**
  66415. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  66416. * @param mesh The mesh to highlight
  66417. * @param color The color of the highlight
  66418. * @param glowEmissiveOnly Extract the glow from the emissive texture
  66419. */
  66420. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  66421. /**
  66422. * Remove a mesh from the highlight layer in order to make it stop glowing.
  66423. * @param mesh The mesh to highlight
  66424. */
  66425. removeMesh(mesh: Mesh): void;
  66426. /**
  66427. * Remove all the meshes currently referenced in the highlight layer
  66428. */
  66429. removeAllMeshes(): void;
  66430. /**
  66431. * Force the stencil to the normal expected value for none glowing parts
  66432. */
  66433. private _defaultStencilReference;
  66434. /**
  66435. * Free any resources and references associated to a mesh.
  66436. * Internal use
  66437. * @param mesh The mesh to free.
  66438. * @hidden
  66439. */
  66440. _disposeMesh(mesh: Mesh): void;
  66441. /**
  66442. * Dispose the highlight layer and free resources.
  66443. */
  66444. dispose(): void;
  66445. /**
  66446. * Gets the class name of the effect layer
  66447. * @returns the string with the class name of the effect layer
  66448. */
  66449. getClassName(): string;
  66450. /**
  66451. * Serializes this Highlight layer
  66452. * @returns a serialized Highlight layer object
  66453. */
  66454. serialize(): any;
  66455. /**
  66456. * Creates a Highlight layer from parsed Highlight layer data
  66457. * @param parsedHightlightLayer defines the Highlight layer data
  66458. * @param scene defines the current scene
  66459. * @param rootUrl defines the root URL containing the Highlight layer information
  66460. * @returns a parsed Highlight layer
  66461. */
  66462. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  66463. }
  66464. }
  66465. declare module "babylonjs/Layers/layerSceneComponent" {
  66466. import { Scene } from "babylonjs/scene";
  66467. import { ISceneComponent } from "babylonjs/sceneComponent";
  66468. import { Layer } from "babylonjs/Layers/layer";
  66469. import { AbstractScene } from "babylonjs/abstractScene";
  66470. module "babylonjs/abstractScene" {
  66471. interface AbstractScene {
  66472. /**
  66473. * The list of layers (background and foreground) of the scene
  66474. */
  66475. layers: Array<Layer>;
  66476. }
  66477. }
  66478. /**
  66479. * Defines the layer scene component responsible to manage any layers
  66480. * in a given scene.
  66481. */
  66482. export class LayerSceneComponent implements ISceneComponent {
  66483. /**
  66484. * The component name helpfull to identify the component in the list of scene components.
  66485. */
  66486. readonly name: string;
  66487. /**
  66488. * The scene the component belongs to.
  66489. */
  66490. scene: Scene;
  66491. private _engine;
  66492. /**
  66493. * Creates a new instance of the component for the given scene
  66494. * @param scene Defines the scene to register the component in
  66495. */
  66496. constructor(scene: Scene);
  66497. /**
  66498. * Registers the component in a given scene
  66499. */
  66500. register(): void;
  66501. /**
  66502. * Rebuilds the elements related to this component in case of
  66503. * context lost for instance.
  66504. */
  66505. rebuild(): void;
  66506. /**
  66507. * Disposes the component and the associated ressources.
  66508. */
  66509. dispose(): void;
  66510. private _draw;
  66511. private _drawCameraPredicate;
  66512. private _drawCameraBackground;
  66513. private _drawCameraForeground;
  66514. private _drawRenderTargetPredicate;
  66515. private _drawRenderTargetBackground;
  66516. private _drawRenderTargetForeground;
  66517. /**
  66518. * Adds all the elements from the container to the scene
  66519. * @param container the container holding the elements
  66520. */
  66521. addFromContainer(container: AbstractScene): void;
  66522. /**
  66523. * Removes all the elements in the container from the scene
  66524. * @param container contains the elements to remove
  66525. * @param dispose if the removed element should be disposed (default: false)
  66526. */
  66527. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66528. }
  66529. }
  66530. declare module "babylonjs/Shaders/layer.fragment" {
  66531. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66532. /** @hidden */
  66533. export var layerPixelShader: {
  66534. name: string;
  66535. shader: string;
  66536. };
  66537. }
  66538. declare module "babylonjs/Shaders/layer.vertex" {
  66539. /** @hidden */
  66540. export var layerVertexShader: {
  66541. name: string;
  66542. shader: string;
  66543. };
  66544. }
  66545. declare module "babylonjs/Layers/layer" {
  66546. import { Observable } from "babylonjs/Misc/observable";
  66547. import { Nullable } from "babylonjs/types";
  66548. import { Scene } from "babylonjs/scene";
  66549. import { Vector2 } from "babylonjs/Maths/math.vector";
  66550. import { Color4 } from "babylonjs/Maths/math.color";
  66551. import { Texture } from "babylonjs/Materials/Textures/texture";
  66552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66553. import "babylonjs/Shaders/layer.fragment";
  66554. import "babylonjs/Shaders/layer.vertex";
  66555. /**
  66556. * This represents a full screen 2d layer.
  66557. * This can be useful to display a picture in the background of your scene for instance.
  66558. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66559. */
  66560. export class Layer {
  66561. /**
  66562. * Define the name of the layer.
  66563. */
  66564. name: string;
  66565. /**
  66566. * Define the texture the layer should display.
  66567. */
  66568. texture: Nullable<Texture>;
  66569. /**
  66570. * Is the layer in background or foreground.
  66571. */
  66572. isBackground: boolean;
  66573. /**
  66574. * Define the color of the layer (instead of texture).
  66575. */
  66576. color: Color4;
  66577. /**
  66578. * Define the scale of the layer in order to zoom in out of the texture.
  66579. */
  66580. scale: Vector2;
  66581. /**
  66582. * Define an offset for the layer in order to shift the texture.
  66583. */
  66584. offset: Vector2;
  66585. /**
  66586. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  66587. */
  66588. alphaBlendingMode: number;
  66589. /**
  66590. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  66591. * Alpha test will not mix with the background color in case of transparency.
  66592. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  66593. */
  66594. alphaTest: boolean;
  66595. /**
  66596. * Define a mask to restrict the layer to only some of the scene cameras.
  66597. */
  66598. layerMask: number;
  66599. /**
  66600. * Define the list of render target the layer is visible into.
  66601. */
  66602. renderTargetTextures: RenderTargetTexture[];
  66603. /**
  66604. * Define if the layer is only used in renderTarget or if it also
  66605. * renders in the main frame buffer of the canvas.
  66606. */
  66607. renderOnlyInRenderTargetTextures: boolean;
  66608. private _scene;
  66609. private _vertexBuffers;
  66610. private _indexBuffer;
  66611. private _effect;
  66612. private _previousDefines;
  66613. /**
  66614. * An event triggered when the layer is disposed.
  66615. */
  66616. onDisposeObservable: Observable<Layer>;
  66617. private _onDisposeObserver;
  66618. /**
  66619. * Back compatibility with callback before the onDisposeObservable existed.
  66620. * The set callback will be triggered when the layer has been disposed.
  66621. */
  66622. set onDispose(callback: () => void);
  66623. /**
  66624. * An event triggered before rendering the scene
  66625. */
  66626. onBeforeRenderObservable: Observable<Layer>;
  66627. private _onBeforeRenderObserver;
  66628. /**
  66629. * Back compatibility with callback before the onBeforeRenderObservable existed.
  66630. * The set callback will be triggered just before rendering the layer.
  66631. */
  66632. set onBeforeRender(callback: () => void);
  66633. /**
  66634. * An event triggered after rendering the scene
  66635. */
  66636. onAfterRenderObservable: Observable<Layer>;
  66637. private _onAfterRenderObserver;
  66638. /**
  66639. * Back compatibility with callback before the onAfterRenderObservable existed.
  66640. * The set callback will be triggered just after rendering the layer.
  66641. */
  66642. set onAfterRender(callback: () => void);
  66643. /**
  66644. * Instantiates a new layer.
  66645. * This represents a full screen 2d layer.
  66646. * This can be useful to display a picture in the background of your scene for instance.
  66647. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66648. * @param name Define the name of the layer in the scene
  66649. * @param imgUrl Define the url of the texture to display in the layer
  66650. * @param scene Define the scene the layer belongs to
  66651. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  66652. * @param color Defines a color for the layer
  66653. */
  66654. constructor(
  66655. /**
  66656. * Define the name of the layer.
  66657. */
  66658. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  66659. private _createIndexBuffer;
  66660. /** @hidden */
  66661. _rebuild(): void;
  66662. /**
  66663. * Renders the layer in the scene.
  66664. */
  66665. render(): void;
  66666. /**
  66667. * Disposes and releases the associated ressources.
  66668. */
  66669. dispose(): void;
  66670. }
  66671. }
  66672. declare module "babylonjs/Layers/index" {
  66673. export * from "babylonjs/Layers/effectLayer";
  66674. export * from "babylonjs/Layers/effectLayerSceneComponent";
  66675. export * from "babylonjs/Layers/glowLayer";
  66676. export * from "babylonjs/Layers/highlightLayer";
  66677. export * from "babylonjs/Layers/layer";
  66678. export * from "babylonjs/Layers/layerSceneComponent";
  66679. }
  66680. declare module "babylonjs/Shaders/lensFlare.fragment" {
  66681. /** @hidden */
  66682. export var lensFlarePixelShader: {
  66683. name: string;
  66684. shader: string;
  66685. };
  66686. }
  66687. declare module "babylonjs/Shaders/lensFlare.vertex" {
  66688. /** @hidden */
  66689. export var lensFlareVertexShader: {
  66690. name: string;
  66691. shader: string;
  66692. };
  66693. }
  66694. declare module "babylonjs/LensFlares/lensFlareSystem" {
  66695. import { Scene } from "babylonjs/scene";
  66696. import { Vector3 } from "babylonjs/Maths/math.vector";
  66697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66698. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  66699. import "babylonjs/Shaders/lensFlare.fragment";
  66700. import "babylonjs/Shaders/lensFlare.vertex";
  66701. import { Viewport } from "babylonjs/Maths/math.viewport";
  66702. /**
  66703. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66704. * It is usually composed of several `lensFlare`.
  66705. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66706. */
  66707. export class LensFlareSystem {
  66708. /**
  66709. * Define the name of the lens flare system
  66710. */
  66711. name: string;
  66712. /**
  66713. * List of lens flares used in this system.
  66714. */
  66715. lensFlares: LensFlare[];
  66716. /**
  66717. * Define a limit from the border the lens flare can be visible.
  66718. */
  66719. borderLimit: number;
  66720. /**
  66721. * Define a viewport border we do not want to see the lens flare in.
  66722. */
  66723. viewportBorder: number;
  66724. /**
  66725. * Define a predicate which could limit the list of meshes able to occlude the effect.
  66726. */
  66727. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  66728. /**
  66729. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  66730. */
  66731. layerMask: number;
  66732. /**
  66733. * Define the id of the lens flare system in the scene.
  66734. * (equal to name by default)
  66735. */
  66736. id: string;
  66737. private _scene;
  66738. private _emitter;
  66739. private _vertexBuffers;
  66740. private _indexBuffer;
  66741. private _effect;
  66742. private _positionX;
  66743. private _positionY;
  66744. private _isEnabled;
  66745. /** @hidden */
  66746. static _SceneComponentInitialization: (scene: Scene) => void;
  66747. /**
  66748. * Instantiates a lens flare system.
  66749. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66750. * It is usually composed of several `lensFlare`.
  66751. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66752. * @param name Define the name of the lens flare system in the scene
  66753. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  66754. * @param scene Define the scene the lens flare system belongs to
  66755. */
  66756. constructor(
  66757. /**
  66758. * Define the name of the lens flare system
  66759. */
  66760. name: string, emitter: any, scene: Scene);
  66761. /**
  66762. * Define if the lens flare system is enabled.
  66763. */
  66764. get isEnabled(): boolean;
  66765. set isEnabled(value: boolean);
  66766. /**
  66767. * Get the scene the effects belongs to.
  66768. * @returns the scene holding the lens flare system
  66769. */
  66770. getScene(): Scene;
  66771. /**
  66772. * Get the emitter of the lens flare system.
  66773. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66774. * @returns the emitter of the lens flare system
  66775. */
  66776. getEmitter(): any;
  66777. /**
  66778. * Set the emitter of the lens flare system.
  66779. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66780. * @param newEmitter Define the new emitter of the system
  66781. */
  66782. setEmitter(newEmitter: any): void;
  66783. /**
  66784. * Get the lens flare system emitter position.
  66785. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  66786. * @returns the position
  66787. */
  66788. getEmitterPosition(): Vector3;
  66789. /**
  66790. * @hidden
  66791. */
  66792. computeEffectivePosition(globalViewport: Viewport): boolean;
  66793. /** @hidden */
  66794. _isVisible(): boolean;
  66795. /**
  66796. * @hidden
  66797. */
  66798. render(): boolean;
  66799. /**
  66800. * Dispose and release the lens flare with its associated resources.
  66801. */
  66802. dispose(): void;
  66803. /**
  66804. * Parse a lens flare system from a JSON repressentation
  66805. * @param parsedLensFlareSystem Define the JSON to parse
  66806. * @param scene Define the scene the parsed system should be instantiated in
  66807. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  66808. * @returns the parsed system
  66809. */
  66810. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  66811. /**
  66812. * Serialize the current Lens Flare System into a JSON representation.
  66813. * @returns the serialized JSON
  66814. */
  66815. serialize(): any;
  66816. }
  66817. }
  66818. declare module "babylonjs/LensFlares/lensFlare" {
  66819. import { Nullable } from "babylonjs/types";
  66820. import { Color3 } from "babylonjs/Maths/math.color";
  66821. import { Texture } from "babylonjs/Materials/Textures/texture";
  66822. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66823. /**
  66824. * This represents one of the lens effect in a `lensFlareSystem`.
  66825. * It controls one of the indiviual texture used in the effect.
  66826. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66827. */
  66828. export class LensFlare {
  66829. /**
  66830. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66831. */
  66832. size: number;
  66833. /**
  66834. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  66835. */
  66836. position: number;
  66837. /**
  66838. * Define the lens color.
  66839. */
  66840. color: Color3;
  66841. /**
  66842. * Define the lens texture.
  66843. */
  66844. texture: Nullable<Texture>;
  66845. /**
  66846. * Define the alpha mode to render this particular lens.
  66847. */
  66848. alphaMode: number;
  66849. private _system;
  66850. /**
  66851. * Creates a new Lens Flare.
  66852. * This represents one of the lens effect in a `lensFlareSystem`.
  66853. * It controls one of the indiviual texture used in the effect.
  66854. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66855. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  66856. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  66857. * @param color Define the lens color
  66858. * @param imgUrl Define the lens texture url
  66859. * @param system Define the `lensFlareSystem` this flare is part of
  66860. * @returns The newly created Lens Flare
  66861. */
  66862. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  66863. /**
  66864. * Instantiates a new Lens Flare.
  66865. * This represents one of the lens effect in a `lensFlareSystem`.
  66866. * It controls one of the indiviual texture used in the effect.
  66867. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66868. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  66869. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  66870. * @param color Define the lens color
  66871. * @param imgUrl Define the lens texture url
  66872. * @param system Define the `lensFlareSystem` this flare is part of
  66873. */
  66874. constructor(
  66875. /**
  66876. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66877. */
  66878. size: number,
  66879. /**
  66880. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  66881. */
  66882. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  66883. /**
  66884. * Dispose and release the lens flare with its associated resources.
  66885. */
  66886. dispose(): void;
  66887. }
  66888. }
  66889. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  66890. import { Nullable } from "babylonjs/types";
  66891. import { Scene } from "babylonjs/scene";
  66892. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  66893. import { AbstractScene } from "babylonjs/abstractScene";
  66894. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66895. module "babylonjs/abstractScene" {
  66896. interface AbstractScene {
  66897. /**
  66898. * The list of lens flare system added to the scene
  66899. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66900. */
  66901. lensFlareSystems: Array<LensFlareSystem>;
  66902. /**
  66903. * Removes the given lens flare system from this scene.
  66904. * @param toRemove The lens flare system to remove
  66905. * @returns The index of the removed lens flare system
  66906. */
  66907. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  66908. /**
  66909. * Adds the given lens flare system to this scene
  66910. * @param newLensFlareSystem The lens flare system to add
  66911. */
  66912. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  66913. /**
  66914. * Gets a lens flare system using its name
  66915. * @param name defines the name to look for
  66916. * @returns the lens flare system or null if not found
  66917. */
  66918. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  66919. /**
  66920. * Gets a lens flare system using its id
  66921. * @param id defines the id to look for
  66922. * @returns the lens flare system or null if not found
  66923. */
  66924. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  66925. }
  66926. }
  66927. /**
  66928. * Defines the lens flare scene component responsible to manage any lens flares
  66929. * in a given scene.
  66930. */
  66931. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  66932. /**
  66933. * The component name helpfull to identify the component in the list of scene components.
  66934. */
  66935. readonly name: string;
  66936. /**
  66937. * The scene the component belongs to.
  66938. */
  66939. scene: Scene;
  66940. /**
  66941. * Creates a new instance of the component for the given scene
  66942. * @param scene Defines the scene to register the component in
  66943. */
  66944. constructor(scene: Scene);
  66945. /**
  66946. * Registers the component in a given scene
  66947. */
  66948. register(): void;
  66949. /**
  66950. * Rebuilds the elements related to this component in case of
  66951. * context lost for instance.
  66952. */
  66953. rebuild(): void;
  66954. /**
  66955. * Adds all the elements from the container to the scene
  66956. * @param container the container holding the elements
  66957. */
  66958. addFromContainer(container: AbstractScene): void;
  66959. /**
  66960. * Removes all the elements in the container from the scene
  66961. * @param container contains the elements to remove
  66962. * @param dispose if the removed element should be disposed (default: false)
  66963. */
  66964. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66965. /**
  66966. * Serializes the component data to the specified json object
  66967. * @param serializationObject The object to serialize to
  66968. */
  66969. serialize(serializationObject: any): void;
  66970. /**
  66971. * Disposes the component and the associated ressources.
  66972. */
  66973. dispose(): void;
  66974. private _draw;
  66975. }
  66976. }
  66977. declare module "babylonjs/LensFlares/index" {
  66978. export * from "babylonjs/LensFlares/lensFlare";
  66979. export * from "babylonjs/LensFlares/lensFlareSystem";
  66980. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  66981. }
  66982. declare module "babylonjs/Shaders/depth.fragment" {
  66983. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66984. /** @hidden */
  66985. export var depthPixelShader: {
  66986. name: string;
  66987. shader: string;
  66988. };
  66989. }
  66990. declare module "babylonjs/Shaders/depth.vertex" {
  66991. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66993. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66994. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66995. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66996. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66997. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66998. /** @hidden */
  66999. export var depthVertexShader: {
  67000. name: string;
  67001. shader: string;
  67002. };
  67003. }
  67004. declare module "babylonjs/Rendering/depthRenderer" {
  67005. import { Nullable } from "babylonjs/types";
  67006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67007. import { Scene } from "babylonjs/scene";
  67008. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67009. import { Camera } from "babylonjs/Cameras/camera";
  67010. import "babylonjs/Shaders/depth.fragment";
  67011. import "babylonjs/Shaders/depth.vertex";
  67012. /**
  67013. * This represents a depth renderer in Babylon.
  67014. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  67015. */
  67016. export class DepthRenderer {
  67017. private _scene;
  67018. private _depthMap;
  67019. private _effect;
  67020. private readonly _storeNonLinearDepth;
  67021. private readonly _clearColor;
  67022. /** Get if the depth renderer is using packed depth or not */
  67023. readonly isPacked: boolean;
  67024. private _cachedDefines;
  67025. private _camera;
  67026. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  67027. enabled: boolean;
  67028. /**
  67029. * Specifiess that the depth renderer will only be used within
  67030. * the camera it is created for.
  67031. * This can help forcing its rendering during the camera processing.
  67032. */
  67033. useOnlyInActiveCamera: boolean;
  67034. /** @hidden */
  67035. static _SceneComponentInitialization: (scene: Scene) => void;
  67036. /**
  67037. * Instantiates a depth renderer
  67038. * @param scene The scene the renderer belongs to
  67039. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  67040. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  67041. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67042. */
  67043. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  67044. /**
  67045. * Creates the depth rendering effect and checks if the effect is ready.
  67046. * @param subMesh The submesh to be used to render the depth map of
  67047. * @param useInstances If multiple world instances should be used
  67048. * @returns if the depth renderer is ready to render the depth map
  67049. */
  67050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67051. /**
  67052. * Gets the texture which the depth map will be written to.
  67053. * @returns The depth map texture
  67054. */
  67055. getDepthMap(): RenderTargetTexture;
  67056. /**
  67057. * Disposes of the depth renderer.
  67058. */
  67059. dispose(): void;
  67060. }
  67061. }
  67062. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  67063. /** @hidden */
  67064. export var minmaxReduxPixelShader: {
  67065. name: string;
  67066. shader: string;
  67067. };
  67068. }
  67069. declare module "babylonjs/Misc/minMaxReducer" {
  67070. import { Nullable } from "babylonjs/types";
  67071. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67072. import { Camera } from "babylonjs/Cameras/camera";
  67073. import { Observer } from "babylonjs/Misc/observable";
  67074. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67075. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  67076. import { Observable } from "babylonjs/Misc/observable";
  67077. import "babylonjs/Shaders/minmaxRedux.fragment";
  67078. /**
  67079. * This class computes a min/max reduction from a texture: it means it computes the minimum
  67080. * and maximum values from all values of the texture.
  67081. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  67082. * The source values are read from the red channel of the texture.
  67083. */
  67084. export class MinMaxReducer {
  67085. /**
  67086. * Observable triggered when the computation has been performed
  67087. */
  67088. onAfterReductionPerformed: Observable<{
  67089. min: number;
  67090. max: number;
  67091. }>;
  67092. protected _camera: Camera;
  67093. protected _sourceTexture: Nullable<RenderTargetTexture>;
  67094. protected _reductionSteps: Nullable<Array<PostProcess>>;
  67095. protected _postProcessManager: PostProcessManager;
  67096. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  67097. protected _forceFullscreenViewport: boolean;
  67098. /**
  67099. * Creates a min/max reducer
  67100. * @param camera The camera to use for the post processes
  67101. */
  67102. constructor(camera: Camera);
  67103. /**
  67104. * Gets the texture used to read the values from.
  67105. */
  67106. get sourceTexture(): Nullable<RenderTargetTexture>;
  67107. /**
  67108. * Sets the source texture to read the values from.
  67109. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  67110. * because in such textures '1' value must not be taken into account to compute the maximum
  67111. * as this value is used to clear the texture.
  67112. * Note that the computation is not activated by calling this function, you must call activate() for that!
  67113. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  67114. * @param depthRedux Indicates if the texture is a depth texture or not
  67115. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  67116. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  67117. */
  67118. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  67119. /**
  67120. * Defines the refresh rate of the computation.
  67121. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67122. */
  67123. get refreshRate(): number;
  67124. set refreshRate(value: number);
  67125. protected _activated: boolean;
  67126. /**
  67127. * Gets the activation status of the reducer
  67128. */
  67129. get activated(): boolean;
  67130. /**
  67131. * Activates the reduction computation.
  67132. * When activated, the observers registered in onAfterReductionPerformed are
  67133. * called after the compuation is performed
  67134. */
  67135. activate(): void;
  67136. /**
  67137. * Deactivates the reduction computation.
  67138. */
  67139. deactivate(): void;
  67140. /**
  67141. * Disposes the min/max reducer
  67142. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  67143. */
  67144. dispose(disposeAll?: boolean): void;
  67145. }
  67146. }
  67147. declare module "babylonjs/Misc/depthReducer" {
  67148. import { Nullable } from "babylonjs/types";
  67149. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67150. import { Camera } from "babylonjs/Cameras/camera";
  67151. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67152. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  67153. /**
  67154. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  67155. */
  67156. export class DepthReducer extends MinMaxReducer {
  67157. private _depthRenderer;
  67158. private _depthRendererId;
  67159. /**
  67160. * Gets the depth renderer used for the computation.
  67161. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  67162. */
  67163. get depthRenderer(): Nullable<DepthRenderer>;
  67164. /**
  67165. * Creates a depth reducer
  67166. * @param camera The camera used to render the depth texture
  67167. */
  67168. constructor(camera: Camera);
  67169. /**
  67170. * Sets the depth renderer to use to generate the depth map
  67171. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  67172. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  67173. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  67174. */
  67175. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  67176. /** @hidden */
  67177. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  67178. /**
  67179. * Activates the reduction computation.
  67180. * When activated, the observers registered in onAfterReductionPerformed are
  67181. * called after the compuation is performed
  67182. */
  67183. activate(): void;
  67184. /**
  67185. * Deactivates the reduction computation.
  67186. */
  67187. deactivate(): void;
  67188. /**
  67189. * Disposes the depth reducer
  67190. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  67191. */
  67192. dispose(disposeAll?: boolean): void;
  67193. }
  67194. }
  67195. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  67196. import { Nullable } from "babylonjs/types";
  67197. import { Scene } from "babylonjs/scene";
  67198. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67201. import { Effect } from "babylonjs/Materials/effect";
  67202. import "babylonjs/Shaders/shadowMap.fragment";
  67203. import "babylonjs/Shaders/shadowMap.vertex";
  67204. import "babylonjs/Shaders/depthBoxBlur.fragment";
  67205. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  67206. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67207. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67208. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67209. /**
  67210. * A CSM implementation allowing casting shadows on large scenes.
  67211. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67212. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  67213. */
  67214. export class CascadedShadowGenerator extends ShadowGenerator {
  67215. private static readonly frustumCornersNDCSpace;
  67216. /**
  67217. * Name of the CSM class
  67218. */
  67219. static CLASSNAME: string;
  67220. /**
  67221. * Defines the default number of cascades used by the CSM.
  67222. */
  67223. static readonly DEFAULT_CASCADES_COUNT: number;
  67224. /**
  67225. * Defines the minimum number of cascades used by the CSM.
  67226. */
  67227. static readonly MIN_CASCADES_COUNT: number;
  67228. /**
  67229. * Defines the maximum number of cascades used by the CSM.
  67230. */
  67231. static readonly MAX_CASCADES_COUNT: number;
  67232. protected _validateFilter(filter: number): number;
  67233. /**
  67234. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  67235. */
  67236. penumbraDarkness: number;
  67237. private _numCascades;
  67238. /**
  67239. * Gets or set the number of cascades used by the CSM.
  67240. */
  67241. get numCascades(): number;
  67242. set numCascades(value: number);
  67243. /**
  67244. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  67245. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  67246. */
  67247. stabilizeCascades: boolean;
  67248. private _freezeShadowCastersBoundingInfo;
  67249. private _freezeShadowCastersBoundingInfoObservable;
  67250. /**
  67251. * Enables or disables the shadow casters bounding info computation.
  67252. * If your shadow casters don't move, you can disable this feature.
  67253. * If it is enabled, the bounding box computation is done every frame.
  67254. */
  67255. get freezeShadowCastersBoundingInfo(): boolean;
  67256. set freezeShadowCastersBoundingInfo(freeze: boolean);
  67257. private _scbiMin;
  67258. private _scbiMax;
  67259. protected _computeShadowCastersBoundingInfo(): void;
  67260. protected _shadowCastersBoundingInfo: BoundingInfo;
  67261. /**
  67262. * Gets or sets the shadow casters bounding info.
  67263. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  67264. * so that the system won't overwrite the bounds you provide
  67265. */
  67266. get shadowCastersBoundingInfo(): BoundingInfo;
  67267. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  67268. protected _breaksAreDirty: boolean;
  67269. protected _minDistance: number;
  67270. protected _maxDistance: number;
  67271. /**
  67272. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  67273. *
  67274. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  67275. * If you don't know these values, simply leave them to their defaults and don't call this function.
  67276. * @param min minimal distance for the breaks (default to 0.)
  67277. * @param max maximal distance for the breaks (default to 1.)
  67278. */
  67279. setMinMaxDistance(min: number, max: number): void;
  67280. /** Gets the minimal distance used in the cascade break computation */
  67281. get minDistance(): number;
  67282. /** Gets the maximal distance used in the cascade break computation */
  67283. get maxDistance(): number;
  67284. /**
  67285. * Gets the class name of that object
  67286. * @returns "CascadedShadowGenerator"
  67287. */
  67288. getClassName(): string;
  67289. private _cascadeMinExtents;
  67290. private _cascadeMaxExtents;
  67291. /**
  67292. * Gets a cascade minimum extents
  67293. * @param cascadeIndex index of the cascade
  67294. * @returns the minimum cascade extents
  67295. */
  67296. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  67297. /**
  67298. * Gets a cascade maximum extents
  67299. * @param cascadeIndex index of the cascade
  67300. * @returns the maximum cascade extents
  67301. */
  67302. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  67303. private _cascades;
  67304. private _currentLayer;
  67305. private _viewSpaceFrustumsZ;
  67306. private _viewMatrices;
  67307. private _projectionMatrices;
  67308. private _transformMatrices;
  67309. private _transformMatricesAsArray;
  67310. private _frustumLengths;
  67311. private _lightSizeUVCorrection;
  67312. private _depthCorrection;
  67313. private _frustumCornersWorldSpace;
  67314. private _frustumCenter;
  67315. private _shadowCameraPos;
  67316. private _shadowMaxZ;
  67317. /**
  67318. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  67319. * It defaults to camera.maxZ
  67320. */
  67321. get shadowMaxZ(): number;
  67322. /**
  67323. * Sets the shadow max z distance.
  67324. */
  67325. set shadowMaxZ(value: number);
  67326. protected _debug: boolean;
  67327. /**
  67328. * Gets or sets the debug flag.
  67329. * When enabled, the cascades are materialized by different colors on the screen.
  67330. */
  67331. get debug(): boolean;
  67332. set debug(dbg: boolean);
  67333. private _depthClamp;
  67334. /**
  67335. * Gets or sets the depth clamping value.
  67336. *
  67337. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  67338. * to account for the shadow casters far away.
  67339. *
  67340. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  67341. */
  67342. get depthClamp(): boolean;
  67343. set depthClamp(value: boolean);
  67344. private _cascadeBlendPercentage;
  67345. /**
  67346. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  67347. * It defaults to 0.1 (10% blending).
  67348. */
  67349. get cascadeBlendPercentage(): number;
  67350. set cascadeBlendPercentage(value: number);
  67351. private _lambda;
  67352. /**
  67353. * Gets or set the lambda parameter.
  67354. * This parameter is used to split the camera frustum and create the cascades.
  67355. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  67356. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  67357. */
  67358. get lambda(): number;
  67359. set lambda(value: number);
  67360. /**
  67361. * Gets the view matrix corresponding to a given cascade
  67362. * @param cascadeNum cascade to retrieve the view matrix from
  67363. * @returns the cascade view matrix
  67364. */
  67365. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  67366. /**
  67367. * Gets the projection matrix corresponding to a given cascade
  67368. * @param cascadeNum cascade to retrieve the projection matrix from
  67369. * @returns the cascade projection matrix
  67370. */
  67371. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  67372. /**
  67373. * Gets the transformation matrix corresponding to a given cascade
  67374. * @param cascadeNum cascade to retrieve the transformation matrix from
  67375. * @returns the cascade transformation matrix
  67376. */
  67377. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  67378. private _depthRenderer;
  67379. /**
  67380. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  67381. *
  67382. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  67383. *
  67384. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  67385. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  67386. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  67387. */
  67388. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  67389. private _depthReducer;
  67390. private _autoCalcDepthBounds;
  67391. /**
  67392. * Gets or sets the autoCalcDepthBounds property.
  67393. *
  67394. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  67395. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  67396. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  67397. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  67398. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  67399. */
  67400. get autoCalcDepthBounds(): boolean;
  67401. set autoCalcDepthBounds(value: boolean);
  67402. /**
  67403. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  67404. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67405. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  67406. * for setting the refresh rate on the renderer yourself!
  67407. */
  67408. get autoCalcDepthBoundsRefreshRate(): number;
  67409. set autoCalcDepthBoundsRefreshRate(value: number);
  67410. /**
  67411. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  67412. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  67413. * you change the camera near/far planes!
  67414. */
  67415. splitFrustum(): void;
  67416. private _splitFrustum;
  67417. private _computeMatrices;
  67418. private _computeFrustumInWorldSpace;
  67419. private _computeCascadeFrustum;
  67420. /**
  67421. * Support test.
  67422. */
  67423. static get IsSupported(): boolean;
  67424. /** @hidden */
  67425. static _SceneComponentInitialization: (scene: Scene) => void;
  67426. /**
  67427. * Creates a Cascaded Shadow Generator object.
  67428. * A ShadowGenerator is the required tool to use the shadows.
  67429. * Each directional light casting shadows needs to use its own ShadowGenerator.
  67430. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67431. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67432. * @param light The directional light object generating the shadows.
  67433. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  67434. */
  67435. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  67436. protected _initializeGenerator(): void;
  67437. protected _createTargetRenderTexture(): void;
  67438. protected _initializeShadowMap(): void;
  67439. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  67440. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  67441. /**
  67442. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67443. * @param defines Defines of the material we want to update
  67444. * @param lightIndex Index of the light in the enabled light list of the material
  67445. */
  67446. prepareDefines(defines: any, lightIndex: number): void;
  67447. /**
  67448. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67449. * defined in the generator but impacting the effect).
  67450. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67451. * @param effect The effect we are binfing the information for
  67452. */
  67453. bindShadowLight(lightIndex: string, effect: Effect): void;
  67454. /**
  67455. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  67456. * (eq to view projection * shadow projection matrices)
  67457. * @returns The transform matrix used to create the shadow map
  67458. */
  67459. getTransformMatrix(): Matrix;
  67460. /**
  67461. * Disposes the ShadowGenerator.
  67462. * Returns nothing.
  67463. */
  67464. dispose(): void;
  67465. /**
  67466. * Serializes the shadow generator setup to a json object.
  67467. * @returns The serialized JSON object
  67468. */
  67469. serialize(): any;
  67470. /**
  67471. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67472. * @param parsedShadowGenerator The JSON object to parse
  67473. * @param scene The scene to create the shadow map for
  67474. * @returns The parsed shadow generator
  67475. */
  67476. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67477. }
  67478. }
  67479. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  67480. import { Scene } from "babylonjs/scene";
  67481. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  67482. import { AbstractScene } from "babylonjs/abstractScene";
  67483. /**
  67484. * Defines the shadow generator component responsible to manage any shadow generators
  67485. * in a given scene.
  67486. */
  67487. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  67488. /**
  67489. * The component name helpfull to identify the component in the list of scene components.
  67490. */
  67491. readonly name: string;
  67492. /**
  67493. * The scene the component belongs to.
  67494. */
  67495. scene: Scene;
  67496. /**
  67497. * Creates a new instance of the component for the given scene
  67498. * @param scene Defines the scene to register the component in
  67499. */
  67500. constructor(scene: Scene);
  67501. /**
  67502. * Registers the component in a given scene
  67503. */
  67504. register(): void;
  67505. /**
  67506. * Rebuilds the elements related to this component in case of
  67507. * context lost for instance.
  67508. */
  67509. rebuild(): void;
  67510. /**
  67511. * Serializes the component data to the specified json object
  67512. * @param serializationObject The object to serialize to
  67513. */
  67514. serialize(serializationObject: any): void;
  67515. /**
  67516. * Adds all the elements from the container to the scene
  67517. * @param container the container holding the elements
  67518. */
  67519. addFromContainer(container: AbstractScene): void;
  67520. /**
  67521. * Removes all the elements in the container from the scene
  67522. * @param container contains the elements to remove
  67523. * @param dispose if the removed element should be disposed (default: false)
  67524. */
  67525. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  67526. /**
  67527. * Rebuilds the elements related to this component in case of
  67528. * context lost for instance.
  67529. */
  67530. dispose(): void;
  67531. private _gatherRenderTargets;
  67532. }
  67533. }
  67534. declare module "babylonjs/Lights/Shadows/index" {
  67535. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  67536. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  67537. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  67538. }
  67539. declare module "babylonjs/Lights/pointLight" {
  67540. import { Scene } from "babylonjs/scene";
  67541. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67543. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  67544. import { Effect } from "babylonjs/Materials/effect";
  67545. /**
  67546. * A point light is a light defined by an unique point in world space.
  67547. * The light is emitted in every direction from this point.
  67548. * A good example of a point light is a standard light bulb.
  67549. * Documentation: https://doc.babylonjs.com/babylon101/lights
  67550. */
  67551. export class PointLight extends ShadowLight {
  67552. private _shadowAngle;
  67553. /**
  67554. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67555. * This specifies what angle the shadow will use to be created.
  67556. *
  67557. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67558. */
  67559. get shadowAngle(): number;
  67560. /**
  67561. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67562. * This specifies what angle the shadow will use to be created.
  67563. *
  67564. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67565. */
  67566. set shadowAngle(value: number);
  67567. /**
  67568. * Gets the direction if it has been set.
  67569. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67570. */
  67571. get direction(): Vector3;
  67572. /**
  67573. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67574. */
  67575. set direction(value: Vector3);
  67576. /**
  67577. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  67578. * A PointLight emits the light in every direction.
  67579. * It can cast shadows.
  67580. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  67581. * ```javascript
  67582. * var pointLight = new PointLight("pl", camera.position, scene);
  67583. * ```
  67584. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67585. * @param name The light friendly name
  67586. * @param position The position of the point light in the scene
  67587. * @param scene The scene the lights belongs to
  67588. */
  67589. constructor(name: string, position: Vector3, scene: Scene);
  67590. /**
  67591. * Returns the string "PointLight"
  67592. * @returns the class name
  67593. */
  67594. getClassName(): string;
  67595. /**
  67596. * Returns the integer 0.
  67597. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67598. */
  67599. getTypeID(): number;
  67600. /**
  67601. * Specifies wether or not the shadowmap should be a cube texture.
  67602. * @returns true if the shadowmap needs to be a cube texture.
  67603. */
  67604. needCube(): boolean;
  67605. /**
  67606. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  67607. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67608. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67609. */
  67610. getShadowDirection(faceIndex?: number): Vector3;
  67611. /**
  67612. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  67613. * - fov = PI / 2
  67614. * - aspect ratio : 1.0
  67615. * - z-near and far equal to the active camera minZ and maxZ.
  67616. * Returns the PointLight.
  67617. */
  67618. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67619. protected _buildUniformLayout(): void;
  67620. /**
  67621. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  67622. * @param effect The effect to update
  67623. * @param lightIndex The index of the light in the effect to update
  67624. * @returns The point light
  67625. */
  67626. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  67627. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  67628. /**
  67629. * Prepares the list of defines specific to the light type.
  67630. * @param defines the list of defines
  67631. * @param lightIndex defines the index of the light for the effect
  67632. */
  67633. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67634. }
  67635. }
  67636. declare module "babylonjs/Lights/index" {
  67637. export * from "babylonjs/Lights/light";
  67638. export * from "babylonjs/Lights/shadowLight";
  67639. export * from "babylonjs/Lights/Shadows/index";
  67640. export * from "babylonjs/Lights/directionalLight";
  67641. export * from "babylonjs/Lights/hemisphericLight";
  67642. export * from "babylonjs/Lights/pointLight";
  67643. export * from "babylonjs/Lights/spotLight";
  67644. }
  67645. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  67646. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67647. /**
  67648. * Header information of HDR texture files.
  67649. */
  67650. export interface HDRInfo {
  67651. /**
  67652. * The height of the texture in pixels.
  67653. */
  67654. height: number;
  67655. /**
  67656. * The width of the texture in pixels.
  67657. */
  67658. width: number;
  67659. /**
  67660. * The index of the beginning of the data in the binary file.
  67661. */
  67662. dataPosition: number;
  67663. }
  67664. /**
  67665. * This groups tools to convert HDR texture to native colors array.
  67666. */
  67667. export class HDRTools {
  67668. private static Ldexp;
  67669. private static Rgbe2float;
  67670. private static readStringLine;
  67671. /**
  67672. * Reads header information from an RGBE texture stored in a native array.
  67673. * More information on this format are available here:
  67674. * https://en.wikipedia.org/wiki/RGBE_image_format
  67675. *
  67676. * @param uint8array The binary file stored in native array.
  67677. * @return The header information.
  67678. */
  67679. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  67680. /**
  67681. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  67682. * This RGBE texture needs to store the information as a panorama.
  67683. *
  67684. * More information on this format are available here:
  67685. * https://en.wikipedia.org/wiki/RGBE_image_format
  67686. *
  67687. * @param buffer The binary file stored in an array buffer.
  67688. * @param size The expected size of the extracted cubemap.
  67689. * @return The Cube Map information.
  67690. */
  67691. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  67692. /**
  67693. * Returns the pixels data extracted from an RGBE texture.
  67694. * This pixels will be stored left to right up to down in the R G B order in one array.
  67695. *
  67696. * More information on this format are available here:
  67697. * https://en.wikipedia.org/wiki/RGBE_image_format
  67698. *
  67699. * @param uint8array The binary file stored in an array buffer.
  67700. * @param hdrInfo The header information of the file.
  67701. * @return The pixels data in RGB right to left up to down order.
  67702. */
  67703. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  67704. private static RGBE_ReadPixels_RLE;
  67705. private static RGBE_ReadPixels_NOT_RLE;
  67706. }
  67707. }
  67708. declare module "babylonjs/Materials/effectRenderer" {
  67709. import { Nullable } from "babylonjs/types";
  67710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  67711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67712. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67713. import { Viewport } from "babylonjs/Maths/math.viewport";
  67714. import { Observable } from "babylonjs/Misc/observable";
  67715. import { Effect } from "babylonjs/Materials/effect";
  67716. import "babylonjs/Shaders/postprocess.vertex";
  67717. /**
  67718. * Effect Render Options
  67719. */
  67720. export interface IEffectRendererOptions {
  67721. /**
  67722. * Defines the vertices positions.
  67723. */
  67724. positions?: number[];
  67725. /**
  67726. * Defines the indices.
  67727. */
  67728. indices?: number[];
  67729. }
  67730. /**
  67731. * Helper class to render one or more effects.
  67732. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  67733. */
  67734. export class EffectRenderer {
  67735. private engine;
  67736. private static _DefaultOptions;
  67737. private _vertexBuffers;
  67738. private _indexBuffer;
  67739. private _fullscreenViewport;
  67740. /**
  67741. * Creates an effect renderer
  67742. * @param engine the engine to use for rendering
  67743. * @param options defines the options of the effect renderer
  67744. */
  67745. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  67746. /**
  67747. * Sets the current viewport in normalized coordinates 0-1
  67748. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  67749. */
  67750. setViewport(viewport?: Viewport): void;
  67751. /**
  67752. * Binds the embedded attributes buffer to the effect.
  67753. * @param effect Defines the effect to bind the attributes for
  67754. */
  67755. bindBuffers(effect: Effect): void;
  67756. /**
  67757. * Sets the current effect wrapper to use during draw.
  67758. * The effect needs to be ready before calling this api.
  67759. * This also sets the default full screen position attribute.
  67760. * @param effectWrapper Defines the effect to draw with
  67761. */
  67762. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  67763. /**
  67764. * Restores engine states
  67765. */
  67766. restoreStates(): void;
  67767. /**
  67768. * Draws a full screen quad.
  67769. */
  67770. draw(): void;
  67771. private isRenderTargetTexture;
  67772. /**
  67773. * renders one or more effects to a specified texture
  67774. * @param effectWrapper the effect to renderer
  67775. * @param outputTexture texture to draw to, if null it will render to the screen.
  67776. */
  67777. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  67778. /**
  67779. * Disposes of the effect renderer
  67780. */
  67781. dispose(): void;
  67782. }
  67783. /**
  67784. * Options to create an EffectWrapper
  67785. */
  67786. interface EffectWrapperCreationOptions {
  67787. /**
  67788. * Engine to use to create the effect
  67789. */
  67790. engine: ThinEngine;
  67791. /**
  67792. * Fragment shader for the effect
  67793. */
  67794. fragmentShader: string;
  67795. /**
  67796. * Use the shader store instead of direct source code
  67797. */
  67798. useShaderStore?: boolean;
  67799. /**
  67800. * Vertex shader for the effect
  67801. */
  67802. vertexShader?: string;
  67803. /**
  67804. * Attributes to use in the shader
  67805. */
  67806. attributeNames?: Array<string>;
  67807. /**
  67808. * Uniforms to use in the shader
  67809. */
  67810. uniformNames?: Array<string>;
  67811. /**
  67812. * Texture sampler names to use in the shader
  67813. */
  67814. samplerNames?: Array<string>;
  67815. /**
  67816. * Defines to use in the shader
  67817. */
  67818. defines?: Array<string>;
  67819. /**
  67820. * Callback when effect is compiled
  67821. */
  67822. onCompiled?: Nullable<(effect: Effect) => void>;
  67823. /**
  67824. * The friendly name of the effect displayed in Spector.
  67825. */
  67826. name?: string;
  67827. }
  67828. /**
  67829. * Wraps an effect to be used for rendering
  67830. */
  67831. export class EffectWrapper {
  67832. /**
  67833. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  67834. */
  67835. onApplyObservable: Observable<{}>;
  67836. /**
  67837. * The underlying effect
  67838. */
  67839. effect: Effect;
  67840. /**
  67841. * Creates an effect to be renderer
  67842. * @param creationOptions options to create the effect
  67843. */
  67844. constructor(creationOptions: EffectWrapperCreationOptions);
  67845. /**
  67846. * Disposes of the effect wrapper
  67847. */
  67848. dispose(): void;
  67849. }
  67850. }
  67851. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  67852. /** @hidden */
  67853. export var hdrFilteringVertexShader: {
  67854. name: string;
  67855. shader: string;
  67856. };
  67857. }
  67858. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  67859. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67860. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  67861. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  67862. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  67863. /** @hidden */
  67864. export var hdrFilteringPixelShader: {
  67865. name: string;
  67866. shader: string;
  67867. };
  67868. }
  67869. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  67870. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67871. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67872. import { Nullable } from "babylonjs/types";
  67873. import "babylonjs/Shaders/hdrFiltering.vertex";
  67874. import "babylonjs/Shaders/hdrFiltering.fragment";
  67875. /**
  67876. * Options for texture filtering
  67877. */
  67878. interface IHDRFilteringOptions {
  67879. /**
  67880. * Scales pixel intensity for the input HDR map.
  67881. */
  67882. hdrScale?: number;
  67883. /**
  67884. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  67885. */
  67886. quality?: number;
  67887. }
  67888. /**
  67889. * Filters HDR maps to get correct renderings of PBR reflections
  67890. */
  67891. export class HDRFiltering {
  67892. private _engine;
  67893. private _effectRenderer;
  67894. private _effectWrapper;
  67895. private _lodGenerationOffset;
  67896. private _lodGenerationScale;
  67897. /**
  67898. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  67899. * you care about baking speed.
  67900. */
  67901. quality: number;
  67902. /**
  67903. * Scales pixel intensity for the input HDR map.
  67904. */
  67905. hdrScale: number;
  67906. /**
  67907. * Instantiates HDR filter for reflection maps
  67908. *
  67909. * @param engine Thin engine
  67910. * @param options Options
  67911. */
  67912. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  67913. private _createRenderTarget;
  67914. private _prefilterInternal;
  67915. private _createEffect;
  67916. /**
  67917. * Get a value indicating if the filter is ready to be used
  67918. * @param texture Texture to filter
  67919. * @returns true if the filter is ready
  67920. */
  67921. isReady(texture: BaseTexture): boolean;
  67922. /**
  67923. * Prefilters a cube texture to have mipmap levels representing roughness values.
  67924. * Prefiltering will be invoked at the end of next rendering pass.
  67925. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  67926. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  67927. * @param texture Texture to filter
  67928. * @param onFinished Callback when filtering is done
  67929. * @return Promise called when prefiltering is done
  67930. */
  67931. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  67932. }
  67933. }
  67934. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  67935. import { Nullable } from "babylonjs/types";
  67936. import { Scene } from "babylonjs/scene";
  67937. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67939. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67940. import "babylonjs/Engines/Extensions/engine.rawTexture";
  67941. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  67942. /**
  67943. * This represents a texture coming from an HDR input.
  67944. *
  67945. * The only supported format is currently panorama picture stored in RGBE format.
  67946. * Example of such files can be found on HDRLib: http://hdrlib.com/
  67947. */
  67948. export class HDRCubeTexture extends BaseTexture {
  67949. private static _facesMapping;
  67950. private _generateHarmonics;
  67951. private _noMipmap;
  67952. private _prefilterOnLoad;
  67953. private _textureMatrix;
  67954. private _size;
  67955. private _onLoad;
  67956. private _onError;
  67957. /**
  67958. * The texture URL.
  67959. */
  67960. url: string;
  67961. protected _isBlocking: boolean;
  67962. /**
  67963. * Sets wether or not the texture is blocking during loading.
  67964. */
  67965. set isBlocking(value: boolean);
  67966. /**
  67967. * Gets wether or not the texture is blocking during loading.
  67968. */
  67969. get isBlocking(): boolean;
  67970. protected _rotationY: number;
  67971. /**
  67972. * Sets texture matrix rotation angle around Y axis in radians.
  67973. */
  67974. set rotationY(value: number);
  67975. /**
  67976. * Gets texture matrix rotation angle around Y axis radians.
  67977. */
  67978. get rotationY(): number;
  67979. /**
  67980. * Gets or sets the center of the bounding box associated with the cube texture
  67981. * It must define where the camera used to render the texture was set
  67982. */
  67983. boundingBoxPosition: Vector3;
  67984. private _boundingBoxSize;
  67985. /**
  67986. * Gets or sets the size of the bounding box associated with the cube texture
  67987. * When defined, the cubemap will switch to local mode
  67988. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67989. * @example https://www.babylonjs-playground.com/#RNASML
  67990. */
  67991. set boundingBoxSize(value: Vector3);
  67992. get boundingBoxSize(): Vector3;
  67993. /**
  67994. * Instantiates an HDRTexture from the following parameters.
  67995. *
  67996. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  67997. * @param sceneOrEngine The scene or engine the texture will be used in
  67998. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  67999. * @param noMipmap Forces to not generate the mipmap if true
  68000. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  68001. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68002. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  68003. */
  68004. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  68005. /**
  68006. * Get the current class name of the texture useful for serialization or dynamic coding.
  68007. * @returns "HDRCubeTexture"
  68008. */
  68009. getClassName(): string;
  68010. /**
  68011. * Occurs when the file is raw .hdr file.
  68012. */
  68013. private loadTexture;
  68014. clone(): HDRCubeTexture;
  68015. delayLoad(): void;
  68016. /**
  68017. * Get the texture reflection matrix used to rotate/transform the reflection.
  68018. * @returns the reflection matrix
  68019. */
  68020. getReflectionTextureMatrix(): Matrix;
  68021. /**
  68022. * Set the texture reflection matrix used to rotate/transform the reflection.
  68023. * @param value Define the reflection matrix to set
  68024. */
  68025. setReflectionTextureMatrix(value: Matrix): void;
  68026. /**
  68027. * Parses a JSON representation of an HDR Texture in order to create the texture
  68028. * @param parsedTexture Define the JSON representation
  68029. * @param scene Define the scene the texture should be created in
  68030. * @param rootUrl Define the root url in case we need to load relative dependencies
  68031. * @returns the newly created texture after parsing
  68032. */
  68033. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  68034. serialize(): any;
  68035. }
  68036. }
  68037. declare module "babylonjs/Physics/physicsEngine" {
  68038. import { Nullable } from "babylonjs/types";
  68039. import { Vector3 } from "babylonjs/Maths/math.vector";
  68040. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  68041. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  68042. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  68043. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68044. /**
  68045. * Class used to control physics engine
  68046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68047. */
  68048. export class PhysicsEngine implements IPhysicsEngine {
  68049. private _physicsPlugin;
  68050. /**
  68051. * Global value used to control the smallest number supported by the simulation
  68052. */
  68053. static Epsilon: number;
  68054. private _impostors;
  68055. private _joints;
  68056. private _subTimeStep;
  68057. /**
  68058. * Gets the gravity vector used by the simulation
  68059. */
  68060. gravity: Vector3;
  68061. /**
  68062. * Factory used to create the default physics plugin.
  68063. * @returns The default physics plugin
  68064. */
  68065. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  68066. /**
  68067. * Creates a new Physics Engine
  68068. * @param gravity defines the gravity vector used by the simulation
  68069. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  68070. */
  68071. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  68072. /**
  68073. * Sets the gravity vector used by the simulation
  68074. * @param gravity defines the gravity vector to use
  68075. */
  68076. setGravity(gravity: Vector3): void;
  68077. /**
  68078. * Set the time step of the physics engine.
  68079. * Default is 1/60.
  68080. * To slow it down, enter 1/600 for example.
  68081. * To speed it up, 1/30
  68082. * @param newTimeStep defines the new timestep to apply to this world.
  68083. */
  68084. setTimeStep(newTimeStep?: number): void;
  68085. /**
  68086. * Get the time step of the physics engine.
  68087. * @returns the current time step
  68088. */
  68089. getTimeStep(): number;
  68090. /**
  68091. * Set the sub time step of the physics engine.
  68092. * Default is 0 meaning there is no sub steps
  68093. * To increase physics resolution precision, set a small value (like 1 ms)
  68094. * @param subTimeStep defines the new sub timestep used for physics resolution.
  68095. */
  68096. setSubTimeStep(subTimeStep?: number): void;
  68097. /**
  68098. * Get the sub time step of the physics engine.
  68099. * @returns the current sub time step
  68100. */
  68101. getSubTimeStep(): number;
  68102. /**
  68103. * Release all resources
  68104. */
  68105. dispose(): void;
  68106. /**
  68107. * Gets the name of the current physics plugin
  68108. * @returns the name of the plugin
  68109. */
  68110. getPhysicsPluginName(): string;
  68111. /**
  68112. * Adding a new impostor for the impostor tracking.
  68113. * This will be done by the impostor itself.
  68114. * @param impostor the impostor to add
  68115. */
  68116. addImpostor(impostor: PhysicsImpostor): void;
  68117. /**
  68118. * Remove an impostor from the engine.
  68119. * This impostor and its mesh will not longer be updated by the physics engine.
  68120. * @param impostor the impostor to remove
  68121. */
  68122. removeImpostor(impostor: PhysicsImpostor): void;
  68123. /**
  68124. * Add a joint to the physics engine
  68125. * @param mainImpostor defines the main impostor to which the joint is added.
  68126. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  68127. * @param joint defines the joint that will connect both impostors.
  68128. */
  68129. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  68130. /**
  68131. * Removes a joint from the simulation
  68132. * @param mainImpostor defines the impostor used with the joint
  68133. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  68134. * @param joint defines the joint to remove
  68135. */
  68136. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  68137. /**
  68138. * Called by the scene. No need to call it.
  68139. * @param delta defines the timespam between frames
  68140. */
  68141. _step(delta: number): void;
  68142. /**
  68143. * Gets the current plugin used to run the simulation
  68144. * @returns current plugin
  68145. */
  68146. getPhysicsPlugin(): IPhysicsEnginePlugin;
  68147. /**
  68148. * Gets the list of physic impostors
  68149. * @returns an array of PhysicsImpostor
  68150. */
  68151. getImpostors(): Array<PhysicsImpostor>;
  68152. /**
  68153. * Gets the impostor for a physics enabled object
  68154. * @param object defines the object impersonated by the impostor
  68155. * @returns the PhysicsImpostor or null if not found
  68156. */
  68157. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  68158. /**
  68159. * Gets the impostor for a physics body object
  68160. * @param body defines physics body used by the impostor
  68161. * @returns the PhysicsImpostor or null if not found
  68162. */
  68163. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  68164. /**
  68165. * Does a raycast in the physics world
  68166. * @param from when should the ray start?
  68167. * @param to when should the ray end?
  68168. * @returns PhysicsRaycastResult
  68169. */
  68170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68171. }
  68172. }
  68173. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  68174. import { Nullable } from "babylonjs/types";
  68175. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  68176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68177. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68178. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68179. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68180. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68181. /** @hidden */
  68182. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  68183. private _useDeltaForWorldStep;
  68184. world: any;
  68185. name: string;
  68186. private _physicsMaterials;
  68187. private _fixedTimeStep;
  68188. private _cannonRaycastResult;
  68189. private _raycastResult;
  68190. private _physicsBodysToRemoveAfterStep;
  68191. private _firstFrame;
  68192. BJSCANNON: any;
  68193. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  68194. setGravity(gravity: Vector3): void;
  68195. setTimeStep(timeStep: number): void;
  68196. getTimeStep(): number;
  68197. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68198. private _removeMarkedPhysicsBodiesFromWorld;
  68199. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68200. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68201. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68202. private _processChildMeshes;
  68203. removePhysicsBody(impostor: PhysicsImpostor): void;
  68204. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68205. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68206. private _addMaterial;
  68207. private _checkWithEpsilon;
  68208. private _createShape;
  68209. private _createHeightmap;
  68210. private _minus90X;
  68211. private _plus90X;
  68212. private _tmpPosition;
  68213. private _tmpDeltaPosition;
  68214. private _tmpUnityRotation;
  68215. private _updatePhysicsBodyTransformation;
  68216. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68217. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68218. isSupported(): boolean;
  68219. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68220. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68221. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68222. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68223. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68224. getBodyMass(impostor: PhysicsImpostor): number;
  68225. getBodyFriction(impostor: PhysicsImpostor): number;
  68226. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68227. getBodyRestitution(impostor: PhysicsImpostor): number;
  68228. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68229. sleepBody(impostor: PhysicsImpostor): void;
  68230. wakeUpBody(impostor: PhysicsImpostor): void;
  68231. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  68232. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  68233. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  68234. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68235. getRadius(impostor: PhysicsImpostor): number;
  68236. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68237. dispose(): void;
  68238. private _extendNamespace;
  68239. /**
  68240. * Does a raycast in the physics world
  68241. * @param from when should the ray start?
  68242. * @param to when should the ray end?
  68243. * @returns PhysicsRaycastResult
  68244. */
  68245. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68246. }
  68247. }
  68248. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  68249. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68250. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68251. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68253. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  68254. import { Nullable } from "babylonjs/types";
  68255. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68256. /** @hidden */
  68257. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  68258. private _useDeltaForWorldStep;
  68259. world: any;
  68260. name: string;
  68261. BJSOIMO: any;
  68262. private _raycastResult;
  68263. private _fixedTimeStep;
  68264. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  68265. setGravity(gravity: Vector3): void;
  68266. setTimeStep(timeStep: number): void;
  68267. getTimeStep(): number;
  68268. private _tmpImpostorsArray;
  68269. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68270. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68271. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68272. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68273. private _tmpPositionVector;
  68274. removePhysicsBody(impostor: PhysicsImpostor): void;
  68275. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68276. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68277. isSupported(): boolean;
  68278. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68279. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68280. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68281. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68282. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68283. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68284. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68285. getBodyMass(impostor: PhysicsImpostor): number;
  68286. getBodyFriction(impostor: PhysicsImpostor): number;
  68287. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68288. getBodyRestitution(impostor: PhysicsImpostor): number;
  68289. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68290. sleepBody(impostor: PhysicsImpostor): void;
  68291. wakeUpBody(impostor: PhysicsImpostor): void;
  68292. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  68293. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  68294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  68295. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68296. getRadius(impostor: PhysicsImpostor): number;
  68297. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68298. dispose(): void;
  68299. /**
  68300. * Does a raycast in the physics world
  68301. * @param from when should the ray start?
  68302. * @param to when should the ray end?
  68303. * @returns PhysicsRaycastResult
  68304. */
  68305. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68306. }
  68307. }
  68308. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  68309. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  68310. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68311. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68312. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68313. import { Nullable } from "babylonjs/types";
  68314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68315. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68316. /**
  68317. * AmmoJS Physics plugin
  68318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68319. * @see https://github.com/kripken/ammo.js/
  68320. */
  68321. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  68322. private _useDeltaForWorldStep;
  68323. /**
  68324. * Reference to the Ammo library
  68325. */
  68326. bjsAMMO: any;
  68327. /**
  68328. * Created ammoJS world which physics bodies are added to
  68329. */
  68330. world: any;
  68331. /**
  68332. * Name of the plugin
  68333. */
  68334. name: string;
  68335. private _timeStep;
  68336. private _fixedTimeStep;
  68337. private _maxSteps;
  68338. private _tmpQuaternion;
  68339. private _tmpAmmoTransform;
  68340. private _tmpAmmoQuaternion;
  68341. private _tmpAmmoConcreteContactResultCallback;
  68342. private _collisionConfiguration;
  68343. private _dispatcher;
  68344. private _overlappingPairCache;
  68345. private _solver;
  68346. private _softBodySolver;
  68347. private _tmpAmmoVectorA;
  68348. private _tmpAmmoVectorB;
  68349. private _tmpAmmoVectorC;
  68350. private _tmpAmmoVectorD;
  68351. private _tmpContactCallbackResult;
  68352. private _tmpAmmoVectorRCA;
  68353. private _tmpAmmoVectorRCB;
  68354. private _raycastResult;
  68355. private _tmpContactPoint;
  68356. private static readonly DISABLE_COLLISION_FLAG;
  68357. private static readonly KINEMATIC_FLAG;
  68358. private static readonly DISABLE_DEACTIVATION_FLAG;
  68359. /**
  68360. * Initializes the ammoJS plugin
  68361. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  68362. * @param ammoInjection can be used to inject your own ammo reference
  68363. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  68364. */
  68365. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  68366. /**
  68367. * Sets the gravity of the physics world (m/(s^2))
  68368. * @param gravity Gravity to set
  68369. */
  68370. setGravity(gravity: Vector3): void;
  68371. /**
  68372. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  68373. * @param timeStep timestep to use in seconds
  68374. */
  68375. setTimeStep(timeStep: number): void;
  68376. /**
  68377. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  68378. * @param fixedTimeStep fixedTimeStep to use in seconds
  68379. */
  68380. setFixedTimeStep(fixedTimeStep: number): void;
  68381. /**
  68382. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  68383. * @param maxSteps the maximum number of steps by the physics engine per frame
  68384. */
  68385. setMaxSteps(maxSteps: number): void;
  68386. /**
  68387. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  68388. * @returns the current timestep in seconds
  68389. */
  68390. getTimeStep(): number;
  68391. /**
  68392. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  68393. */
  68394. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  68395. private _isImpostorInContact;
  68396. private _isImpostorPairInContact;
  68397. private _stepSimulation;
  68398. /**
  68399. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  68400. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  68401. * After the step the babylon meshes are set to the position of the physics imposters
  68402. * @param delta amount of time to step forward
  68403. * @param impostors array of imposters to update before/after the step
  68404. */
  68405. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68406. /**
  68407. * Update babylon mesh to match physics world object
  68408. * @param impostor imposter to match
  68409. */
  68410. private _afterSoftStep;
  68411. /**
  68412. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68413. * @param impostor imposter to match
  68414. */
  68415. private _ropeStep;
  68416. /**
  68417. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68418. * @param impostor imposter to match
  68419. */
  68420. private _softbodyOrClothStep;
  68421. private _tmpMatrix;
  68422. /**
  68423. * Applies an impulse on the imposter
  68424. * @param impostor imposter to apply impulse to
  68425. * @param force amount of force to be applied to the imposter
  68426. * @param contactPoint the location to apply the impulse on the imposter
  68427. */
  68428. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68429. /**
  68430. * Applies a force on the imposter
  68431. * @param impostor imposter to apply force
  68432. * @param force amount of force to be applied to the imposter
  68433. * @param contactPoint the location to apply the force on the imposter
  68434. */
  68435. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68436. /**
  68437. * Creates a physics body using the plugin
  68438. * @param impostor the imposter to create the physics body on
  68439. */
  68440. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68441. /**
  68442. * Removes the physics body from the imposter and disposes of the body's memory
  68443. * @param impostor imposter to remove the physics body from
  68444. */
  68445. removePhysicsBody(impostor: PhysicsImpostor): void;
  68446. /**
  68447. * Generates a joint
  68448. * @param impostorJoint the imposter joint to create the joint with
  68449. */
  68450. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68451. /**
  68452. * Removes a joint
  68453. * @param impostorJoint the imposter joint to remove the joint from
  68454. */
  68455. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68456. private _addMeshVerts;
  68457. /**
  68458. * Initialise the soft body vertices to match its object's (mesh) vertices
  68459. * Softbody vertices (nodes) are in world space and to match this
  68460. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  68461. * @param impostor to create the softbody for
  68462. */
  68463. private _softVertexData;
  68464. /**
  68465. * Create an impostor's soft body
  68466. * @param impostor to create the softbody for
  68467. */
  68468. private _createSoftbody;
  68469. /**
  68470. * Create cloth for an impostor
  68471. * @param impostor to create the softbody for
  68472. */
  68473. private _createCloth;
  68474. /**
  68475. * Create rope for an impostor
  68476. * @param impostor to create the softbody for
  68477. */
  68478. private _createRope;
  68479. /**
  68480. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  68481. * @param impostor to create the custom physics shape for
  68482. */
  68483. private _createCustom;
  68484. private _addHullVerts;
  68485. private _createShape;
  68486. /**
  68487. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  68488. * @param impostor imposter containing the physics body and babylon object
  68489. */
  68490. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68491. /**
  68492. * Sets the babylon object's position/rotation from the physics body's position/rotation
  68493. * @param impostor imposter containing the physics body and babylon object
  68494. * @param newPosition new position
  68495. * @param newRotation new rotation
  68496. */
  68497. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68498. /**
  68499. * If this plugin is supported
  68500. * @returns true if its supported
  68501. */
  68502. isSupported(): boolean;
  68503. /**
  68504. * Sets the linear velocity of the physics body
  68505. * @param impostor imposter to set the velocity on
  68506. * @param velocity velocity to set
  68507. */
  68508. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68509. /**
  68510. * Sets the angular velocity of the physics body
  68511. * @param impostor imposter to set the velocity on
  68512. * @param velocity velocity to set
  68513. */
  68514. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68515. /**
  68516. * gets the linear velocity
  68517. * @param impostor imposter to get linear velocity from
  68518. * @returns linear velocity
  68519. */
  68520. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68521. /**
  68522. * gets the angular velocity
  68523. * @param impostor imposter to get angular velocity from
  68524. * @returns angular velocity
  68525. */
  68526. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68527. /**
  68528. * Sets the mass of physics body
  68529. * @param impostor imposter to set the mass on
  68530. * @param mass mass to set
  68531. */
  68532. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68533. /**
  68534. * Gets the mass of the physics body
  68535. * @param impostor imposter to get the mass from
  68536. * @returns mass
  68537. */
  68538. getBodyMass(impostor: PhysicsImpostor): number;
  68539. /**
  68540. * Gets friction of the impostor
  68541. * @param impostor impostor to get friction from
  68542. * @returns friction value
  68543. */
  68544. getBodyFriction(impostor: PhysicsImpostor): number;
  68545. /**
  68546. * Sets friction of the impostor
  68547. * @param impostor impostor to set friction on
  68548. * @param friction friction value
  68549. */
  68550. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68551. /**
  68552. * Gets restitution of the impostor
  68553. * @param impostor impostor to get restitution from
  68554. * @returns restitution value
  68555. */
  68556. getBodyRestitution(impostor: PhysicsImpostor): number;
  68557. /**
  68558. * Sets resitution of the impostor
  68559. * @param impostor impostor to set resitution on
  68560. * @param restitution resitution value
  68561. */
  68562. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68563. /**
  68564. * Gets pressure inside the impostor
  68565. * @param impostor impostor to get pressure from
  68566. * @returns pressure value
  68567. */
  68568. getBodyPressure(impostor: PhysicsImpostor): number;
  68569. /**
  68570. * Sets pressure inside a soft body impostor
  68571. * Cloth and rope must remain 0 pressure
  68572. * @param impostor impostor to set pressure on
  68573. * @param pressure pressure value
  68574. */
  68575. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  68576. /**
  68577. * Gets stiffness of the impostor
  68578. * @param impostor impostor to get stiffness from
  68579. * @returns pressure value
  68580. */
  68581. getBodyStiffness(impostor: PhysicsImpostor): number;
  68582. /**
  68583. * Sets stiffness of the impostor
  68584. * @param impostor impostor to set stiffness on
  68585. * @param stiffness stiffness value from 0 to 1
  68586. */
  68587. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  68588. /**
  68589. * Gets velocityIterations of the impostor
  68590. * @param impostor impostor to get velocity iterations from
  68591. * @returns velocityIterations value
  68592. */
  68593. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  68594. /**
  68595. * Sets velocityIterations of the impostor
  68596. * @param impostor impostor to set velocity iterations on
  68597. * @param velocityIterations velocityIterations value
  68598. */
  68599. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  68600. /**
  68601. * Gets positionIterations of the impostor
  68602. * @param impostor impostor to get position iterations from
  68603. * @returns positionIterations value
  68604. */
  68605. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  68606. /**
  68607. * Sets positionIterations of the impostor
  68608. * @param impostor impostor to set position on
  68609. * @param positionIterations positionIterations value
  68610. */
  68611. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  68612. /**
  68613. * Append an anchor to a cloth object
  68614. * @param impostor is the cloth impostor to add anchor to
  68615. * @param otherImpostor is the rigid impostor to anchor to
  68616. * @param width ratio across width from 0 to 1
  68617. * @param height ratio up height from 0 to 1
  68618. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  68619. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68620. */
  68621. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68622. /**
  68623. * Append an hook to a rope object
  68624. * @param impostor is the rope impostor to add hook to
  68625. * @param otherImpostor is the rigid impostor to hook to
  68626. * @param length ratio along the rope from 0 to 1
  68627. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  68628. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68629. */
  68630. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68631. /**
  68632. * Sleeps the physics body and stops it from being active
  68633. * @param impostor impostor to sleep
  68634. */
  68635. sleepBody(impostor: PhysicsImpostor): void;
  68636. /**
  68637. * Activates the physics body
  68638. * @param impostor impostor to activate
  68639. */
  68640. wakeUpBody(impostor: PhysicsImpostor): void;
  68641. /**
  68642. * Updates the distance parameters of the joint
  68643. * @param joint joint to update
  68644. * @param maxDistance maximum distance of the joint
  68645. * @param minDistance minimum distance of the joint
  68646. */
  68647. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  68648. /**
  68649. * Sets a motor on the joint
  68650. * @param joint joint to set motor on
  68651. * @param speed speed of the motor
  68652. * @param maxForce maximum force of the motor
  68653. * @param motorIndex index of the motor
  68654. */
  68655. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  68656. /**
  68657. * Sets the motors limit
  68658. * @param joint joint to set limit on
  68659. * @param upperLimit upper limit
  68660. * @param lowerLimit lower limit
  68661. */
  68662. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  68663. /**
  68664. * Syncs the position and rotation of a mesh with the impostor
  68665. * @param mesh mesh to sync
  68666. * @param impostor impostor to update the mesh with
  68667. */
  68668. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68669. /**
  68670. * Gets the radius of the impostor
  68671. * @param impostor impostor to get radius from
  68672. * @returns the radius
  68673. */
  68674. getRadius(impostor: PhysicsImpostor): number;
  68675. /**
  68676. * Gets the box size of the impostor
  68677. * @param impostor impostor to get box size from
  68678. * @param result the resulting box size
  68679. */
  68680. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68681. /**
  68682. * Disposes of the impostor
  68683. */
  68684. dispose(): void;
  68685. /**
  68686. * Does a raycast in the physics world
  68687. * @param from when should the ray start?
  68688. * @param to when should the ray end?
  68689. * @returns PhysicsRaycastResult
  68690. */
  68691. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68692. }
  68693. }
  68694. declare module "babylonjs/Probes/reflectionProbe" {
  68695. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68696. import { Vector3 } from "babylonjs/Maths/math.vector";
  68697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68698. import { Nullable } from "babylonjs/types";
  68699. import { Scene } from "babylonjs/scene";
  68700. module "babylonjs/abstractScene" {
  68701. interface AbstractScene {
  68702. /**
  68703. * The list of reflection probes added to the scene
  68704. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68705. */
  68706. reflectionProbes: Array<ReflectionProbe>;
  68707. /**
  68708. * Removes the given reflection probe from this scene.
  68709. * @param toRemove The reflection probe to remove
  68710. * @returns The index of the removed reflection probe
  68711. */
  68712. removeReflectionProbe(toRemove: ReflectionProbe): number;
  68713. /**
  68714. * Adds the given reflection probe to this scene.
  68715. * @param newReflectionProbe The reflection probe to add
  68716. */
  68717. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  68718. }
  68719. }
  68720. /**
  68721. * Class used to generate realtime reflection / refraction cube textures
  68722. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68723. */
  68724. export class ReflectionProbe {
  68725. /** defines the name of the probe */
  68726. name: string;
  68727. private _scene;
  68728. private _renderTargetTexture;
  68729. private _projectionMatrix;
  68730. private _viewMatrix;
  68731. private _target;
  68732. private _add;
  68733. private _attachedMesh;
  68734. private _invertYAxis;
  68735. /** Gets or sets probe position (center of the cube map) */
  68736. position: Vector3;
  68737. /**
  68738. * Creates a new reflection probe
  68739. * @param name defines the name of the probe
  68740. * @param size defines the texture resolution (for each face)
  68741. * @param scene defines the hosting scene
  68742. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  68743. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  68744. */
  68745. constructor(
  68746. /** defines the name of the probe */
  68747. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  68748. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  68749. get samples(): number;
  68750. set samples(value: number);
  68751. /** Gets or sets the refresh rate to use (on every frame by default) */
  68752. get refreshRate(): number;
  68753. set refreshRate(value: number);
  68754. /**
  68755. * Gets the hosting scene
  68756. * @returns a Scene
  68757. */
  68758. getScene(): Scene;
  68759. /** Gets the internal CubeTexture used to render to */
  68760. get cubeTexture(): RenderTargetTexture;
  68761. /** Gets the list of meshes to render */
  68762. get renderList(): Nullable<AbstractMesh[]>;
  68763. /**
  68764. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  68765. * @param mesh defines the mesh to attach to
  68766. */
  68767. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  68768. /**
  68769. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  68770. * @param renderingGroupId The rendering group id corresponding to its index
  68771. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  68772. */
  68773. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  68774. /**
  68775. * Clean all associated resources
  68776. */
  68777. dispose(): void;
  68778. /**
  68779. * Converts the reflection probe information to a readable string for debug purpose.
  68780. * @param fullDetails Supports for multiple levels of logging within scene loading
  68781. * @returns the human readable reflection probe info
  68782. */
  68783. toString(fullDetails?: boolean): string;
  68784. /**
  68785. * Get the class name of the relfection probe.
  68786. * @returns "ReflectionProbe"
  68787. */
  68788. getClassName(): string;
  68789. /**
  68790. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  68791. * @returns The JSON representation of the texture
  68792. */
  68793. serialize(): any;
  68794. /**
  68795. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  68796. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  68797. * @param scene Define the scene the parsed reflection probe should be instantiated in
  68798. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  68799. * @returns The parsed reflection probe if successful
  68800. */
  68801. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  68802. }
  68803. }
  68804. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  68805. /** @hidden */
  68806. export var _BabylonLoaderRegistered: boolean;
  68807. /**
  68808. * Helps setting up some configuration for the babylon file loader.
  68809. */
  68810. export class BabylonFileLoaderConfiguration {
  68811. /**
  68812. * The loader does not allow injecting custom physix engine into the plugins.
  68813. * Unfortunately in ES6, we need to manually inject them into the plugin.
  68814. * So you could set this variable to your engine import to make it work.
  68815. */
  68816. static LoaderInjectedPhysicsEngine: any;
  68817. }
  68818. }
  68819. declare module "babylonjs/Loading/Plugins/index" {
  68820. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  68821. }
  68822. declare module "babylonjs/Loading/index" {
  68823. export * from "babylonjs/Loading/loadingScreen";
  68824. export * from "babylonjs/Loading/Plugins/index";
  68825. export * from "babylonjs/Loading/sceneLoader";
  68826. export * from "babylonjs/Loading/sceneLoaderFlags";
  68827. }
  68828. declare module "babylonjs/Materials/Background/index" {
  68829. export * from "babylonjs/Materials/Background/backgroundMaterial";
  68830. }
  68831. declare module "babylonjs/Materials/Occlusion/occlusionMaterial" {
  68832. import { Scene } from "babylonjs/scene";
  68833. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  68834. import "babylonjs/Shaders/color.fragment";
  68835. import "babylonjs/Shaders/color.vertex";
  68836. /**
  68837. * A material to use for fast depth-only rendering.
  68838. */
  68839. export class OcclusionMaterial extends ShaderMaterial {
  68840. constructor(name: string, scene: Scene);
  68841. }
  68842. }
  68843. declare module "babylonjs/Materials/Occlusion/index" {
  68844. export * from "babylonjs/Materials/Occlusion/occlusionMaterial";
  68845. }
  68846. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  68847. import { Scene } from "babylonjs/scene";
  68848. import { Color3 } from "babylonjs/Maths/math.color";
  68849. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  68850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68851. /**
  68852. * The Physically based simple base material of BJS.
  68853. *
  68854. * This enables better naming and convention enforcements on top of the pbrMaterial.
  68855. * It is used as the base class for both the specGloss and metalRough conventions.
  68856. */
  68857. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  68858. /**
  68859. * Number of Simultaneous lights allowed on the material.
  68860. */
  68861. maxSimultaneousLights: number;
  68862. /**
  68863. * If sets to true, disables all the lights affecting the material.
  68864. */
  68865. disableLighting: boolean;
  68866. /**
  68867. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  68868. */
  68869. environmentTexture: BaseTexture;
  68870. /**
  68871. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  68872. */
  68873. invertNormalMapX: boolean;
  68874. /**
  68875. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  68876. */
  68877. invertNormalMapY: boolean;
  68878. /**
  68879. * Normal map used in the model.
  68880. */
  68881. normalTexture: BaseTexture;
  68882. /**
  68883. * Emissivie color used to self-illuminate the model.
  68884. */
  68885. emissiveColor: Color3;
  68886. /**
  68887. * Emissivie texture used to self-illuminate the model.
  68888. */
  68889. emissiveTexture: BaseTexture;
  68890. /**
  68891. * Occlusion Channel Strenght.
  68892. */
  68893. occlusionStrength: number;
  68894. /**
  68895. * Occlusion Texture of the material (adding extra occlusion effects).
  68896. */
  68897. occlusionTexture: BaseTexture;
  68898. /**
  68899. * Defines the alpha limits in alpha test mode.
  68900. */
  68901. alphaCutOff: number;
  68902. /**
  68903. * Gets the current double sided mode.
  68904. */
  68905. get doubleSided(): boolean;
  68906. /**
  68907. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  68908. */
  68909. set doubleSided(value: boolean);
  68910. /**
  68911. * Stores the pre-calculated light information of a mesh in a texture.
  68912. */
  68913. lightmapTexture: BaseTexture;
  68914. /**
  68915. * If true, the light map contains occlusion information instead of lighting info.
  68916. */
  68917. useLightmapAsShadowmap: boolean;
  68918. /**
  68919. * Instantiates a new PBRMaterial instance.
  68920. *
  68921. * @param name The material name
  68922. * @param scene The scene the material will be use in.
  68923. */
  68924. constructor(name: string, scene: Scene);
  68925. getClassName(): string;
  68926. }
  68927. }
  68928. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  68929. import { Scene } from "babylonjs/scene";
  68930. import { Color3 } from "babylonjs/Maths/math.color";
  68931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68932. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68933. /**
  68934. * The PBR material of BJS following the metal roughness convention.
  68935. *
  68936. * This fits to the PBR convention in the GLTF definition:
  68937. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  68938. */
  68939. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  68940. /**
  68941. * The base color has two different interpretations depending on the value of metalness.
  68942. * When the material is a metal, the base color is the specific measured reflectance value
  68943. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  68944. * of the material.
  68945. */
  68946. baseColor: Color3;
  68947. /**
  68948. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  68949. * well as opacity information in the alpha channel.
  68950. */
  68951. baseTexture: BaseTexture;
  68952. /**
  68953. * Specifies the metallic scalar value of the material.
  68954. * Can also be used to scale the metalness values of the metallic texture.
  68955. */
  68956. metallic: number;
  68957. /**
  68958. * Specifies the roughness scalar value of the material.
  68959. * Can also be used to scale the roughness values of the metallic texture.
  68960. */
  68961. roughness: number;
  68962. /**
  68963. * Texture containing both the metallic value in the B channel and the
  68964. * roughness value in the G channel to keep better precision.
  68965. */
  68966. metallicRoughnessTexture: BaseTexture;
  68967. /**
  68968. * Instantiates a new PBRMetalRoughnessMaterial instance.
  68969. *
  68970. * @param name The material name
  68971. * @param scene The scene the material will be use in.
  68972. */
  68973. constructor(name: string, scene: Scene);
  68974. /**
  68975. * Return the currrent class name of the material.
  68976. */
  68977. getClassName(): string;
  68978. /**
  68979. * Makes a duplicate of the current material.
  68980. * @param name - name to use for the new material.
  68981. */
  68982. clone(name: string): PBRMetallicRoughnessMaterial;
  68983. /**
  68984. * Serialize the material to a parsable JSON object.
  68985. */
  68986. serialize(): any;
  68987. /**
  68988. * Parses a JSON object correponding to the serialize function.
  68989. */
  68990. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  68991. }
  68992. }
  68993. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  68994. import { Scene } from "babylonjs/scene";
  68995. import { Color3 } from "babylonjs/Maths/math.color";
  68996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68997. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68998. /**
  68999. * The PBR material of BJS following the specular glossiness convention.
  69000. *
  69001. * This fits to the PBR convention in the GLTF definition:
  69002. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  69003. */
  69004. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  69005. /**
  69006. * Specifies the diffuse color of the material.
  69007. */
  69008. diffuseColor: Color3;
  69009. /**
  69010. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  69011. * channel.
  69012. */
  69013. diffuseTexture: BaseTexture;
  69014. /**
  69015. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  69016. */
  69017. specularColor: Color3;
  69018. /**
  69019. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  69020. */
  69021. glossiness: number;
  69022. /**
  69023. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  69024. */
  69025. specularGlossinessTexture: BaseTexture;
  69026. /**
  69027. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  69028. */
  69029. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  69030. /**
  69031. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  69032. *
  69033. * @param name The material name
  69034. * @param scene The scene the material will be use in.
  69035. */
  69036. constructor(name: string, scene: Scene);
  69037. /**
  69038. * Return the currrent class name of the material.
  69039. */
  69040. getClassName(): string;
  69041. /**
  69042. * Makes a duplicate of the current material.
  69043. * @param name - name to use for the new material.
  69044. */
  69045. clone(name: string): PBRSpecularGlossinessMaterial;
  69046. /**
  69047. * Serialize the material to a parsable JSON object.
  69048. */
  69049. serialize(): any;
  69050. /**
  69051. * Parses a JSON object correponding to the serialize function.
  69052. */
  69053. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  69054. }
  69055. }
  69056. declare module "babylonjs/Materials/PBR/index" {
  69057. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  69058. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  69059. export * from "babylonjs/Materials/PBR/pbrMaterial";
  69060. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  69061. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  69062. }
  69063. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  69064. import { Nullable } from "babylonjs/types";
  69065. import { Scene } from "babylonjs/scene";
  69066. import { Matrix } from "babylonjs/Maths/math.vector";
  69067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69068. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  69069. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69070. /**
  69071. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  69072. * It can help converting any input color in a desired output one. This can then be used to create effects
  69073. * from sepia, black and white to sixties or futuristic rendering...
  69074. *
  69075. * The only supported format is currently 3dl.
  69076. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  69077. */
  69078. export class ColorGradingTexture extends BaseTexture {
  69079. /**
  69080. * The texture URL.
  69081. */
  69082. url: string;
  69083. /**
  69084. * Empty line regex stored for GC.
  69085. */
  69086. private static _noneEmptyLineRegex;
  69087. private _textureMatrix;
  69088. private _onLoad;
  69089. /**
  69090. * Instantiates a ColorGradingTexture from the following parameters.
  69091. *
  69092. * @param url The location of the color gradind data (currently only supporting 3dl)
  69093. * @param sceneOrEngine The scene or engine the texture will be used in
  69094. * @param onLoad defines a callback triggered when the texture has been loaded
  69095. */
  69096. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  69097. /**
  69098. * Fires the onload event from the constructor if requested.
  69099. */
  69100. private _triggerOnLoad;
  69101. /**
  69102. * Returns the texture matrix used in most of the material.
  69103. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  69104. */
  69105. getTextureMatrix(): Matrix;
  69106. /**
  69107. * Occurs when the file being loaded is a .3dl LUT file.
  69108. */
  69109. private load3dlTexture;
  69110. /**
  69111. * Starts the loading process of the texture.
  69112. */
  69113. private loadTexture;
  69114. /**
  69115. * Clones the color gradind texture.
  69116. */
  69117. clone(): ColorGradingTexture;
  69118. /**
  69119. * Called during delayed load for textures.
  69120. */
  69121. delayLoad(): void;
  69122. /**
  69123. * Parses a color grading texture serialized by Babylon.
  69124. * @param parsedTexture The texture information being parsedTexture
  69125. * @param scene The scene to load the texture in
  69126. * @param rootUrl The root url of the data assets to load
  69127. * @return A color gradind texture
  69128. */
  69129. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  69130. /**
  69131. * Serializes the LUT texture to json format.
  69132. */
  69133. serialize(): any;
  69134. }
  69135. }
  69136. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  69137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69138. import { Scene } from "babylonjs/scene";
  69139. import { Nullable } from "babylonjs/types";
  69140. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69141. /**
  69142. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  69143. */
  69144. export class EquiRectangularCubeTexture extends BaseTexture {
  69145. /** The six faces of the cube. */
  69146. private static _FacesMapping;
  69147. private _noMipmap;
  69148. private _onLoad;
  69149. private _onError;
  69150. /** The size of the cubemap. */
  69151. private _size;
  69152. /** The buffer of the image. */
  69153. private _buffer;
  69154. /** The width of the input image. */
  69155. private _width;
  69156. /** The height of the input image. */
  69157. private _height;
  69158. /** The URL to the image. */
  69159. url: string;
  69160. /**
  69161. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  69162. * @param url The location of the image
  69163. * @param scene The scene the texture will be used in
  69164. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  69165. * @param noMipmap Forces to not generate the mipmap if true
  69166. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69167. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69168. * @param onLoad — defines a callback called when texture is loaded
  69169. * @param onError — defines a callback called if there is an error
  69170. */
  69171. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  69172. /**
  69173. * Load the image data, by putting the image on a canvas and extracting its buffer.
  69174. */
  69175. private loadImage;
  69176. /**
  69177. * Convert the image buffer into a cubemap and create a CubeTexture.
  69178. */
  69179. private loadTexture;
  69180. /**
  69181. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  69182. * @param buffer The ArrayBuffer that should be converted.
  69183. * @returns The buffer as Float32Array.
  69184. */
  69185. private getFloat32ArrayFromArrayBuffer;
  69186. /**
  69187. * Get the current class name of the texture useful for serialization or dynamic coding.
  69188. * @returns "EquiRectangularCubeTexture"
  69189. */
  69190. getClassName(): string;
  69191. /**
  69192. * Create a clone of the current EquiRectangularCubeTexture and return it.
  69193. * @returns A clone of the current EquiRectangularCubeTexture.
  69194. */
  69195. clone(): EquiRectangularCubeTexture;
  69196. }
  69197. }
  69198. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  69199. import { Nullable } from "babylonjs/types";
  69200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69201. import { Matrix } from "babylonjs/Maths/math.vector";
  69202. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  69203. import "babylonjs/Engines/Extensions/engine.videoTexture";
  69204. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  69205. import { Scene } from "babylonjs/scene";
  69206. /**
  69207. * Defines the options related to the creation of an HtmlElementTexture
  69208. */
  69209. export interface IHtmlElementTextureOptions {
  69210. /**
  69211. * Defines wether mip maps should be created or not.
  69212. */
  69213. generateMipMaps?: boolean;
  69214. /**
  69215. * Defines the sampling mode of the texture.
  69216. */
  69217. samplingMode?: number;
  69218. /**
  69219. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  69220. */
  69221. engine: Nullable<ThinEngine>;
  69222. /**
  69223. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  69224. */
  69225. scene: Nullable<Scene>;
  69226. }
  69227. /**
  69228. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  69229. * To be as efficient as possible depending on your constraints nothing aside the first upload
  69230. * is automatically managed.
  69231. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  69232. * in your application.
  69233. *
  69234. * As the update is not automatic, you need to call them manually.
  69235. */
  69236. export class HtmlElementTexture extends BaseTexture {
  69237. /**
  69238. * The texture URL.
  69239. */
  69240. element: HTMLVideoElement | HTMLCanvasElement;
  69241. private static readonly DefaultOptions;
  69242. private _textureMatrix;
  69243. private _isVideo;
  69244. private _generateMipMaps;
  69245. private _samplingMode;
  69246. /**
  69247. * Instantiates a HtmlElementTexture from the following parameters.
  69248. *
  69249. * @param name Defines the name of the texture
  69250. * @param element Defines the video or canvas the texture is filled with
  69251. * @param options Defines the other none mandatory texture creation options
  69252. */
  69253. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  69254. private _createInternalTexture;
  69255. /**
  69256. * Returns the texture matrix used in most of the material.
  69257. */
  69258. getTextureMatrix(): Matrix;
  69259. /**
  69260. * Updates the content of the texture.
  69261. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  69262. */
  69263. update(invertY?: Nullable<boolean>): void;
  69264. }
  69265. }
  69266. declare module "babylonjs/Misc/tga" {
  69267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69268. /**
  69269. * Based on jsTGALoader - Javascript loader for TGA file
  69270. * By Vincent Thibault
  69271. * @see http://blog.robrowser.com/javascript-tga-loader.html
  69272. */
  69273. export class TGATools {
  69274. private static _TYPE_INDEXED;
  69275. private static _TYPE_RGB;
  69276. private static _TYPE_GREY;
  69277. private static _TYPE_RLE_INDEXED;
  69278. private static _TYPE_RLE_RGB;
  69279. private static _TYPE_RLE_GREY;
  69280. private static _ORIGIN_MASK;
  69281. private static _ORIGIN_SHIFT;
  69282. private static _ORIGIN_BL;
  69283. private static _ORIGIN_BR;
  69284. private static _ORIGIN_UL;
  69285. private static _ORIGIN_UR;
  69286. /**
  69287. * Gets the header of a TGA file
  69288. * @param data defines the TGA data
  69289. * @returns the header
  69290. */
  69291. static GetTGAHeader(data: Uint8Array): any;
  69292. /**
  69293. * Uploads TGA content to a Babylon Texture
  69294. * @hidden
  69295. */
  69296. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  69297. /** @hidden */
  69298. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  69299. /** @hidden */
  69300. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  69301. /** @hidden */
  69302. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  69303. /** @hidden */
  69304. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  69305. /** @hidden */
  69306. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  69307. /** @hidden */
  69308. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  69309. }
  69310. }
  69311. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  69312. import { Nullable } from "babylonjs/types";
  69313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69314. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69315. /**
  69316. * Implementation of the TGA Texture Loader.
  69317. * @hidden
  69318. */
  69319. export class _TGATextureLoader implements IInternalTextureLoader {
  69320. /**
  69321. * Defines wether the loader supports cascade loading the different faces.
  69322. */
  69323. readonly supportCascades: boolean;
  69324. /**
  69325. * This returns if the loader support the current file information.
  69326. * @param extension defines the file extension of the file being loaded
  69327. * @returns true if the loader can load the specified file
  69328. */
  69329. canLoad(extension: string): boolean;
  69330. /**
  69331. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69332. * @param data contains the texture data
  69333. * @param texture defines the BabylonJS internal texture
  69334. * @param createPolynomials will be true if polynomials have been requested
  69335. * @param onLoad defines the callback to trigger once the texture is ready
  69336. * @param onError defines the callback to trigger in case of error
  69337. */
  69338. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69339. /**
  69340. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69341. * @param data contains the texture data
  69342. * @param texture defines the BabylonJS internal texture
  69343. * @param callback defines the method to call once ready to upload
  69344. */
  69345. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69346. }
  69347. }
  69348. declare module "babylonjs/Materials/Textures/Loaders/hdrTextureLoader" {
  69349. import { Nullable } from "babylonjs/types";
  69350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69351. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69352. /**
  69353. * Implementation of the HDR Texture Loader.
  69354. * @hidden
  69355. */
  69356. export class _HDRTextureLoader implements IInternalTextureLoader {
  69357. /**
  69358. * Defines wether the loader supports cascade loading the different faces.
  69359. */
  69360. readonly supportCascades: boolean;
  69361. /**
  69362. * This returns if the loader support the current file information.
  69363. * @param extension defines the file extension of the file being loaded
  69364. * @returns true if the loader can load the specified file
  69365. */
  69366. canLoad(extension: string): boolean;
  69367. /**
  69368. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69369. * @param data contains the texture data
  69370. * @param texture defines the BabylonJS internal texture
  69371. * @param createPolynomials will be true if polynomials have been requested
  69372. * @param onLoad defines the callback to trigger once the texture is ready
  69373. * @param onError defines the callback to trigger in case of error
  69374. */
  69375. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69376. /**
  69377. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69378. * @param data contains the texture data
  69379. * @param texture defines the BabylonJS internal texture
  69380. * @param callback defines the method to call once ready to upload
  69381. */
  69382. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69383. }
  69384. }
  69385. declare module "babylonjs/Misc/basis" {
  69386. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69387. /**
  69388. * Info about the .basis files
  69389. */
  69390. class BasisFileInfo {
  69391. /**
  69392. * If the file has alpha
  69393. */
  69394. hasAlpha: boolean;
  69395. /**
  69396. * Info about each image of the basis file
  69397. */
  69398. images: Array<{
  69399. levels: Array<{
  69400. width: number;
  69401. height: number;
  69402. transcodedPixels: ArrayBufferView;
  69403. }>;
  69404. }>;
  69405. }
  69406. /**
  69407. * Result of transcoding a basis file
  69408. */
  69409. class TranscodeResult {
  69410. /**
  69411. * Info about the .basis file
  69412. */
  69413. fileInfo: BasisFileInfo;
  69414. /**
  69415. * Format to use when loading the file
  69416. */
  69417. format: number;
  69418. }
  69419. /**
  69420. * Configuration options for the Basis transcoder
  69421. */
  69422. export class BasisTranscodeConfiguration {
  69423. /**
  69424. * Supported compression formats used to determine the supported output format of the transcoder
  69425. */
  69426. supportedCompressionFormats?: {
  69427. /**
  69428. * etc1 compression format
  69429. */
  69430. etc1?: boolean;
  69431. /**
  69432. * s3tc compression format
  69433. */
  69434. s3tc?: boolean;
  69435. /**
  69436. * pvrtc compression format
  69437. */
  69438. pvrtc?: boolean;
  69439. /**
  69440. * etc2 compression format
  69441. */
  69442. etc2?: boolean;
  69443. };
  69444. /**
  69445. * If mipmap levels should be loaded for transcoded images (Default: true)
  69446. */
  69447. loadMipmapLevels?: boolean;
  69448. /**
  69449. * Index of a single image to load (Default: all images)
  69450. */
  69451. loadSingleImage?: number;
  69452. }
  69453. /**
  69454. * Used to load .Basis files
  69455. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  69456. */
  69457. export class BasisTools {
  69458. private static _IgnoreSupportedFormats;
  69459. /**
  69460. * URL to use when loading the basis transcoder
  69461. */
  69462. static JSModuleURL: string;
  69463. /**
  69464. * URL to use when loading the wasm module for the transcoder
  69465. */
  69466. static WasmModuleURL: string;
  69467. /**
  69468. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  69469. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  69470. * @returns internal format corresponding to the Basis format
  69471. */
  69472. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  69473. private static _WorkerPromise;
  69474. private static _Worker;
  69475. private static _actionId;
  69476. private static _CreateWorkerAsync;
  69477. /**
  69478. * Transcodes a loaded image file to compressed pixel data
  69479. * @param data image data to transcode
  69480. * @param config configuration options for the transcoding
  69481. * @returns a promise resulting in the transcoded image
  69482. */
  69483. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  69484. /**
  69485. * Loads a texture from the transcode result
  69486. * @param texture texture load to
  69487. * @param transcodeResult the result of transcoding the basis file to load from
  69488. */
  69489. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  69490. }
  69491. }
  69492. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  69493. import { Nullable } from "babylonjs/types";
  69494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69495. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69496. /**
  69497. * Loader for .basis file format
  69498. */
  69499. export class _BasisTextureLoader implements IInternalTextureLoader {
  69500. /**
  69501. * Defines whether the loader supports cascade loading the different faces.
  69502. */
  69503. readonly supportCascades: boolean;
  69504. /**
  69505. * This returns if the loader support the current file information.
  69506. * @param extension defines the file extension of the file being loaded
  69507. * @returns true if the loader can load the specified file
  69508. */
  69509. canLoad(extension: string): boolean;
  69510. /**
  69511. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69512. * @param data contains the texture data
  69513. * @param texture defines the BabylonJS internal texture
  69514. * @param createPolynomials will be true if polynomials have been requested
  69515. * @param onLoad defines the callback to trigger once the texture is ready
  69516. * @param onError defines the callback to trigger in case of error
  69517. */
  69518. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69519. /**
  69520. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69521. * @param data contains the texture data
  69522. * @param texture defines the BabylonJS internal texture
  69523. * @param callback defines the method to call once ready to upload
  69524. */
  69525. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69526. }
  69527. }
  69528. declare module "babylonjs/Materials/Textures/Loaders/index" {
  69529. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  69530. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  69531. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  69532. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  69533. export * from "babylonjs/Materials/Textures/Loaders/hdrTextureLoader";
  69534. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  69535. }
  69536. declare module "babylonjs/Materials/Textures/Packer/frame" {
  69537. import { Vector2 } from "babylonjs/Maths/math.vector";
  69538. /**
  69539. * Defines the basic options interface of a TexturePacker Frame
  69540. */
  69541. export interface ITexturePackerFrame {
  69542. /**
  69543. * The frame ID
  69544. */
  69545. id: number;
  69546. /**
  69547. * The frames Scale
  69548. */
  69549. scale: Vector2;
  69550. /**
  69551. * The Frames offset
  69552. */
  69553. offset: Vector2;
  69554. }
  69555. /**
  69556. * This is a support class for frame Data on texture packer sets.
  69557. */
  69558. export class TexturePackerFrame implements ITexturePackerFrame {
  69559. /**
  69560. * The frame ID
  69561. */
  69562. id: number;
  69563. /**
  69564. * The frames Scale
  69565. */
  69566. scale: Vector2;
  69567. /**
  69568. * The Frames offset
  69569. */
  69570. offset: Vector2;
  69571. /**
  69572. * Initializes a texture package frame.
  69573. * @param id The numerical frame identifier
  69574. * @param scale Scalar Vector2 for UV frame
  69575. * @param offset Vector2 for the frame position in UV units.
  69576. * @returns TexturePackerFrame
  69577. */
  69578. constructor(id: number, scale: Vector2, offset: Vector2);
  69579. }
  69580. }
  69581. declare module "babylonjs/Materials/Textures/Packer/packer" {
  69582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69583. import { Scene } from "babylonjs/scene";
  69584. import { Nullable } from "babylonjs/types";
  69585. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  69586. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  69587. /**
  69588. * Defines the basic options interface of a TexturePacker
  69589. */
  69590. export interface ITexturePackerOptions {
  69591. /**
  69592. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  69593. */
  69594. map?: string[];
  69595. /**
  69596. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69597. */
  69598. uvsIn?: string;
  69599. /**
  69600. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69601. */
  69602. uvsOut?: string;
  69603. /**
  69604. * number representing the layout style. Defaults to LAYOUT_STRIP
  69605. */
  69606. layout?: number;
  69607. /**
  69608. * number of columns if using custom column count layout(2). This defaults to 4.
  69609. */
  69610. colnum?: number;
  69611. /**
  69612. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  69613. */
  69614. updateInputMeshes?: boolean;
  69615. /**
  69616. * boolean flag to dispose all the source textures. Defaults to true.
  69617. */
  69618. disposeSources?: boolean;
  69619. /**
  69620. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  69621. */
  69622. fillBlanks?: boolean;
  69623. /**
  69624. * string value representing the context fill style color. Defaults to 'black'.
  69625. */
  69626. customFillColor?: string;
  69627. /**
  69628. * Width and Height Value of each Frame in the TexturePacker Sets
  69629. */
  69630. frameSize?: number;
  69631. /**
  69632. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  69633. */
  69634. paddingRatio?: number;
  69635. /**
  69636. * Number that declares the fill method for the padding gutter.
  69637. */
  69638. paddingMode?: number;
  69639. /**
  69640. * If in SUBUV_COLOR padding mode what color to use.
  69641. */
  69642. paddingColor?: Color3 | Color4;
  69643. }
  69644. /**
  69645. * Defines the basic interface of a TexturePacker JSON File
  69646. */
  69647. export interface ITexturePackerJSON {
  69648. /**
  69649. * The frame ID
  69650. */
  69651. name: string;
  69652. /**
  69653. * The base64 channel data
  69654. */
  69655. sets: any;
  69656. /**
  69657. * The options of the Packer
  69658. */
  69659. options: ITexturePackerOptions;
  69660. /**
  69661. * The frame data of the Packer
  69662. */
  69663. frames: Array<number>;
  69664. }
  69665. /**
  69666. * This is a support class that generates a series of packed texture sets.
  69667. * @see https://doc.babylonjs.com/babylon101/materials
  69668. */
  69669. export class TexturePacker {
  69670. /** Packer Layout Constant 0 */
  69671. static readonly LAYOUT_STRIP: number;
  69672. /** Packer Layout Constant 1 */
  69673. static readonly LAYOUT_POWER2: number;
  69674. /** Packer Layout Constant 2 */
  69675. static readonly LAYOUT_COLNUM: number;
  69676. /** Packer Layout Constant 0 */
  69677. static readonly SUBUV_WRAP: number;
  69678. /** Packer Layout Constant 1 */
  69679. static readonly SUBUV_EXTEND: number;
  69680. /** Packer Layout Constant 2 */
  69681. static readonly SUBUV_COLOR: number;
  69682. /** The Name of the Texture Package */
  69683. name: string;
  69684. /** The scene scope of the TexturePacker */
  69685. scene: Scene;
  69686. /** The Meshes to target */
  69687. meshes: AbstractMesh[];
  69688. /** Arguments passed with the Constructor */
  69689. options: ITexturePackerOptions;
  69690. /** The promise that is started upon initialization */
  69691. promise: Nullable<Promise<TexturePacker | string>>;
  69692. /** The Container object for the channel sets that are generated */
  69693. sets: object;
  69694. /** The Container array for the frames that are generated */
  69695. frames: TexturePackerFrame[];
  69696. /** The expected number of textures the system is parsing. */
  69697. private _expecting;
  69698. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  69699. private _paddingValue;
  69700. /**
  69701. * Initializes a texture package series from an array of meshes or a single mesh.
  69702. * @param name The name of the package
  69703. * @param meshes The target meshes to compose the package from
  69704. * @param options The arguments that texture packer should follow while building.
  69705. * @param scene The scene which the textures are scoped to.
  69706. * @returns TexturePacker
  69707. */
  69708. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  69709. /**
  69710. * Starts the package process
  69711. * @param resolve The promises resolution function
  69712. * @returns TexturePacker
  69713. */
  69714. private _createFrames;
  69715. /**
  69716. * Calculates the Size of the Channel Sets
  69717. * @returns Vector2
  69718. */
  69719. private _calculateSize;
  69720. /**
  69721. * Calculates the UV data for the frames.
  69722. * @param baseSize the base frameSize
  69723. * @param padding the base frame padding
  69724. * @param dtSize size of the Dynamic Texture for that channel
  69725. * @param dtUnits is 1/dtSize
  69726. * @param update flag to update the input meshes
  69727. */
  69728. private _calculateMeshUVFrames;
  69729. /**
  69730. * Calculates the frames Offset.
  69731. * @param index of the frame
  69732. * @returns Vector2
  69733. */
  69734. private _getFrameOffset;
  69735. /**
  69736. * Updates a Mesh to the frame data
  69737. * @param mesh that is the target
  69738. * @param frameID or the frame index
  69739. */
  69740. private _updateMeshUV;
  69741. /**
  69742. * Updates a Meshes materials to use the texture packer channels
  69743. * @param m is the mesh to target
  69744. * @param force all channels on the packer to be set.
  69745. */
  69746. private _updateTextureReferences;
  69747. /**
  69748. * Public method to set a Mesh to a frame
  69749. * @param m that is the target
  69750. * @param frameID or the frame index
  69751. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  69752. */
  69753. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  69754. /**
  69755. * Starts the async promise to compile the texture packer.
  69756. * @returns Promise<void>
  69757. */
  69758. processAsync(): Promise<void>;
  69759. /**
  69760. * Disposes all textures associated with this packer
  69761. */
  69762. dispose(): void;
  69763. /**
  69764. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  69765. * @param imageType is the image type to use.
  69766. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  69767. */
  69768. download(imageType?: string, quality?: number): void;
  69769. /**
  69770. * Public method to load a texturePacker JSON file.
  69771. * @param data of the JSON file in string format.
  69772. */
  69773. updateFromJSON(data: string): void;
  69774. }
  69775. }
  69776. declare module "babylonjs/Materials/Textures/Packer/index" {
  69777. export * from "babylonjs/Materials/Textures/Packer/packer";
  69778. export * from "babylonjs/Materials/Textures/Packer/frame";
  69779. }
  69780. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  69781. import { Scene } from "babylonjs/scene";
  69782. import { Texture } from "babylonjs/Materials/Textures/texture";
  69783. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69784. /**
  69785. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  69786. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69787. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69788. */
  69789. export class CustomProceduralTexture extends ProceduralTexture {
  69790. private _animate;
  69791. private _time;
  69792. private _config;
  69793. private _texturePath;
  69794. /**
  69795. * Instantiates a new Custom Procedural Texture.
  69796. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  69797. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69798. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69799. * @param name Define the name of the texture
  69800. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  69801. * @param size Define the size of the texture to create
  69802. * @param scene Define the scene the texture belongs to
  69803. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  69804. * @param generateMipMaps Define if the texture should creates mip maps or not
  69805. */
  69806. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69807. private _loadJson;
  69808. /**
  69809. * Is the texture ready to be used ? (rendered at least once)
  69810. * @returns true if ready, otherwise, false.
  69811. */
  69812. isReady(): boolean;
  69813. /**
  69814. * Render the texture to its associated render target.
  69815. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  69816. */
  69817. render(useCameraPostProcess?: boolean): void;
  69818. /**
  69819. * Update the list of dependant textures samplers in the shader.
  69820. */
  69821. updateTextures(): void;
  69822. /**
  69823. * Update the uniform values of the procedural texture in the shader.
  69824. */
  69825. updateShaderUniforms(): void;
  69826. /**
  69827. * Define if the texture animates or not.
  69828. */
  69829. get animate(): boolean;
  69830. set animate(value: boolean);
  69831. }
  69832. }
  69833. declare module "babylonjs/Shaders/noise.fragment" {
  69834. /** @hidden */
  69835. export var noisePixelShader: {
  69836. name: string;
  69837. shader: string;
  69838. };
  69839. }
  69840. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  69841. import { Nullable } from "babylonjs/types";
  69842. import { Scene } from "babylonjs/scene";
  69843. import { Texture } from "babylonjs/Materials/Textures/texture";
  69844. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69845. import "babylonjs/Shaders/noise.fragment";
  69846. /**
  69847. * Class used to generate noise procedural textures
  69848. */
  69849. export class NoiseProceduralTexture extends ProceduralTexture {
  69850. /** Gets or sets the start time (default is 0) */
  69851. time: number;
  69852. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  69853. brightness: number;
  69854. /** Defines the number of octaves to process */
  69855. octaves: number;
  69856. /** Defines the level of persistence (0.8 by default) */
  69857. persistence: number;
  69858. /** Gets or sets animation speed factor (default is 1) */
  69859. animationSpeedFactor: number;
  69860. /**
  69861. * Creates a new NoiseProceduralTexture
  69862. * @param name defines the name fo the texture
  69863. * @param size defines the size of the texture (default is 256)
  69864. * @param scene defines the hosting scene
  69865. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  69866. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  69867. */
  69868. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69869. private _updateShaderUniforms;
  69870. protected _getDefines(): string;
  69871. /** Generate the current state of the procedural texture */
  69872. render(useCameraPostProcess?: boolean): void;
  69873. /**
  69874. * Serializes this noise procedural texture
  69875. * @returns a serialized noise procedural texture object
  69876. */
  69877. serialize(): any;
  69878. /**
  69879. * Clone the texture.
  69880. * @returns the cloned texture
  69881. */
  69882. clone(): NoiseProceduralTexture;
  69883. /**
  69884. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  69885. * @param parsedTexture defines parsed texture data
  69886. * @param scene defines the current scene
  69887. * @param rootUrl defines the root URL containing noise procedural texture information
  69888. * @returns a parsed NoiseProceduralTexture
  69889. */
  69890. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  69891. }
  69892. }
  69893. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  69894. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  69895. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  69896. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69897. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  69898. }
  69899. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  69900. import { Nullable } from "babylonjs/types";
  69901. import { Scene } from "babylonjs/scene";
  69902. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  69903. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69904. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  69905. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69906. /**
  69907. * Raw cube texture where the raw buffers are passed in
  69908. */
  69909. export class RawCubeTexture extends CubeTexture {
  69910. /**
  69911. * Creates a cube texture where the raw buffers are passed in.
  69912. * @param scene defines the scene the texture is attached to
  69913. * @param data defines the array of data to use to create each face
  69914. * @param size defines the size of the textures
  69915. * @param format defines the format of the data
  69916. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  69917. * @param generateMipMaps defines if the engine should generate the mip levels
  69918. * @param invertY defines if data must be stored with Y axis inverted
  69919. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  69920. * @param compression defines the compression used (null by default)
  69921. */
  69922. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  69923. /**
  69924. * Updates the raw cube texture.
  69925. * @param data defines the data to store
  69926. * @param format defines the data format
  69927. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69928. * @param invertY defines if data must be stored with Y axis inverted
  69929. * @param compression defines the compression used (null by default)
  69930. * @param level defines which level of the texture to update
  69931. */
  69932. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  69933. /**
  69934. * Updates a raw cube texture with RGBD encoded data.
  69935. * @param data defines the array of data [mipmap][face] to use to create each face
  69936. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  69937. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  69938. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  69939. * @returns a promsie that resolves when the operation is complete
  69940. */
  69941. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  69942. /**
  69943. * Clones the raw cube texture.
  69944. * @return a new cube texture
  69945. */
  69946. clone(): CubeTexture;
  69947. /** @hidden */
  69948. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  69949. }
  69950. }
  69951. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  69952. import { Scene } from "babylonjs/scene";
  69953. import { Texture } from "babylonjs/Materials/Textures/texture";
  69954. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69955. /**
  69956. * Class used to store 2D array textures containing user data
  69957. */
  69958. export class RawTexture2DArray extends Texture {
  69959. /** Gets or sets the texture format to use */
  69960. format: number;
  69961. /**
  69962. * Create a new RawTexture2DArray
  69963. * @param data defines the data of the texture
  69964. * @param width defines the width of the texture
  69965. * @param height defines the height of the texture
  69966. * @param depth defines the number of layers of the texture
  69967. * @param format defines the texture format to use
  69968. * @param scene defines the hosting scene
  69969. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69970. * @param invertY defines if texture must be stored with Y axis inverted
  69971. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69972. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69973. */
  69974. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  69975. /** Gets or sets the texture format to use */
  69976. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  69977. /**
  69978. * Update the texture with new data
  69979. * @param data defines the data to store in the texture
  69980. */
  69981. update(data: ArrayBufferView): void;
  69982. }
  69983. }
  69984. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  69985. import { Scene } from "babylonjs/scene";
  69986. import { Texture } from "babylonjs/Materials/Textures/texture";
  69987. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69988. /**
  69989. * Class used to store 3D textures containing user data
  69990. */
  69991. export class RawTexture3D extends Texture {
  69992. /** Gets or sets the texture format to use */
  69993. format: number;
  69994. /**
  69995. * Create a new RawTexture3D
  69996. * @param data defines the data of the texture
  69997. * @param width defines the width of the texture
  69998. * @param height defines the height of the texture
  69999. * @param depth defines the depth of the texture
  70000. * @param format defines the texture format to use
  70001. * @param scene defines the hosting scene
  70002. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  70003. * @param invertY defines if texture must be stored with Y axis inverted
  70004. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70005. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  70006. */
  70007. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  70008. /** Gets or sets the texture format to use */
  70009. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  70010. /**
  70011. * Update the texture with new data
  70012. * @param data defines the data to store in the texture
  70013. */
  70014. update(data: ArrayBufferView): void;
  70015. }
  70016. }
  70017. declare module "babylonjs/Materials/Textures/refractionTexture" {
  70018. import { Scene } from "babylonjs/scene";
  70019. import { Plane } from "babylonjs/Maths/math.plane";
  70020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70021. /**
  70022. * Creates a refraction texture used by refraction channel of the standard material.
  70023. * It is like a mirror but to see through a material.
  70024. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  70025. */
  70026. export class RefractionTexture extends RenderTargetTexture {
  70027. /**
  70028. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  70029. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  70030. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  70031. */
  70032. refractionPlane: Plane;
  70033. /**
  70034. * Define how deep under the surface we should see.
  70035. */
  70036. depth: number;
  70037. /**
  70038. * Creates a refraction texture used by refraction channel of the standard material.
  70039. * It is like a mirror but to see through a material.
  70040. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  70041. * @param name Define the texture name
  70042. * @param size Define the size of the underlying texture
  70043. * @param scene Define the scene the refraction belongs to
  70044. * @param generateMipMaps Define if we need to generate mips level for the refraction
  70045. */
  70046. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  70047. /**
  70048. * Clone the refraction texture.
  70049. * @returns the cloned texture
  70050. */
  70051. clone(): RefractionTexture;
  70052. /**
  70053. * Serialize the texture to a JSON representation you could use in Parse later on
  70054. * @returns the serialized JSON representation
  70055. */
  70056. serialize(): any;
  70057. }
  70058. }
  70059. declare module "babylonjs/Materials/Textures/index" {
  70060. export * from "babylonjs/Materials/Textures/baseTexture";
  70061. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  70062. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  70063. export * from "babylonjs/Materials/Textures/cubeTexture";
  70064. export * from "babylonjs/Materials/Textures/dynamicTexture";
  70065. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70066. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  70067. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  70068. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  70069. export * from "babylonjs/Materials/Textures/internalTexture";
  70070. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  70071. export * from "babylonjs/Materials/Textures/Loaders/index";
  70072. export * from "babylonjs/Materials/Textures/mirrorTexture";
  70073. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  70074. export * from "babylonjs/Materials/Textures/Packer/index";
  70075. export * from "babylonjs/Materials/Textures/Procedurals/index";
  70076. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  70077. export * from "babylonjs/Materials/Textures/rawTexture";
  70078. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  70079. export * from "babylonjs/Materials/Textures/rawTexture3D";
  70080. export * from "babylonjs/Materials/Textures/refractionTexture";
  70081. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  70082. export * from "babylonjs/Materials/Textures/texture";
  70083. export * from "babylonjs/Materials/Textures/videoTexture";
  70084. }
  70085. declare module "babylonjs/Materials/Node/Enums/index" {
  70086. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  70087. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  70088. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  70089. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  70090. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  70091. }
  70092. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  70093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70096. import { Mesh } from "babylonjs/Meshes/mesh";
  70097. import { Effect } from "babylonjs/Materials/effect";
  70098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70099. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70100. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70102. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70103. /**
  70104. * Block used to add support for vertex skinning (bones)
  70105. */
  70106. export class BonesBlock extends NodeMaterialBlock {
  70107. /**
  70108. * Creates a new BonesBlock
  70109. * @param name defines the block name
  70110. */
  70111. constructor(name: string);
  70112. /**
  70113. * Initialize the block and prepare the context for build
  70114. * @param state defines the state that will be used for the build
  70115. */
  70116. initialize(state: NodeMaterialBuildState): void;
  70117. /**
  70118. * Gets the current class name
  70119. * @returns the class name
  70120. */
  70121. getClassName(): string;
  70122. /**
  70123. * Gets the matrix indices input component
  70124. */
  70125. get matricesIndices(): NodeMaterialConnectionPoint;
  70126. /**
  70127. * Gets the matrix weights input component
  70128. */
  70129. get matricesWeights(): NodeMaterialConnectionPoint;
  70130. /**
  70131. * Gets the extra matrix indices input component
  70132. */
  70133. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  70134. /**
  70135. * Gets the extra matrix weights input component
  70136. */
  70137. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  70138. /**
  70139. * Gets the world input component
  70140. */
  70141. get world(): NodeMaterialConnectionPoint;
  70142. /**
  70143. * Gets the output component
  70144. */
  70145. get output(): NodeMaterialConnectionPoint;
  70146. autoConfigure(material: NodeMaterial): void;
  70147. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  70148. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70149. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70150. protected _buildBlock(state: NodeMaterialBuildState): this;
  70151. }
  70152. }
  70153. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  70154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70158. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70160. /**
  70161. * Block used to add support for instances
  70162. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  70163. */
  70164. export class InstancesBlock extends NodeMaterialBlock {
  70165. /**
  70166. * Creates a new InstancesBlock
  70167. * @param name defines the block name
  70168. */
  70169. constructor(name: string);
  70170. /**
  70171. * Gets the current class name
  70172. * @returns the class name
  70173. */
  70174. getClassName(): string;
  70175. /**
  70176. * Gets the first world row input component
  70177. */
  70178. get world0(): NodeMaterialConnectionPoint;
  70179. /**
  70180. * Gets the second world row input component
  70181. */
  70182. get world1(): NodeMaterialConnectionPoint;
  70183. /**
  70184. * Gets the third world row input component
  70185. */
  70186. get world2(): NodeMaterialConnectionPoint;
  70187. /**
  70188. * Gets the forth world row input component
  70189. */
  70190. get world3(): NodeMaterialConnectionPoint;
  70191. /**
  70192. * Gets the world input component
  70193. */
  70194. get world(): NodeMaterialConnectionPoint;
  70195. /**
  70196. * Gets the output component
  70197. */
  70198. get output(): NodeMaterialConnectionPoint;
  70199. /**
  70200. * Gets the isntanceID component
  70201. */
  70202. get instanceID(): NodeMaterialConnectionPoint;
  70203. autoConfigure(material: NodeMaterial): void;
  70204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  70205. protected _buildBlock(state: NodeMaterialBuildState): this;
  70206. }
  70207. }
  70208. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  70209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70213. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70214. import { Effect } from "babylonjs/Materials/effect";
  70215. import { Mesh } from "babylonjs/Meshes/mesh";
  70216. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70217. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70218. /**
  70219. * Block used to add morph targets support to vertex shader
  70220. */
  70221. export class MorphTargetsBlock extends NodeMaterialBlock {
  70222. private _repeatableContentAnchor;
  70223. /**
  70224. * Create a new MorphTargetsBlock
  70225. * @param name defines the block name
  70226. */
  70227. constructor(name: string);
  70228. /**
  70229. * Gets the current class name
  70230. * @returns the class name
  70231. */
  70232. getClassName(): string;
  70233. /**
  70234. * Gets the position input component
  70235. */
  70236. get position(): NodeMaterialConnectionPoint;
  70237. /**
  70238. * Gets the normal input component
  70239. */
  70240. get normal(): NodeMaterialConnectionPoint;
  70241. /**
  70242. * Gets the tangent input component
  70243. */
  70244. get tangent(): NodeMaterialConnectionPoint;
  70245. /**
  70246. * Gets the tangent input component
  70247. */
  70248. get uv(): NodeMaterialConnectionPoint;
  70249. /**
  70250. * Gets the position output component
  70251. */
  70252. get positionOutput(): NodeMaterialConnectionPoint;
  70253. /**
  70254. * Gets the normal output component
  70255. */
  70256. get normalOutput(): NodeMaterialConnectionPoint;
  70257. /**
  70258. * Gets the tangent output component
  70259. */
  70260. get tangentOutput(): NodeMaterialConnectionPoint;
  70261. /**
  70262. * Gets the tangent output component
  70263. */
  70264. get uvOutput(): NodeMaterialConnectionPoint;
  70265. initialize(state: NodeMaterialBuildState): void;
  70266. autoConfigure(material: NodeMaterial): void;
  70267. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70268. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70269. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  70270. protected _buildBlock(state: NodeMaterialBuildState): this;
  70271. }
  70272. }
  70273. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  70274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70277. import { Nullable } from "babylonjs/types";
  70278. import { Scene } from "babylonjs/scene";
  70279. import { Effect } from "babylonjs/Materials/effect";
  70280. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70281. import { Mesh } from "babylonjs/Meshes/mesh";
  70282. import { Light } from "babylonjs/Lights/light";
  70283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70284. /**
  70285. * Block used to get data information from a light
  70286. */
  70287. export class LightInformationBlock extends NodeMaterialBlock {
  70288. private _lightDataUniformName;
  70289. private _lightColorUniformName;
  70290. private _lightTypeDefineName;
  70291. /**
  70292. * Gets or sets the light associated with this block
  70293. */
  70294. light: Nullable<Light>;
  70295. /**
  70296. * Creates a new LightInformationBlock
  70297. * @param name defines the block name
  70298. */
  70299. constructor(name: string);
  70300. /**
  70301. * Gets the current class name
  70302. * @returns the class name
  70303. */
  70304. getClassName(): string;
  70305. /**
  70306. * Gets the world position input component
  70307. */
  70308. get worldPosition(): NodeMaterialConnectionPoint;
  70309. /**
  70310. * Gets the direction output component
  70311. */
  70312. get direction(): NodeMaterialConnectionPoint;
  70313. /**
  70314. * Gets the direction output component
  70315. */
  70316. get color(): NodeMaterialConnectionPoint;
  70317. /**
  70318. * Gets the direction output component
  70319. */
  70320. get intensity(): NodeMaterialConnectionPoint;
  70321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70322. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70323. protected _buildBlock(state: NodeMaterialBuildState): this;
  70324. serialize(): any;
  70325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70326. }
  70327. }
  70328. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  70329. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  70330. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  70331. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  70332. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  70333. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  70334. }
  70335. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  70336. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70337. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70338. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70340. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70341. import { Effect } from "babylonjs/Materials/effect";
  70342. import { Mesh } from "babylonjs/Meshes/mesh";
  70343. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70344. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70345. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70346. /**
  70347. * Block used to add image processing support to fragment shader
  70348. */
  70349. export class ImageProcessingBlock extends NodeMaterialBlock {
  70350. /**
  70351. * Create a new ImageProcessingBlock
  70352. * @param name defines the block name
  70353. */
  70354. constructor(name: string);
  70355. /**
  70356. * Gets the current class name
  70357. * @returns the class name
  70358. */
  70359. getClassName(): string;
  70360. /**
  70361. * Gets the color input component
  70362. */
  70363. get color(): NodeMaterialConnectionPoint;
  70364. /**
  70365. * Gets the output component
  70366. */
  70367. get output(): NodeMaterialConnectionPoint;
  70368. /**
  70369. * Initialize the block and prepare the context for build
  70370. * @param state defines the state that will be used for the build
  70371. */
  70372. initialize(state: NodeMaterialBuildState): void;
  70373. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  70374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70375. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70376. protected _buildBlock(state: NodeMaterialBuildState): this;
  70377. }
  70378. }
  70379. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  70380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70383. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70385. import { Effect } from "babylonjs/Materials/effect";
  70386. import { Mesh } from "babylonjs/Meshes/mesh";
  70387. import { Scene } from "babylonjs/scene";
  70388. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70389. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70390. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70391. /**
  70392. * Block used to pertub normals based on a normal map
  70393. */
  70394. export class PerturbNormalBlock extends NodeMaterialBlock {
  70395. private _tangentSpaceParameterName;
  70396. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  70397. invertX: boolean;
  70398. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  70399. invertY: boolean;
  70400. /**
  70401. * Create a new PerturbNormalBlock
  70402. * @param name defines the block name
  70403. */
  70404. constructor(name: string);
  70405. /**
  70406. * Gets the current class name
  70407. * @returns the class name
  70408. */
  70409. getClassName(): string;
  70410. /**
  70411. * Gets the world position input component
  70412. */
  70413. get worldPosition(): NodeMaterialConnectionPoint;
  70414. /**
  70415. * Gets the world normal input component
  70416. */
  70417. get worldNormal(): NodeMaterialConnectionPoint;
  70418. /**
  70419. * Gets the world tangent input component
  70420. */
  70421. get worldTangent(): NodeMaterialConnectionPoint;
  70422. /**
  70423. * Gets the uv input component
  70424. */
  70425. get uv(): NodeMaterialConnectionPoint;
  70426. /**
  70427. * Gets the normal map color input component
  70428. */
  70429. get normalMapColor(): NodeMaterialConnectionPoint;
  70430. /**
  70431. * Gets the strength input component
  70432. */
  70433. get strength(): NodeMaterialConnectionPoint;
  70434. /**
  70435. * Gets the output component
  70436. */
  70437. get output(): NodeMaterialConnectionPoint;
  70438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70439. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70440. autoConfigure(material: NodeMaterial): void;
  70441. protected _buildBlock(state: NodeMaterialBuildState): this;
  70442. protected _dumpPropertiesCode(): string;
  70443. serialize(): any;
  70444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70445. }
  70446. }
  70447. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  70448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70451. /**
  70452. * Block used to discard a pixel if a value is smaller than a cutoff
  70453. */
  70454. export class DiscardBlock extends NodeMaterialBlock {
  70455. /**
  70456. * Create a new DiscardBlock
  70457. * @param name defines the block name
  70458. */
  70459. constructor(name: string);
  70460. /**
  70461. * Gets the current class name
  70462. * @returns the class name
  70463. */
  70464. getClassName(): string;
  70465. /**
  70466. * Gets the color input component
  70467. */
  70468. get value(): NodeMaterialConnectionPoint;
  70469. /**
  70470. * Gets the cutoff input component
  70471. */
  70472. get cutoff(): NodeMaterialConnectionPoint;
  70473. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70474. }
  70475. }
  70476. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  70477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70480. /**
  70481. * Block used to test if the fragment shader is front facing
  70482. */
  70483. export class FrontFacingBlock extends NodeMaterialBlock {
  70484. /**
  70485. * Creates a new FrontFacingBlock
  70486. * @param name defines the block name
  70487. */
  70488. constructor(name: string);
  70489. /**
  70490. * Gets the current class name
  70491. * @returns the class name
  70492. */
  70493. getClassName(): string;
  70494. /**
  70495. * Gets the output component
  70496. */
  70497. get output(): NodeMaterialConnectionPoint;
  70498. protected _buildBlock(state: NodeMaterialBuildState): this;
  70499. }
  70500. }
  70501. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  70502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70505. /**
  70506. * Block used to get the derivative value on x and y of a given input
  70507. */
  70508. export class DerivativeBlock extends NodeMaterialBlock {
  70509. /**
  70510. * Create a new DerivativeBlock
  70511. * @param name defines the block name
  70512. */
  70513. constructor(name: string);
  70514. /**
  70515. * Gets the current class name
  70516. * @returns the class name
  70517. */
  70518. getClassName(): string;
  70519. /**
  70520. * Gets the input component
  70521. */
  70522. get input(): NodeMaterialConnectionPoint;
  70523. /**
  70524. * Gets the derivative output on x
  70525. */
  70526. get dx(): NodeMaterialConnectionPoint;
  70527. /**
  70528. * Gets the derivative output on y
  70529. */
  70530. get dy(): NodeMaterialConnectionPoint;
  70531. protected _buildBlock(state: NodeMaterialBuildState): this;
  70532. }
  70533. }
  70534. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  70535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70538. /**
  70539. * Block used to make gl_FragCoord available
  70540. */
  70541. export class FragCoordBlock extends NodeMaterialBlock {
  70542. /**
  70543. * Creates a new FragCoordBlock
  70544. * @param name defines the block name
  70545. */
  70546. constructor(name: string);
  70547. /**
  70548. * Gets the current class name
  70549. * @returns the class name
  70550. */
  70551. getClassName(): string;
  70552. /**
  70553. * Gets the xy component
  70554. */
  70555. get xy(): NodeMaterialConnectionPoint;
  70556. /**
  70557. * Gets the xyz component
  70558. */
  70559. get xyz(): NodeMaterialConnectionPoint;
  70560. /**
  70561. * Gets the xyzw component
  70562. */
  70563. get xyzw(): NodeMaterialConnectionPoint;
  70564. /**
  70565. * Gets the x component
  70566. */
  70567. get x(): NodeMaterialConnectionPoint;
  70568. /**
  70569. * Gets the y component
  70570. */
  70571. get y(): NodeMaterialConnectionPoint;
  70572. /**
  70573. * Gets the z component
  70574. */
  70575. get z(): NodeMaterialConnectionPoint;
  70576. /**
  70577. * Gets the w component
  70578. */
  70579. get output(): NodeMaterialConnectionPoint;
  70580. protected writeOutputs(state: NodeMaterialBuildState): string;
  70581. protected _buildBlock(state: NodeMaterialBuildState): this;
  70582. }
  70583. }
  70584. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  70585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70588. import { Effect } from "babylonjs/Materials/effect";
  70589. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70590. import { Mesh } from "babylonjs/Meshes/mesh";
  70591. /**
  70592. * Block used to get the screen sizes
  70593. */
  70594. export class ScreenSizeBlock extends NodeMaterialBlock {
  70595. private _varName;
  70596. private _scene;
  70597. /**
  70598. * Creates a new ScreenSizeBlock
  70599. * @param name defines the block name
  70600. */
  70601. constructor(name: string);
  70602. /**
  70603. * Gets the current class name
  70604. * @returns the class name
  70605. */
  70606. getClassName(): string;
  70607. /**
  70608. * Gets the xy component
  70609. */
  70610. get xy(): NodeMaterialConnectionPoint;
  70611. /**
  70612. * Gets the x component
  70613. */
  70614. get x(): NodeMaterialConnectionPoint;
  70615. /**
  70616. * Gets the y component
  70617. */
  70618. get y(): NodeMaterialConnectionPoint;
  70619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70620. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  70621. protected _buildBlock(state: NodeMaterialBuildState): this;
  70622. }
  70623. }
  70624. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  70625. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  70626. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  70627. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  70628. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  70629. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  70630. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  70631. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  70632. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  70633. }
  70634. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  70635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70637. import { Mesh } from "babylonjs/Meshes/mesh";
  70638. import { Effect } from "babylonjs/Materials/effect";
  70639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70641. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70642. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  70643. /**
  70644. * Block used to add support for scene fog
  70645. */
  70646. export class FogBlock extends NodeMaterialBlock {
  70647. private _fogDistanceName;
  70648. private _fogParameters;
  70649. /**
  70650. * Create a new FogBlock
  70651. * @param name defines the block name
  70652. */
  70653. constructor(name: string);
  70654. /**
  70655. * Gets the current class name
  70656. * @returns the class name
  70657. */
  70658. getClassName(): string;
  70659. /**
  70660. * Gets the world position input component
  70661. */
  70662. get worldPosition(): NodeMaterialConnectionPoint;
  70663. /**
  70664. * Gets the view input component
  70665. */
  70666. get view(): NodeMaterialConnectionPoint;
  70667. /**
  70668. * Gets the color input component
  70669. */
  70670. get input(): NodeMaterialConnectionPoint;
  70671. /**
  70672. * Gets the fog color input component
  70673. */
  70674. get fogColor(): NodeMaterialConnectionPoint;
  70675. /**
  70676. * Gets the output component
  70677. */
  70678. get output(): NodeMaterialConnectionPoint;
  70679. autoConfigure(material: NodeMaterial): void;
  70680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70682. protected _buildBlock(state: NodeMaterialBuildState): this;
  70683. }
  70684. }
  70685. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  70686. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70687. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70690. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70691. import { Effect } from "babylonjs/Materials/effect";
  70692. import { Mesh } from "babylonjs/Meshes/mesh";
  70693. import { Light } from "babylonjs/Lights/light";
  70694. import { Nullable } from "babylonjs/types";
  70695. import { Scene } from "babylonjs/scene";
  70696. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  70697. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  70698. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  70699. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  70700. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  70701. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70702. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  70703. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  70704. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  70705. /**
  70706. * Block used to add light in the fragment shader
  70707. */
  70708. export class LightBlock extends NodeMaterialBlock {
  70709. private _lightId;
  70710. /**
  70711. * Gets or sets the light associated with this block
  70712. */
  70713. light: Nullable<Light>;
  70714. /**
  70715. * Create a new LightBlock
  70716. * @param name defines the block name
  70717. */
  70718. constructor(name: string);
  70719. /**
  70720. * Gets the current class name
  70721. * @returns the class name
  70722. */
  70723. getClassName(): string;
  70724. /**
  70725. * Gets the world position input component
  70726. */
  70727. get worldPosition(): NodeMaterialConnectionPoint;
  70728. /**
  70729. * Gets the world normal input component
  70730. */
  70731. get worldNormal(): NodeMaterialConnectionPoint;
  70732. /**
  70733. * Gets the camera (or eye) position component
  70734. */
  70735. get cameraPosition(): NodeMaterialConnectionPoint;
  70736. /**
  70737. * Gets the glossiness component
  70738. */
  70739. get glossiness(): NodeMaterialConnectionPoint;
  70740. /**
  70741. * Gets the glossinness power component
  70742. */
  70743. get glossPower(): NodeMaterialConnectionPoint;
  70744. /**
  70745. * Gets the diffuse color component
  70746. */
  70747. get diffuseColor(): NodeMaterialConnectionPoint;
  70748. /**
  70749. * Gets the specular color component
  70750. */
  70751. get specularColor(): NodeMaterialConnectionPoint;
  70752. /**
  70753. * Gets the view matrix component
  70754. */
  70755. get view(): NodeMaterialConnectionPoint;
  70756. /**
  70757. * Gets the diffuse output component
  70758. */
  70759. get diffuseOutput(): NodeMaterialConnectionPoint;
  70760. /**
  70761. * Gets the specular output component
  70762. */
  70763. get specularOutput(): NodeMaterialConnectionPoint;
  70764. /**
  70765. * Gets the shadow output component
  70766. */
  70767. get shadow(): NodeMaterialConnectionPoint;
  70768. autoConfigure(material: NodeMaterial): void;
  70769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70770. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  70771. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70772. private _injectVertexCode;
  70773. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70774. serialize(): any;
  70775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70776. }
  70777. }
  70778. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  70779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70781. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70782. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  70783. /**
  70784. * Block used to read a reflection texture from a sampler
  70785. */
  70786. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  70787. /**
  70788. * Create a new ReflectionTextureBlock
  70789. * @param name defines the block name
  70790. */
  70791. constructor(name: string);
  70792. /**
  70793. * Gets the current class name
  70794. * @returns the class name
  70795. */
  70796. getClassName(): string;
  70797. /**
  70798. * Gets the world position input component
  70799. */
  70800. get position(): NodeMaterialConnectionPoint;
  70801. /**
  70802. * Gets the world position input component
  70803. */
  70804. get worldPosition(): NodeMaterialConnectionPoint;
  70805. /**
  70806. * Gets the world normal input component
  70807. */
  70808. get worldNormal(): NodeMaterialConnectionPoint;
  70809. /**
  70810. * Gets the world input component
  70811. */
  70812. get world(): NodeMaterialConnectionPoint;
  70813. /**
  70814. * Gets the camera (or eye) position component
  70815. */
  70816. get cameraPosition(): NodeMaterialConnectionPoint;
  70817. /**
  70818. * Gets the view input component
  70819. */
  70820. get view(): NodeMaterialConnectionPoint;
  70821. /**
  70822. * Gets the rgb output component
  70823. */
  70824. get rgb(): NodeMaterialConnectionPoint;
  70825. /**
  70826. * Gets the rgba output component
  70827. */
  70828. get rgba(): NodeMaterialConnectionPoint;
  70829. /**
  70830. * Gets the r output component
  70831. */
  70832. get r(): NodeMaterialConnectionPoint;
  70833. /**
  70834. * Gets the g output component
  70835. */
  70836. get g(): NodeMaterialConnectionPoint;
  70837. /**
  70838. * Gets the b output component
  70839. */
  70840. get b(): NodeMaterialConnectionPoint;
  70841. /**
  70842. * Gets the a output component
  70843. */
  70844. get a(): NodeMaterialConnectionPoint;
  70845. autoConfigure(material: NodeMaterial): void;
  70846. protected _buildBlock(state: NodeMaterialBuildState): this;
  70847. }
  70848. }
  70849. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  70850. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  70851. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  70852. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  70853. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  70854. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  70855. }
  70856. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  70857. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  70858. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  70859. }
  70860. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  70861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70864. /**
  70865. * Block used to add 2 vectors
  70866. */
  70867. export class AddBlock extends NodeMaterialBlock {
  70868. /**
  70869. * Creates a new AddBlock
  70870. * @param name defines the block name
  70871. */
  70872. constructor(name: string);
  70873. /**
  70874. * Gets the current class name
  70875. * @returns the class name
  70876. */
  70877. getClassName(): string;
  70878. /**
  70879. * Gets the left operand input component
  70880. */
  70881. get left(): NodeMaterialConnectionPoint;
  70882. /**
  70883. * Gets the right operand input component
  70884. */
  70885. get right(): NodeMaterialConnectionPoint;
  70886. /**
  70887. * Gets the output component
  70888. */
  70889. get output(): NodeMaterialConnectionPoint;
  70890. protected _buildBlock(state: NodeMaterialBuildState): this;
  70891. }
  70892. }
  70893. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  70894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70897. /**
  70898. * Block used to scale a vector by a float
  70899. */
  70900. export class ScaleBlock extends NodeMaterialBlock {
  70901. /**
  70902. * Creates a new ScaleBlock
  70903. * @param name defines the block name
  70904. */
  70905. constructor(name: string);
  70906. /**
  70907. * Gets the current class name
  70908. * @returns the class name
  70909. */
  70910. getClassName(): string;
  70911. /**
  70912. * Gets the input component
  70913. */
  70914. get input(): NodeMaterialConnectionPoint;
  70915. /**
  70916. * Gets the factor input component
  70917. */
  70918. get factor(): NodeMaterialConnectionPoint;
  70919. /**
  70920. * Gets the output component
  70921. */
  70922. get output(): NodeMaterialConnectionPoint;
  70923. protected _buildBlock(state: NodeMaterialBuildState): this;
  70924. }
  70925. }
  70926. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  70927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70930. import { Scene } from "babylonjs/scene";
  70931. /**
  70932. * Block used to clamp a float
  70933. */
  70934. export class ClampBlock extends NodeMaterialBlock {
  70935. /** Gets or sets the minimum range */
  70936. minimum: number;
  70937. /** Gets or sets the maximum range */
  70938. maximum: number;
  70939. /**
  70940. * Creates a new ClampBlock
  70941. * @param name defines the block name
  70942. */
  70943. constructor(name: string);
  70944. /**
  70945. * Gets the current class name
  70946. * @returns the class name
  70947. */
  70948. getClassName(): string;
  70949. /**
  70950. * Gets the value input component
  70951. */
  70952. get value(): NodeMaterialConnectionPoint;
  70953. /**
  70954. * Gets the output component
  70955. */
  70956. get output(): NodeMaterialConnectionPoint;
  70957. protected _buildBlock(state: NodeMaterialBuildState): this;
  70958. protected _dumpPropertiesCode(): string;
  70959. serialize(): any;
  70960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70961. }
  70962. }
  70963. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  70964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70967. /**
  70968. * Block used to apply a cross product between 2 vectors
  70969. */
  70970. export class CrossBlock extends NodeMaterialBlock {
  70971. /**
  70972. * Creates a new CrossBlock
  70973. * @param name defines the block name
  70974. */
  70975. constructor(name: string);
  70976. /**
  70977. * Gets the current class name
  70978. * @returns the class name
  70979. */
  70980. getClassName(): string;
  70981. /**
  70982. * Gets the left operand input component
  70983. */
  70984. get left(): NodeMaterialConnectionPoint;
  70985. /**
  70986. * Gets the right operand input component
  70987. */
  70988. get right(): NodeMaterialConnectionPoint;
  70989. /**
  70990. * Gets the output component
  70991. */
  70992. get output(): NodeMaterialConnectionPoint;
  70993. protected _buildBlock(state: NodeMaterialBuildState): this;
  70994. }
  70995. }
  70996. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  70997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71000. /**
  71001. * Block used to apply a dot product between 2 vectors
  71002. */
  71003. export class DotBlock extends NodeMaterialBlock {
  71004. /**
  71005. * Creates a new DotBlock
  71006. * @param name defines the block name
  71007. */
  71008. constructor(name: string);
  71009. /**
  71010. * Gets the current class name
  71011. * @returns the class name
  71012. */
  71013. getClassName(): string;
  71014. /**
  71015. * Gets the left operand input component
  71016. */
  71017. get left(): NodeMaterialConnectionPoint;
  71018. /**
  71019. * Gets the right operand input component
  71020. */
  71021. get right(): NodeMaterialConnectionPoint;
  71022. /**
  71023. * Gets the output component
  71024. */
  71025. get output(): NodeMaterialConnectionPoint;
  71026. protected _buildBlock(state: NodeMaterialBuildState): this;
  71027. }
  71028. }
  71029. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  71030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71033. /**
  71034. * Block used to normalize a vector
  71035. */
  71036. export class NormalizeBlock extends NodeMaterialBlock {
  71037. /**
  71038. * Creates a new NormalizeBlock
  71039. * @param name defines the block name
  71040. */
  71041. constructor(name: string);
  71042. /**
  71043. * Gets the current class name
  71044. * @returns the class name
  71045. */
  71046. getClassName(): string;
  71047. /**
  71048. * Gets the input component
  71049. */
  71050. get input(): NodeMaterialConnectionPoint;
  71051. /**
  71052. * Gets the output component
  71053. */
  71054. get output(): NodeMaterialConnectionPoint;
  71055. protected _buildBlock(state: NodeMaterialBuildState): this;
  71056. }
  71057. }
  71058. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  71059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71062. /**
  71063. * Block used to create a Color3/4 out of individual inputs (one for each component)
  71064. */
  71065. export class ColorMergerBlock extends NodeMaterialBlock {
  71066. /**
  71067. * Create a new ColorMergerBlock
  71068. * @param name defines the block name
  71069. */
  71070. constructor(name: string);
  71071. /**
  71072. * Gets the current class name
  71073. * @returns the class name
  71074. */
  71075. getClassName(): string;
  71076. /**
  71077. * Gets the rgb component (input)
  71078. */
  71079. get rgbIn(): NodeMaterialConnectionPoint;
  71080. /**
  71081. * Gets the r component (input)
  71082. */
  71083. get r(): NodeMaterialConnectionPoint;
  71084. /**
  71085. * Gets the g component (input)
  71086. */
  71087. get g(): NodeMaterialConnectionPoint;
  71088. /**
  71089. * Gets the b component (input)
  71090. */
  71091. get b(): NodeMaterialConnectionPoint;
  71092. /**
  71093. * Gets the a component (input)
  71094. */
  71095. get a(): NodeMaterialConnectionPoint;
  71096. /**
  71097. * Gets the rgba component (output)
  71098. */
  71099. get rgba(): NodeMaterialConnectionPoint;
  71100. /**
  71101. * Gets the rgb component (output)
  71102. */
  71103. get rgbOut(): NodeMaterialConnectionPoint;
  71104. /**
  71105. * Gets the rgb component (output)
  71106. * @deprecated Please use rgbOut instead.
  71107. */
  71108. get rgb(): NodeMaterialConnectionPoint;
  71109. protected _buildBlock(state: NodeMaterialBuildState): this;
  71110. }
  71111. }
  71112. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  71113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71116. /**
  71117. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  71118. */
  71119. export class VectorSplitterBlock extends NodeMaterialBlock {
  71120. /**
  71121. * Create a new VectorSplitterBlock
  71122. * @param name defines the block name
  71123. */
  71124. constructor(name: string);
  71125. /**
  71126. * Gets the current class name
  71127. * @returns the class name
  71128. */
  71129. getClassName(): string;
  71130. /**
  71131. * Gets the xyzw component (input)
  71132. */
  71133. get xyzw(): NodeMaterialConnectionPoint;
  71134. /**
  71135. * Gets the xyz component (input)
  71136. */
  71137. get xyzIn(): NodeMaterialConnectionPoint;
  71138. /**
  71139. * Gets the xy component (input)
  71140. */
  71141. get xyIn(): NodeMaterialConnectionPoint;
  71142. /**
  71143. * Gets the xyz component (output)
  71144. */
  71145. get xyzOut(): NodeMaterialConnectionPoint;
  71146. /**
  71147. * Gets the xy component (output)
  71148. */
  71149. get xyOut(): NodeMaterialConnectionPoint;
  71150. /**
  71151. * Gets the x component (output)
  71152. */
  71153. get x(): NodeMaterialConnectionPoint;
  71154. /**
  71155. * Gets the y component (output)
  71156. */
  71157. get y(): NodeMaterialConnectionPoint;
  71158. /**
  71159. * Gets the z component (output)
  71160. */
  71161. get z(): NodeMaterialConnectionPoint;
  71162. /**
  71163. * Gets the w component (output)
  71164. */
  71165. get w(): NodeMaterialConnectionPoint;
  71166. protected _inputRename(name: string): string;
  71167. protected _outputRename(name: string): string;
  71168. protected _buildBlock(state: NodeMaterialBuildState): this;
  71169. }
  71170. }
  71171. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  71172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71175. /**
  71176. * Block used to lerp between 2 values
  71177. */
  71178. export class LerpBlock extends NodeMaterialBlock {
  71179. /**
  71180. * Creates a new LerpBlock
  71181. * @param name defines the block name
  71182. */
  71183. constructor(name: string);
  71184. /**
  71185. * Gets the current class name
  71186. * @returns the class name
  71187. */
  71188. getClassName(): string;
  71189. /**
  71190. * Gets the left operand input component
  71191. */
  71192. get left(): NodeMaterialConnectionPoint;
  71193. /**
  71194. * Gets the right operand input component
  71195. */
  71196. get right(): NodeMaterialConnectionPoint;
  71197. /**
  71198. * Gets the gradient operand input component
  71199. */
  71200. get gradient(): NodeMaterialConnectionPoint;
  71201. /**
  71202. * Gets the output component
  71203. */
  71204. get output(): NodeMaterialConnectionPoint;
  71205. protected _buildBlock(state: NodeMaterialBuildState): this;
  71206. }
  71207. }
  71208. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  71209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71212. /**
  71213. * Block used to divide 2 vectors
  71214. */
  71215. export class DivideBlock extends NodeMaterialBlock {
  71216. /**
  71217. * Creates a new DivideBlock
  71218. * @param name defines the block name
  71219. */
  71220. constructor(name: string);
  71221. /**
  71222. * Gets the current class name
  71223. * @returns the class name
  71224. */
  71225. getClassName(): string;
  71226. /**
  71227. * Gets the left operand input component
  71228. */
  71229. get left(): NodeMaterialConnectionPoint;
  71230. /**
  71231. * Gets the right operand input component
  71232. */
  71233. get right(): NodeMaterialConnectionPoint;
  71234. /**
  71235. * Gets the output component
  71236. */
  71237. get output(): NodeMaterialConnectionPoint;
  71238. protected _buildBlock(state: NodeMaterialBuildState): this;
  71239. }
  71240. }
  71241. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  71242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71245. /**
  71246. * Block used to subtract 2 vectors
  71247. */
  71248. export class SubtractBlock extends NodeMaterialBlock {
  71249. /**
  71250. * Creates a new SubtractBlock
  71251. * @param name defines the block name
  71252. */
  71253. constructor(name: string);
  71254. /**
  71255. * Gets the current class name
  71256. * @returns the class name
  71257. */
  71258. getClassName(): string;
  71259. /**
  71260. * Gets the left operand input component
  71261. */
  71262. get left(): NodeMaterialConnectionPoint;
  71263. /**
  71264. * Gets the right operand input component
  71265. */
  71266. get right(): NodeMaterialConnectionPoint;
  71267. /**
  71268. * Gets the output component
  71269. */
  71270. get output(): NodeMaterialConnectionPoint;
  71271. protected _buildBlock(state: NodeMaterialBuildState): this;
  71272. }
  71273. }
  71274. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  71275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71278. /**
  71279. * Block used to step a value
  71280. */
  71281. export class StepBlock extends NodeMaterialBlock {
  71282. /**
  71283. * Creates a new StepBlock
  71284. * @param name defines the block name
  71285. */
  71286. constructor(name: string);
  71287. /**
  71288. * Gets the current class name
  71289. * @returns the class name
  71290. */
  71291. getClassName(): string;
  71292. /**
  71293. * Gets the value operand input component
  71294. */
  71295. get value(): NodeMaterialConnectionPoint;
  71296. /**
  71297. * Gets the edge operand input component
  71298. */
  71299. get edge(): NodeMaterialConnectionPoint;
  71300. /**
  71301. * Gets the output component
  71302. */
  71303. get output(): NodeMaterialConnectionPoint;
  71304. protected _buildBlock(state: NodeMaterialBuildState): this;
  71305. }
  71306. }
  71307. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  71308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71311. /**
  71312. * Block used to get the opposite (1 - x) of a value
  71313. */
  71314. export class OneMinusBlock extends NodeMaterialBlock {
  71315. /**
  71316. * Creates a new OneMinusBlock
  71317. * @param name defines the block name
  71318. */
  71319. constructor(name: string);
  71320. /**
  71321. * Gets the current class name
  71322. * @returns the class name
  71323. */
  71324. getClassName(): string;
  71325. /**
  71326. * Gets the input component
  71327. */
  71328. get input(): NodeMaterialConnectionPoint;
  71329. /**
  71330. * Gets the output component
  71331. */
  71332. get output(): NodeMaterialConnectionPoint;
  71333. protected _buildBlock(state: NodeMaterialBuildState): this;
  71334. }
  71335. }
  71336. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  71337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71340. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71341. /**
  71342. * Block used to get the view direction
  71343. */
  71344. export class ViewDirectionBlock extends NodeMaterialBlock {
  71345. /**
  71346. * Creates a new ViewDirectionBlock
  71347. * @param name defines the block name
  71348. */
  71349. constructor(name: string);
  71350. /**
  71351. * Gets the current class name
  71352. * @returns the class name
  71353. */
  71354. getClassName(): string;
  71355. /**
  71356. * Gets the world position component
  71357. */
  71358. get worldPosition(): NodeMaterialConnectionPoint;
  71359. /**
  71360. * Gets the camera position component
  71361. */
  71362. get cameraPosition(): NodeMaterialConnectionPoint;
  71363. /**
  71364. * Gets the output component
  71365. */
  71366. get output(): NodeMaterialConnectionPoint;
  71367. autoConfigure(material: NodeMaterial): void;
  71368. protected _buildBlock(state: NodeMaterialBuildState): this;
  71369. }
  71370. }
  71371. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  71372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71375. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71376. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  71377. /**
  71378. * Block used to compute fresnel value
  71379. */
  71380. export class FresnelBlock extends NodeMaterialBlock {
  71381. /**
  71382. * Create a new FresnelBlock
  71383. * @param name defines the block name
  71384. */
  71385. constructor(name: string);
  71386. /**
  71387. * Gets the current class name
  71388. * @returns the class name
  71389. */
  71390. getClassName(): string;
  71391. /**
  71392. * Gets the world normal input component
  71393. */
  71394. get worldNormal(): NodeMaterialConnectionPoint;
  71395. /**
  71396. * Gets the view direction input component
  71397. */
  71398. get viewDirection(): NodeMaterialConnectionPoint;
  71399. /**
  71400. * Gets the bias input component
  71401. */
  71402. get bias(): NodeMaterialConnectionPoint;
  71403. /**
  71404. * Gets the camera (or eye) position component
  71405. */
  71406. get power(): NodeMaterialConnectionPoint;
  71407. /**
  71408. * Gets the fresnel output component
  71409. */
  71410. get fresnel(): NodeMaterialConnectionPoint;
  71411. autoConfigure(material: NodeMaterial): void;
  71412. protected _buildBlock(state: NodeMaterialBuildState): this;
  71413. }
  71414. }
  71415. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  71416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71419. /**
  71420. * Block used to get the max of 2 values
  71421. */
  71422. export class MaxBlock extends NodeMaterialBlock {
  71423. /**
  71424. * Creates a new MaxBlock
  71425. * @param name defines the block name
  71426. */
  71427. constructor(name: string);
  71428. /**
  71429. * Gets the current class name
  71430. * @returns the class name
  71431. */
  71432. getClassName(): string;
  71433. /**
  71434. * Gets the left operand input component
  71435. */
  71436. get left(): NodeMaterialConnectionPoint;
  71437. /**
  71438. * Gets the right operand input component
  71439. */
  71440. get right(): NodeMaterialConnectionPoint;
  71441. /**
  71442. * Gets the output component
  71443. */
  71444. get output(): NodeMaterialConnectionPoint;
  71445. protected _buildBlock(state: NodeMaterialBuildState): this;
  71446. }
  71447. }
  71448. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  71449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71452. /**
  71453. * Block used to get the min of 2 values
  71454. */
  71455. export class MinBlock extends NodeMaterialBlock {
  71456. /**
  71457. * Creates a new MinBlock
  71458. * @param name defines the block name
  71459. */
  71460. constructor(name: string);
  71461. /**
  71462. * Gets the current class name
  71463. * @returns the class name
  71464. */
  71465. getClassName(): string;
  71466. /**
  71467. * Gets the left operand input component
  71468. */
  71469. get left(): NodeMaterialConnectionPoint;
  71470. /**
  71471. * Gets the right operand input component
  71472. */
  71473. get right(): NodeMaterialConnectionPoint;
  71474. /**
  71475. * Gets the output component
  71476. */
  71477. get output(): NodeMaterialConnectionPoint;
  71478. protected _buildBlock(state: NodeMaterialBuildState): this;
  71479. }
  71480. }
  71481. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  71482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71485. /**
  71486. * Block used to get the distance between 2 values
  71487. */
  71488. export class DistanceBlock extends NodeMaterialBlock {
  71489. /**
  71490. * Creates a new DistanceBlock
  71491. * @param name defines the block name
  71492. */
  71493. constructor(name: string);
  71494. /**
  71495. * Gets the current class name
  71496. * @returns the class name
  71497. */
  71498. getClassName(): string;
  71499. /**
  71500. * Gets the left operand input component
  71501. */
  71502. get left(): NodeMaterialConnectionPoint;
  71503. /**
  71504. * Gets the right operand input component
  71505. */
  71506. get right(): NodeMaterialConnectionPoint;
  71507. /**
  71508. * Gets the output component
  71509. */
  71510. get output(): NodeMaterialConnectionPoint;
  71511. protected _buildBlock(state: NodeMaterialBuildState): this;
  71512. }
  71513. }
  71514. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  71515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71518. /**
  71519. * Block used to get the length of a vector
  71520. */
  71521. export class LengthBlock extends NodeMaterialBlock {
  71522. /**
  71523. * Creates a new LengthBlock
  71524. * @param name defines the block name
  71525. */
  71526. constructor(name: string);
  71527. /**
  71528. * Gets the current class name
  71529. * @returns the class name
  71530. */
  71531. getClassName(): string;
  71532. /**
  71533. * Gets the value input component
  71534. */
  71535. get value(): NodeMaterialConnectionPoint;
  71536. /**
  71537. * Gets the output component
  71538. */
  71539. get output(): NodeMaterialConnectionPoint;
  71540. protected _buildBlock(state: NodeMaterialBuildState): this;
  71541. }
  71542. }
  71543. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  71544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71547. /**
  71548. * Block used to get negative version of a value (i.e. x * -1)
  71549. */
  71550. export class NegateBlock extends NodeMaterialBlock {
  71551. /**
  71552. * Creates a new NegateBlock
  71553. * @param name defines the block name
  71554. */
  71555. constructor(name: string);
  71556. /**
  71557. * Gets the current class name
  71558. * @returns the class name
  71559. */
  71560. getClassName(): string;
  71561. /**
  71562. * Gets the value input component
  71563. */
  71564. get value(): NodeMaterialConnectionPoint;
  71565. /**
  71566. * Gets the output component
  71567. */
  71568. get output(): NodeMaterialConnectionPoint;
  71569. protected _buildBlock(state: NodeMaterialBuildState): this;
  71570. }
  71571. }
  71572. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  71573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71576. /**
  71577. * Block used to get the value of the first parameter raised to the power of the second
  71578. */
  71579. export class PowBlock extends NodeMaterialBlock {
  71580. /**
  71581. * Creates a new PowBlock
  71582. * @param name defines the block name
  71583. */
  71584. constructor(name: string);
  71585. /**
  71586. * Gets the current class name
  71587. * @returns the class name
  71588. */
  71589. getClassName(): string;
  71590. /**
  71591. * Gets the value operand input component
  71592. */
  71593. get value(): NodeMaterialConnectionPoint;
  71594. /**
  71595. * Gets the power operand input component
  71596. */
  71597. get power(): NodeMaterialConnectionPoint;
  71598. /**
  71599. * Gets the output component
  71600. */
  71601. get output(): NodeMaterialConnectionPoint;
  71602. protected _buildBlock(state: NodeMaterialBuildState): this;
  71603. }
  71604. }
  71605. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  71606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71610. /**
  71611. * Block used to get a random number
  71612. */
  71613. export class RandomNumberBlock extends NodeMaterialBlock {
  71614. /**
  71615. * Creates a new RandomNumberBlock
  71616. * @param name defines the block name
  71617. */
  71618. constructor(name: string);
  71619. /**
  71620. * Gets the current class name
  71621. * @returns the class name
  71622. */
  71623. getClassName(): string;
  71624. /**
  71625. * Gets the seed input component
  71626. */
  71627. get seed(): NodeMaterialConnectionPoint;
  71628. /**
  71629. * Gets the output component
  71630. */
  71631. get output(): NodeMaterialConnectionPoint;
  71632. protected _buildBlock(state: NodeMaterialBuildState): this;
  71633. }
  71634. }
  71635. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  71636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71639. /**
  71640. * Block used to compute arc tangent of 2 values
  71641. */
  71642. export class ArcTan2Block extends NodeMaterialBlock {
  71643. /**
  71644. * Creates a new ArcTan2Block
  71645. * @param name defines the block name
  71646. */
  71647. constructor(name: string);
  71648. /**
  71649. * Gets the current class name
  71650. * @returns the class name
  71651. */
  71652. getClassName(): string;
  71653. /**
  71654. * Gets the x operand input component
  71655. */
  71656. get x(): NodeMaterialConnectionPoint;
  71657. /**
  71658. * Gets the y operand input component
  71659. */
  71660. get y(): NodeMaterialConnectionPoint;
  71661. /**
  71662. * Gets the output component
  71663. */
  71664. get output(): NodeMaterialConnectionPoint;
  71665. protected _buildBlock(state: NodeMaterialBuildState): this;
  71666. }
  71667. }
  71668. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  71669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71672. /**
  71673. * Block used to smooth step a value
  71674. */
  71675. export class SmoothStepBlock extends NodeMaterialBlock {
  71676. /**
  71677. * Creates a new SmoothStepBlock
  71678. * @param name defines the block name
  71679. */
  71680. constructor(name: string);
  71681. /**
  71682. * Gets the current class name
  71683. * @returns the class name
  71684. */
  71685. getClassName(): string;
  71686. /**
  71687. * Gets the value operand input component
  71688. */
  71689. get value(): NodeMaterialConnectionPoint;
  71690. /**
  71691. * Gets the first edge operand input component
  71692. */
  71693. get edge0(): NodeMaterialConnectionPoint;
  71694. /**
  71695. * Gets the second edge operand input component
  71696. */
  71697. get edge1(): NodeMaterialConnectionPoint;
  71698. /**
  71699. * Gets the output component
  71700. */
  71701. get output(): NodeMaterialConnectionPoint;
  71702. protected _buildBlock(state: NodeMaterialBuildState): this;
  71703. }
  71704. }
  71705. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  71706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71709. /**
  71710. * Block used to get the reciprocal (1 / x) of a value
  71711. */
  71712. export class ReciprocalBlock extends NodeMaterialBlock {
  71713. /**
  71714. * Creates a new ReciprocalBlock
  71715. * @param name defines the block name
  71716. */
  71717. constructor(name: string);
  71718. /**
  71719. * Gets the current class name
  71720. * @returns the class name
  71721. */
  71722. getClassName(): string;
  71723. /**
  71724. * Gets the input component
  71725. */
  71726. get input(): NodeMaterialConnectionPoint;
  71727. /**
  71728. * Gets the output component
  71729. */
  71730. get output(): NodeMaterialConnectionPoint;
  71731. protected _buildBlock(state: NodeMaterialBuildState): this;
  71732. }
  71733. }
  71734. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  71735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71738. /**
  71739. * Block used to replace a color by another one
  71740. */
  71741. export class ReplaceColorBlock extends NodeMaterialBlock {
  71742. /**
  71743. * Creates a new ReplaceColorBlock
  71744. * @param name defines the block name
  71745. */
  71746. constructor(name: string);
  71747. /**
  71748. * Gets the current class name
  71749. * @returns the class name
  71750. */
  71751. getClassName(): string;
  71752. /**
  71753. * Gets the value input component
  71754. */
  71755. get value(): NodeMaterialConnectionPoint;
  71756. /**
  71757. * Gets the reference input component
  71758. */
  71759. get reference(): NodeMaterialConnectionPoint;
  71760. /**
  71761. * Gets the distance input component
  71762. */
  71763. get distance(): NodeMaterialConnectionPoint;
  71764. /**
  71765. * Gets the replacement input component
  71766. */
  71767. get replacement(): NodeMaterialConnectionPoint;
  71768. /**
  71769. * Gets the output component
  71770. */
  71771. get output(): NodeMaterialConnectionPoint;
  71772. protected _buildBlock(state: NodeMaterialBuildState): this;
  71773. }
  71774. }
  71775. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  71776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71779. /**
  71780. * Block used to posterize a value
  71781. * @see https://en.wikipedia.org/wiki/Posterization
  71782. */
  71783. export class PosterizeBlock extends NodeMaterialBlock {
  71784. /**
  71785. * Creates a new PosterizeBlock
  71786. * @param name defines the block name
  71787. */
  71788. constructor(name: string);
  71789. /**
  71790. * Gets the current class name
  71791. * @returns the class name
  71792. */
  71793. getClassName(): string;
  71794. /**
  71795. * Gets the value input component
  71796. */
  71797. get value(): NodeMaterialConnectionPoint;
  71798. /**
  71799. * Gets the steps input component
  71800. */
  71801. get steps(): NodeMaterialConnectionPoint;
  71802. /**
  71803. * Gets the output component
  71804. */
  71805. get output(): NodeMaterialConnectionPoint;
  71806. protected _buildBlock(state: NodeMaterialBuildState): this;
  71807. }
  71808. }
  71809. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  71810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71811. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71812. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71813. import { Scene } from "babylonjs/scene";
  71814. /**
  71815. * Operations supported by the Wave block
  71816. */
  71817. export enum WaveBlockKind {
  71818. /** SawTooth */
  71819. SawTooth = 0,
  71820. /** Square */
  71821. Square = 1,
  71822. /** Triangle */
  71823. Triangle = 2
  71824. }
  71825. /**
  71826. * Block used to apply wave operation to floats
  71827. */
  71828. export class WaveBlock extends NodeMaterialBlock {
  71829. /**
  71830. * Gets or sets the kibnd of wave to be applied by the block
  71831. */
  71832. kind: WaveBlockKind;
  71833. /**
  71834. * Creates a new WaveBlock
  71835. * @param name defines the block name
  71836. */
  71837. constructor(name: string);
  71838. /**
  71839. * Gets the current class name
  71840. * @returns the class name
  71841. */
  71842. getClassName(): string;
  71843. /**
  71844. * Gets the input component
  71845. */
  71846. get input(): NodeMaterialConnectionPoint;
  71847. /**
  71848. * Gets the output component
  71849. */
  71850. get output(): NodeMaterialConnectionPoint;
  71851. protected _buildBlock(state: NodeMaterialBuildState): this;
  71852. serialize(): any;
  71853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71854. }
  71855. }
  71856. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  71857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71860. import { Color3 } from "babylonjs/Maths/math.color";
  71861. import { Scene } from "babylonjs/scene";
  71862. import { Observable } from "babylonjs/Misc/observable";
  71863. /**
  71864. * Class used to store a color step for the GradientBlock
  71865. */
  71866. export class GradientBlockColorStep {
  71867. private _step;
  71868. /**
  71869. * Gets value indicating which step this color is associated with (between 0 and 1)
  71870. */
  71871. get step(): number;
  71872. /**
  71873. * Sets a value indicating which step this color is associated with (between 0 and 1)
  71874. */
  71875. set step(val: number);
  71876. private _color;
  71877. /**
  71878. * Gets the color associated with this step
  71879. */
  71880. get color(): Color3;
  71881. /**
  71882. * Sets the color associated with this step
  71883. */
  71884. set color(val: Color3);
  71885. /**
  71886. * Creates a new GradientBlockColorStep
  71887. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  71888. * @param color defines the color associated with this step
  71889. */
  71890. constructor(step: number, color: Color3);
  71891. }
  71892. /**
  71893. * Block used to return a color from a gradient based on an input value between 0 and 1
  71894. */
  71895. export class GradientBlock extends NodeMaterialBlock {
  71896. /**
  71897. * Gets or sets the list of color steps
  71898. */
  71899. colorSteps: GradientBlockColorStep[];
  71900. /** Gets an observable raised when the value is changed */
  71901. onValueChangedObservable: Observable<GradientBlock>;
  71902. /** calls observable when the value is changed*/
  71903. colorStepsUpdated(): void;
  71904. /**
  71905. * Creates a new GradientBlock
  71906. * @param name defines the block name
  71907. */
  71908. constructor(name: string);
  71909. /**
  71910. * Gets the current class name
  71911. * @returns the class name
  71912. */
  71913. getClassName(): string;
  71914. /**
  71915. * Gets the gradient input component
  71916. */
  71917. get gradient(): NodeMaterialConnectionPoint;
  71918. /**
  71919. * Gets the output component
  71920. */
  71921. get output(): NodeMaterialConnectionPoint;
  71922. private _writeColorConstant;
  71923. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71924. serialize(): any;
  71925. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71926. protected _dumpPropertiesCode(): string;
  71927. }
  71928. }
  71929. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  71930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71933. /**
  71934. * Block used to normalize lerp between 2 values
  71935. */
  71936. export class NLerpBlock extends NodeMaterialBlock {
  71937. /**
  71938. * Creates a new NLerpBlock
  71939. * @param name defines the block name
  71940. */
  71941. constructor(name: string);
  71942. /**
  71943. * Gets the current class name
  71944. * @returns the class name
  71945. */
  71946. getClassName(): string;
  71947. /**
  71948. * Gets the left operand input component
  71949. */
  71950. get left(): NodeMaterialConnectionPoint;
  71951. /**
  71952. * Gets the right operand input component
  71953. */
  71954. get right(): NodeMaterialConnectionPoint;
  71955. /**
  71956. * Gets the gradient operand input component
  71957. */
  71958. get gradient(): NodeMaterialConnectionPoint;
  71959. /**
  71960. * Gets the output component
  71961. */
  71962. get output(): NodeMaterialConnectionPoint;
  71963. protected _buildBlock(state: NodeMaterialBuildState): this;
  71964. }
  71965. }
  71966. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  71967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71970. import { Scene } from "babylonjs/scene";
  71971. /**
  71972. * block used to Generate a Worley Noise 3D Noise Pattern
  71973. */
  71974. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  71975. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  71976. manhattanDistance: boolean;
  71977. /**
  71978. * Creates a new WorleyNoise3DBlock
  71979. * @param name defines the block name
  71980. */
  71981. constructor(name: string);
  71982. /**
  71983. * Gets the current class name
  71984. * @returns the class name
  71985. */
  71986. getClassName(): string;
  71987. /**
  71988. * Gets the seed input component
  71989. */
  71990. get seed(): NodeMaterialConnectionPoint;
  71991. /**
  71992. * Gets the jitter input component
  71993. */
  71994. get jitter(): NodeMaterialConnectionPoint;
  71995. /**
  71996. * Gets the output component
  71997. */
  71998. get output(): NodeMaterialConnectionPoint;
  71999. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  72000. /**
  72001. * Exposes the properties to the UI?
  72002. */
  72003. protected _dumpPropertiesCode(): string;
  72004. /**
  72005. * Exposes the properties to the Seralize?
  72006. */
  72007. serialize(): any;
  72008. /**
  72009. * Exposes the properties to the deseralize?
  72010. */
  72011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72012. }
  72013. }
  72014. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  72015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72018. /**
  72019. * block used to Generate a Simplex Perlin 3d Noise Pattern
  72020. */
  72021. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  72022. /**
  72023. * Creates a new SimplexPerlin3DBlock
  72024. * @param name defines the block name
  72025. */
  72026. constructor(name: string);
  72027. /**
  72028. * Gets the current class name
  72029. * @returns the class name
  72030. */
  72031. getClassName(): string;
  72032. /**
  72033. * Gets the seed operand input component
  72034. */
  72035. get seed(): NodeMaterialConnectionPoint;
  72036. /**
  72037. * Gets the output component
  72038. */
  72039. get output(): NodeMaterialConnectionPoint;
  72040. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  72041. }
  72042. }
  72043. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  72044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72047. /**
  72048. * Block used to blend normals
  72049. */
  72050. export class NormalBlendBlock extends NodeMaterialBlock {
  72051. /**
  72052. * Creates a new NormalBlendBlock
  72053. * @param name defines the block name
  72054. */
  72055. constructor(name: string);
  72056. /**
  72057. * Gets the current class name
  72058. * @returns the class name
  72059. */
  72060. getClassName(): string;
  72061. /**
  72062. * Gets the first input component
  72063. */
  72064. get normalMap0(): NodeMaterialConnectionPoint;
  72065. /**
  72066. * Gets the second input component
  72067. */
  72068. get normalMap1(): NodeMaterialConnectionPoint;
  72069. /**
  72070. * Gets the output component
  72071. */
  72072. get output(): NodeMaterialConnectionPoint;
  72073. protected _buildBlock(state: NodeMaterialBuildState): this;
  72074. }
  72075. }
  72076. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  72077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72080. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  72081. /**
  72082. * Block used to rotate a 2d vector by a given angle
  72083. */
  72084. export class Rotate2dBlock extends NodeMaterialBlock {
  72085. /**
  72086. * Creates a new Rotate2dBlock
  72087. * @param name defines the block name
  72088. */
  72089. constructor(name: string);
  72090. /**
  72091. * Gets the current class name
  72092. * @returns the class name
  72093. */
  72094. getClassName(): string;
  72095. /**
  72096. * Gets the input vector
  72097. */
  72098. get input(): NodeMaterialConnectionPoint;
  72099. /**
  72100. * Gets the input angle
  72101. */
  72102. get angle(): NodeMaterialConnectionPoint;
  72103. /**
  72104. * Gets the output component
  72105. */
  72106. get output(): NodeMaterialConnectionPoint;
  72107. autoConfigure(material: NodeMaterial): void;
  72108. protected _buildBlock(state: NodeMaterialBuildState): this;
  72109. }
  72110. }
  72111. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  72112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72115. /**
  72116. * Block used to get the reflected vector from a direction and a normal
  72117. */
  72118. export class ReflectBlock extends NodeMaterialBlock {
  72119. /**
  72120. * Creates a new ReflectBlock
  72121. * @param name defines the block name
  72122. */
  72123. constructor(name: string);
  72124. /**
  72125. * Gets the current class name
  72126. * @returns the class name
  72127. */
  72128. getClassName(): string;
  72129. /**
  72130. * Gets the incident component
  72131. */
  72132. get incident(): NodeMaterialConnectionPoint;
  72133. /**
  72134. * Gets the normal component
  72135. */
  72136. get normal(): NodeMaterialConnectionPoint;
  72137. /**
  72138. * Gets the output component
  72139. */
  72140. get output(): NodeMaterialConnectionPoint;
  72141. protected _buildBlock(state: NodeMaterialBuildState): this;
  72142. }
  72143. }
  72144. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  72145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72148. /**
  72149. * Block used to get the refracted vector from a direction and a normal
  72150. */
  72151. export class RefractBlock extends NodeMaterialBlock {
  72152. /**
  72153. * Creates a new RefractBlock
  72154. * @param name defines the block name
  72155. */
  72156. constructor(name: string);
  72157. /**
  72158. * Gets the current class name
  72159. * @returns the class name
  72160. */
  72161. getClassName(): string;
  72162. /**
  72163. * Gets the incident component
  72164. */
  72165. get incident(): NodeMaterialConnectionPoint;
  72166. /**
  72167. * Gets the normal component
  72168. */
  72169. get normal(): NodeMaterialConnectionPoint;
  72170. /**
  72171. * Gets the index of refraction component
  72172. */
  72173. get ior(): NodeMaterialConnectionPoint;
  72174. /**
  72175. * Gets the output component
  72176. */
  72177. get output(): NodeMaterialConnectionPoint;
  72178. protected _buildBlock(state: NodeMaterialBuildState): this;
  72179. }
  72180. }
  72181. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  72182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72185. /**
  72186. * Block used to desaturate a color
  72187. */
  72188. export class DesaturateBlock extends NodeMaterialBlock {
  72189. /**
  72190. * Creates a new DesaturateBlock
  72191. * @param name defines the block name
  72192. */
  72193. constructor(name: string);
  72194. /**
  72195. * Gets the current class name
  72196. * @returns the class name
  72197. */
  72198. getClassName(): string;
  72199. /**
  72200. * Gets the color operand input component
  72201. */
  72202. get color(): NodeMaterialConnectionPoint;
  72203. /**
  72204. * Gets the level operand input component
  72205. */
  72206. get level(): NodeMaterialConnectionPoint;
  72207. /**
  72208. * Gets the output component
  72209. */
  72210. get output(): NodeMaterialConnectionPoint;
  72211. protected _buildBlock(state: NodeMaterialBuildState): this;
  72212. }
  72213. }
  72214. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  72215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72217. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72218. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  72219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72220. import { Nullable } from "babylonjs/types";
  72221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  72222. import { Mesh } from "babylonjs/Meshes/mesh";
  72223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72224. import { Effect } from "babylonjs/Materials/effect";
  72225. import { Scene } from "babylonjs/scene";
  72226. /**
  72227. * Block used to implement the reflection module of the PBR material
  72228. */
  72229. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  72230. /** @hidden */
  72231. _defineLODReflectionAlpha: string;
  72232. /** @hidden */
  72233. _defineLinearSpecularReflection: string;
  72234. private _vEnvironmentIrradianceName;
  72235. /** @hidden */
  72236. _vReflectionMicrosurfaceInfosName: string;
  72237. /** @hidden */
  72238. _vReflectionInfosName: string;
  72239. /** @hidden */
  72240. _vReflectionFilteringInfoName: string;
  72241. private _scene;
  72242. /**
  72243. * The properties below are set by the main PBR block prior to calling methods of this class.
  72244. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72245. * It's less burden on the user side in the editor part.
  72246. */
  72247. /** @hidden */
  72248. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72249. /** @hidden */
  72250. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72251. /** @hidden */
  72252. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  72253. /** @hidden */
  72254. viewConnectionPoint: NodeMaterialConnectionPoint;
  72255. /**
  72256. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  72257. * diffuse part of the IBL.
  72258. */
  72259. useSphericalHarmonics: boolean;
  72260. /**
  72261. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  72262. */
  72263. forceIrradianceInFragment: boolean;
  72264. /**
  72265. * Create a new ReflectionBlock
  72266. * @param name defines the block name
  72267. */
  72268. constructor(name: string);
  72269. /**
  72270. * Gets the current class name
  72271. * @returns the class name
  72272. */
  72273. getClassName(): string;
  72274. /**
  72275. * Gets the position input component
  72276. */
  72277. get position(): NodeMaterialConnectionPoint;
  72278. /**
  72279. * Gets the world position input component
  72280. */
  72281. get worldPosition(): NodeMaterialConnectionPoint;
  72282. /**
  72283. * Gets the world normal input component
  72284. */
  72285. get worldNormal(): NodeMaterialConnectionPoint;
  72286. /**
  72287. * Gets the world input component
  72288. */
  72289. get world(): NodeMaterialConnectionPoint;
  72290. /**
  72291. * Gets the camera (or eye) position component
  72292. */
  72293. get cameraPosition(): NodeMaterialConnectionPoint;
  72294. /**
  72295. * Gets the view input component
  72296. */
  72297. get view(): NodeMaterialConnectionPoint;
  72298. /**
  72299. * Gets the color input component
  72300. */
  72301. get color(): NodeMaterialConnectionPoint;
  72302. /**
  72303. * Gets the reflection object output component
  72304. */
  72305. get reflection(): NodeMaterialConnectionPoint;
  72306. /**
  72307. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  72308. */
  72309. get hasTexture(): boolean;
  72310. /**
  72311. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  72312. */
  72313. get reflectionColor(): string;
  72314. protected _getTexture(): Nullable<BaseTexture>;
  72315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72317. /**
  72318. * Gets the code to inject in the vertex shader
  72319. * @param state current state of the node material building
  72320. * @returns the shader code
  72321. */
  72322. handleVertexSide(state: NodeMaterialBuildState): string;
  72323. /**
  72324. * Gets the main code of the block (fragment side)
  72325. * @param state current state of the node material building
  72326. * @param normalVarName name of the existing variable corresponding to the normal
  72327. * @returns the shader code
  72328. */
  72329. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  72330. protected _buildBlock(state: NodeMaterialBuildState): this;
  72331. protected _dumpPropertiesCode(): string;
  72332. serialize(): any;
  72333. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72334. }
  72335. }
  72336. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  72337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72340. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72342. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72343. import { Scene } from "babylonjs/scene";
  72344. import { Nullable } from "babylonjs/types";
  72345. /**
  72346. * Block used to implement the sheen module of the PBR material
  72347. */
  72348. export class SheenBlock extends NodeMaterialBlock {
  72349. /**
  72350. * Create a new SheenBlock
  72351. * @param name defines the block name
  72352. */
  72353. constructor(name: string);
  72354. /**
  72355. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  72356. * It allows the strength of the sheen effect to not depend on the base color of the material,
  72357. * making it easier to setup and tweak the effect
  72358. */
  72359. albedoScaling: boolean;
  72360. /**
  72361. * Defines if the sheen is linked to the sheen color.
  72362. */
  72363. linkSheenWithAlbedo: boolean;
  72364. /**
  72365. * Initialize the block and prepare the context for build
  72366. * @param state defines the state that will be used for the build
  72367. */
  72368. initialize(state: NodeMaterialBuildState): void;
  72369. /**
  72370. * Gets the current class name
  72371. * @returns the class name
  72372. */
  72373. getClassName(): string;
  72374. /**
  72375. * Gets the intensity input component
  72376. */
  72377. get intensity(): NodeMaterialConnectionPoint;
  72378. /**
  72379. * Gets the color input component
  72380. */
  72381. get color(): NodeMaterialConnectionPoint;
  72382. /**
  72383. * Gets the roughness input component
  72384. */
  72385. get roughness(): NodeMaterialConnectionPoint;
  72386. /**
  72387. * Gets the sheen object output component
  72388. */
  72389. get sheen(): NodeMaterialConnectionPoint;
  72390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72391. /**
  72392. * Gets the main code of the block (fragment side)
  72393. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72394. * @returns the shader code
  72395. */
  72396. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  72397. protected _buildBlock(state: NodeMaterialBuildState): this;
  72398. protected _dumpPropertiesCode(): string;
  72399. serialize(): any;
  72400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72401. }
  72402. }
  72403. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  72404. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72409. /**
  72410. * Block used to implement the anisotropy module of the PBR material
  72411. */
  72412. export class AnisotropyBlock extends NodeMaterialBlock {
  72413. /**
  72414. * The two properties below are set by the main PBR block prior to calling methods of this class.
  72415. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72416. * It's less burden on the user side in the editor part.
  72417. */
  72418. /** @hidden */
  72419. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72420. /** @hidden */
  72421. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72422. /**
  72423. * Create a new AnisotropyBlock
  72424. * @param name defines the block name
  72425. */
  72426. constructor(name: string);
  72427. /**
  72428. * Initialize the block and prepare the context for build
  72429. * @param state defines the state that will be used for the build
  72430. */
  72431. initialize(state: NodeMaterialBuildState): void;
  72432. /**
  72433. * Gets the current class name
  72434. * @returns the class name
  72435. */
  72436. getClassName(): string;
  72437. /**
  72438. * Gets the intensity input component
  72439. */
  72440. get intensity(): NodeMaterialConnectionPoint;
  72441. /**
  72442. * Gets the direction input component
  72443. */
  72444. get direction(): NodeMaterialConnectionPoint;
  72445. /**
  72446. * Gets the uv input component
  72447. */
  72448. get uv(): NodeMaterialConnectionPoint;
  72449. /**
  72450. * Gets the worldTangent input component
  72451. */
  72452. get worldTangent(): NodeMaterialConnectionPoint;
  72453. /**
  72454. * Gets the anisotropy object output component
  72455. */
  72456. get anisotropy(): NodeMaterialConnectionPoint;
  72457. private _generateTBNSpace;
  72458. /**
  72459. * Gets the main code of the block (fragment side)
  72460. * @param state current state of the node material building
  72461. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72462. * @returns the shader code
  72463. */
  72464. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  72465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72466. protected _buildBlock(state: NodeMaterialBuildState): this;
  72467. }
  72468. }
  72469. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  72470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72475. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72476. import { Scene } from "babylonjs/scene";
  72477. import { Nullable } from "babylonjs/types";
  72478. import { Mesh } from "babylonjs/Meshes/mesh";
  72479. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72480. import { Effect } from "babylonjs/Materials/effect";
  72481. /**
  72482. * Block used to implement the clear coat module of the PBR material
  72483. */
  72484. export class ClearCoatBlock extends NodeMaterialBlock {
  72485. private _scene;
  72486. /**
  72487. * Create a new ClearCoatBlock
  72488. * @param name defines the block name
  72489. */
  72490. constructor(name: string);
  72491. /**
  72492. * Defines if the F0 value should be remapped to account for the interface change in the material.
  72493. */
  72494. remapF0OnInterfaceChange: boolean;
  72495. /**
  72496. * Initialize the block and prepare the context for build
  72497. * @param state defines the state that will be used for the build
  72498. */
  72499. initialize(state: NodeMaterialBuildState): void;
  72500. /**
  72501. * Gets the current class name
  72502. * @returns the class name
  72503. */
  72504. getClassName(): string;
  72505. /**
  72506. * Gets the intensity input component
  72507. */
  72508. get intensity(): NodeMaterialConnectionPoint;
  72509. /**
  72510. * Gets the roughness input component
  72511. */
  72512. get roughness(): NodeMaterialConnectionPoint;
  72513. /**
  72514. * Gets the ior input component
  72515. */
  72516. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72517. /**
  72518. * Gets the bump texture input component
  72519. */
  72520. get normalMapColor(): NodeMaterialConnectionPoint;
  72521. /**
  72522. * Gets the uv input component
  72523. */
  72524. get uv(): NodeMaterialConnectionPoint;
  72525. /**
  72526. * Gets the tint color input component
  72527. */
  72528. get tintColor(): NodeMaterialConnectionPoint;
  72529. /**
  72530. * Gets the tint "at distance" input component
  72531. */
  72532. get tintAtDistance(): NodeMaterialConnectionPoint;
  72533. /**
  72534. * Gets the tint thickness input component
  72535. */
  72536. get tintThickness(): NodeMaterialConnectionPoint;
  72537. /**
  72538. * Gets the world tangent input component
  72539. */
  72540. get worldTangent(): NodeMaterialConnectionPoint;
  72541. /**
  72542. * Gets the clear coat object output component
  72543. */
  72544. get clearcoat(): NodeMaterialConnectionPoint;
  72545. autoConfigure(material: NodeMaterial): void;
  72546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72548. private _generateTBNSpace;
  72549. /**
  72550. * Gets the main code of the block (fragment side)
  72551. * @param state current state of the node material building
  72552. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  72553. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72554. * @param worldPosVarName name of the variable holding the world position
  72555. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72556. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  72557. * @param worldNormalVarName name of the variable holding the world normal
  72558. * @returns the shader code
  72559. */
  72560. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  72561. protected _buildBlock(state: NodeMaterialBuildState): this;
  72562. protected _dumpPropertiesCode(): string;
  72563. serialize(): any;
  72564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72565. }
  72566. }
  72567. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  72568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72571. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72573. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72574. import { Nullable } from "babylonjs/types";
  72575. /**
  72576. * Block used to implement the sub surface module of the PBR material
  72577. */
  72578. export class SubSurfaceBlock extends NodeMaterialBlock {
  72579. /**
  72580. * Create a new SubSurfaceBlock
  72581. * @param name defines the block name
  72582. */
  72583. constructor(name: string);
  72584. /**
  72585. * Initialize the block and prepare the context for build
  72586. * @param state defines the state that will be used for the build
  72587. */
  72588. initialize(state: NodeMaterialBuildState): void;
  72589. /**
  72590. * Gets the current class name
  72591. * @returns the class name
  72592. */
  72593. getClassName(): string;
  72594. /**
  72595. * Gets the thickness component
  72596. */
  72597. get thickness(): NodeMaterialConnectionPoint;
  72598. /**
  72599. * Gets the tint color input component
  72600. */
  72601. get tintColor(): NodeMaterialConnectionPoint;
  72602. /**
  72603. * Gets the translucency intensity input component
  72604. */
  72605. get translucencyIntensity(): NodeMaterialConnectionPoint;
  72606. /**
  72607. * Gets the translucency diffusion distance input component
  72608. */
  72609. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  72610. /**
  72611. * Gets the refraction object parameters
  72612. */
  72613. get refraction(): NodeMaterialConnectionPoint;
  72614. /**
  72615. * Gets the sub surface object output component
  72616. */
  72617. get subsurface(): NodeMaterialConnectionPoint;
  72618. autoConfigure(material: NodeMaterial): void;
  72619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72620. /**
  72621. * Gets the main code of the block (fragment side)
  72622. * @param state current state of the node material building
  72623. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  72624. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72625. * @param worldPosVarName name of the variable holding the world position
  72626. * @returns the shader code
  72627. */
  72628. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  72629. protected _buildBlock(state: NodeMaterialBuildState): this;
  72630. }
  72631. }
  72632. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  72633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72636. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72637. import { Light } from "babylonjs/Lights/light";
  72638. import { Nullable } from "babylonjs/types";
  72639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72640. import { Effect } from "babylonjs/Materials/effect";
  72641. import { Mesh } from "babylonjs/Meshes/mesh";
  72642. import { Scene } from "babylonjs/scene";
  72643. /**
  72644. * Block used to implement the PBR metallic/roughness model
  72645. */
  72646. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  72647. /**
  72648. * Gets or sets the light associated with this block
  72649. */
  72650. light: Nullable<Light>;
  72651. private _lightId;
  72652. private _scene;
  72653. private _environmentBRDFTexture;
  72654. private _environmentBrdfSamplerName;
  72655. private _vNormalWName;
  72656. private _invertNormalName;
  72657. private _metallicReflectanceColor;
  72658. private _metallicF0Factor;
  72659. private _vMetallicReflectanceFactorsName;
  72660. /**
  72661. * Create a new ReflectionBlock
  72662. * @param name defines the block name
  72663. */
  72664. constructor(name: string);
  72665. /**
  72666. * Intensity of the direct lights e.g. the four lights available in your scene.
  72667. * This impacts both the direct diffuse and specular highlights.
  72668. */
  72669. directIntensity: number;
  72670. /**
  72671. * Intensity of the environment e.g. how much the environment will light the object
  72672. * either through harmonics for rough material or through the refelction for shiny ones.
  72673. */
  72674. environmentIntensity: number;
  72675. /**
  72676. * This is a special control allowing the reduction of the specular highlights coming from the
  72677. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  72678. */
  72679. specularIntensity: number;
  72680. /**
  72681. * Defines the falloff type used in this material.
  72682. * It by default is Physical.
  72683. */
  72684. lightFalloff: number;
  72685. /**
  72686. * Specifies that alpha test should be used
  72687. */
  72688. useAlphaTest: boolean;
  72689. /**
  72690. * Defines the alpha limits in alpha test mode.
  72691. */
  72692. alphaTestCutoff: number;
  72693. /**
  72694. * Specifies that alpha blending should be used
  72695. */
  72696. useAlphaBlending: boolean;
  72697. /**
  72698. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  72699. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  72700. */
  72701. useRadianceOverAlpha: boolean;
  72702. /**
  72703. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  72704. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  72705. */
  72706. useSpecularOverAlpha: boolean;
  72707. /**
  72708. * Enables specular anti aliasing in the PBR shader.
  72709. * It will both interacts on the Geometry for analytical and IBL lighting.
  72710. * It also prefilter the roughness map based on the bump values.
  72711. */
  72712. enableSpecularAntiAliasing: boolean;
  72713. /**
  72714. * Enables realtime filtering on the texture.
  72715. */
  72716. realTimeFiltering: boolean;
  72717. /**
  72718. * Quality switch for realtime filtering
  72719. */
  72720. realTimeFilteringQuality: number;
  72721. /**
  72722. * Defines if the material uses energy conservation.
  72723. */
  72724. useEnergyConservation: boolean;
  72725. /**
  72726. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  72727. * too much the area relying on ambient texture to define their ambient occlusion.
  72728. */
  72729. useRadianceOcclusion: boolean;
  72730. /**
  72731. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  72732. * makes the reflect vector face the model (under horizon).
  72733. */
  72734. useHorizonOcclusion: boolean;
  72735. /**
  72736. * If set to true, no lighting calculations will be applied.
  72737. */
  72738. unlit: boolean;
  72739. /**
  72740. * Force normal to face away from face.
  72741. */
  72742. forceNormalForward: boolean;
  72743. /**
  72744. * Defines the material debug mode.
  72745. * It helps seeing only some components of the material while troubleshooting.
  72746. */
  72747. debugMode: number;
  72748. /**
  72749. * Specify from where on screen the debug mode should start.
  72750. * The value goes from -1 (full screen) to 1 (not visible)
  72751. * It helps with side by side comparison against the final render
  72752. * This defaults to 0
  72753. */
  72754. debugLimit: number;
  72755. /**
  72756. * As the default viewing range might not be enough (if the ambient is really small for instance)
  72757. * You can use the factor to better multiply the final value.
  72758. */
  72759. debugFactor: number;
  72760. /**
  72761. * Initialize the block and prepare the context for build
  72762. * @param state defines the state that will be used for the build
  72763. */
  72764. initialize(state: NodeMaterialBuildState): void;
  72765. /**
  72766. * Gets the current class name
  72767. * @returns the class name
  72768. */
  72769. getClassName(): string;
  72770. /**
  72771. * Gets the world position input component
  72772. */
  72773. get worldPosition(): NodeMaterialConnectionPoint;
  72774. /**
  72775. * Gets the world normal input component
  72776. */
  72777. get worldNormal(): NodeMaterialConnectionPoint;
  72778. /**
  72779. * Gets the view matrix parameter
  72780. */
  72781. get view(): NodeMaterialConnectionPoint;
  72782. /**
  72783. * Gets the camera position input component
  72784. */
  72785. get cameraPosition(): NodeMaterialConnectionPoint;
  72786. /**
  72787. * Gets the perturbed normal input component
  72788. */
  72789. get perturbedNormal(): NodeMaterialConnectionPoint;
  72790. /**
  72791. * Gets the base color input component
  72792. */
  72793. get baseColor(): NodeMaterialConnectionPoint;
  72794. /**
  72795. * Gets the metallic input component
  72796. */
  72797. get metallic(): NodeMaterialConnectionPoint;
  72798. /**
  72799. * Gets the roughness input component
  72800. */
  72801. get roughness(): NodeMaterialConnectionPoint;
  72802. /**
  72803. * Gets the ambient occlusion input component
  72804. */
  72805. get ambientOcc(): NodeMaterialConnectionPoint;
  72806. /**
  72807. * Gets the opacity input component
  72808. */
  72809. get opacity(): NodeMaterialConnectionPoint;
  72810. /**
  72811. * Gets the index of refraction input component
  72812. */
  72813. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72814. /**
  72815. * Gets the ambient color input component
  72816. */
  72817. get ambientColor(): NodeMaterialConnectionPoint;
  72818. /**
  72819. * Gets the reflection object parameters
  72820. */
  72821. get reflection(): NodeMaterialConnectionPoint;
  72822. /**
  72823. * Gets the clear coat object parameters
  72824. */
  72825. get clearcoat(): NodeMaterialConnectionPoint;
  72826. /**
  72827. * Gets the sheen object parameters
  72828. */
  72829. get sheen(): NodeMaterialConnectionPoint;
  72830. /**
  72831. * Gets the sub surface object parameters
  72832. */
  72833. get subsurface(): NodeMaterialConnectionPoint;
  72834. /**
  72835. * Gets the anisotropy object parameters
  72836. */
  72837. get anisotropy(): NodeMaterialConnectionPoint;
  72838. /**
  72839. * Gets the ambient output component
  72840. */
  72841. get ambientClr(): NodeMaterialConnectionPoint;
  72842. /**
  72843. * Gets the diffuse output component
  72844. */
  72845. get diffuseDir(): NodeMaterialConnectionPoint;
  72846. /**
  72847. * Gets the specular output component
  72848. */
  72849. get specularDir(): NodeMaterialConnectionPoint;
  72850. /**
  72851. * Gets the clear coat output component
  72852. */
  72853. get clearcoatDir(): NodeMaterialConnectionPoint;
  72854. /**
  72855. * Gets the sheen output component
  72856. */
  72857. get sheenDir(): NodeMaterialConnectionPoint;
  72858. /**
  72859. * Gets the indirect diffuse output component
  72860. */
  72861. get diffuseIndirect(): NodeMaterialConnectionPoint;
  72862. /**
  72863. * Gets the indirect specular output component
  72864. */
  72865. get specularIndirect(): NodeMaterialConnectionPoint;
  72866. /**
  72867. * Gets the indirect clear coat output component
  72868. */
  72869. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  72870. /**
  72871. * Gets the indirect sheen output component
  72872. */
  72873. get sheenIndirect(): NodeMaterialConnectionPoint;
  72874. /**
  72875. * Gets the refraction output component
  72876. */
  72877. get refraction(): NodeMaterialConnectionPoint;
  72878. /**
  72879. * Gets the global lighting output component
  72880. */
  72881. get lighting(): NodeMaterialConnectionPoint;
  72882. /**
  72883. * Gets the shadow output component
  72884. */
  72885. get shadow(): NodeMaterialConnectionPoint;
  72886. /**
  72887. * Gets the alpha output component
  72888. */
  72889. get alpha(): NodeMaterialConnectionPoint;
  72890. autoConfigure(material: NodeMaterial): void;
  72891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72892. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  72893. isReady(): boolean;
  72894. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  72895. private _injectVertexCode;
  72896. private _getAlbedoOpacityCode;
  72897. private _getAmbientOcclusionCode;
  72898. private _getReflectivityCode;
  72899. protected _buildBlock(state: NodeMaterialBuildState): this;
  72900. protected _dumpPropertiesCode(): string;
  72901. serialize(): any;
  72902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72903. }
  72904. }
  72905. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  72906. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  72907. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  72908. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  72909. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72910. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  72911. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  72912. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  72913. }
  72914. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  72915. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  72916. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  72917. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  72918. }
  72919. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  72920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72923. /**
  72924. * Block used to compute value of one parameter modulo another
  72925. */
  72926. export class ModBlock extends NodeMaterialBlock {
  72927. /**
  72928. * Creates a new ModBlock
  72929. * @param name defines the block name
  72930. */
  72931. constructor(name: string);
  72932. /**
  72933. * Gets the current class name
  72934. * @returns the class name
  72935. */
  72936. getClassName(): string;
  72937. /**
  72938. * Gets the left operand input component
  72939. */
  72940. get left(): NodeMaterialConnectionPoint;
  72941. /**
  72942. * Gets the right operand input component
  72943. */
  72944. get right(): NodeMaterialConnectionPoint;
  72945. /**
  72946. * Gets the output component
  72947. */
  72948. get output(): NodeMaterialConnectionPoint;
  72949. protected _buildBlock(state: NodeMaterialBuildState): this;
  72950. }
  72951. }
  72952. declare module "babylonjs/Materials/Node/Blocks/index" {
  72953. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  72954. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  72955. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  72956. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  72957. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  72958. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  72959. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  72960. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  72961. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  72962. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  72963. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  72964. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  72965. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  72966. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  72967. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  72968. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  72969. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  72970. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  72971. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  72972. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  72973. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  72974. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  72975. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  72976. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  72977. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  72978. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  72979. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  72980. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  72981. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  72982. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  72983. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  72984. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  72985. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  72986. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  72987. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  72988. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  72989. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  72990. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  72991. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  72992. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  72993. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  72994. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  72995. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  72996. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  72997. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  72998. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  72999. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  73000. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  73001. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  73002. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  73003. }
  73004. declare module "babylonjs/Materials/Node/Optimizers/index" {
  73005. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  73006. }
  73007. declare module "babylonjs/Materials/Node/index" {
  73008. export * from "babylonjs/Materials/Node/Enums/index";
  73009. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  73010. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  73011. export * from "babylonjs/Materials/Node/nodeMaterial";
  73012. export * from "babylonjs/Materials/Node/Blocks/index";
  73013. export * from "babylonjs/Materials/Node/Optimizers/index";
  73014. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  73015. }
  73016. declare module "babylonjs/Materials/index" {
  73017. export * from "babylonjs/Materials/Background/index";
  73018. export * from "babylonjs/Materials/colorCurves";
  73019. export * from "babylonjs/Materials/iEffectFallbacks";
  73020. export * from "babylonjs/Materials/effectFallbacks";
  73021. export * from "babylonjs/Materials/effect";
  73022. export * from "babylonjs/Materials/fresnelParameters";
  73023. export * from "babylonjs/Materials/imageProcessingConfiguration";
  73024. export * from "babylonjs/Materials/material";
  73025. export * from "babylonjs/Materials/materialDefines";
  73026. export * from "babylonjs/Materials/thinMaterialHelper";
  73027. export * from "babylonjs/Materials/materialHelper";
  73028. export * from "babylonjs/Materials/multiMaterial";
  73029. export * from "babylonjs/Materials/Occlusion/index";
  73030. export * from "babylonjs/Materials/PBR/index";
  73031. export * from "babylonjs/Materials/pushMaterial";
  73032. export * from "babylonjs/Materials/shaderMaterial";
  73033. export * from "babylonjs/Materials/standardMaterial";
  73034. export * from "babylonjs/Materials/Textures/index";
  73035. export * from "babylonjs/Materials/uniformBuffer";
  73036. export * from "babylonjs/Materials/materialFlags";
  73037. export * from "babylonjs/Materials/Node/index";
  73038. export * from "babylonjs/Materials/effectRenderer";
  73039. export * from "babylonjs/Materials/shadowDepthWrapper";
  73040. }
  73041. declare module "babylonjs/Maths/index" {
  73042. export * from "babylonjs/Maths/math.scalar";
  73043. export * from "babylonjs/Maths/math.functions";
  73044. export * from "babylonjs/Maths/math";
  73045. export * from "babylonjs/Maths/sphericalPolynomial";
  73046. }
  73047. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  73048. import { IDisposable } from "babylonjs/scene";
  73049. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  73050. /**
  73051. * Configuration for Draco compression
  73052. */
  73053. export interface IDracoCompressionConfiguration {
  73054. /**
  73055. * Configuration for the decoder.
  73056. */
  73057. decoder: {
  73058. /**
  73059. * The url to the WebAssembly module.
  73060. */
  73061. wasmUrl?: string;
  73062. /**
  73063. * The url to the WebAssembly binary.
  73064. */
  73065. wasmBinaryUrl?: string;
  73066. /**
  73067. * The url to the fallback JavaScript module.
  73068. */
  73069. fallbackUrl?: string;
  73070. };
  73071. }
  73072. /**
  73073. * Draco compression (https://google.github.io/draco/)
  73074. *
  73075. * This class wraps the Draco module.
  73076. *
  73077. * **Encoder**
  73078. *
  73079. * The encoder is not currently implemented.
  73080. *
  73081. * **Decoder**
  73082. *
  73083. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  73084. *
  73085. * To update the configuration, use the following code:
  73086. * ```javascript
  73087. * DracoCompression.Configuration = {
  73088. * decoder: {
  73089. * wasmUrl: "<url to the WebAssembly library>",
  73090. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  73091. * fallbackUrl: "<url to the fallback JavaScript library>",
  73092. * }
  73093. * };
  73094. * ```
  73095. *
  73096. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  73097. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  73098. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  73099. *
  73100. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  73101. * ```javascript
  73102. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  73103. * ```
  73104. *
  73105. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  73106. */
  73107. export class DracoCompression implements IDisposable {
  73108. private _workerPoolPromise?;
  73109. private _decoderModulePromise?;
  73110. /**
  73111. * The configuration. Defaults to the following urls:
  73112. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  73113. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  73114. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  73115. */
  73116. static Configuration: IDracoCompressionConfiguration;
  73117. /**
  73118. * Returns true if the decoder configuration is available.
  73119. */
  73120. static get DecoderAvailable(): boolean;
  73121. /**
  73122. * Default number of workers to create when creating the draco compression object.
  73123. */
  73124. static DefaultNumWorkers: number;
  73125. private static GetDefaultNumWorkers;
  73126. private static _Default;
  73127. /**
  73128. * Default instance for the draco compression object.
  73129. */
  73130. static get Default(): DracoCompression;
  73131. /**
  73132. * Constructor
  73133. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  73134. */
  73135. constructor(numWorkers?: number);
  73136. /**
  73137. * Stop all async operations and release resources.
  73138. */
  73139. dispose(): void;
  73140. /**
  73141. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  73142. * @returns a promise that resolves when ready
  73143. */
  73144. whenReadyAsync(): Promise<void>;
  73145. /**
  73146. * Decode Draco compressed mesh data to vertex data.
  73147. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  73148. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  73149. * @returns A promise that resolves with the decoded vertex data
  73150. */
  73151. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  73152. [kind: string]: number;
  73153. }): Promise<VertexData>;
  73154. }
  73155. }
  73156. declare module "babylonjs/Meshes/Compression/index" {
  73157. export * from "babylonjs/Meshes/Compression/dracoCompression";
  73158. }
  73159. declare module "babylonjs/Meshes/csg" {
  73160. import { Nullable } from "babylonjs/types";
  73161. import { Scene } from "babylonjs/scene";
  73162. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  73163. import { Mesh } from "babylonjs/Meshes/mesh";
  73164. import { Material } from "babylonjs/Materials/material";
  73165. /**
  73166. * Class for building Constructive Solid Geometry
  73167. */
  73168. export class CSG {
  73169. private polygons;
  73170. /**
  73171. * The world matrix
  73172. */
  73173. matrix: Matrix;
  73174. /**
  73175. * Stores the position
  73176. */
  73177. position: Vector3;
  73178. /**
  73179. * Stores the rotation
  73180. */
  73181. rotation: Vector3;
  73182. /**
  73183. * Stores the rotation quaternion
  73184. */
  73185. rotationQuaternion: Nullable<Quaternion>;
  73186. /**
  73187. * Stores the scaling vector
  73188. */
  73189. scaling: Vector3;
  73190. /**
  73191. * Convert the Mesh to CSG
  73192. * @param mesh The Mesh to convert to CSG
  73193. * @returns A new CSG from the Mesh
  73194. */
  73195. static FromMesh(mesh: Mesh): CSG;
  73196. /**
  73197. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  73198. * @param polygons Polygons used to construct a CSG solid
  73199. */
  73200. private static FromPolygons;
  73201. /**
  73202. * Clones, or makes a deep copy, of the CSG
  73203. * @returns A new CSG
  73204. */
  73205. clone(): CSG;
  73206. /**
  73207. * Unions this CSG with another CSG
  73208. * @param csg The CSG to union against this CSG
  73209. * @returns The unioned CSG
  73210. */
  73211. union(csg: CSG): CSG;
  73212. /**
  73213. * Unions this CSG with another CSG in place
  73214. * @param csg The CSG to union against this CSG
  73215. */
  73216. unionInPlace(csg: CSG): void;
  73217. /**
  73218. * Subtracts this CSG with another CSG
  73219. * @param csg The CSG to subtract against this CSG
  73220. * @returns A new CSG
  73221. */
  73222. subtract(csg: CSG): CSG;
  73223. /**
  73224. * Subtracts this CSG with another CSG in place
  73225. * @param csg The CSG to subtact against this CSG
  73226. */
  73227. subtractInPlace(csg: CSG): void;
  73228. /**
  73229. * Intersect this CSG with another CSG
  73230. * @param csg The CSG to intersect against this CSG
  73231. * @returns A new CSG
  73232. */
  73233. intersect(csg: CSG): CSG;
  73234. /**
  73235. * Intersects this CSG with another CSG in place
  73236. * @param csg The CSG to intersect against this CSG
  73237. */
  73238. intersectInPlace(csg: CSG): void;
  73239. /**
  73240. * Return a new CSG solid with solid and empty space switched. This solid is
  73241. * not modified.
  73242. * @returns A new CSG solid with solid and empty space switched
  73243. */
  73244. inverse(): CSG;
  73245. /**
  73246. * Inverses the CSG in place
  73247. */
  73248. inverseInPlace(): void;
  73249. /**
  73250. * This is used to keep meshes transformations so they can be restored
  73251. * when we build back a Babylon Mesh
  73252. * NB : All CSG operations are performed in world coordinates
  73253. * @param csg The CSG to copy the transform attributes from
  73254. * @returns This CSG
  73255. */
  73256. copyTransformAttributes(csg: CSG): CSG;
  73257. /**
  73258. * Build Raw mesh from CSG
  73259. * Coordinates here are in world space
  73260. * @param name The name of the mesh geometry
  73261. * @param scene The Scene
  73262. * @param keepSubMeshes Specifies if the submeshes should be kept
  73263. * @returns A new Mesh
  73264. */
  73265. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  73266. /**
  73267. * Build Mesh from CSG taking material and transforms into account
  73268. * @param name The name of the Mesh
  73269. * @param material The material of the Mesh
  73270. * @param scene The Scene
  73271. * @param keepSubMeshes Specifies if submeshes should be kept
  73272. * @returns The new Mesh
  73273. */
  73274. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  73275. }
  73276. }
  73277. declare module "babylonjs/Meshes/trailMesh" {
  73278. import { Mesh } from "babylonjs/Meshes/mesh";
  73279. import { Scene } from "babylonjs/scene";
  73280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73281. /**
  73282. * Class used to create a trail following a mesh
  73283. */
  73284. export class TrailMesh extends Mesh {
  73285. private _generator;
  73286. private _autoStart;
  73287. private _running;
  73288. private _diameter;
  73289. private _length;
  73290. private _sectionPolygonPointsCount;
  73291. private _sectionVectors;
  73292. private _sectionNormalVectors;
  73293. private _beforeRenderObserver;
  73294. /**
  73295. * @constructor
  73296. * @param name The value used by scene.getMeshByName() to do a lookup.
  73297. * @param generator The mesh or transform node to generate a trail.
  73298. * @param scene The scene to add this mesh to.
  73299. * @param diameter Diameter of trailing mesh. Default is 1.
  73300. * @param length Length of trailing mesh. Default is 60.
  73301. * @param autoStart Automatically start trailing mesh. Default true.
  73302. */
  73303. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  73304. /**
  73305. * "TrailMesh"
  73306. * @returns "TrailMesh"
  73307. */
  73308. getClassName(): string;
  73309. private _createMesh;
  73310. /**
  73311. * Start trailing mesh.
  73312. */
  73313. start(): void;
  73314. /**
  73315. * Stop trailing mesh.
  73316. */
  73317. stop(): void;
  73318. /**
  73319. * Update trailing mesh geometry.
  73320. */
  73321. update(): void;
  73322. /**
  73323. * Returns a new TrailMesh object.
  73324. * @param name is a string, the name given to the new mesh
  73325. * @param newGenerator use new generator object for cloned trail mesh
  73326. * @returns a new mesh
  73327. */
  73328. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  73329. /**
  73330. * Serializes this trail mesh
  73331. * @param serializationObject object to write serialization to
  73332. */
  73333. serialize(serializationObject: any): void;
  73334. /**
  73335. * Parses a serialized trail mesh
  73336. * @param parsedMesh the serialized mesh
  73337. * @param scene the scene to create the trail mesh in
  73338. * @returns the created trail mesh
  73339. */
  73340. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  73341. }
  73342. }
  73343. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  73344. import { Nullable } from "babylonjs/types";
  73345. import { Scene } from "babylonjs/scene";
  73346. import { Vector4 } from "babylonjs/Maths/math.vector";
  73347. import { Color4 } from "babylonjs/Maths/math.color";
  73348. import { Mesh } from "babylonjs/Meshes/mesh";
  73349. /**
  73350. * Class containing static functions to help procedurally build meshes
  73351. */
  73352. export class TiledBoxBuilder {
  73353. /**
  73354. * Creates a box mesh
  73355. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  73356. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73360. * @param name defines the name of the mesh
  73361. * @param options defines the options used to create the mesh
  73362. * @param scene defines the hosting scene
  73363. * @returns the box mesh
  73364. */
  73365. static CreateTiledBox(name: string, options: {
  73366. pattern?: number;
  73367. width?: number;
  73368. height?: number;
  73369. depth?: number;
  73370. tileSize?: number;
  73371. tileWidth?: number;
  73372. tileHeight?: number;
  73373. alignHorizontal?: number;
  73374. alignVertical?: number;
  73375. faceUV?: Vector4[];
  73376. faceColors?: Color4[];
  73377. sideOrientation?: number;
  73378. updatable?: boolean;
  73379. }, scene?: Nullable<Scene>): Mesh;
  73380. }
  73381. }
  73382. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  73383. import { Vector4 } from "babylonjs/Maths/math.vector";
  73384. import { Mesh } from "babylonjs/Meshes/mesh";
  73385. /**
  73386. * Class containing static functions to help procedurally build meshes
  73387. */
  73388. export class TorusKnotBuilder {
  73389. /**
  73390. * Creates a torus knot mesh
  73391. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  73392. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  73393. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  73394. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  73395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73398. * @param name defines the name of the mesh
  73399. * @param options defines the options used to create the mesh
  73400. * @param scene defines the hosting scene
  73401. * @returns the torus knot mesh
  73402. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  73403. */
  73404. static CreateTorusKnot(name: string, options: {
  73405. radius?: number;
  73406. tube?: number;
  73407. radialSegments?: number;
  73408. tubularSegments?: number;
  73409. p?: number;
  73410. q?: number;
  73411. updatable?: boolean;
  73412. sideOrientation?: number;
  73413. frontUVs?: Vector4;
  73414. backUVs?: Vector4;
  73415. }, scene: any): Mesh;
  73416. }
  73417. }
  73418. declare module "babylonjs/Meshes/polygonMesh" {
  73419. import { Scene } from "babylonjs/scene";
  73420. import { Vector2 } from "babylonjs/Maths/math.vector";
  73421. import { Mesh } from "babylonjs/Meshes/mesh";
  73422. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  73423. import { Path2 } from "babylonjs/Maths/math.path";
  73424. /**
  73425. * Polygon
  73426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  73427. */
  73428. export class Polygon {
  73429. /**
  73430. * Creates a rectangle
  73431. * @param xmin bottom X coord
  73432. * @param ymin bottom Y coord
  73433. * @param xmax top X coord
  73434. * @param ymax top Y coord
  73435. * @returns points that make the resulting rectation
  73436. */
  73437. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  73438. /**
  73439. * Creates a circle
  73440. * @param radius radius of circle
  73441. * @param cx scale in x
  73442. * @param cy scale in y
  73443. * @param numberOfSides number of sides that make up the circle
  73444. * @returns points that make the resulting circle
  73445. */
  73446. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  73447. /**
  73448. * Creates a polygon from input string
  73449. * @param input Input polygon data
  73450. * @returns the parsed points
  73451. */
  73452. static Parse(input: string): Vector2[];
  73453. /**
  73454. * Starts building a polygon from x and y coordinates
  73455. * @param x x coordinate
  73456. * @param y y coordinate
  73457. * @returns the started path2
  73458. */
  73459. static StartingAt(x: number, y: number): Path2;
  73460. }
  73461. /**
  73462. * Builds a polygon
  73463. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  73464. */
  73465. export class PolygonMeshBuilder {
  73466. private _points;
  73467. private _outlinepoints;
  73468. private _holes;
  73469. private _name;
  73470. private _scene;
  73471. private _epoints;
  73472. private _eholes;
  73473. private _addToepoint;
  73474. /**
  73475. * Babylon reference to the earcut plugin.
  73476. */
  73477. bjsEarcut: any;
  73478. /**
  73479. * Creates a PolygonMeshBuilder
  73480. * @param name name of the builder
  73481. * @param contours Path of the polygon
  73482. * @param scene scene to add to when creating the mesh
  73483. * @param earcutInjection can be used to inject your own earcut reference
  73484. */
  73485. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  73486. /**
  73487. * Adds a hole within the polygon
  73488. * @param hole Array of points defining the hole
  73489. * @returns this
  73490. */
  73491. addHole(hole: Vector2[]): PolygonMeshBuilder;
  73492. /**
  73493. * Creates the polygon
  73494. * @param updatable If the mesh should be updatable
  73495. * @param depth The depth of the mesh created
  73496. * @param smoothingThreshold Dot product threshold for smoothed normals
  73497. * @returns the created mesh
  73498. */
  73499. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  73500. /**
  73501. * Creates the polygon
  73502. * @param depth The depth of the mesh created
  73503. * @param smoothingThreshold Dot product threshold for smoothed normals
  73504. * @returns the created VertexData
  73505. */
  73506. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  73507. /**
  73508. * Adds a side to the polygon
  73509. * @param positions points that make the polygon
  73510. * @param normals normals of the polygon
  73511. * @param uvs uvs of the polygon
  73512. * @param indices indices of the polygon
  73513. * @param bounds bounds of the polygon
  73514. * @param points points of the polygon
  73515. * @param depth depth of the polygon
  73516. * @param flip flip of the polygon
  73517. */
  73518. private addSide;
  73519. }
  73520. }
  73521. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  73522. import { Scene } from "babylonjs/scene";
  73523. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73524. import { Color4 } from "babylonjs/Maths/math.color";
  73525. import { Mesh } from "babylonjs/Meshes/mesh";
  73526. import { Nullable } from "babylonjs/types";
  73527. /**
  73528. * Class containing static functions to help procedurally build meshes
  73529. */
  73530. export class PolygonBuilder {
  73531. /**
  73532. * Creates a polygon mesh
  73533. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  73534. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  73535. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  73538. * * Remember you can only change the shape positions, not their number when updating a polygon
  73539. * @param name defines the name of the mesh
  73540. * @param options defines the options used to create the mesh
  73541. * @param scene defines the hosting scene
  73542. * @param earcutInjection can be used to inject your own earcut reference
  73543. * @returns the polygon mesh
  73544. */
  73545. static CreatePolygon(name: string, options: {
  73546. shape: Vector3[];
  73547. holes?: Vector3[][];
  73548. depth?: number;
  73549. smoothingThreshold?: number;
  73550. faceUV?: Vector4[];
  73551. faceColors?: Color4[];
  73552. updatable?: boolean;
  73553. sideOrientation?: number;
  73554. frontUVs?: Vector4;
  73555. backUVs?: Vector4;
  73556. wrap?: boolean;
  73557. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73558. /**
  73559. * Creates an extruded polygon mesh, with depth in the Y direction.
  73560. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  73561. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73562. * @param name defines the name of the mesh
  73563. * @param options defines the options used to create the mesh
  73564. * @param scene defines the hosting scene
  73565. * @param earcutInjection can be used to inject your own earcut reference
  73566. * @returns the polygon mesh
  73567. */
  73568. static ExtrudePolygon(name: string, options: {
  73569. shape: Vector3[];
  73570. holes?: Vector3[][];
  73571. depth?: number;
  73572. faceUV?: Vector4[];
  73573. faceColors?: Color4[];
  73574. updatable?: boolean;
  73575. sideOrientation?: number;
  73576. frontUVs?: Vector4;
  73577. backUVs?: Vector4;
  73578. wrap?: boolean;
  73579. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73580. }
  73581. }
  73582. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  73583. import { Scene } from "babylonjs/scene";
  73584. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73585. import { Mesh } from "babylonjs/Meshes/mesh";
  73586. import { Nullable } from "babylonjs/types";
  73587. /**
  73588. * Class containing static functions to help procedurally build meshes
  73589. */
  73590. export class LatheBuilder {
  73591. /**
  73592. * Creates lathe mesh.
  73593. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  73594. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  73595. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  73596. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  73597. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  73598. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  73599. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  73600. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  73601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73605. * @param name defines the name of the mesh
  73606. * @param options defines the options used to create the mesh
  73607. * @param scene defines the hosting scene
  73608. * @returns the lathe mesh
  73609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  73610. */
  73611. static CreateLathe(name: string, options: {
  73612. shape: Vector3[];
  73613. radius?: number;
  73614. tessellation?: number;
  73615. clip?: number;
  73616. arc?: number;
  73617. closed?: boolean;
  73618. updatable?: boolean;
  73619. sideOrientation?: number;
  73620. frontUVs?: Vector4;
  73621. backUVs?: Vector4;
  73622. cap?: number;
  73623. invertUV?: boolean;
  73624. }, scene?: Nullable<Scene>): Mesh;
  73625. }
  73626. }
  73627. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  73628. import { Nullable } from "babylonjs/types";
  73629. import { Scene } from "babylonjs/scene";
  73630. import { Vector4 } from "babylonjs/Maths/math.vector";
  73631. import { Mesh } from "babylonjs/Meshes/mesh";
  73632. /**
  73633. * Class containing static functions to help procedurally build meshes
  73634. */
  73635. export class TiledPlaneBuilder {
  73636. /**
  73637. * Creates a tiled plane mesh
  73638. * * The parameter `pattern` will, depending on value, do nothing or
  73639. * * * flip (reflect about central vertical) alternate tiles across and up
  73640. * * * flip every tile on alternate rows
  73641. * * * rotate (180 degs) alternate tiles across and up
  73642. * * * rotate every tile on alternate rows
  73643. * * * flip and rotate alternate tiles across and up
  73644. * * * flip and rotate every tile on alternate rows
  73645. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  73646. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  73647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73648. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73649. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  73650. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  73651. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73652. * @param name defines the name of the mesh
  73653. * @param options defines the options used to create the mesh
  73654. * @param scene defines the hosting scene
  73655. * @returns the box mesh
  73656. */
  73657. static CreateTiledPlane(name: string, options: {
  73658. pattern?: number;
  73659. tileSize?: number;
  73660. tileWidth?: number;
  73661. tileHeight?: number;
  73662. size?: number;
  73663. width?: number;
  73664. height?: number;
  73665. alignHorizontal?: number;
  73666. alignVertical?: number;
  73667. sideOrientation?: number;
  73668. frontUVs?: Vector4;
  73669. backUVs?: Vector4;
  73670. updatable?: boolean;
  73671. }, scene?: Nullable<Scene>): Mesh;
  73672. }
  73673. }
  73674. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  73675. import { Nullable } from "babylonjs/types";
  73676. import { Scene } from "babylonjs/scene";
  73677. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73678. import { Mesh } from "babylonjs/Meshes/mesh";
  73679. /**
  73680. * Class containing static functions to help procedurally build meshes
  73681. */
  73682. export class TubeBuilder {
  73683. /**
  73684. * Creates a tube mesh.
  73685. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73686. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  73687. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  73688. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  73689. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  73690. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  73691. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  73692. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  73693. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  73694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73698. * @param name defines the name of the mesh
  73699. * @param options defines the options used to create the mesh
  73700. * @param scene defines the hosting scene
  73701. * @returns the tube mesh
  73702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73703. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  73704. */
  73705. static CreateTube(name: string, options: {
  73706. path: Vector3[];
  73707. radius?: number;
  73708. tessellation?: number;
  73709. radiusFunction?: {
  73710. (i: number, distance: number): number;
  73711. };
  73712. cap?: number;
  73713. arc?: number;
  73714. updatable?: boolean;
  73715. sideOrientation?: number;
  73716. frontUVs?: Vector4;
  73717. backUVs?: Vector4;
  73718. instance?: Mesh;
  73719. invertUV?: boolean;
  73720. }, scene?: Nullable<Scene>): Mesh;
  73721. }
  73722. }
  73723. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  73724. import { Scene } from "babylonjs/scene";
  73725. import { Vector4 } from "babylonjs/Maths/math.vector";
  73726. import { Mesh } from "babylonjs/Meshes/mesh";
  73727. import { Nullable } from "babylonjs/types";
  73728. /**
  73729. * Class containing static functions to help procedurally build meshes
  73730. */
  73731. export class IcoSphereBuilder {
  73732. /**
  73733. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73734. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73735. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  73736. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73737. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  73738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73741. * @param name defines the name of the mesh
  73742. * @param options defines the options used to create the mesh
  73743. * @param scene defines the hosting scene
  73744. * @returns the icosahedron mesh
  73745. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73746. */
  73747. static CreateIcoSphere(name: string, options: {
  73748. radius?: number;
  73749. radiusX?: number;
  73750. radiusY?: number;
  73751. radiusZ?: number;
  73752. flat?: boolean;
  73753. subdivisions?: number;
  73754. sideOrientation?: number;
  73755. frontUVs?: Vector4;
  73756. backUVs?: Vector4;
  73757. updatable?: boolean;
  73758. }, scene?: Nullable<Scene>): Mesh;
  73759. }
  73760. }
  73761. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  73762. import { Vector3 } from "babylonjs/Maths/math.vector";
  73763. import { Mesh } from "babylonjs/Meshes/mesh";
  73764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73765. /**
  73766. * Class containing static functions to help procedurally build meshes
  73767. */
  73768. export class DecalBuilder {
  73769. /**
  73770. * Creates a decal mesh.
  73771. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  73772. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  73773. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  73774. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  73775. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  73776. * @param name defines the name of the mesh
  73777. * @param sourceMesh defines the mesh where the decal must be applied
  73778. * @param options defines the options used to create the mesh
  73779. * @param scene defines the hosting scene
  73780. * @returns the decal mesh
  73781. * @see https://doc.babylonjs.com/how_to/decals
  73782. */
  73783. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  73784. position?: Vector3;
  73785. normal?: Vector3;
  73786. size?: Vector3;
  73787. angle?: number;
  73788. }): Mesh;
  73789. }
  73790. }
  73791. declare module "babylonjs/Meshes/meshBuilder" {
  73792. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  73793. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  73794. import { Nullable } from "babylonjs/types";
  73795. import { Scene } from "babylonjs/scene";
  73796. import { Mesh } from "babylonjs/Meshes/mesh";
  73797. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  73798. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  73799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73800. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  73801. import { Plane } from "babylonjs/Maths/math.plane";
  73802. /**
  73803. * Class containing static functions to help procedurally build meshes
  73804. */
  73805. export class MeshBuilder {
  73806. /**
  73807. * Creates a box mesh
  73808. * * The parameter `size` sets the size (float) of each box side (default 1)
  73809. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  73810. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  73811. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73815. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73816. * @param name defines the name of the mesh
  73817. * @param options defines the options used to create the mesh
  73818. * @param scene defines the hosting scene
  73819. * @returns the box mesh
  73820. */
  73821. static CreateBox(name: string, options: {
  73822. size?: number;
  73823. width?: number;
  73824. height?: number;
  73825. depth?: number;
  73826. faceUV?: Vector4[];
  73827. faceColors?: Color4[];
  73828. sideOrientation?: number;
  73829. frontUVs?: Vector4;
  73830. backUVs?: Vector4;
  73831. wrap?: boolean;
  73832. topBaseAt?: number;
  73833. bottomBaseAt?: number;
  73834. updatable?: boolean;
  73835. }, scene?: Nullable<Scene>): Mesh;
  73836. /**
  73837. * Creates a tiled box mesh
  73838. * * faceTiles sets the pattern, tile size and number of tiles for a face
  73839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73840. * @param name defines the name of the mesh
  73841. * @param options defines the options used to create the mesh
  73842. * @param scene defines the hosting scene
  73843. * @returns the tiled box mesh
  73844. */
  73845. static CreateTiledBox(name: string, options: {
  73846. pattern?: number;
  73847. size?: number;
  73848. width?: number;
  73849. height?: number;
  73850. depth: number;
  73851. tileSize?: number;
  73852. tileWidth?: number;
  73853. tileHeight?: number;
  73854. faceUV?: Vector4[];
  73855. faceColors?: Color4[];
  73856. alignHorizontal?: number;
  73857. alignVertical?: number;
  73858. sideOrientation?: number;
  73859. updatable?: boolean;
  73860. }, scene?: Nullable<Scene>): Mesh;
  73861. /**
  73862. * Creates a sphere mesh
  73863. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  73864. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  73865. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  73866. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  73867. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  73868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73871. * @param name defines the name of the mesh
  73872. * @param options defines the options used to create the mesh
  73873. * @param scene defines the hosting scene
  73874. * @returns the sphere mesh
  73875. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  73876. */
  73877. static CreateSphere(name: string, options: {
  73878. segments?: number;
  73879. diameter?: number;
  73880. diameterX?: number;
  73881. diameterY?: number;
  73882. diameterZ?: number;
  73883. arc?: number;
  73884. slice?: number;
  73885. sideOrientation?: number;
  73886. frontUVs?: Vector4;
  73887. backUVs?: Vector4;
  73888. updatable?: boolean;
  73889. }, scene?: Nullable<Scene>): Mesh;
  73890. /**
  73891. * Creates a plane polygonal mesh. By default, this is a disc
  73892. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  73893. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  73894. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  73895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73898. * @param name defines the name of the mesh
  73899. * @param options defines the options used to create the mesh
  73900. * @param scene defines the hosting scene
  73901. * @returns the plane polygonal mesh
  73902. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  73903. */
  73904. static CreateDisc(name: string, options: {
  73905. radius?: number;
  73906. tessellation?: number;
  73907. arc?: number;
  73908. updatable?: boolean;
  73909. sideOrientation?: number;
  73910. frontUVs?: Vector4;
  73911. backUVs?: Vector4;
  73912. }, scene?: Nullable<Scene>): Mesh;
  73913. /**
  73914. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73915. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73916. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  73917. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73918. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  73919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73922. * @param name defines the name of the mesh
  73923. * @param options defines the options used to create the mesh
  73924. * @param scene defines the hosting scene
  73925. * @returns the icosahedron mesh
  73926. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73927. */
  73928. static CreateIcoSphere(name: string, options: {
  73929. radius?: number;
  73930. radiusX?: number;
  73931. radiusY?: number;
  73932. radiusZ?: number;
  73933. flat?: boolean;
  73934. subdivisions?: number;
  73935. sideOrientation?: number;
  73936. frontUVs?: Vector4;
  73937. backUVs?: Vector4;
  73938. updatable?: boolean;
  73939. }, scene?: Nullable<Scene>): Mesh;
  73940. /**
  73941. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73942. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  73943. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  73944. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  73945. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  73946. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  73947. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  73948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73950. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73951. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  73952. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  73953. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  73954. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  73955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73956. * @param name defines the name of the mesh
  73957. * @param options defines the options used to create the mesh
  73958. * @param scene defines the hosting scene
  73959. * @returns the ribbon mesh
  73960. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  73961. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73962. */
  73963. static CreateRibbon(name: string, options: {
  73964. pathArray: Vector3[][];
  73965. closeArray?: boolean;
  73966. closePath?: boolean;
  73967. offset?: number;
  73968. updatable?: boolean;
  73969. sideOrientation?: number;
  73970. frontUVs?: Vector4;
  73971. backUVs?: Vector4;
  73972. instance?: Mesh;
  73973. invertUV?: boolean;
  73974. uvs?: Vector2[];
  73975. colors?: Color4[];
  73976. }, scene?: Nullable<Scene>): Mesh;
  73977. /**
  73978. * Creates a cylinder or a cone mesh
  73979. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  73980. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  73981. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  73982. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  73983. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  73984. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  73985. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  73986. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  73987. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  73988. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  73989. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  73990. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  73991. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  73992. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  73993. * * If `enclose` is false, a ring surface is one element.
  73994. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  73995. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  73996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73999. * @param name defines the name of the mesh
  74000. * @param options defines the options used to create the mesh
  74001. * @param scene defines the hosting scene
  74002. * @returns the cylinder mesh
  74003. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  74004. */
  74005. static CreateCylinder(name: string, options: {
  74006. height?: number;
  74007. diameterTop?: number;
  74008. diameterBottom?: number;
  74009. diameter?: number;
  74010. tessellation?: number;
  74011. subdivisions?: number;
  74012. arc?: number;
  74013. faceColors?: Color4[];
  74014. faceUV?: Vector4[];
  74015. updatable?: boolean;
  74016. hasRings?: boolean;
  74017. enclose?: boolean;
  74018. cap?: number;
  74019. sideOrientation?: number;
  74020. frontUVs?: Vector4;
  74021. backUVs?: Vector4;
  74022. }, scene?: Nullable<Scene>): Mesh;
  74023. /**
  74024. * Creates a torus mesh
  74025. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  74026. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  74027. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  74028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74031. * @param name defines the name of the mesh
  74032. * @param options defines the options used to create the mesh
  74033. * @param scene defines the hosting scene
  74034. * @returns the torus mesh
  74035. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  74036. */
  74037. static CreateTorus(name: string, options: {
  74038. diameter?: number;
  74039. thickness?: number;
  74040. tessellation?: number;
  74041. updatable?: boolean;
  74042. sideOrientation?: number;
  74043. frontUVs?: Vector4;
  74044. backUVs?: Vector4;
  74045. }, scene?: Nullable<Scene>): Mesh;
  74046. /**
  74047. * Creates a torus knot mesh
  74048. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  74049. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  74050. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  74051. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  74052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74055. * @param name defines the name of the mesh
  74056. * @param options defines the options used to create the mesh
  74057. * @param scene defines the hosting scene
  74058. * @returns the torus knot mesh
  74059. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  74060. */
  74061. static CreateTorusKnot(name: string, options: {
  74062. radius?: number;
  74063. tube?: number;
  74064. radialSegments?: number;
  74065. tubularSegments?: number;
  74066. p?: number;
  74067. q?: number;
  74068. updatable?: boolean;
  74069. sideOrientation?: number;
  74070. frontUVs?: Vector4;
  74071. backUVs?: Vector4;
  74072. }, scene?: Nullable<Scene>): Mesh;
  74073. /**
  74074. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  74075. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  74076. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  74077. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  74078. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  74079. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  74080. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  74081. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  74082. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  74083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74084. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  74085. * @param name defines the name of the new line system
  74086. * @param options defines the options used to create the line system
  74087. * @param scene defines the hosting scene
  74088. * @returns a new line system mesh
  74089. */
  74090. static CreateLineSystem(name: string, options: {
  74091. lines: Vector3[][];
  74092. updatable?: boolean;
  74093. instance?: Nullable<LinesMesh>;
  74094. colors?: Nullable<Color4[][]>;
  74095. useVertexAlpha?: boolean;
  74096. }, scene: Nullable<Scene>): LinesMesh;
  74097. /**
  74098. * Creates a line mesh
  74099. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  74100. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  74101. * * The parameter `points` is an array successive Vector3
  74102. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  74103. * * The optional parameter `colors` is an array of successive Color4, one per line point
  74104. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  74105. * * When updating an instance, remember that only point positions can change, not the number of points
  74106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  74108. * @param name defines the name of the new line system
  74109. * @param options defines the options used to create the line system
  74110. * @param scene defines the hosting scene
  74111. * @returns a new line mesh
  74112. */
  74113. static CreateLines(name: string, options: {
  74114. points: Vector3[];
  74115. updatable?: boolean;
  74116. instance?: Nullable<LinesMesh>;
  74117. colors?: Color4[];
  74118. useVertexAlpha?: boolean;
  74119. }, scene?: Nullable<Scene>): LinesMesh;
  74120. /**
  74121. * Creates a dashed line mesh
  74122. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  74123. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  74124. * * The parameter `points` is an array successive Vector3
  74125. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  74126. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  74127. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  74128. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  74129. * * When updating an instance, remember that only point positions can change, not the number of points
  74130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74131. * @param name defines the name of the mesh
  74132. * @param options defines the options used to create the mesh
  74133. * @param scene defines the hosting scene
  74134. * @returns the dashed line mesh
  74135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  74136. */
  74137. static CreateDashedLines(name: string, options: {
  74138. points: Vector3[];
  74139. dashSize?: number;
  74140. gapSize?: number;
  74141. dashNb?: number;
  74142. updatable?: boolean;
  74143. instance?: LinesMesh;
  74144. }, scene?: Nullable<Scene>): LinesMesh;
  74145. /**
  74146. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  74147. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  74148. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  74149. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  74150. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  74151. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  74152. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  74153. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  74154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74156. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  74157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74158. * @param name defines the name of the mesh
  74159. * @param options defines the options used to create the mesh
  74160. * @param scene defines the hosting scene
  74161. * @returns the extruded shape mesh
  74162. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  74164. */
  74165. static ExtrudeShape(name: string, options: {
  74166. shape: Vector3[];
  74167. path: Vector3[];
  74168. scale?: number;
  74169. rotation?: number;
  74170. cap?: number;
  74171. updatable?: boolean;
  74172. sideOrientation?: number;
  74173. frontUVs?: Vector4;
  74174. backUVs?: Vector4;
  74175. instance?: Mesh;
  74176. invertUV?: boolean;
  74177. }, scene?: Nullable<Scene>): Mesh;
  74178. /**
  74179. * Creates an custom extruded shape mesh.
  74180. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  74181. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  74182. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  74183. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  74184. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  74185. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  74186. * * It must returns a float value that will be the scale value applied to the shape on each path point
  74187. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  74188. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  74189. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  74190. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  74191. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  74192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74196. * @param name defines the name of the mesh
  74197. * @param options defines the options used to create the mesh
  74198. * @param scene defines the hosting scene
  74199. * @returns the custom extruded shape mesh
  74200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  74201. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  74203. */
  74204. static ExtrudeShapeCustom(name: string, options: {
  74205. shape: Vector3[];
  74206. path: Vector3[];
  74207. scaleFunction?: any;
  74208. rotationFunction?: any;
  74209. ribbonCloseArray?: boolean;
  74210. ribbonClosePath?: boolean;
  74211. cap?: number;
  74212. updatable?: boolean;
  74213. sideOrientation?: number;
  74214. frontUVs?: Vector4;
  74215. backUVs?: Vector4;
  74216. instance?: Mesh;
  74217. invertUV?: boolean;
  74218. }, scene?: Nullable<Scene>): Mesh;
  74219. /**
  74220. * Creates lathe mesh.
  74221. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  74222. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  74223. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  74224. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  74225. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  74226. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  74227. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  74228. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  74229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74233. * @param name defines the name of the mesh
  74234. * @param options defines the options used to create the mesh
  74235. * @param scene defines the hosting scene
  74236. * @returns the lathe mesh
  74237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  74238. */
  74239. static CreateLathe(name: string, options: {
  74240. shape: Vector3[];
  74241. radius?: number;
  74242. tessellation?: number;
  74243. clip?: number;
  74244. arc?: number;
  74245. closed?: boolean;
  74246. updatable?: boolean;
  74247. sideOrientation?: number;
  74248. frontUVs?: Vector4;
  74249. backUVs?: Vector4;
  74250. cap?: number;
  74251. invertUV?: boolean;
  74252. }, scene?: Nullable<Scene>): Mesh;
  74253. /**
  74254. * Creates a tiled plane mesh
  74255. * * You can set a limited pattern arrangement with the tiles
  74256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74259. * @param name defines the name of the mesh
  74260. * @param options defines the options used to create the mesh
  74261. * @param scene defines the hosting scene
  74262. * @returns the plane mesh
  74263. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  74264. */
  74265. static CreateTiledPlane(name: string, options: {
  74266. pattern?: number;
  74267. tileSize?: number;
  74268. tileWidth?: number;
  74269. tileHeight?: number;
  74270. size?: number;
  74271. width?: number;
  74272. height?: number;
  74273. alignHorizontal?: number;
  74274. alignVertical?: number;
  74275. sideOrientation?: number;
  74276. frontUVs?: Vector4;
  74277. backUVs?: Vector4;
  74278. updatable?: boolean;
  74279. }, scene?: Nullable<Scene>): Mesh;
  74280. /**
  74281. * Creates a plane mesh
  74282. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  74283. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  74284. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  74285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74288. * @param name defines the name of the mesh
  74289. * @param options defines the options used to create the mesh
  74290. * @param scene defines the hosting scene
  74291. * @returns the plane mesh
  74292. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  74293. */
  74294. static CreatePlane(name: string, options: {
  74295. size?: number;
  74296. width?: number;
  74297. height?: number;
  74298. sideOrientation?: number;
  74299. frontUVs?: Vector4;
  74300. backUVs?: Vector4;
  74301. updatable?: boolean;
  74302. sourcePlane?: Plane;
  74303. }, scene?: Nullable<Scene>): Mesh;
  74304. /**
  74305. * Creates a ground mesh
  74306. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  74307. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  74308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74309. * @param name defines the name of the mesh
  74310. * @param options defines the options used to create the mesh
  74311. * @param scene defines the hosting scene
  74312. * @returns the ground mesh
  74313. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  74314. */
  74315. static CreateGround(name: string, options: {
  74316. width?: number;
  74317. height?: number;
  74318. subdivisions?: number;
  74319. subdivisionsX?: number;
  74320. subdivisionsY?: number;
  74321. updatable?: boolean;
  74322. }, scene?: Nullable<Scene>): Mesh;
  74323. /**
  74324. * Creates a tiled ground mesh
  74325. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  74326. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  74327. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  74328. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  74329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74330. * @param name defines the name of the mesh
  74331. * @param options defines the options used to create the mesh
  74332. * @param scene defines the hosting scene
  74333. * @returns the tiled ground mesh
  74334. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  74335. */
  74336. static CreateTiledGround(name: string, options: {
  74337. xmin: number;
  74338. zmin: number;
  74339. xmax: number;
  74340. zmax: number;
  74341. subdivisions?: {
  74342. w: number;
  74343. h: number;
  74344. };
  74345. precision?: {
  74346. w: number;
  74347. h: number;
  74348. };
  74349. updatable?: boolean;
  74350. }, scene?: Nullable<Scene>): Mesh;
  74351. /**
  74352. * Creates a ground mesh from a height map
  74353. * * The parameter `url` sets the URL of the height map image resource.
  74354. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  74355. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  74356. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  74357. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  74358. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  74359. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  74360. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  74361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74362. * @param name defines the name of the mesh
  74363. * @param url defines the url to the height map
  74364. * @param options defines the options used to create the mesh
  74365. * @param scene defines the hosting scene
  74366. * @returns the ground mesh
  74367. * @see https://doc.babylonjs.com/babylon101/height_map
  74368. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  74369. */
  74370. static CreateGroundFromHeightMap(name: string, url: string, options: {
  74371. width?: number;
  74372. height?: number;
  74373. subdivisions?: number;
  74374. minHeight?: number;
  74375. maxHeight?: number;
  74376. colorFilter?: Color3;
  74377. alphaFilter?: number;
  74378. updatable?: boolean;
  74379. onReady?: (mesh: GroundMesh) => void;
  74380. }, scene?: Nullable<Scene>): GroundMesh;
  74381. /**
  74382. * Creates a polygon mesh
  74383. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  74384. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  74385. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  74386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  74388. * * Remember you can only change the shape positions, not their number when updating a polygon
  74389. * @param name defines the name of the mesh
  74390. * @param options defines the options used to create the mesh
  74391. * @param scene defines the hosting scene
  74392. * @param earcutInjection can be used to inject your own earcut reference
  74393. * @returns the polygon mesh
  74394. */
  74395. static CreatePolygon(name: string, options: {
  74396. shape: Vector3[];
  74397. holes?: Vector3[][];
  74398. depth?: number;
  74399. faceUV?: Vector4[];
  74400. faceColors?: Color4[];
  74401. updatable?: boolean;
  74402. sideOrientation?: number;
  74403. frontUVs?: Vector4;
  74404. backUVs?: Vector4;
  74405. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74406. /**
  74407. * Creates an extruded polygon mesh, with depth in the Y direction.
  74408. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  74409. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74410. * @param name defines the name of the mesh
  74411. * @param options defines the options used to create the mesh
  74412. * @param scene defines the hosting scene
  74413. * @param earcutInjection can be used to inject your own earcut reference
  74414. * @returns the polygon mesh
  74415. */
  74416. static ExtrudePolygon(name: string, options: {
  74417. shape: Vector3[];
  74418. holes?: Vector3[][];
  74419. depth?: number;
  74420. faceUV?: Vector4[];
  74421. faceColors?: Color4[];
  74422. updatable?: boolean;
  74423. sideOrientation?: number;
  74424. frontUVs?: Vector4;
  74425. backUVs?: Vector4;
  74426. wrap?: boolean;
  74427. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74428. /**
  74429. * Creates a tube mesh.
  74430. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  74431. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  74432. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  74433. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  74434. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  74435. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  74436. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  74437. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  74438. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  74439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74443. * @param name defines the name of the mesh
  74444. * @param options defines the options used to create the mesh
  74445. * @param scene defines the hosting scene
  74446. * @returns the tube mesh
  74447. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74448. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  74449. */
  74450. static CreateTube(name: string, options: {
  74451. path: Vector3[];
  74452. radius?: number;
  74453. tessellation?: number;
  74454. radiusFunction?: {
  74455. (i: number, distance: number): number;
  74456. };
  74457. cap?: number;
  74458. arc?: number;
  74459. updatable?: boolean;
  74460. sideOrientation?: number;
  74461. frontUVs?: Vector4;
  74462. backUVs?: Vector4;
  74463. instance?: Mesh;
  74464. invertUV?: boolean;
  74465. }, scene?: Nullable<Scene>): Mesh;
  74466. /**
  74467. * Creates a polyhedron mesh
  74468. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  74469. * * The parameter `size` (positive float, default 1) sets the polygon size
  74470. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  74471. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  74472. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  74473. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  74474. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74475. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  74476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74479. * @param name defines the name of the mesh
  74480. * @param options defines the options used to create the mesh
  74481. * @param scene defines the hosting scene
  74482. * @returns the polyhedron mesh
  74483. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  74484. */
  74485. static CreatePolyhedron(name: string, options: {
  74486. type?: number;
  74487. size?: number;
  74488. sizeX?: number;
  74489. sizeY?: number;
  74490. sizeZ?: number;
  74491. custom?: any;
  74492. faceUV?: Vector4[];
  74493. faceColors?: Color4[];
  74494. flat?: boolean;
  74495. updatable?: boolean;
  74496. sideOrientation?: number;
  74497. frontUVs?: Vector4;
  74498. backUVs?: Vector4;
  74499. }, scene?: Nullable<Scene>): Mesh;
  74500. /**
  74501. * Creates a decal mesh.
  74502. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  74503. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  74504. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  74505. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  74506. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  74507. * @param name defines the name of the mesh
  74508. * @param sourceMesh defines the mesh where the decal must be applied
  74509. * @param options defines the options used to create the mesh
  74510. * @param scene defines the hosting scene
  74511. * @returns the decal mesh
  74512. * @see https://doc.babylonjs.com/how_to/decals
  74513. */
  74514. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  74515. position?: Vector3;
  74516. normal?: Vector3;
  74517. size?: Vector3;
  74518. angle?: number;
  74519. }): Mesh;
  74520. /**
  74521. * Creates a Capsule Mesh
  74522. * @param name defines the name of the mesh.
  74523. * @param options the constructors options used to shape the mesh.
  74524. * @param scene defines the scene the mesh is scoped to.
  74525. * @returns the capsule mesh
  74526. * @see https://doc.babylonjs.com/how_to/capsule_shape
  74527. */
  74528. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  74529. }
  74530. }
  74531. declare module "babylonjs/Meshes/meshSimplification" {
  74532. import { Mesh } from "babylonjs/Meshes/mesh";
  74533. /**
  74534. * A simplifier interface for future simplification implementations
  74535. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74536. */
  74537. export interface ISimplifier {
  74538. /**
  74539. * Simplification of a given mesh according to the given settings.
  74540. * Since this requires computation, it is assumed that the function runs async.
  74541. * @param settings The settings of the simplification, including quality and distance
  74542. * @param successCallback A callback that will be called after the mesh was simplified.
  74543. * @param errorCallback in case of an error, this callback will be called. optional.
  74544. */
  74545. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  74546. }
  74547. /**
  74548. * Expected simplification settings.
  74549. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  74550. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74551. */
  74552. export interface ISimplificationSettings {
  74553. /**
  74554. * Gets or sets the expected quality
  74555. */
  74556. quality: number;
  74557. /**
  74558. * Gets or sets the distance when this optimized version should be used
  74559. */
  74560. distance: number;
  74561. /**
  74562. * Gets an already optimized mesh
  74563. */
  74564. optimizeMesh?: boolean;
  74565. }
  74566. /**
  74567. * Class used to specify simplification options
  74568. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74569. */
  74570. export class SimplificationSettings implements ISimplificationSettings {
  74571. /** expected quality */
  74572. quality: number;
  74573. /** distance when this optimized version should be used */
  74574. distance: number;
  74575. /** already optimized mesh */
  74576. optimizeMesh?: boolean | undefined;
  74577. /**
  74578. * Creates a SimplificationSettings
  74579. * @param quality expected quality
  74580. * @param distance distance when this optimized version should be used
  74581. * @param optimizeMesh already optimized mesh
  74582. */
  74583. constructor(
  74584. /** expected quality */
  74585. quality: number,
  74586. /** distance when this optimized version should be used */
  74587. distance: number,
  74588. /** already optimized mesh */
  74589. optimizeMesh?: boolean | undefined);
  74590. }
  74591. /**
  74592. * Interface used to define a simplification task
  74593. */
  74594. export interface ISimplificationTask {
  74595. /**
  74596. * Array of settings
  74597. */
  74598. settings: Array<ISimplificationSettings>;
  74599. /**
  74600. * Simplification type
  74601. */
  74602. simplificationType: SimplificationType;
  74603. /**
  74604. * Mesh to simplify
  74605. */
  74606. mesh: Mesh;
  74607. /**
  74608. * Callback called on success
  74609. */
  74610. successCallback?: () => void;
  74611. /**
  74612. * Defines if parallel processing can be used
  74613. */
  74614. parallelProcessing: boolean;
  74615. }
  74616. /**
  74617. * Queue used to order the simplification tasks
  74618. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74619. */
  74620. export class SimplificationQueue {
  74621. private _simplificationArray;
  74622. /**
  74623. * Gets a boolean indicating that the process is still running
  74624. */
  74625. running: boolean;
  74626. /**
  74627. * Creates a new queue
  74628. */
  74629. constructor();
  74630. /**
  74631. * Adds a new simplification task
  74632. * @param task defines a task to add
  74633. */
  74634. addTask(task: ISimplificationTask): void;
  74635. /**
  74636. * Execute next task
  74637. */
  74638. executeNext(): void;
  74639. /**
  74640. * Execute a simplification task
  74641. * @param task defines the task to run
  74642. */
  74643. runSimplification(task: ISimplificationTask): void;
  74644. private getSimplifier;
  74645. }
  74646. /**
  74647. * The implemented types of simplification
  74648. * At the moment only Quadratic Error Decimation is implemented
  74649. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74650. */
  74651. export enum SimplificationType {
  74652. /** Quadratic error decimation */
  74653. QUADRATIC = 0
  74654. }
  74655. /**
  74656. * An implementation of the Quadratic Error simplification algorithm.
  74657. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  74658. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  74659. * @author RaananW
  74660. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74661. */
  74662. export class QuadraticErrorSimplification implements ISimplifier {
  74663. private _mesh;
  74664. private triangles;
  74665. private vertices;
  74666. private references;
  74667. private _reconstructedMesh;
  74668. /** Gets or sets the number pf sync interations */
  74669. syncIterations: number;
  74670. /** Gets or sets the aggressiveness of the simplifier */
  74671. aggressiveness: number;
  74672. /** Gets or sets the number of allowed iterations for decimation */
  74673. decimationIterations: number;
  74674. /** Gets or sets the espilon to use for bounding box computation */
  74675. boundingBoxEpsilon: number;
  74676. /**
  74677. * Creates a new QuadraticErrorSimplification
  74678. * @param _mesh defines the target mesh
  74679. */
  74680. constructor(_mesh: Mesh);
  74681. /**
  74682. * Simplification of a given mesh according to the given settings.
  74683. * Since this requires computation, it is assumed that the function runs async.
  74684. * @param settings The settings of the simplification, including quality and distance
  74685. * @param successCallback A callback that will be called after the mesh was simplified.
  74686. */
  74687. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  74688. private runDecimation;
  74689. private initWithMesh;
  74690. private init;
  74691. private reconstructMesh;
  74692. private initDecimatedMesh;
  74693. private isFlipped;
  74694. private updateTriangles;
  74695. private identifyBorder;
  74696. private updateMesh;
  74697. private vertexError;
  74698. private calculateError;
  74699. }
  74700. }
  74701. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  74702. import { Scene } from "babylonjs/scene";
  74703. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  74704. import { ISceneComponent } from "babylonjs/sceneComponent";
  74705. module "babylonjs/scene" {
  74706. interface Scene {
  74707. /** @hidden (Backing field) */
  74708. _simplificationQueue: SimplificationQueue;
  74709. /**
  74710. * Gets or sets the simplification queue attached to the scene
  74711. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74712. */
  74713. simplificationQueue: SimplificationQueue;
  74714. }
  74715. }
  74716. module "babylonjs/Meshes/mesh" {
  74717. interface Mesh {
  74718. /**
  74719. * Simplify the mesh according to the given array of settings.
  74720. * Function will return immediately and will simplify async
  74721. * @param settings a collection of simplification settings
  74722. * @param parallelProcessing should all levels calculate parallel or one after the other
  74723. * @param simplificationType the type of simplification to run
  74724. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  74725. * @returns the current mesh
  74726. */
  74727. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  74728. }
  74729. }
  74730. /**
  74731. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  74732. * created in a scene
  74733. */
  74734. export class SimplicationQueueSceneComponent implements ISceneComponent {
  74735. /**
  74736. * The component name helpfull to identify the component in the list of scene components.
  74737. */
  74738. readonly name: string;
  74739. /**
  74740. * The scene the component belongs to.
  74741. */
  74742. scene: Scene;
  74743. /**
  74744. * Creates a new instance of the component for the given scene
  74745. * @param scene Defines the scene to register the component in
  74746. */
  74747. constructor(scene: Scene);
  74748. /**
  74749. * Registers the component in a given scene
  74750. */
  74751. register(): void;
  74752. /**
  74753. * Rebuilds the elements related to this component in case of
  74754. * context lost for instance.
  74755. */
  74756. rebuild(): void;
  74757. /**
  74758. * Disposes the component and the associated ressources
  74759. */
  74760. dispose(): void;
  74761. private _beforeCameraUpdate;
  74762. }
  74763. }
  74764. declare module "babylonjs/Meshes/Builders/index" {
  74765. export * from "babylonjs/Meshes/Builders/boxBuilder";
  74766. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  74767. export * from "babylonjs/Meshes/Builders/discBuilder";
  74768. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  74769. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  74770. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  74771. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  74772. export * from "babylonjs/Meshes/Builders/torusBuilder";
  74773. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  74774. export * from "babylonjs/Meshes/Builders/linesBuilder";
  74775. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  74776. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  74777. export * from "babylonjs/Meshes/Builders/latheBuilder";
  74778. export * from "babylonjs/Meshes/Builders/planeBuilder";
  74779. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  74780. export * from "babylonjs/Meshes/Builders/groundBuilder";
  74781. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  74782. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  74783. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74784. export * from "babylonjs/Meshes/Builders/decalBuilder";
  74785. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74786. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  74787. }
  74788. declare module "babylonjs/Meshes/thinInstanceMesh" {
  74789. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  74790. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  74791. import { Matrix } from "babylonjs/Maths/math.vector";
  74792. module "babylonjs/Meshes/mesh" {
  74793. interface Mesh {
  74794. /**
  74795. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  74796. */
  74797. thinInstanceEnablePicking: boolean;
  74798. /**
  74799. * Creates a new thin instance
  74800. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  74801. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  74802. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  74803. */
  74804. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  74805. /**
  74806. * Adds the transformation (matrix) of the current mesh as a thin instance
  74807. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  74808. * @returns the thin instance index number
  74809. */
  74810. thinInstanceAddSelf(refresh: boolean): number;
  74811. /**
  74812. * Registers a custom attribute to be used with thin instances
  74813. * @param kind name of the attribute
  74814. * @param stride size in floats of the attribute
  74815. */
  74816. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  74817. /**
  74818. * Sets the matrix of a thin instance
  74819. * @param index index of the thin instance
  74820. * @param matrix matrix to set
  74821. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  74822. */
  74823. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  74824. /**
  74825. * Sets the value of a custom attribute for a thin instance
  74826. * @param kind name of the attribute
  74827. * @param index index of the thin instance
  74828. * @param value value to set
  74829. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  74830. */
  74831. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  74832. /**
  74833. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  74834. */
  74835. thinInstanceCount: number;
  74836. /**
  74837. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  74838. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  74839. * @param buffer buffer to set
  74840. * @param stride size in floats of each value of the buffer
  74841. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  74842. */
  74843. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  74844. /**
  74845. * Gets the list of world matrices
  74846. * @return an array containing all the world matrices from the thin instances
  74847. */
  74848. thinInstanceGetWorldMatrices(): Matrix[];
  74849. /**
  74850. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  74851. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74852. */
  74853. thinInstanceBufferUpdated(kind: string): void;
  74854. /**
  74855. * Applies a partial update to a buffer directly on the GPU
  74856. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  74857. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74858. * @param data the data to set in the GPU buffer
  74859. * @param offset the offset in the GPU buffer where to update the data
  74860. */
  74861. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  74862. /**
  74863. * Refreshes the bounding info, taking into account all the thin instances defined
  74864. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  74865. */
  74866. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  74867. /** @hidden */
  74868. _thinInstanceInitializeUserStorage(): void;
  74869. /** @hidden */
  74870. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  74871. /** @hidden */
  74872. _userThinInstanceBuffersStorage: {
  74873. data: {
  74874. [key: string]: Float32Array;
  74875. };
  74876. sizes: {
  74877. [key: string]: number;
  74878. };
  74879. vertexBuffers: {
  74880. [key: string]: Nullable<VertexBuffer>;
  74881. };
  74882. strides: {
  74883. [key: string]: number;
  74884. };
  74885. };
  74886. }
  74887. }
  74888. }
  74889. declare module "babylonjs/Meshes/index" {
  74890. export * from "babylonjs/Meshes/abstractMesh";
  74891. export * from "babylonjs/Meshes/buffer";
  74892. export * from "babylonjs/Meshes/Compression/index";
  74893. export * from "babylonjs/Meshes/csg";
  74894. export * from "babylonjs/Meshes/geometry";
  74895. export * from "babylonjs/Meshes/groundMesh";
  74896. export * from "babylonjs/Meshes/trailMesh";
  74897. export * from "babylonjs/Meshes/instancedMesh";
  74898. export * from "babylonjs/Meshes/linesMesh";
  74899. export * from "babylonjs/Meshes/mesh";
  74900. export * from "babylonjs/Meshes/mesh.vertexData";
  74901. export * from "babylonjs/Meshes/meshBuilder";
  74902. export * from "babylonjs/Meshes/meshSimplification";
  74903. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  74904. export * from "babylonjs/Meshes/polygonMesh";
  74905. export * from "babylonjs/Meshes/subMesh";
  74906. export * from "babylonjs/Meshes/meshLODLevel";
  74907. export * from "babylonjs/Meshes/transformNode";
  74908. export * from "babylonjs/Meshes/Builders/index";
  74909. export * from "babylonjs/Meshes/dataBuffer";
  74910. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  74911. export * from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  74912. import "babylonjs/Meshes/thinInstanceMesh";
  74913. export * from "babylonjs/Meshes/thinInstanceMesh";
  74914. }
  74915. declare module "babylonjs/Morph/index" {
  74916. export * from "babylonjs/Morph/morphTarget";
  74917. export * from "babylonjs/Morph/morphTargetManager";
  74918. }
  74919. declare module "babylonjs/Navigation/INavigationEngine" {
  74920. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74921. import { Vector3 } from "babylonjs/Maths/math";
  74922. import { Mesh } from "babylonjs/Meshes/mesh";
  74923. import { Scene } from "babylonjs/scene";
  74924. /**
  74925. * Navigation plugin interface to add navigation constrained by a navigation mesh
  74926. */
  74927. export interface INavigationEnginePlugin {
  74928. /**
  74929. * plugin name
  74930. */
  74931. name: string;
  74932. /**
  74933. * Creates a navigation mesh
  74934. * @param meshes array of all the geometry used to compute the navigatio mesh
  74935. * @param parameters bunch of parameters used to filter geometry
  74936. */
  74937. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  74938. /**
  74939. * Create a navigation mesh debug mesh
  74940. * @param scene is where the mesh will be added
  74941. * @returns debug display mesh
  74942. */
  74943. createDebugNavMesh(scene: Scene): Mesh;
  74944. /**
  74945. * Get a navigation mesh constrained position, closest to the parameter position
  74946. * @param position world position
  74947. * @returns the closest point to position constrained by the navigation mesh
  74948. */
  74949. getClosestPoint(position: Vector3): Vector3;
  74950. /**
  74951. * Get a navigation mesh constrained position, closest to the parameter position
  74952. * @param position world position
  74953. * @param result output the closest point to position constrained by the navigation mesh
  74954. */
  74955. getClosestPointToRef(position: Vector3, result: Vector3): void;
  74956. /**
  74957. * Get a navigation mesh constrained position, within a particular radius
  74958. * @param position world position
  74959. * @param maxRadius the maximum distance to the constrained world position
  74960. * @returns the closest point to position constrained by the navigation mesh
  74961. */
  74962. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  74963. /**
  74964. * Get a navigation mesh constrained position, within a particular radius
  74965. * @param position world position
  74966. * @param maxRadius the maximum distance to the constrained world position
  74967. * @param result output the closest point to position constrained by the navigation mesh
  74968. */
  74969. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  74970. /**
  74971. * Compute the final position from a segment made of destination-position
  74972. * @param position world position
  74973. * @param destination world position
  74974. * @returns the resulting point along the navmesh
  74975. */
  74976. moveAlong(position: Vector3, destination: Vector3): Vector3;
  74977. /**
  74978. * Compute the final position from a segment made of destination-position
  74979. * @param position world position
  74980. * @param destination world position
  74981. * @param result output the resulting point along the navmesh
  74982. */
  74983. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  74984. /**
  74985. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  74986. * @param start world position
  74987. * @param end world position
  74988. * @returns array containing world position composing the path
  74989. */
  74990. computePath(start: Vector3, end: Vector3): Vector3[];
  74991. /**
  74992. * If this plugin is supported
  74993. * @returns true if plugin is supported
  74994. */
  74995. isSupported(): boolean;
  74996. /**
  74997. * Create a new Crowd so you can add agents
  74998. * @param maxAgents the maximum agent count in the crowd
  74999. * @param maxAgentRadius the maximum radius an agent can have
  75000. * @param scene to attach the crowd to
  75001. * @returns the crowd you can add agents to
  75002. */
  75003. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  75004. /**
  75005. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75006. * The queries will try to find a solution within those bounds
  75007. * default is (1,1,1)
  75008. * @param extent x,y,z value that define the extent around the queries point of reference
  75009. */
  75010. setDefaultQueryExtent(extent: Vector3): void;
  75011. /**
  75012. * Get the Bounding box extent specified by setDefaultQueryExtent
  75013. * @returns the box extent values
  75014. */
  75015. getDefaultQueryExtent(): Vector3;
  75016. /**
  75017. * build the navmesh from a previously saved state using getNavmeshData
  75018. * @param data the Uint8Array returned by getNavmeshData
  75019. */
  75020. buildFromNavmeshData(data: Uint8Array): void;
  75021. /**
  75022. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  75023. * @returns data the Uint8Array that can be saved and reused
  75024. */
  75025. getNavmeshData(): Uint8Array;
  75026. /**
  75027. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75028. * @param result output the box extent values
  75029. */
  75030. getDefaultQueryExtentToRef(result: Vector3): void;
  75031. /**
  75032. * Set the time step of the navigation tick update.
  75033. * Default is 1/60.
  75034. * A value of 0 will disable fixed time update
  75035. * @param newTimeStep the new timestep to apply to this world.
  75036. */
  75037. setTimeStep(newTimeStep: number): void;
  75038. /**
  75039. * Get the time step of the navigation tick update.
  75040. * @returns the current time step
  75041. */
  75042. getTimeStep(): number;
  75043. /**
  75044. * If delta time in navigation tick update is greater than the time step
  75045. * a number of sub iterations are done. If more iterations are need to reach deltatime
  75046. * they will be discarded.
  75047. * A value of 0 will set to no maximum and update will use as many substeps as needed
  75048. * @param newStepCount the maximum number of iterations
  75049. */
  75050. setMaximumSubStepCount(newStepCount: number): void;
  75051. /**
  75052. * Get the maximum number of iterations per navigation tick update
  75053. * @returns the maximum number of iterations
  75054. */
  75055. getMaximumSubStepCount(): number;
  75056. /**
  75057. * Release all resources
  75058. */
  75059. dispose(): void;
  75060. }
  75061. /**
  75062. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  75063. */
  75064. export interface ICrowd {
  75065. /**
  75066. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  75067. * You can attach anything to that node. The node position is updated in the scene update tick.
  75068. * @param pos world position that will be constrained by the navigation mesh
  75069. * @param parameters agent parameters
  75070. * @param transform hooked to the agent that will be update by the scene
  75071. * @returns agent index
  75072. */
  75073. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  75074. /**
  75075. * Returns the agent position in world space
  75076. * @param index agent index returned by addAgent
  75077. * @returns world space position
  75078. */
  75079. getAgentPosition(index: number): Vector3;
  75080. /**
  75081. * Gets the agent position result in world space
  75082. * @param index agent index returned by addAgent
  75083. * @param result output world space position
  75084. */
  75085. getAgentPositionToRef(index: number, result: Vector3): void;
  75086. /**
  75087. * Gets the agent velocity in world space
  75088. * @param index agent index returned by addAgent
  75089. * @returns world space velocity
  75090. */
  75091. getAgentVelocity(index: number): Vector3;
  75092. /**
  75093. * Gets the agent velocity result in world space
  75094. * @param index agent index returned by addAgent
  75095. * @param result output world space velocity
  75096. */
  75097. getAgentVelocityToRef(index: number, result: Vector3): void;
  75098. /**
  75099. * Gets the agent next target point on the path
  75100. * @param index agent index returned by addAgent
  75101. * @returns world space position
  75102. */
  75103. getAgentNextTargetPath(index: number): Vector3;
  75104. /**
  75105. * Gets the agent state
  75106. * @param index agent index returned by addAgent
  75107. * @returns agent state
  75108. */
  75109. getAgentState(index: number): number;
  75110. /**
  75111. * returns true if the agent in over an off mesh link connection
  75112. * @param index agent index returned by addAgent
  75113. * @returns true if over an off mesh link connection
  75114. */
  75115. overOffmeshConnection(index: number): boolean;
  75116. /**
  75117. * Gets the agent next target point on the path
  75118. * @param index agent index returned by addAgent
  75119. * @param result output world space position
  75120. */
  75121. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75122. /**
  75123. * remove a particular agent previously created
  75124. * @param index agent index returned by addAgent
  75125. */
  75126. removeAgent(index: number): void;
  75127. /**
  75128. * get the list of all agents attached to this crowd
  75129. * @returns list of agent indices
  75130. */
  75131. getAgents(): number[];
  75132. /**
  75133. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  75134. * @param deltaTime in seconds
  75135. */
  75136. update(deltaTime: number): void;
  75137. /**
  75138. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75139. * @param index agent index returned by addAgent
  75140. * @param destination targeted world position
  75141. */
  75142. agentGoto(index: number, destination: Vector3): void;
  75143. /**
  75144. * Teleport the agent to a new position
  75145. * @param index agent index returned by addAgent
  75146. * @param destination targeted world position
  75147. */
  75148. agentTeleport(index: number, destination: Vector3): void;
  75149. /**
  75150. * Update agent parameters
  75151. * @param index agent index returned by addAgent
  75152. * @param parameters agent parameters
  75153. */
  75154. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75155. /**
  75156. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75157. * The queries will try to find a solution within those bounds
  75158. * default is (1,1,1)
  75159. * @param extent x,y,z value that define the extent around the queries point of reference
  75160. */
  75161. setDefaultQueryExtent(extent: Vector3): void;
  75162. /**
  75163. * Get the Bounding box extent specified by setDefaultQueryExtent
  75164. * @returns the box extent values
  75165. */
  75166. getDefaultQueryExtent(): Vector3;
  75167. /**
  75168. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75169. * @param result output the box extent values
  75170. */
  75171. getDefaultQueryExtentToRef(result: Vector3): void;
  75172. /**
  75173. * Release all resources
  75174. */
  75175. dispose(): void;
  75176. }
  75177. /**
  75178. * Configures an agent
  75179. */
  75180. export interface IAgentParameters {
  75181. /**
  75182. * Agent radius. [Limit: >= 0]
  75183. */
  75184. radius: number;
  75185. /**
  75186. * Agent height. [Limit: > 0]
  75187. */
  75188. height: number;
  75189. /**
  75190. * Maximum allowed acceleration. [Limit: >= 0]
  75191. */
  75192. maxAcceleration: number;
  75193. /**
  75194. * Maximum allowed speed. [Limit: >= 0]
  75195. */
  75196. maxSpeed: number;
  75197. /**
  75198. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  75199. */
  75200. collisionQueryRange: number;
  75201. /**
  75202. * The path visibility optimization range. [Limit: > 0]
  75203. */
  75204. pathOptimizationRange: number;
  75205. /**
  75206. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  75207. */
  75208. separationWeight: number;
  75209. }
  75210. /**
  75211. * Configures the navigation mesh creation
  75212. */
  75213. export interface INavMeshParameters {
  75214. /**
  75215. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  75216. */
  75217. cs: number;
  75218. /**
  75219. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  75220. */
  75221. ch: number;
  75222. /**
  75223. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  75224. */
  75225. walkableSlopeAngle: number;
  75226. /**
  75227. * Minimum floor to 'ceiling' height that will still allow the floor area to
  75228. * be considered walkable. [Limit: >= 3] [Units: vx]
  75229. */
  75230. walkableHeight: number;
  75231. /**
  75232. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  75233. */
  75234. walkableClimb: number;
  75235. /**
  75236. * The distance to erode/shrink the walkable area of the heightfield away from
  75237. * obstructions. [Limit: >=0] [Units: vx]
  75238. */
  75239. walkableRadius: number;
  75240. /**
  75241. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  75242. */
  75243. maxEdgeLen: number;
  75244. /**
  75245. * The maximum distance a simplfied contour's border edges should deviate
  75246. * the original raw contour. [Limit: >=0] [Units: vx]
  75247. */
  75248. maxSimplificationError: number;
  75249. /**
  75250. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  75251. */
  75252. minRegionArea: number;
  75253. /**
  75254. * Any regions with a span count smaller than this value will, if possible,
  75255. * be merged with larger regions. [Limit: >=0] [Units: vx]
  75256. */
  75257. mergeRegionArea: number;
  75258. /**
  75259. * The maximum number of vertices allowed for polygons generated during the
  75260. * contour to polygon conversion process. [Limit: >= 3]
  75261. */
  75262. maxVertsPerPoly: number;
  75263. /**
  75264. * Sets the sampling distance to use when generating the detail mesh.
  75265. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  75266. */
  75267. detailSampleDist: number;
  75268. /**
  75269. * The maximum distance the detail mesh surface should deviate from heightfield
  75270. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  75271. */
  75272. detailSampleMaxError: number;
  75273. }
  75274. }
  75275. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  75276. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  75277. import { Mesh } from "babylonjs/Meshes/mesh";
  75278. import { Scene } from "babylonjs/scene";
  75279. import { Vector3 } from "babylonjs/Maths/math";
  75280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75281. /**
  75282. * RecastJS navigation plugin
  75283. */
  75284. export class RecastJSPlugin implements INavigationEnginePlugin {
  75285. /**
  75286. * Reference to the Recast library
  75287. */
  75288. bjsRECAST: any;
  75289. /**
  75290. * plugin name
  75291. */
  75292. name: string;
  75293. /**
  75294. * the first navmesh created. We might extend this to support multiple navmeshes
  75295. */
  75296. navMesh: any;
  75297. private _maximumSubStepCount;
  75298. private _timeStep;
  75299. /**
  75300. * Initializes the recastJS plugin
  75301. * @param recastInjection can be used to inject your own recast reference
  75302. */
  75303. constructor(recastInjection?: any);
  75304. /**
  75305. * Set the time step of the navigation tick update.
  75306. * Default is 1/60.
  75307. * A value of 0 will disable fixed time update
  75308. * @param newTimeStep the new timestep to apply to this world.
  75309. */
  75310. setTimeStep(newTimeStep?: number): void;
  75311. /**
  75312. * Get the time step of the navigation tick update.
  75313. * @returns the current time step
  75314. */
  75315. getTimeStep(): number;
  75316. /**
  75317. * If delta time in navigation tick update is greater than the time step
  75318. * a number of sub iterations are done. If more iterations are need to reach deltatime
  75319. * they will be discarded.
  75320. * A value of 0 will set to no maximum and update will use as many substeps as needed
  75321. * @param newStepCount the maximum number of iterations
  75322. */
  75323. setMaximumSubStepCount(newStepCount?: number): void;
  75324. /**
  75325. * Get the maximum number of iterations per navigation tick update
  75326. * @returns the maximum number of iterations
  75327. */
  75328. getMaximumSubStepCount(): number;
  75329. /**
  75330. * Creates a navigation mesh
  75331. * @param meshes array of all the geometry used to compute the navigatio mesh
  75332. * @param parameters bunch of parameters used to filter geometry
  75333. */
  75334. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  75335. /**
  75336. * Create a navigation mesh debug mesh
  75337. * @param scene is where the mesh will be added
  75338. * @returns debug display mesh
  75339. */
  75340. createDebugNavMesh(scene: Scene): Mesh;
  75341. /**
  75342. * Get a navigation mesh constrained position, closest to the parameter position
  75343. * @param position world position
  75344. * @returns the closest point to position constrained by the navigation mesh
  75345. */
  75346. getClosestPoint(position: Vector3): Vector3;
  75347. /**
  75348. * Get a navigation mesh constrained position, closest to the parameter position
  75349. * @param position world position
  75350. * @param result output the closest point to position constrained by the navigation mesh
  75351. */
  75352. getClosestPointToRef(position: Vector3, result: Vector3): void;
  75353. /**
  75354. * Get a navigation mesh constrained position, within a particular radius
  75355. * @param position world position
  75356. * @param maxRadius the maximum distance to the constrained world position
  75357. * @returns the closest point to position constrained by the navigation mesh
  75358. */
  75359. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  75360. /**
  75361. * Get a navigation mesh constrained position, within a particular radius
  75362. * @param position world position
  75363. * @param maxRadius the maximum distance to the constrained world position
  75364. * @param result output the closest point to position constrained by the navigation mesh
  75365. */
  75366. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  75367. /**
  75368. * Compute the final position from a segment made of destination-position
  75369. * @param position world position
  75370. * @param destination world position
  75371. * @returns the resulting point along the navmesh
  75372. */
  75373. moveAlong(position: Vector3, destination: Vector3): Vector3;
  75374. /**
  75375. * Compute the final position from a segment made of destination-position
  75376. * @param position world position
  75377. * @param destination world position
  75378. * @param result output the resulting point along the navmesh
  75379. */
  75380. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  75381. /**
  75382. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  75383. * @param start world position
  75384. * @param end world position
  75385. * @returns array containing world position composing the path
  75386. */
  75387. computePath(start: Vector3, end: Vector3): Vector3[];
  75388. /**
  75389. * Create a new Crowd so you can add agents
  75390. * @param maxAgents the maximum agent count in the crowd
  75391. * @param maxAgentRadius the maximum radius an agent can have
  75392. * @param scene to attach the crowd to
  75393. * @returns the crowd you can add agents to
  75394. */
  75395. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  75396. /**
  75397. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75398. * The queries will try to find a solution within those bounds
  75399. * default is (1,1,1)
  75400. * @param extent x,y,z value that define the extent around the queries point of reference
  75401. */
  75402. setDefaultQueryExtent(extent: Vector3): void;
  75403. /**
  75404. * Get the Bounding box extent specified by setDefaultQueryExtent
  75405. * @returns the box extent values
  75406. */
  75407. getDefaultQueryExtent(): Vector3;
  75408. /**
  75409. * build the navmesh from a previously saved state using getNavmeshData
  75410. * @param data the Uint8Array returned by getNavmeshData
  75411. */
  75412. buildFromNavmeshData(data: Uint8Array): void;
  75413. /**
  75414. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  75415. * @returns data the Uint8Array that can be saved and reused
  75416. */
  75417. getNavmeshData(): Uint8Array;
  75418. /**
  75419. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75420. * @param result output the box extent values
  75421. */
  75422. getDefaultQueryExtentToRef(result: Vector3): void;
  75423. /**
  75424. * Disposes
  75425. */
  75426. dispose(): void;
  75427. /**
  75428. * If this plugin is supported
  75429. * @returns true if plugin is supported
  75430. */
  75431. isSupported(): boolean;
  75432. }
  75433. /**
  75434. * Recast detour crowd implementation
  75435. */
  75436. export class RecastJSCrowd implements ICrowd {
  75437. /**
  75438. * Recast/detour plugin
  75439. */
  75440. bjsRECASTPlugin: RecastJSPlugin;
  75441. /**
  75442. * Link to the detour crowd
  75443. */
  75444. recastCrowd: any;
  75445. /**
  75446. * One transform per agent
  75447. */
  75448. transforms: TransformNode[];
  75449. /**
  75450. * All agents created
  75451. */
  75452. agents: number[];
  75453. /**
  75454. * Link to the scene is kept to unregister the crowd from the scene
  75455. */
  75456. private _scene;
  75457. /**
  75458. * Observer for crowd updates
  75459. */
  75460. private _onBeforeAnimationsObserver;
  75461. /**
  75462. * Constructor
  75463. * @param plugin recastJS plugin
  75464. * @param maxAgents the maximum agent count in the crowd
  75465. * @param maxAgentRadius the maximum radius an agent can have
  75466. * @param scene to attach the crowd to
  75467. * @returns the crowd you can add agents to
  75468. */
  75469. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  75470. /**
  75471. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  75472. * You can attach anything to that node. The node position is updated in the scene update tick.
  75473. * @param pos world position that will be constrained by the navigation mesh
  75474. * @param parameters agent parameters
  75475. * @param transform hooked to the agent that will be update by the scene
  75476. * @returns agent index
  75477. */
  75478. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  75479. /**
  75480. * Returns the agent position in world space
  75481. * @param index agent index returned by addAgent
  75482. * @returns world space position
  75483. */
  75484. getAgentPosition(index: number): Vector3;
  75485. /**
  75486. * Returns the agent position result in world space
  75487. * @param index agent index returned by addAgent
  75488. * @param result output world space position
  75489. */
  75490. getAgentPositionToRef(index: number, result: Vector3): void;
  75491. /**
  75492. * Returns the agent velocity in world space
  75493. * @param index agent index returned by addAgent
  75494. * @returns world space velocity
  75495. */
  75496. getAgentVelocity(index: number): Vector3;
  75497. /**
  75498. * Returns the agent velocity result in world space
  75499. * @param index agent index returned by addAgent
  75500. * @param result output world space velocity
  75501. */
  75502. getAgentVelocityToRef(index: number, result: Vector3): void;
  75503. /**
  75504. * Returns the agent next target point on the path
  75505. * @param index agent index returned by addAgent
  75506. * @returns world space position
  75507. */
  75508. getAgentNextTargetPath(index: number): Vector3;
  75509. /**
  75510. * Returns the agent next target point on the path
  75511. * @param index agent index returned by addAgent
  75512. * @param result output world space position
  75513. */
  75514. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75515. /**
  75516. * Gets the agent state
  75517. * @param index agent index returned by addAgent
  75518. * @returns agent state
  75519. */
  75520. getAgentState(index: number): number;
  75521. /**
  75522. * returns true if the agent in over an off mesh link connection
  75523. * @param index agent index returned by addAgent
  75524. * @returns true if over an off mesh link connection
  75525. */
  75526. overOffmeshConnection(index: number): boolean;
  75527. /**
  75528. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75529. * @param index agent index returned by addAgent
  75530. * @param destination targeted world position
  75531. */
  75532. agentGoto(index: number, destination: Vector3): void;
  75533. /**
  75534. * Teleport the agent to a new position
  75535. * @param index agent index returned by addAgent
  75536. * @param destination targeted world position
  75537. */
  75538. agentTeleport(index: number, destination: Vector3): void;
  75539. /**
  75540. * Update agent parameters
  75541. * @param index agent index returned by addAgent
  75542. * @param parameters agent parameters
  75543. */
  75544. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75545. /**
  75546. * remove a particular agent previously created
  75547. * @param index agent index returned by addAgent
  75548. */
  75549. removeAgent(index: number): void;
  75550. /**
  75551. * get the list of all agents attached to this crowd
  75552. * @returns list of agent indices
  75553. */
  75554. getAgents(): number[];
  75555. /**
  75556. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  75557. * @param deltaTime in seconds
  75558. */
  75559. update(deltaTime: number): void;
  75560. /**
  75561. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75562. * The queries will try to find a solution within those bounds
  75563. * default is (1,1,1)
  75564. * @param extent x,y,z value that define the extent around the queries point of reference
  75565. */
  75566. setDefaultQueryExtent(extent: Vector3): void;
  75567. /**
  75568. * Get the Bounding box extent specified by setDefaultQueryExtent
  75569. * @returns the box extent values
  75570. */
  75571. getDefaultQueryExtent(): Vector3;
  75572. /**
  75573. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75574. * @param result output the box extent values
  75575. */
  75576. getDefaultQueryExtentToRef(result: Vector3): void;
  75577. /**
  75578. * Release all resources
  75579. */
  75580. dispose(): void;
  75581. }
  75582. }
  75583. declare module "babylonjs/Navigation/Plugins/index" {
  75584. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  75585. }
  75586. declare module "babylonjs/Navigation/index" {
  75587. export * from "babylonjs/Navigation/INavigationEngine";
  75588. export * from "babylonjs/Navigation/Plugins/index";
  75589. }
  75590. declare module "babylonjs/Offline/database" {
  75591. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  75592. /**
  75593. * Class used to enable access to IndexedDB
  75594. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75595. */
  75596. export class Database implements IOfflineProvider {
  75597. private _callbackManifestChecked;
  75598. private _currentSceneUrl;
  75599. private _db;
  75600. private _enableSceneOffline;
  75601. private _enableTexturesOffline;
  75602. private _manifestVersionFound;
  75603. private _mustUpdateRessources;
  75604. private _hasReachedQuota;
  75605. private _isSupported;
  75606. private _idbFactory;
  75607. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  75608. private static IsUASupportingBlobStorage;
  75609. /**
  75610. * Gets a boolean indicating if Database storate is enabled (off by default)
  75611. */
  75612. static IDBStorageEnabled: boolean;
  75613. /**
  75614. * Gets a boolean indicating if scene must be saved in the database
  75615. */
  75616. get enableSceneOffline(): boolean;
  75617. /**
  75618. * Gets a boolean indicating if textures must be saved in the database
  75619. */
  75620. get enableTexturesOffline(): boolean;
  75621. /**
  75622. * Creates a new Database
  75623. * @param urlToScene defines the url to load the scene
  75624. * @param callbackManifestChecked defines the callback to use when manifest is checked
  75625. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  75626. */
  75627. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  75628. private static _ParseURL;
  75629. private static _ReturnFullUrlLocation;
  75630. private _checkManifestFile;
  75631. /**
  75632. * Open the database and make it available
  75633. * @param successCallback defines the callback to call on success
  75634. * @param errorCallback defines the callback to call on error
  75635. */
  75636. open(successCallback: () => void, errorCallback: () => void): void;
  75637. /**
  75638. * Loads an image from the database
  75639. * @param url defines the url to load from
  75640. * @param image defines the target DOM image
  75641. */
  75642. loadImage(url: string, image: HTMLImageElement): void;
  75643. private _loadImageFromDBAsync;
  75644. private _saveImageIntoDBAsync;
  75645. private _checkVersionFromDB;
  75646. private _loadVersionFromDBAsync;
  75647. private _saveVersionIntoDBAsync;
  75648. /**
  75649. * Loads a file from database
  75650. * @param url defines the URL to load from
  75651. * @param sceneLoaded defines a callback to call on success
  75652. * @param progressCallBack defines a callback to call when progress changed
  75653. * @param errorCallback defines a callback to call on error
  75654. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75655. */
  75656. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75657. private _loadFileAsync;
  75658. private _saveFileAsync;
  75659. /**
  75660. * Validates if xhr data is correct
  75661. * @param xhr defines the request to validate
  75662. * @param dataType defines the expected data type
  75663. * @returns true if data is correct
  75664. */
  75665. private static _ValidateXHRData;
  75666. }
  75667. }
  75668. declare module "babylonjs/Offline/index" {
  75669. export * from "babylonjs/Offline/database";
  75670. export * from "babylonjs/Offline/IOfflineProvider";
  75671. }
  75672. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  75673. /** @hidden */
  75674. export var gpuUpdateParticlesPixelShader: {
  75675. name: string;
  75676. shader: string;
  75677. };
  75678. }
  75679. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  75680. /** @hidden */
  75681. export var gpuUpdateParticlesVertexShader: {
  75682. name: string;
  75683. shader: string;
  75684. };
  75685. }
  75686. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  75687. /** @hidden */
  75688. export var clipPlaneFragmentDeclaration2: {
  75689. name: string;
  75690. shader: string;
  75691. };
  75692. }
  75693. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  75694. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  75695. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  75696. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  75697. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  75698. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  75699. /** @hidden */
  75700. export var gpuRenderParticlesPixelShader: {
  75701. name: string;
  75702. shader: string;
  75703. };
  75704. }
  75705. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  75706. /** @hidden */
  75707. export var clipPlaneVertexDeclaration2: {
  75708. name: string;
  75709. shader: string;
  75710. };
  75711. }
  75712. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  75713. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  75714. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  75715. /** @hidden */
  75716. export var gpuRenderParticlesVertexShader: {
  75717. name: string;
  75718. shader: string;
  75719. };
  75720. }
  75721. declare module "babylonjs/Particles/gpuParticleSystem" {
  75722. import { Nullable } from "babylonjs/types";
  75723. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  75724. import { Observable } from "babylonjs/Misc/observable";
  75725. import { Matrix } from "babylonjs/Maths/math.vector";
  75726. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  75727. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75728. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  75729. import { IDisposable } from "babylonjs/scene";
  75730. import { Effect } from "babylonjs/Materials/effect";
  75731. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75732. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75733. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  75734. import { Scene } from "babylonjs/scene";
  75735. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  75736. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  75737. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  75738. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  75739. /**
  75740. * This represents a GPU particle system in Babylon
  75741. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  75742. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  75743. */
  75744. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  75745. /**
  75746. * The layer mask we are rendering the particles through.
  75747. */
  75748. layerMask: number;
  75749. private _capacity;
  75750. private _activeCount;
  75751. private _currentActiveCount;
  75752. private _accumulatedCount;
  75753. private _renderEffect;
  75754. private _updateEffect;
  75755. private _buffer0;
  75756. private _buffer1;
  75757. private _spriteBuffer;
  75758. private _updateVAO;
  75759. private _renderVAO;
  75760. private _targetIndex;
  75761. private _sourceBuffer;
  75762. private _targetBuffer;
  75763. private _currentRenderId;
  75764. private _started;
  75765. private _stopped;
  75766. private _timeDelta;
  75767. private _randomTexture;
  75768. private _randomTexture2;
  75769. private _attributesStrideSize;
  75770. private _updateEffectOptions;
  75771. private _randomTextureSize;
  75772. private _actualFrame;
  75773. private _customEffect;
  75774. private readonly _rawTextureWidth;
  75775. /**
  75776. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  75777. */
  75778. static get IsSupported(): boolean;
  75779. /**
  75780. * An event triggered when the system is disposed.
  75781. */
  75782. onDisposeObservable: Observable<IParticleSystem>;
  75783. /**
  75784. * An event triggered when the system is stopped
  75785. */
  75786. onStoppedObservable: Observable<IParticleSystem>;
  75787. /**
  75788. * Gets the maximum number of particles active at the same time.
  75789. * @returns The max number of active particles.
  75790. */
  75791. getCapacity(): number;
  75792. /**
  75793. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  75794. * to override the particles.
  75795. */
  75796. forceDepthWrite: boolean;
  75797. /**
  75798. * Gets or set the number of active particles
  75799. */
  75800. get activeParticleCount(): number;
  75801. set activeParticleCount(value: number);
  75802. private _preWarmDone;
  75803. /**
  75804. * Specifies if the particles are updated in emitter local space or world space.
  75805. */
  75806. isLocal: boolean;
  75807. /** Gets or sets a matrix to use to compute projection */
  75808. defaultProjectionMatrix: Matrix;
  75809. /**
  75810. * Is this system ready to be used/rendered
  75811. * @return true if the system is ready
  75812. */
  75813. isReady(): boolean;
  75814. /**
  75815. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75816. * @returns True if it has been started, otherwise false.
  75817. */
  75818. isStarted(): boolean;
  75819. /**
  75820. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  75821. * @returns True if it has been stopped, otherwise false.
  75822. */
  75823. isStopped(): boolean;
  75824. /**
  75825. * Gets a boolean indicating that the system is stopping
  75826. * @returns true if the system is currently stopping
  75827. */
  75828. isStopping(): boolean;
  75829. /**
  75830. * Gets the number of particles active at the same time.
  75831. * @returns The number of active particles.
  75832. */
  75833. getActiveCount(): number;
  75834. /**
  75835. * Starts the particle system and begins to emit
  75836. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75837. */
  75838. start(delay?: number): void;
  75839. /**
  75840. * Stops the particle system.
  75841. */
  75842. stop(): void;
  75843. /**
  75844. * Remove all active particles
  75845. */
  75846. reset(): void;
  75847. /**
  75848. * Returns the string "GPUParticleSystem"
  75849. * @returns a string containing the class name
  75850. */
  75851. getClassName(): string;
  75852. /**
  75853. * Gets the custom effect used to render the particles
  75854. * @param blendMode Blend mode for which the effect should be retrieved
  75855. * @returns The effect
  75856. */
  75857. getCustomEffect(blendMode?: number): Nullable<Effect>;
  75858. /**
  75859. * Sets the custom effect used to render the particles
  75860. * @param effect The effect to set
  75861. * @param blendMode Blend mode for which the effect should be set
  75862. */
  75863. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  75864. /** @hidden */
  75865. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  75866. /**
  75867. * Observable that will be called just before the particles are drawn
  75868. */
  75869. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  75870. /**
  75871. * Gets the name of the particle vertex shader
  75872. */
  75873. get vertexShaderName(): string;
  75874. private _colorGradientsTexture;
  75875. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  75876. /**
  75877. * Adds a new color gradient
  75878. * @param gradient defines the gradient to use (between 0 and 1)
  75879. * @param color1 defines the color to affect to the specified gradient
  75880. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75881. * @returns the current particle system
  75882. */
  75883. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  75884. private _refreshColorGradient;
  75885. /** Force the system to rebuild all gradients that need to be resync */
  75886. forceRefreshGradients(): void;
  75887. /**
  75888. * Remove a specific color gradient
  75889. * @param gradient defines the gradient to remove
  75890. * @returns the current particle system
  75891. */
  75892. removeColorGradient(gradient: number): GPUParticleSystem;
  75893. private _angularSpeedGradientsTexture;
  75894. private _sizeGradientsTexture;
  75895. private _velocityGradientsTexture;
  75896. private _limitVelocityGradientsTexture;
  75897. private _dragGradientsTexture;
  75898. private _addFactorGradient;
  75899. /**
  75900. * Adds a new size gradient
  75901. * @param gradient defines the gradient to use (between 0 and 1)
  75902. * @param factor defines the size factor to affect to the specified gradient
  75903. * @returns the current particle system
  75904. */
  75905. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  75906. /**
  75907. * Remove a specific size gradient
  75908. * @param gradient defines the gradient to remove
  75909. * @returns the current particle system
  75910. */
  75911. removeSizeGradient(gradient: number): GPUParticleSystem;
  75912. private _refreshFactorGradient;
  75913. /**
  75914. * Adds a new angular speed gradient
  75915. * @param gradient defines the gradient to use (between 0 and 1)
  75916. * @param factor defines the angular speed to affect to the specified gradient
  75917. * @returns the current particle system
  75918. */
  75919. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  75920. /**
  75921. * Remove a specific angular speed gradient
  75922. * @param gradient defines the gradient to remove
  75923. * @returns the current particle system
  75924. */
  75925. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  75926. /**
  75927. * Adds a new velocity gradient
  75928. * @param gradient defines the gradient to use (between 0 and 1)
  75929. * @param factor defines the velocity to affect to the specified gradient
  75930. * @returns the current particle system
  75931. */
  75932. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75933. /**
  75934. * Remove a specific velocity gradient
  75935. * @param gradient defines the gradient to remove
  75936. * @returns the current particle system
  75937. */
  75938. removeVelocityGradient(gradient: number): GPUParticleSystem;
  75939. /**
  75940. * Adds a new limit velocity gradient
  75941. * @param gradient defines the gradient to use (between 0 and 1)
  75942. * @param factor defines the limit velocity value to affect to the specified gradient
  75943. * @returns the current particle system
  75944. */
  75945. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75946. /**
  75947. * Remove a specific limit velocity gradient
  75948. * @param gradient defines the gradient to remove
  75949. * @returns the current particle system
  75950. */
  75951. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  75952. /**
  75953. * Adds a new drag gradient
  75954. * @param gradient defines the gradient to use (between 0 and 1)
  75955. * @param factor defines the drag value to affect to the specified gradient
  75956. * @returns the current particle system
  75957. */
  75958. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  75959. /**
  75960. * Remove a specific drag gradient
  75961. * @param gradient defines the gradient to remove
  75962. * @returns the current particle system
  75963. */
  75964. removeDragGradient(gradient: number): GPUParticleSystem;
  75965. /**
  75966. * Not supported by GPUParticleSystem
  75967. * @param gradient defines the gradient to use (between 0 and 1)
  75968. * @param factor defines the emit rate value to affect to the specified gradient
  75969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75970. * @returns the current particle system
  75971. */
  75972. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75973. /**
  75974. * Not supported by GPUParticleSystem
  75975. * @param gradient defines the gradient to remove
  75976. * @returns the current particle system
  75977. */
  75978. removeEmitRateGradient(gradient: number): IParticleSystem;
  75979. /**
  75980. * Not supported by GPUParticleSystem
  75981. * @param gradient defines the gradient to use (between 0 and 1)
  75982. * @param factor defines the start size value to affect to the specified gradient
  75983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75984. * @returns the current particle system
  75985. */
  75986. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75987. /**
  75988. * Not supported by GPUParticleSystem
  75989. * @param gradient defines the gradient to remove
  75990. * @returns the current particle system
  75991. */
  75992. removeStartSizeGradient(gradient: number): IParticleSystem;
  75993. /**
  75994. * Not supported by GPUParticleSystem
  75995. * @param gradient defines the gradient to use (between 0 and 1)
  75996. * @param min defines the color remap minimal range
  75997. * @param max defines the color remap maximal range
  75998. * @returns the current particle system
  75999. */
  76000. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76001. /**
  76002. * Not supported by GPUParticleSystem
  76003. * @param gradient defines the gradient to remove
  76004. * @returns the current particle system
  76005. */
  76006. removeColorRemapGradient(): IParticleSystem;
  76007. /**
  76008. * Not supported by GPUParticleSystem
  76009. * @param gradient defines the gradient to use (between 0 and 1)
  76010. * @param min defines the alpha remap minimal range
  76011. * @param max defines the alpha remap maximal range
  76012. * @returns the current particle system
  76013. */
  76014. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76015. /**
  76016. * Not supported by GPUParticleSystem
  76017. * @param gradient defines the gradient to remove
  76018. * @returns the current particle system
  76019. */
  76020. removeAlphaRemapGradient(): IParticleSystem;
  76021. /**
  76022. * Not supported by GPUParticleSystem
  76023. * @param gradient defines the gradient to use (between 0 and 1)
  76024. * @param color defines the color to affect to the specified gradient
  76025. * @returns the current particle system
  76026. */
  76027. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76028. /**
  76029. * Not supported by GPUParticleSystem
  76030. * @param gradient defines the gradient to remove
  76031. * @returns the current particle system
  76032. */
  76033. removeRampGradient(): IParticleSystem;
  76034. /**
  76035. * Not supported by GPUParticleSystem
  76036. * @returns the list of ramp gradients
  76037. */
  76038. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76039. /**
  76040. * Not supported by GPUParticleSystem
  76041. * Gets or sets a boolean indicating that ramp gradients must be used
  76042. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76043. */
  76044. get useRampGradients(): boolean;
  76045. set useRampGradients(value: boolean);
  76046. /**
  76047. * Not supported by GPUParticleSystem
  76048. * @param gradient defines the gradient to use (between 0 and 1)
  76049. * @param factor defines the life time factor to affect to the specified gradient
  76050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76051. * @returns the current particle system
  76052. */
  76053. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76054. /**
  76055. * Not supported by GPUParticleSystem
  76056. * @param gradient defines the gradient to remove
  76057. * @returns the current particle system
  76058. */
  76059. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76060. /**
  76061. * Instantiates a GPU particle system.
  76062. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  76063. * @param name The name of the particle system
  76064. * @param options The options used to create the system
  76065. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  76066. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  76067. * @param customEffect a custom effect used to change the way particles are rendered by default
  76068. */
  76069. constructor(name: string, options: Partial<{
  76070. capacity: number;
  76071. randomTextureSize: number;
  76072. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  76073. protected _reset(): void;
  76074. private _createUpdateVAO;
  76075. private _createRenderVAO;
  76076. private _initialize;
  76077. /** @hidden */
  76078. _recreateUpdateEffect(): void;
  76079. private _getEffect;
  76080. /**
  76081. * Fill the defines array according to the current settings of the particle system
  76082. * @param defines Array to be updated
  76083. * @param blendMode blend mode to take into account when updating the array
  76084. */
  76085. fillDefines(defines: Array<string>, blendMode?: number): void;
  76086. /**
  76087. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  76088. * @param uniforms Uniforms array to fill
  76089. * @param attributes Attributes array to fill
  76090. * @param samplers Samplers array to fill
  76091. */
  76092. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  76093. /** @hidden */
  76094. _recreateRenderEffect(): Effect;
  76095. /**
  76096. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  76097. * @param preWarm defines if we are in the pre-warmimg phase
  76098. */
  76099. animate(preWarm?: boolean): void;
  76100. private _createFactorGradientTexture;
  76101. private _createSizeGradientTexture;
  76102. private _createAngularSpeedGradientTexture;
  76103. private _createVelocityGradientTexture;
  76104. private _createLimitVelocityGradientTexture;
  76105. private _createDragGradientTexture;
  76106. private _createColorGradientTexture;
  76107. /**
  76108. * Renders the particle system in its current state
  76109. * @param preWarm defines if the system should only update the particles but not render them
  76110. * @returns the current number of particles
  76111. */
  76112. render(preWarm?: boolean): number;
  76113. /**
  76114. * Rebuilds the particle system
  76115. */
  76116. rebuild(): void;
  76117. private _releaseBuffers;
  76118. private _releaseVAOs;
  76119. /**
  76120. * Disposes the particle system and free the associated resources
  76121. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76122. */
  76123. dispose(disposeTexture?: boolean): void;
  76124. /**
  76125. * Clones the particle system.
  76126. * @param name The name of the cloned object
  76127. * @param newEmitter The new emitter to use
  76128. * @returns the cloned particle system
  76129. */
  76130. clone(name: string, newEmitter: any): GPUParticleSystem;
  76131. /**
  76132. * Serializes the particle system to a JSON object
  76133. * @param serializeTexture defines if the texture must be serialized as well
  76134. * @returns the JSON object
  76135. */
  76136. serialize(serializeTexture?: boolean): any;
  76137. /**
  76138. * Parses a JSON object to create a GPU particle system.
  76139. * @param parsedParticleSystem The JSON object to parse
  76140. * @param sceneOrEngine The scene or the engine to create the particle system in
  76141. * @param rootUrl The root url to use to load external dependencies like texture
  76142. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  76143. * @returns the parsed GPU particle system
  76144. */
  76145. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  76146. }
  76147. }
  76148. declare module "babylonjs/Particles/particleSystemSet" {
  76149. import { Nullable } from "babylonjs/types";
  76150. import { Color3 } from "babylonjs/Maths/math.color";
  76151. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76153. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76154. import { Scene, IDisposable } from "babylonjs/scene";
  76155. /**
  76156. * Represents a set of particle systems working together to create a specific effect
  76157. */
  76158. export class ParticleSystemSet implements IDisposable {
  76159. /**
  76160. * Gets or sets base Assets URL
  76161. */
  76162. static BaseAssetsUrl: string;
  76163. private _emitterCreationOptions;
  76164. private _emitterNode;
  76165. /**
  76166. * Gets the particle system list
  76167. */
  76168. systems: IParticleSystem[];
  76169. /**
  76170. * Gets the emitter node used with this set
  76171. */
  76172. get emitterNode(): Nullable<TransformNode>;
  76173. /**
  76174. * Creates a new emitter mesh as a sphere
  76175. * @param options defines the options used to create the sphere
  76176. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  76177. * @param scene defines the hosting scene
  76178. */
  76179. setEmitterAsSphere(options: {
  76180. diameter: number;
  76181. segments: number;
  76182. color: Color3;
  76183. }, renderingGroupId: number, scene: Scene): void;
  76184. /**
  76185. * Starts all particle systems of the set
  76186. * @param emitter defines an optional mesh to use as emitter for the particle systems
  76187. */
  76188. start(emitter?: AbstractMesh): void;
  76189. /**
  76190. * Release all associated resources
  76191. */
  76192. dispose(): void;
  76193. /**
  76194. * Serialize the set into a JSON compatible object
  76195. * @param serializeTexture defines if the texture must be serialized as well
  76196. * @returns a JSON compatible representation of the set
  76197. */
  76198. serialize(serializeTexture?: boolean): any;
  76199. /**
  76200. * Parse a new ParticleSystemSet from a serialized source
  76201. * @param data defines a JSON compatible representation of the set
  76202. * @param scene defines the hosting scene
  76203. * @param gpu defines if we want GPU particles or CPU particles
  76204. * @returns a new ParticleSystemSet
  76205. */
  76206. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  76207. }
  76208. }
  76209. declare module "babylonjs/Particles/particleHelper" {
  76210. import { Nullable } from "babylonjs/types";
  76211. import { Scene } from "babylonjs/scene";
  76212. import { Vector3 } from "babylonjs/Maths/math.vector";
  76213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76214. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76215. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  76216. /**
  76217. * This class is made for on one-liner static method to help creating particle system set.
  76218. */
  76219. export class ParticleHelper {
  76220. /**
  76221. * Gets or sets base Assets URL
  76222. */
  76223. static BaseAssetsUrl: string;
  76224. /** Define the Url to load snippets */
  76225. static SnippetUrl: string;
  76226. /**
  76227. * Create a default particle system that you can tweak
  76228. * @param emitter defines the emitter to use
  76229. * @param capacity defines the system capacity (default is 500 particles)
  76230. * @param scene defines the hosting scene
  76231. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  76232. * @returns the new Particle system
  76233. */
  76234. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  76235. /**
  76236. * This is the main static method (one-liner) of this helper to create different particle systems
  76237. * @param type This string represents the type to the particle system to create
  76238. * @param scene The scene where the particle system should live
  76239. * @param gpu If the system will use gpu
  76240. * @returns the ParticleSystemSet created
  76241. */
  76242. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  76243. /**
  76244. * Static function used to export a particle system to a ParticleSystemSet variable.
  76245. * Please note that the emitter shape is not exported
  76246. * @param systems defines the particle systems to export
  76247. * @returns the created particle system set
  76248. */
  76249. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  76250. /**
  76251. * Creates a particle system from a snippet saved in a remote file
  76252. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  76253. * @param url defines the url to load from
  76254. * @param scene defines the hosting scene
  76255. * @param gpu If the system will use gpu
  76256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76257. * @returns a promise that will resolve to the new particle system
  76258. */
  76259. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  76260. /**
  76261. * Creates a particle system from a snippet saved by the particle system editor
  76262. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  76263. * @param scene defines the hosting scene
  76264. * @param gpu If the system will use gpu
  76265. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76266. * @returns a promise that will resolve to the new particle system
  76267. */
  76268. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  76269. }
  76270. }
  76271. declare module "babylonjs/Particles/particleSystemComponent" {
  76272. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76273. import { Effect } from "babylonjs/Materials/effect";
  76274. import "babylonjs/Shaders/particles.vertex";
  76275. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  76276. module "babylonjs/Engines/engine" {
  76277. interface Engine {
  76278. /**
  76279. * Create an effect to use with particle systems.
  76280. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  76281. * the particle system for which you want to create a custom effect in the last parameter
  76282. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  76283. * @param uniformsNames defines a list of attribute names
  76284. * @param samplers defines an array of string used to represent textures
  76285. * @param defines defines the string containing the defines to use to compile the shaders
  76286. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  76287. * @param onCompiled defines a function to call when the effect creation is successful
  76288. * @param onError defines a function to call when the effect creation has failed
  76289. * @param particleSystem the particle system you want to create the effect for
  76290. * @returns the new Effect
  76291. */
  76292. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  76293. }
  76294. }
  76295. module "babylonjs/Meshes/mesh" {
  76296. interface Mesh {
  76297. /**
  76298. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  76299. * @returns an array of IParticleSystem
  76300. */
  76301. getEmittedParticleSystems(): IParticleSystem[];
  76302. /**
  76303. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  76304. * @returns an array of IParticleSystem
  76305. */
  76306. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  76307. }
  76308. }
  76309. }
  76310. declare module "babylonjs/Particles/pointsCloudSystem" {
  76311. import { Color4 } from "babylonjs/Maths/math";
  76312. import { Mesh } from "babylonjs/Meshes/mesh";
  76313. import { Scene, IDisposable } from "babylonjs/scene";
  76314. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  76315. /** Defines the 4 color options */
  76316. export enum PointColor {
  76317. /** color value */
  76318. Color = 2,
  76319. /** uv value */
  76320. UV = 1,
  76321. /** random value */
  76322. Random = 0,
  76323. /** stated value */
  76324. Stated = 3
  76325. }
  76326. /**
  76327. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  76328. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  76329. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  76330. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  76331. *
  76332. * Full documentation here : TO BE ENTERED
  76333. */
  76334. export class PointsCloudSystem implements IDisposable {
  76335. /**
  76336. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  76337. * Example : var p = SPS.particles[i];
  76338. */
  76339. particles: CloudPoint[];
  76340. /**
  76341. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  76342. */
  76343. nbParticles: number;
  76344. /**
  76345. * This a counter for your own usage. It's not set by any SPS functions.
  76346. */
  76347. counter: number;
  76348. /**
  76349. * The PCS name. This name is also given to the underlying mesh.
  76350. */
  76351. name: string;
  76352. /**
  76353. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  76354. */
  76355. mesh: Mesh;
  76356. /**
  76357. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  76358. * Please read :
  76359. */
  76360. vars: any;
  76361. /**
  76362. * @hidden
  76363. */
  76364. _size: number;
  76365. private _scene;
  76366. private _promises;
  76367. private _positions;
  76368. private _indices;
  76369. private _normals;
  76370. private _colors;
  76371. private _uvs;
  76372. private _indices32;
  76373. private _positions32;
  76374. private _colors32;
  76375. private _uvs32;
  76376. private _updatable;
  76377. private _isVisibilityBoxLocked;
  76378. private _alwaysVisible;
  76379. private _groups;
  76380. private _groupCounter;
  76381. private _computeParticleColor;
  76382. private _computeParticleTexture;
  76383. private _computeParticleRotation;
  76384. private _computeBoundingBox;
  76385. private _isReady;
  76386. /**
  76387. * Creates a PCS (Points Cloud System) object
  76388. * @param name (String) is the PCS name, this will be the underlying mesh name
  76389. * @param pointSize (number) is the size for each point
  76390. * @param scene (Scene) is the scene in which the PCS is added
  76391. * @param options defines the options of the PCS e.g.
  76392. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  76393. */
  76394. constructor(name: string, pointSize: number, scene: Scene, options?: {
  76395. updatable?: boolean;
  76396. });
  76397. /**
  76398. * Builds the PCS underlying mesh. Returns a standard Mesh.
  76399. * If no points were added to the PCS, the returned mesh is just a single point.
  76400. * @returns a promise for the created mesh
  76401. */
  76402. buildMeshAsync(): Promise<Mesh>;
  76403. /**
  76404. * @hidden
  76405. */
  76406. private _buildMesh;
  76407. private _addParticle;
  76408. private _randomUnitVector;
  76409. private _getColorIndicesForCoord;
  76410. private _setPointsColorOrUV;
  76411. private _colorFromTexture;
  76412. private _calculateDensity;
  76413. /**
  76414. * Adds points to the PCS in random positions within a unit sphere
  76415. * @param nb (positive integer) the number of particles to be created from this model
  76416. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  76417. * @returns the number of groups in the system
  76418. */
  76419. addPoints(nb: number, pointFunction?: any): number;
  76420. /**
  76421. * Adds points to the PCS from the surface of the model shape
  76422. * @param mesh is any Mesh object that will be used as a surface model for the points
  76423. * @param nb (positive integer) the number of particles to be created from this model
  76424. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76425. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76426. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76427. * @returns the number of groups in the system
  76428. */
  76429. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76430. /**
  76431. * Adds points to the PCS inside the model shape
  76432. * @param mesh is any Mesh object that will be used as a surface model for the points
  76433. * @param nb (positive integer) the number of particles to be created from this model
  76434. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76435. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76436. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76437. * @returns the number of groups in the system
  76438. */
  76439. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76440. /**
  76441. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  76442. * This method calls `updateParticle()` for each particle of the SPS.
  76443. * For an animated SPS, it is usually called within the render loop.
  76444. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  76445. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  76446. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  76447. * @returns the PCS.
  76448. */
  76449. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  76450. /**
  76451. * Disposes the PCS.
  76452. */
  76453. dispose(): void;
  76454. /**
  76455. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  76456. * doc :
  76457. * @returns the PCS.
  76458. */
  76459. refreshVisibleSize(): PointsCloudSystem;
  76460. /**
  76461. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  76462. * @param size the size (float) of the visibility box
  76463. * note : this doesn't lock the PCS mesh bounding box.
  76464. * doc :
  76465. */
  76466. setVisibilityBox(size: number): void;
  76467. /**
  76468. * Gets whether the PCS is always visible or not
  76469. * doc :
  76470. */
  76471. get isAlwaysVisible(): boolean;
  76472. /**
  76473. * Sets the PCS as always visible or not
  76474. * doc :
  76475. */
  76476. set isAlwaysVisible(val: boolean);
  76477. /**
  76478. * Tells to `setParticles()` to compute the particle rotations or not
  76479. * Default value : false. The PCS is faster when it's set to false
  76480. * Note : particle rotations are only applied to parent particles
  76481. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  76482. */
  76483. set computeParticleRotation(val: boolean);
  76484. /**
  76485. * Tells to `setParticles()` to compute the particle colors or not.
  76486. * Default value : true. The PCS is faster when it's set to false.
  76487. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76488. */
  76489. set computeParticleColor(val: boolean);
  76490. set computeParticleTexture(val: boolean);
  76491. /**
  76492. * Gets if `setParticles()` computes the particle colors or not.
  76493. * Default value : false. The PCS is faster when it's set to false.
  76494. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76495. */
  76496. get computeParticleColor(): boolean;
  76497. /**
  76498. * Gets if `setParticles()` computes the particle textures or not.
  76499. * Default value : false. The PCS is faster when it's set to false.
  76500. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  76501. */
  76502. get computeParticleTexture(): boolean;
  76503. /**
  76504. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  76505. */
  76506. set computeBoundingBox(val: boolean);
  76507. /**
  76508. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  76509. */
  76510. get computeBoundingBox(): boolean;
  76511. /**
  76512. * This function does nothing. It may be overwritten to set all the particle first values.
  76513. * The PCS doesn't call this function, you may have to call it by your own.
  76514. * doc :
  76515. */
  76516. initParticles(): void;
  76517. /**
  76518. * This function does nothing. It may be overwritten to recycle a particle
  76519. * The PCS doesn't call this function, you can to call it
  76520. * doc :
  76521. * @param particle The particle to recycle
  76522. * @returns the recycled particle
  76523. */
  76524. recycleParticle(particle: CloudPoint): CloudPoint;
  76525. /**
  76526. * Updates a particle : this function should be overwritten by the user.
  76527. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  76528. * doc :
  76529. * @example : just set a particle position or velocity and recycle conditions
  76530. * @param particle The particle to update
  76531. * @returns the updated particle
  76532. */
  76533. updateParticle(particle: CloudPoint): CloudPoint;
  76534. /**
  76535. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  76536. * This does nothing and may be overwritten by the user.
  76537. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76538. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76539. * @param update the boolean update value actually passed to setParticles()
  76540. */
  76541. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76542. /**
  76543. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  76544. * This will be passed three parameters.
  76545. * This does nothing and may be overwritten by the user.
  76546. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76547. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76548. * @param update the boolean update value actually passed to setParticles()
  76549. */
  76550. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76551. }
  76552. }
  76553. declare module "babylonjs/Particles/cloudPoint" {
  76554. import { Nullable } from "babylonjs/types";
  76555. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  76556. import { Mesh } from "babylonjs/Meshes/mesh";
  76557. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  76558. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  76559. /**
  76560. * Represents one particle of a points cloud system.
  76561. */
  76562. export class CloudPoint {
  76563. /**
  76564. * particle global index
  76565. */
  76566. idx: number;
  76567. /**
  76568. * The color of the particle
  76569. */
  76570. color: Nullable<Color4>;
  76571. /**
  76572. * The world space position of the particle.
  76573. */
  76574. position: Vector3;
  76575. /**
  76576. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  76577. */
  76578. rotation: Vector3;
  76579. /**
  76580. * The world space rotation quaternion of the particle.
  76581. */
  76582. rotationQuaternion: Nullable<Quaternion>;
  76583. /**
  76584. * The uv of the particle.
  76585. */
  76586. uv: Nullable<Vector2>;
  76587. /**
  76588. * The current speed of the particle.
  76589. */
  76590. velocity: Vector3;
  76591. /**
  76592. * The pivot point in the particle local space.
  76593. */
  76594. pivot: Vector3;
  76595. /**
  76596. * Must the particle be translated from its pivot point in its local space ?
  76597. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  76598. * Default : false
  76599. */
  76600. translateFromPivot: boolean;
  76601. /**
  76602. * Index of this particle in the global "positions" array (Internal use)
  76603. * @hidden
  76604. */
  76605. _pos: number;
  76606. /**
  76607. * @hidden Index of this particle in the global "indices" array (Internal use)
  76608. */
  76609. _ind: number;
  76610. /**
  76611. * Group this particle belongs to
  76612. */
  76613. _group: PointsGroup;
  76614. /**
  76615. * Group id of this particle
  76616. */
  76617. groupId: number;
  76618. /**
  76619. * Index of the particle in its group id (Internal use)
  76620. */
  76621. idxInGroup: number;
  76622. /**
  76623. * @hidden Particle BoundingInfo object (Internal use)
  76624. */
  76625. _boundingInfo: BoundingInfo;
  76626. /**
  76627. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  76628. */
  76629. _pcs: PointsCloudSystem;
  76630. /**
  76631. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  76632. */
  76633. _stillInvisible: boolean;
  76634. /**
  76635. * @hidden Last computed particle rotation matrix
  76636. */
  76637. _rotationMatrix: number[];
  76638. /**
  76639. * Parent particle Id, if any.
  76640. * Default null.
  76641. */
  76642. parentId: Nullable<number>;
  76643. /**
  76644. * @hidden Internal global position in the PCS.
  76645. */
  76646. _globalPosition: Vector3;
  76647. /**
  76648. * Creates a Point Cloud object.
  76649. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  76650. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  76651. * @param group (PointsGroup) is the group the particle belongs to
  76652. * @param groupId (integer) is the group identifier in the PCS.
  76653. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  76654. * @param pcs defines the PCS it is associated to
  76655. */
  76656. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  76657. /**
  76658. * get point size
  76659. */
  76660. get size(): Vector3;
  76661. /**
  76662. * Set point size
  76663. */
  76664. set size(scale: Vector3);
  76665. /**
  76666. * Legacy support, changed quaternion to rotationQuaternion
  76667. */
  76668. get quaternion(): Nullable<Quaternion>;
  76669. /**
  76670. * Legacy support, changed quaternion to rotationQuaternion
  76671. */
  76672. set quaternion(q: Nullable<Quaternion>);
  76673. /**
  76674. * Returns a boolean. True if the particle intersects a mesh, else false
  76675. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  76676. * @param target is the object (point or mesh) what the intersection is computed against
  76677. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  76678. * @returns true if it intersects
  76679. */
  76680. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  76681. /**
  76682. * get the rotation matrix of the particle
  76683. * @hidden
  76684. */
  76685. getRotationMatrix(m: Matrix): void;
  76686. }
  76687. /**
  76688. * Represents a group of points in a points cloud system
  76689. * * PCS internal tool, don't use it manually.
  76690. */
  76691. export class PointsGroup {
  76692. /**
  76693. * The group id
  76694. * @hidden
  76695. */
  76696. groupID: number;
  76697. /**
  76698. * image data for group (internal use)
  76699. * @hidden
  76700. */
  76701. _groupImageData: Nullable<ArrayBufferView>;
  76702. /**
  76703. * Image Width (internal use)
  76704. * @hidden
  76705. */
  76706. _groupImgWidth: number;
  76707. /**
  76708. * Image Height (internal use)
  76709. * @hidden
  76710. */
  76711. _groupImgHeight: number;
  76712. /**
  76713. * Custom position function (internal use)
  76714. * @hidden
  76715. */
  76716. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  76717. /**
  76718. * density per facet for surface points
  76719. * @hidden
  76720. */
  76721. _groupDensity: number[];
  76722. /**
  76723. * Only when points are colored by texture carries pointer to texture list array
  76724. * @hidden
  76725. */
  76726. _textureNb: number;
  76727. /**
  76728. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  76729. * PCS internal tool, don't use it manually.
  76730. * @hidden
  76731. */
  76732. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  76733. }
  76734. }
  76735. declare module "babylonjs/Particles/index" {
  76736. export * from "babylonjs/Particles/baseParticleSystem";
  76737. export * from "babylonjs/Particles/EmitterTypes/index";
  76738. export * from "babylonjs/Particles/gpuParticleSystem";
  76739. export * from "babylonjs/Particles/IParticleSystem";
  76740. export * from "babylonjs/Particles/particle";
  76741. export * from "babylonjs/Particles/particleHelper";
  76742. export * from "babylonjs/Particles/particleSystem";
  76743. import "babylonjs/Particles/particleSystemComponent";
  76744. export * from "babylonjs/Particles/particleSystemComponent";
  76745. export * from "babylonjs/Particles/particleSystemSet";
  76746. export * from "babylonjs/Particles/solidParticle";
  76747. export * from "babylonjs/Particles/solidParticleSystem";
  76748. export * from "babylonjs/Particles/cloudPoint";
  76749. export * from "babylonjs/Particles/pointsCloudSystem";
  76750. export * from "babylonjs/Particles/subEmitter";
  76751. }
  76752. declare module "babylonjs/Physics/physicsEngineComponent" {
  76753. import { Nullable } from "babylonjs/types";
  76754. import { Observable, Observer } from "babylonjs/Misc/observable";
  76755. import { Vector3 } from "babylonjs/Maths/math.vector";
  76756. import { Mesh } from "babylonjs/Meshes/mesh";
  76757. import { ISceneComponent } from "babylonjs/sceneComponent";
  76758. import { Scene } from "babylonjs/scene";
  76759. import { Node } from "babylonjs/node";
  76760. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  76761. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76762. module "babylonjs/scene" {
  76763. interface Scene {
  76764. /** @hidden (Backing field) */
  76765. _physicsEngine: Nullable<IPhysicsEngine>;
  76766. /** @hidden */
  76767. _physicsTimeAccumulator: number;
  76768. /**
  76769. * Gets the current physics engine
  76770. * @returns a IPhysicsEngine or null if none attached
  76771. */
  76772. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  76773. /**
  76774. * Enables physics to the current scene
  76775. * @param gravity defines the scene's gravity for the physics engine
  76776. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  76777. * @return a boolean indicating if the physics engine was initialized
  76778. */
  76779. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  76780. /**
  76781. * Disables and disposes the physics engine associated with the scene
  76782. */
  76783. disablePhysicsEngine(): void;
  76784. /**
  76785. * Gets a boolean indicating if there is an active physics engine
  76786. * @returns a boolean indicating if there is an active physics engine
  76787. */
  76788. isPhysicsEnabled(): boolean;
  76789. /**
  76790. * Deletes a physics compound impostor
  76791. * @param compound defines the compound to delete
  76792. */
  76793. deleteCompoundImpostor(compound: any): void;
  76794. /**
  76795. * An event triggered when physic simulation is about to be run
  76796. */
  76797. onBeforePhysicsObservable: Observable<Scene>;
  76798. /**
  76799. * An event triggered when physic simulation has been done
  76800. */
  76801. onAfterPhysicsObservable: Observable<Scene>;
  76802. }
  76803. }
  76804. module "babylonjs/Meshes/abstractMesh" {
  76805. interface AbstractMesh {
  76806. /** @hidden */
  76807. _physicsImpostor: Nullable<PhysicsImpostor>;
  76808. /**
  76809. * Gets or sets impostor used for physic simulation
  76810. * @see https://doc.babylonjs.com/features/physics_engine
  76811. */
  76812. physicsImpostor: Nullable<PhysicsImpostor>;
  76813. /**
  76814. * Gets the current physics impostor
  76815. * @see https://doc.babylonjs.com/features/physics_engine
  76816. * @returns a physics impostor or null
  76817. */
  76818. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  76819. /** Apply a physic impulse to the mesh
  76820. * @param force defines the force to apply
  76821. * @param contactPoint defines where to apply the force
  76822. * @returns the current mesh
  76823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76824. */
  76825. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  76826. /**
  76827. * Creates a physic joint between two meshes
  76828. * @param otherMesh defines the other mesh to use
  76829. * @param pivot1 defines the pivot to use on this mesh
  76830. * @param pivot2 defines the pivot to use on the other mesh
  76831. * @param options defines additional options (can be plugin dependent)
  76832. * @returns the current mesh
  76833. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  76834. */
  76835. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  76836. /** @hidden */
  76837. _disposePhysicsObserver: Nullable<Observer<Node>>;
  76838. }
  76839. }
  76840. /**
  76841. * Defines the physics engine scene component responsible to manage a physics engine
  76842. */
  76843. export class PhysicsEngineSceneComponent implements ISceneComponent {
  76844. /**
  76845. * The component name helpful to identify the component in the list of scene components.
  76846. */
  76847. readonly name: string;
  76848. /**
  76849. * The scene the component belongs to.
  76850. */
  76851. scene: Scene;
  76852. /**
  76853. * Creates a new instance of the component for the given scene
  76854. * @param scene Defines the scene to register the component in
  76855. */
  76856. constructor(scene: Scene);
  76857. /**
  76858. * Registers the component in a given scene
  76859. */
  76860. register(): void;
  76861. /**
  76862. * Rebuilds the elements related to this component in case of
  76863. * context lost for instance.
  76864. */
  76865. rebuild(): void;
  76866. /**
  76867. * Disposes the component and the associated ressources
  76868. */
  76869. dispose(): void;
  76870. }
  76871. }
  76872. declare module "babylonjs/Physics/physicsHelper" {
  76873. import { Nullable } from "babylonjs/types";
  76874. import { Vector3 } from "babylonjs/Maths/math.vector";
  76875. import { Mesh } from "babylonjs/Meshes/mesh";
  76876. import { Scene } from "babylonjs/scene";
  76877. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76878. /**
  76879. * A helper for physics simulations
  76880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76881. */
  76882. export class PhysicsHelper {
  76883. private _scene;
  76884. private _physicsEngine;
  76885. /**
  76886. * Initializes the Physics helper
  76887. * @param scene Babylon.js scene
  76888. */
  76889. constructor(scene: Scene);
  76890. /**
  76891. * Applies a radial explosion impulse
  76892. * @param origin the origin of the explosion
  76893. * @param radiusOrEventOptions the radius or the options of radial explosion
  76894. * @param strength the explosion strength
  76895. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76896. * @returns A physics radial explosion event, or null
  76897. */
  76898. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76899. /**
  76900. * Applies a radial explosion force
  76901. * @param origin the origin of the explosion
  76902. * @param radiusOrEventOptions the radius or the options of radial explosion
  76903. * @param strength the explosion strength
  76904. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76905. * @returns A physics radial explosion event, or null
  76906. */
  76907. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76908. /**
  76909. * Creates a gravitational field
  76910. * @param origin the origin of the explosion
  76911. * @param radiusOrEventOptions the radius or the options of radial explosion
  76912. * @param strength the explosion strength
  76913. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76914. * @returns A physics gravitational field event, or null
  76915. */
  76916. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  76917. /**
  76918. * Creates a physics updraft event
  76919. * @param origin the origin of the updraft
  76920. * @param radiusOrEventOptions the radius or the options of the updraft
  76921. * @param strength the strength of the updraft
  76922. * @param height the height of the updraft
  76923. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  76924. * @returns A physics updraft event, or null
  76925. */
  76926. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  76927. /**
  76928. * Creates a physics vortex event
  76929. * @param origin the of the vortex
  76930. * @param radiusOrEventOptions the radius or the options of the vortex
  76931. * @param strength the strength of the vortex
  76932. * @param height the height of the vortex
  76933. * @returns a Physics vortex event, or null
  76934. * A physics vortex event or null
  76935. */
  76936. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  76937. }
  76938. /**
  76939. * Represents a physics radial explosion event
  76940. */
  76941. class PhysicsRadialExplosionEvent {
  76942. private _scene;
  76943. private _options;
  76944. private _sphere;
  76945. private _dataFetched;
  76946. /**
  76947. * Initializes a radial explosioin event
  76948. * @param _scene BabylonJS scene
  76949. * @param _options The options for the vortex event
  76950. */
  76951. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  76952. /**
  76953. * Returns the data related to the radial explosion event (sphere).
  76954. * @returns The radial explosion event data
  76955. */
  76956. getData(): PhysicsRadialExplosionEventData;
  76957. /**
  76958. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  76959. * @param impostor A physics imposter
  76960. * @param origin the origin of the explosion
  76961. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  76962. */
  76963. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  76964. /**
  76965. * Triggers affecterd impostors callbacks
  76966. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  76967. */
  76968. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  76969. /**
  76970. * Disposes the sphere.
  76971. * @param force Specifies if the sphere should be disposed by force
  76972. */
  76973. dispose(force?: boolean): void;
  76974. /*** Helpers ***/
  76975. private _prepareSphere;
  76976. private _intersectsWithSphere;
  76977. }
  76978. /**
  76979. * Represents a gravitational field event
  76980. */
  76981. class PhysicsGravitationalFieldEvent {
  76982. private _physicsHelper;
  76983. private _scene;
  76984. private _origin;
  76985. private _options;
  76986. private _tickCallback;
  76987. private _sphere;
  76988. private _dataFetched;
  76989. /**
  76990. * Initializes the physics gravitational field event
  76991. * @param _physicsHelper A physics helper
  76992. * @param _scene BabylonJS scene
  76993. * @param _origin The origin position of the gravitational field event
  76994. * @param _options The options for the vortex event
  76995. */
  76996. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  76997. /**
  76998. * Returns the data related to the gravitational field event (sphere).
  76999. * @returns A gravitational field event
  77000. */
  77001. getData(): PhysicsGravitationalFieldEventData;
  77002. /**
  77003. * Enables the gravitational field.
  77004. */
  77005. enable(): void;
  77006. /**
  77007. * Disables the gravitational field.
  77008. */
  77009. disable(): void;
  77010. /**
  77011. * Disposes the sphere.
  77012. * @param force The force to dispose from the gravitational field event
  77013. */
  77014. dispose(force?: boolean): void;
  77015. private _tick;
  77016. }
  77017. /**
  77018. * Represents a physics updraft event
  77019. */
  77020. class PhysicsUpdraftEvent {
  77021. private _scene;
  77022. private _origin;
  77023. private _options;
  77024. private _physicsEngine;
  77025. private _originTop;
  77026. private _originDirection;
  77027. private _tickCallback;
  77028. private _cylinder;
  77029. private _cylinderPosition;
  77030. private _dataFetched;
  77031. /**
  77032. * Initializes the physics updraft event
  77033. * @param _scene BabylonJS scene
  77034. * @param _origin The origin position of the updraft
  77035. * @param _options The options for the updraft event
  77036. */
  77037. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  77038. /**
  77039. * Returns the data related to the updraft event (cylinder).
  77040. * @returns A physics updraft event
  77041. */
  77042. getData(): PhysicsUpdraftEventData;
  77043. /**
  77044. * Enables the updraft.
  77045. */
  77046. enable(): void;
  77047. /**
  77048. * Disables the updraft.
  77049. */
  77050. disable(): void;
  77051. /**
  77052. * Disposes the cylinder.
  77053. * @param force Specifies if the updraft should be disposed by force
  77054. */
  77055. dispose(force?: boolean): void;
  77056. private getImpostorHitData;
  77057. private _tick;
  77058. /*** Helpers ***/
  77059. private _prepareCylinder;
  77060. private _intersectsWithCylinder;
  77061. }
  77062. /**
  77063. * Represents a physics vortex event
  77064. */
  77065. class PhysicsVortexEvent {
  77066. private _scene;
  77067. private _origin;
  77068. private _options;
  77069. private _physicsEngine;
  77070. private _originTop;
  77071. private _tickCallback;
  77072. private _cylinder;
  77073. private _cylinderPosition;
  77074. private _dataFetched;
  77075. /**
  77076. * Initializes the physics vortex event
  77077. * @param _scene The BabylonJS scene
  77078. * @param _origin The origin position of the vortex
  77079. * @param _options The options for the vortex event
  77080. */
  77081. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  77082. /**
  77083. * Returns the data related to the vortex event (cylinder).
  77084. * @returns The physics vortex event data
  77085. */
  77086. getData(): PhysicsVortexEventData;
  77087. /**
  77088. * Enables the vortex.
  77089. */
  77090. enable(): void;
  77091. /**
  77092. * Disables the cortex.
  77093. */
  77094. disable(): void;
  77095. /**
  77096. * Disposes the sphere.
  77097. * @param force
  77098. */
  77099. dispose(force?: boolean): void;
  77100. private getImpostorHitData;
  77101. private _tick;
  77102. /*** Helpers ***/
  77103. private _prepareCylinder;
  77104. private _intersectsWithCylinder;
  77105. }
  77106. /**
  77107. * Options fot the radial explosion event
  77108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77109. */
  77110. export class PhysicsRadialExplosionEventOptions {
  77111. /**
  77112. * The radius of the sphere for the radial explosion.
  77113. */
  77114. radius: number;
  77115. /**
  77116. * The strenth of the explosion.
  77117. */
  77118. strength: number;
  77119. /**
  77120. * The strenght of the force in correspondence to the distance of the affected object
  77121. */
  77122. falloff: PhysicsRadialImpulseFalloff;
  77123. /**
  77124. * Sphere options for the radial explosion.
  77125. */
  77126. sphere: {
  77127. segments: number;
  77128. diameter: number;
  77129. };
  77130. /**
  77131. * Sphere options for the radial explosion.
  77132. */
  77133. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  77134. }
  77135. /**
  77136. * Options fot the updraft event
  77137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77138. */
  77139. export class PhysicsUpdraftEventOptions {
  77140. /**
  77141. * The radius of the cylinder for the vortex
  77142. */
  77143. radius: number;
  77144. /**
  77145. * The strenth of the updraft.
  77146. */
  77147. strength: number;
  77148. /**
  77149. * The height of the cylinder for the updraft.
  77150. */
  77151. height: number;
  77152. /**
  77153. * The mode for the the updraft.
  77154. */
  77155. updraftMode: PhysicsUpdraftMode;
  77156. }
  77157. /**
  77158. * Options fot the vortex event
  77159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77160. */
  77161. export class PhysicsVortexEventOptions {
  77162. /**
  77163. * The radius of the cylinder for the vortex
  77164. */
  77165. radius: number;
  77166. /**
  77167. * The strenth of the vortex.
  77168. */
  77169. strength: number;
  77170. /**
  77171. * The height of the cylinder for the vortex.
  77172. */
  77173. height: number;
  77174. /**
  77175. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  77176. */
  77177. centripetalForceThreshold: number;
  77178. /**
  77179. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  77180. */
  77181. centripetalForceMultiplier: number;
  77182. /**
  77183. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  77184. */
  77185. centrifugalForceMultiplier: number;
  77186. /**
  77187. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  77188. */
  77189. updraftForceMultiplier: number;
  77190. }
  77191. /**
  77192. * The strenght of the force in correspondence to the distance of the affected object
  77193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77194. */
  77195. export enum PhysicsRadialImpulseFalloff {
  77196. /** Defines that impulse is constant in strength across it's whole radius */
  77197. Constant = 0,
  77198. /** Defines that impulse gets weaker if it's further from the origin */
  77199. Linear = 1
  77200. }
  77201. /**
  77202. * The strength of the force in correspondence to the distance of the affected object
  77203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77204. */
  77205. export enum PhysicsUpdraftMode {
  77206. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  77207. Center = 0,
  77208. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  77209. Perpendicular = 1
  77210. }
  77211. /**
  77212. * Interface for a physics hit data
  77213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77214. */
  77215. export interface PhysicsHitData {
  77216. /**
  77217. * The force applied at the contact point
  77218. */
  77219. force: Vector3;
  77220. /**
  77221. * The contact point
  77222. */
  77223. contactPoint: Vector3;
  77224. /**
  77225. * The distance from the origin to the contact point
  77226. */
  77227. distanceFromOrigin: number;
  77228. }
  77229. /**
  77230. * Interface for radial explosion event data
  77231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77232. */
  77233. export interface PhysicsRadialExplosionEventData {
  77234. /**
  77235. * A sphere used for the radial explosion event
  77236. */
  77237. sphere: Mesh;
  77238. }
  77239. /**
  77240. * Interface for gravitational field event data
  77241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77242. */
  77243. export interface PhysicsGravitationalFieldEventData {
  77244. /**
  77245. * A sphere mesh used for the gravitational field event
  77246. */
  77247. sphere: Mesh;
  77248. }
  77249. /**
  77250. * Interface for updraft event data
  77251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77252. */
  77253. export interface PhysicsUpdraftEventData {
  77254. /**
  77255. * A cylinder used for the updraft event
  77256. */
  77257. cylinder: Mesh;
  77258. }
  77259. /**
  77260. * Interface for vortex event data
  77261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77262. */
  77263. export interface PhysicsVortexEventData {
  77264. /**
  77265. * A cylinder used for the vortex event
  77266. */
  77267. cylinder: Mesh;
  77268. }
  77269. /**
  77270. * Interface for an affected physics impostor
  77271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77272. */
  77273. export interface PhysicsAffectedImpostorWithData {
  77274. /**
  77275. * The impostor affected by the effect
  77276. */
  77277. impostor: PhysicsImpostor;
  77278. /**
  77279. * The data about the hit/horce from the explosion
  77280. */
  77281. hitData: PhysicsHitData;
  77282. }
  77283. }
  77284. declare module "babylonjs/Physics/Plugins/index" {
  77285. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  77286. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  77287. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  77288. }
  77289. declare module "babylonjs/Physics/index" {
  77290. export * from "babylonjs/Physics/IPhysicsEngine";
  77291. export * from "babylonjs/Physics/physicsEngine";
  77292. export * from "babylonjs/Physics/physicsEngineComponent";
  77293. export * from "babylonjs/Physics/physicsHelper";
  77294. export * from "babylonjs/Physics/physicsImpostor";
  77295. export * from "babylonjs/Physics/physicsJoint";
  77296. export * from "babylonjs/Physics/Plugins/index";
  77297. }
  77298. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  77299. /** @hidden */
  77300. export var blackAndWhitePixelShader: {
  77301. name: string;
  77302. shader: string;
  77303. };
  77304. }
  77305. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  77306. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77307. import { Camera } from "babylonjs/Cameras/camera";
  77308. import { Engine } from "babylonjs/Engines/engine";
  77309. import "babylonjs/Shaders/blackAndWhite.fragment";
  77310. import { Nullable } from "babylonjs/types";
  77311. import { Scene } from "babylonjs/scene";
  77312. /**
  77313. * Post process used to render in black and white
  77314. */
  77315. export class BlackAndWhitePostProcess extends PostProcess {
  77316. /**
  77317. * Linear about to convert he result to black and white (default: 1)
  77318. */
  77319. degree: number;
  77320. /**
  77321. * Gets a string identifying the name of the class
  77322. * @returns "BlackAndWhitePostProcess" string
  77323. */
  77324. getClassName(): string;
  77325. /**
  77326. * Creates a black and white post process
  77327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  77328. * @param name The name of the effect.
  77329. * @param options The required width/height ratio to downsize to before computing the render pass.
  77330. * @param camera The camera to apply the render pass to.
  77331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77332. * @param engine The engine which the post process will be applied. (default: current engine)
  77333. * @param reusable If the post process can be reused on the same frame. (default: false)
  77334. */
  77335. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77336. /** @hidden */
  77337. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  77338. }
  77339. }
  77340. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  77341. import { Nullable } from "babylonjs/types";
  77342. import { Camera } from "babylonjs/Cameras/camera";
  77343. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77344. import { Engine } from "babylonjs/Engines/engine";
  77345. /**
  77346. * This represents a set of one or more post processes in Babylon.
  77347. * A post process can be used to apply a shader to a texture after it is rendered.
  77348. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  77349. */
  77350. export class PostProcessRenderEffect {
  77351. private _postProcesses;
  77352. private _getPostProcesses;
  77353. private _singleInstance;
  77354. private _cameras;
  77355. private _indicesForCamera;
  77356. /**
  77357. * Name of the effect
  77358. * @hidden
  77359. */
  77360. _name: string;
  77361. /**
  77362. * Instantiates a post process render effect.
  77363. * A post process can be used to apply a shader to a texture after it is rendered.
  77364. * @param engine The engine the effect is tied to
  77365. * @param name The name of the effect
  77366. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  77367. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  77368. */
  77369. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  77370. /**
  77371. * Checks if all the post processes in the effect are supported.
  77372. */
  77373. get isSupported(): boolean;
  77374. /**
  77375. * Updates the current state of the effect
  77376. * @hidden
  77377. */
  77378. _update(): void;
  77379. /**
  77380. * Attaches the effect on cameras
  77381. * @param cameras The camera to attach to.
  77382. * @hidden
  77383. */
  77384. _attachCameras(cameras: Camera): void;
  77385. /**
  77386. * Attaches the effect on cameras
  77387. * @param cameras The camera to attach to.
  77388. * @hidden
  77389. */
  77390. _attachCameras(cameras: Camera[]): void;
  77391. /**
  77392. * Detaches the effect on cameras
  77393. * @param cameras The camera to detatch from.
  77394. * @hidden
  77395. */
  77396. _detachCameras(cameras: Camera): void;
  77397. /**
  77398. * Detatches the effect on cameras
  77399. * @param cameras The camera to detatch from.
  77400. * @hidden
  77401. */
  77402. _detachCameras(cameras: Camera[]): void;
  77403. /**
  77404. * Enables the effect on given cameras
  77405. * @param cameras The camera to enable.
  77406. * @hidden
  77407. */
  77408. _enable(cameras: Camera): void;
  77409. /**
  77410. * Enables the effect on given cameras
  77411. * @param cameras The camera to enable.
  77412. * @hidden
  77413. */
  77414. _enable(cameras: Nullable<Camera[]>): void;
  77415. /**
  77416. * Disables the effect on the given cameras
  77417. * @param cameras The camera to disable.
  77418. * @hidden
  77419. */
  77420. _disable(cameras: Camera): void;
  77421. /**
  77422. * Disables the effect on the given cameras
  77423. * @param cameras The camera to disable.
  77424. * @hidden
  77425. */
  77426. _disable(cameras: Nullable<Camera[]>): void;
  77427. /**
  77428. * Gets a list of the post processes contained in the effect.
  77429. * @param camera The camera to get the post processes on.
  77430. * @returns The list of the post processes in the effect.
  77431. */
  77432. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  77433. }
  77434. }
  77435. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  77436. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77437. /** @hidden */
  77438. export var extractHighlightsPixelShader: {
  77439. name: string;
  77440. shader: string;
  77441. };
  77442. }
  77443. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  77444. import { Nullable } from "babylonjs/types";
  77445. import { Camera } from "babylonjs/Cameras/camera";
  77446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77447. import { Engine } from "babylonjs/Engines/engine";
  77448. import "babylonjs/Shaders/extractHighlights.fragment";
  77449. /**
  77450. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  77451. */
  77452. export class ExtractHighlightsPostProcess extends PostProcess {
  77453. /**
  77454. * The luminance threshold, pixels below this value will be set to black.
  77455. */
  77456. threshold: number;
  77457. /** @hidden */
  77458. _exposure: number;
  77459. /**
  77460. * Post process which has the input texture to be used when performing highlight extraction
  77461. * @hidden
  77462. */
  77463. _inputPostProcess: Nullable<PostProcess>;
  77464. /**
  77465. * Gets a string identifying the name of the class
  77466. * @returns "ExtractHighlightsPostProcess" string
  77467. */
  77468. getClassName(): string;
  77469. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77470. }
  77471. }
  77472. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  77473. /** @hidden */
  77474. export var bloomMergePixelShader: {
  77475. name: string;
  77476. shader: string;
  77477. };
  77478. }
  77479. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  77480. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77481. import { Nullable } from "babylonjs/types";
  77482. import { Engine } from "babylonjs/Engines/engine";
  77483. import { Camera } from "babylonjs/Cameras/camera";
  77484. import "babylonjs/Shaders/bloomMerge.fragment";
  77485. /**
  77486. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77487. */
  77488. export class BloomMergePostProcess extends PostProcess {
  77489. /** Weight of the bloom to be added to the original input. */
  77490. weight: number;
  77491. /**
  77492. * Gets a string identifying the name of the class
  77493. * @returns "BloomMergePostProcess" string
  77494. */
  77495. getClassName(): string;
  77496. /**
  77497. * Creates a new instance of @see BloomMergePostProcess
  77498. * @param name The name of the effect.
  77499. * @param originalFromInput Post process which's input will be used for the merge.
  77500. * @param blurred Blurred highlights post process which's output will be used.
  77501. * @param weight Weight of the bloom to be added to the original input.
  77502. * @param options The required width/height ratio to downsize to before computing the render pass.
  77503. * @param camera The camera to apply the render pass to.
  77504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77505. * @param engine The engine which the post process will be applied. (default: current engine)
  77506. * @param reusable If the post process can be reused on the same frame. (default: false)
  77507. * @param textureType Type of textures used when performing the post process. (default: 0)
  77508. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  77509. */
  77510. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  77511. /** Weight of the bloom to be added to the original input. */
  77512. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77513. }
  77514. }
  77515. declare module "babylonjs/PostProcesses/bloomEffect" {
  77516. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77517. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77518. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77519. import { Camera } from "babylonjs/Cameras/camera";
  77520. import { Scene } from "babylonjs/scene";
  77521. /**
  77522. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  77523. */
  77524. export class BloomEffect extends PostProcessRenderEffect {
  77525. private bloomScale;
  77526. /**
  77527. * @hidden Internal
  77528. */
  77529. _effects: Array<PostProcess>;
  77530. /**
  77531. * @hidden Internal
  77532. */
  77533. _downscale: ExtractHighlightsPostProcess;
  77534. private _blurX;
  77535. private _blurY;
  77536. private _merge;
  77537. /**
  77538. * The luminance threshold to find bright areas of the image to bloom.
  77539. */
  77540. get threshold(): number;
  77541. set threshold(value: number);
  77542. /**
  77543. * The strength of the bloom.
  77544. */
  77545. get weight(): number;
  77546. set weight(value: number);
  77547. /**
  77548. * Specifies the size of the bloom blur kernel, relative to the final output size
  77549. */
  77550. get kernel(): number;
  77551. set kernel(value: number);
  77552. /**
  77553. * Creates a new instance of @see BloomEffect
  77554. * @param scene The scene the effect belongs to.
  77555. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  77556. * @param bloomKernel The size of the kernel to be used when applying the blur.
  77557. * @param bloomWeight The the strength of bloom.
  77558. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77559. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  77560. */
  77561. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  77562. /**
  77563. * Disposes each of the internal effects for a given camera.
  77564. * @param camera The camera to dispose the effect on.
  77565. */
  77566. disposeEffects(camera: Camera): void;
  77567. /**
  77568. * @hidden Internal
  77569. */
  77570. _updateEffects(): void;
  77571. /**
  77572. * Internal
  77573. * @returns if all the contained post processes are ready.
  77574. * @hidden
  77575. */
  77576. _isReady(): boolean;
  77577. }
  77578. }
  77579. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  77580. /** @hidden */
  77581. export var chromaticAberrationPixelShader: {
  77582. name: string;
  77583. shader: string;
  77584. };
  77585. }
  77586. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  77587. import { Vector2 } from "babylonjs/Maths/math.vector";
  77588. import { Nullable } from "babylonjs/types";
  77589. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77590. import { Camera } from "babylonjs/Cameras/camera";
  77591. import { Engine } from "babylonjs/Engines/engine";
  77592. import "babylonjs/Shaders/chromaticAberration.fragment";
  77593. import { Scene } from "babylonjs/scene";
  77594. /**
  77595. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  77596. */
  77597. export class ChromaticAberrationPostProcess extends PostProcess {
  77598. /**
  77599. * The amount of seperation of rgb channels (default: 30)
  77600. */
  77601. aberrationAmount: number;
  77602. /**
  77603. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  77604. */
  77605. radialIntensity: number;
  77606. /**
  77607. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  77608. */
  77609. direction: Vector2;
  77610. /**
  77611. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  77612. */
  77613. centerPosition: Vector2;
  77614. /** The width of the screen to apply the effect on */
  77615. screenWidth: number;
  77616. /** The height of the screen to apply the effect on */
  77617. screenHeight: number;
  77618. /**
  77619. * Gets a string identifying the name of the class
  77620. * @returns "ChromaticAberrationPostProcess" string
  77621. */
  77622. getClassName(): string;
  77623. /**
  77624. * Creates a new instance ChromaticAberrationPostProcess
  77625. * @param name The name of the effect.
  77626. * @param screenWidth The width of the screen to apply the effect on.
  77627. * @param screenHeight The height of the screen to apply the effect on.
  77628. * @param options The required width/height ratio to downsize to before computing the render pass.
  77629. * @param camera The camera to apply the render pass to.
  77630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77631. * @param engine The engine which the post process will be applied. (default: current engine)
  77632. * @param reusable If the post process can be reused on the same frame. (default: false)
  77633. * @param textureType Type of textures used when performing the post process. (default: 0)
  77634. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  77635. */
  77636. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77637. /** @hidden */
  77638. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  77639. }
  77640. }
  77641. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  77642. /** @hidden */
  77643. export var circleOfConfusionPixelShader: {
  77644. name: string;
  77645. shader: string;
  77646. };
  77647. }
  77648. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  77649. import { Nullable } from "babylonjs/types";
  77650. import { Engine } from "babylonjs/Engines/engine";
  77651. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77653. import { Camera } from "babylonjs/Cameras/camera";
  77654. import "babylonjs/Shaders/circleOfConfusion.fragment";
  77655. /**
  77656. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  77657. */
  77658. export class CircleOfConfusionPostProcess extends PostProcess {
  77659. /**
  77660. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  77661. */
  77662. lensSize: number;
  77663. /**
  77664. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77665. */
  77666. fStop: number;
  77667. /**
  77668. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77669. */
  77670. focusDistance: number;
  77671. /**
  77672. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  77673. */
  77674. focalLength: number;
  77675. /**
  77676. * Gets a string identifying the name of the class
  77677. * @returns "CircleOfConfusionPostProcess" string
  77678. */
  77679. getClassName(): string;
  77680. private _depthTexture;
  77681. /**
  77682. * Creates a new instance CircleOfConfusionPostProcess
  77683. * @param name The name of the effect.
  77684. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  77685. * @param options The required width/height ratio to downsize to before computing the render pass.
  77686. * @param camera The camera to apply the render pass to.
  77687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77688. * @param engine The engine which the post process will be applied. (default: current engine)
  77689. * @param reusable If the post process can be reused on the same frame. (default: false)
  77690. * @param textureType Type of textures used when performing the post process. (default: 0)
  77691. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  77692. */
  77693. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77694. /**
  77695. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  77696. */
  77697. set depthTexture(value: RenderTargetTexture);
  77698. }
  77699. }
  77700. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  77701. /** @hidden */
  77702. export var colorCorrectionPixelShader: {
  77703. name: string;
  77704. shader: string;
  77705. };
  77706. }
  77707. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  77708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77709. import { Engine } from "babylonjs/Engines/engine";
  77710. import { Camera } from "babylonjs/Cameras/camera";
  77711. import "babylonjs/Shaders/colorCorrection.fragment";
  77712. import { Nullable } from "babylonjs/types";
  77713. import { Scene } from "babylonjs/scene";
  77714. /**
  77715. *
  77716. * This post-process allows the modification of rendered colors by using
  77717. * a 'look-up table' (LUT). This effect is also called Color Grading.
  77718. *
  77719. * The object needs to be provided an url to a texture containing the color
  77720. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  77721. * Use an image editing software to tweak the LUT to match your needs.
  77722. *
  77723. * For an example of a color LUT, see here:
  77724. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  77725. * For explanations on color grading, see here:
  77726. * @see http://udn.epicgames.com/Three/ColorGrading.html
  77727. *
  77728. */
  77729. export class ColorCorrectionPostProcess extends PostProcess {
  77730. private _colorTableTexture;
  77731. /**
  77732. * Gets the color table url used to create the LUT texture
  77733. */
  77734. colorTableUrl: string;
  77735. /**
  77736. * Gets a string identifying the name of the class
  77737. * @returns "ColorCorrectionPostProcess" string
  77738. */
  77739. getClassName(): string;
  77740. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77741. /** @hidden */
  77742. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  77743. }
  77744. }
  77745. declare module "babylonjs/Shaders/convolution.fragment" {
  77746. /** @hidden */
  77747. export var convolutionPixelShader: {
  77748. name: string;
  77749. shader: string;
  77750. };
  77751. }
  77752. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  77753. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77754. import { Nullable } from "babylonjs/types";
  77755. import { Camera } from "babylonjs/Cameras/camera";
  77756. import { Engine } from "babylonjs/Engines/engine";
  77757. import "babylonjs/Shaders/convolution.fragment";
  77758. import { Scene } from "babylonjs/scene";
  77759. /**
  77760. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  77761. * input texture to perform effects such as edge detection or sharpening
  77762. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  77763. */
  77764. export class ConvolutionPostProcess extends PostProcess {
  77765. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  77766. kernel: number[];
  77767. /**
  77768. * Gets a string identifying the name of the class
  77769. * @returns "ConvolutionPostProcess" string
  77770. */
  77771. getClassName(): string;
  77772. /**
  77773. * Creates a new instance ConvolutionPostProcess
  77774. * @param name The name of the effect.
  77775. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  77776. * @param options The required width/height ratio to downsize to before computing the render pass.
  77777. * @param camera The camera to apply the render pass to.
  77778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77779. * @param engine The engine which the post process will be applied. (default: current engine)
  77780. * @param reusable If the post process can be reused on the same frame. (default: false)
  77781. * @param textureType Type of textures used when performing the post process. (default: 0)
  77782. */
  77783. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77784. /** @hidden */
  77785. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  77786. /**
  77787. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77788. */
  77789. static EdgeDetect0Kernel: number[];
  77790. /**
  77791. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77792. */
  77793. static EdgeDetect1Kernel: number[];
  77794. /**
  77795. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77796. */
  77797. static EdgeDetect2Kernel: number[];
  77798. /**
  77799. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77800. */
  77801. static SharpenKernel: number[];
  77802. /**
  77803. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77804. */
  77805. static EmbossKernel: number[];
  77806. /**
  77807. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77808. */
  77809. static GaussianKernel: number[];
  77810. }
  77811. }
  77812. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  77813. import { Nullable } from "babylonjs/types";
  77814. import { Vector2 } from "babylonjs/Maths/math.vector";
  77815. import { Camera } from "babylonjs/Cameras/camera";
  77816. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77817. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  77818. import { Engine } from "babylonjs/Engines/engine";
  77819. import { Scene } from "babylonjs/scene";
  77820. /**
  77821. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  77822. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  77823. * based on samples that have a large difference in distance than the center pixel.
  77824. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  77825. */
  77826. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  77827. /**
  77828. * The direction the blur should be applied
  77829. */
  77830. direction: Vector2;
  77831. /**
  77832. * Gets a string identifying the name of the class
  77833. * @returns "DepthOfFieldBlurPostProcess" string
  77834. */
  77835. getClassName(): string;
  77836. /**
  77837. * Creates a new instance CircleOfConfusionPostProcess
  77838. * @param name The name of the effect.
  77839. * @param scene The scene the effect belongs to.
  77840. * @param direction The direction the blur should be applied.
  77841. * @param kernel The size of the kernel used to blur.
  77842. * @param options The required width/height ratio to downsize to before computing the render pass.
  77843. * @param camera The camera to apply the render pass to.
  77844. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  77845. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  77846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77847. * @param engine The engine which the post process will be applied. (default: current engine)
  77848. * @param reusable If the post process can be reused on the same frame. (default: false)
  77849. * @param textureType Type of textures used when performing the post process. (default: 0)
  77850. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  77851. */
  77852. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77853. }
  77854. }
  77855. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  77856. /** @hidden */
  77857. export var depthOfFieldMergePixelShader: {
  77858. name: string;
  77859. shader: string;
  77860. };
  77861. }
  77862. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  77863. import { Nullable } from "babylonjs/types";
  77864. import { Camera } from "babylonjs/Cameras/camera";
  77865. import { Effect } from "babylonjs/Materials/effect";
  77866. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77867. import { Engine } from "babylonjs/Engines/engine";
  77868. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  77869. /**
  77870. * Options to be set when merging outputs from the default pipeline.
  77871. */
  77872. export class DepthOfFieldMergePostProcessOptions {
  77873. /**
  77874. * The original image to merge on top of
  77875. */
  77876. originalFromInput: PostProcess;
  77877. /**
  77878. * Parameters to perform the merge of the depth of field effect
  77879. */
  77880. depthOfField?: {
  77881. circleOfConfusion: PostProcess;
  77882. blurSteps: Array<PostProcess>;
  77883. };
  77884. /**
  77885. * Parameters to perform the merge of bloom effect
  77886. */
  77887. bloom?: {
  77888. blurred: PostProcess;
  77889. weight: number;
  77890. };
  77891. }
  77892. /**
  77893. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77894. */
  77895. export class DepthOfFieldMergePostProcess extends PostProcess {
  77896. private blurSteps;
  77897. /**
  77898. * Gets a string identifying the name of the class
  77899. * @returns "DepthOfFieldMergePostProcess" string
  77900. */
  77901. getClassName(): string;
  77902. /**
  77903. * Creates a new instance of DepthOfFieldMergePostProcess
  77904. * @param name The name of the effect.
  77905. * @param originalFromInput Post process which's input will be used for the merge.
  77906. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  77907. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  77908. * @param options The required width/height ratio to downsize to before computing the render pass.
  77909. * @param camera The camera to apply the render pass to.
  77910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77911. * @param engine The engine which the post process will be applied. (default: current engine)
  77912. * @param reusable If the post process can be reused on the same frame. (default: false)
  77913. * @param textureType Type of textures used when performing the post process. (default: 0)
  77914. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  77915. */
  77916. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77917. /**
  77918. * Updates the effect with the current post process compile time values and recompiles the shader.
  77919. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  77920. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  77921. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  77922. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  77923. * @param onCompiled Called when the shader has been compiled.
  77924. * @param onError Called if there is an error when compiling a shader.
  77925. */
  77926. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  77927. }
  77928. }
  77929. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  77930. import { Nullable } from "babylonjs/types";
  77931. import { Camera } from "babylonjs/Cameras/camera";
  77932. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77934. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77935. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77936. import { Scene } from "babylonjs/scene";
  77937. /**
  77938. * Specifies the level of max blur that should be applied when using the depth of field effect
  77939. */
  77940. export enum DepthOfFieldEffectBlurLevel {
  77941. /**
  77942. * Subtle blur
  77943. */
  77944. Low = 0,
  77945. /**
  77946. * Medium blur
  77947. */
  77948. Medium = 1,
  77949. /**
  77950. * Large blur
  77951. */
  77952. High = 2
  77953. }
  77954. /**
  77955. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  77956. */
  77957. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  77958. private _circleOfConfusion;
  77959. /**
  77960. * @hidden Internal, blurs from high to low
  77961. */
  77962. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  77963. private _depthOfFieldBlurY;
  77964. private _dofMerge;
  77965. /**
  77966. * @hidden Internal post processes in depth of field effect
  77967. */
  77968. _effects: Array<PostProcess>;
  77969. /**
  77970. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  77971. */
  77972. set focalLength(value: number);
  77973. get focalLength(): number;
  77974. /**
  77975. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77976. */
  77977. set fStop(value: number);
  77978. get fStop(): number;
  77979. /**
  77980. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77981. */
  77982. set focusDistance(value: number);
  77983. get focusDistance(): number;
  77984. /**
  77985. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  77986. */
  77987. set lensSize(value: number);
  77988. get lensSize(): number;
  77989. /**
  77990. * Creates a new instance DepthOfFieldEffect
  77991. * @param scene The scene the effect belongs to.
  77992. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  77993. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77994. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  77995. */
  77996. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  77997. /**
  77998. * Get the current class name of the current effet
  77999. * @returns "DepthOfFieldEffect"
  78000. */
  78001. getClassName(): string;
  78002. /**
  78003. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  78004. */
  78005. set depthTexture(value: RenderTargetTexture);
  78006. /**
  78007. * Disposes each of the internal effects for a given camera.
  78008. * @param camera The camera to dispose the effect on.
  78009. */
  78010. disposeEffects(camera: Camera): void;
  78011. /**
  78012. * @hidden Internal
  78013. */
  78014. _updateEffects(): void;
  78015. /**
  78016. * Internal
  78017. * @returns if all the contained post processes are ready.
  78018. * @hidden
  78019. */
  78020. _isReady(): boolean;
  78021. }
  78022. }
  78023. declare module "babylonjs/Shaders/displayPass.fragment" {
  78024. /** @hidden */
  78025. export var displayPassPixelShader: {
  78026. name: string;
  78027. shader: string;
  78028. };
  78029. }
  78030. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  78031. import { Nullable } from "babylonjs/types";
  78032. import { Camera } from "babylonjs/Cameras/camera";
  78033. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78034. import { Engine } from "babylonjs/Engines/engine";
  78035. import "babylonjs/Shaders/displayPass.fragment";
  78036. import { Scene } from "babylonjs/scene";
  78037. /**
  78038. * DisplayPassPostProcess which produces an output the same as it's input
  78039. */
  78040. export class DisplayPassPostProcess extends PostProcess {
  78041. /**
  78042. * Gets a string identifying the name of the class
  78043. * @returns "DisplayPassPostProcess" string
  78044. */
  78045. getClassName(): string;
  78046. /**
  78047. * Creates the DisplayPassPostProcess
  78048. * @param name The name of the effect.
  78049. * @param options The required width/height ratio to downsize to before computing the render pass.
  78050. * @param camera The camera to apply the render pass to.
  78051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78052. * @param engine The engine which the post process will be applied. (default: current engine)
  78053. * @param reusable If the post process can be reused on the same frame. (default: false)
  78054. */
  78055. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78056. /** @hidden */
  78057. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  78058. }
  78059. }
  78060. declare module "babylonjs/Shaders/filter.fragment" {
  78061. /** @hidden */
  78062. export var filterPixelShader: {
  78063. name: string;
  78064. shader: string;
  78065. };
  78066. }
  78067. declare module "babylonjs/PostProcesses/filterPostProcess" {
  78068. import { Nullable } from "babylonjs/types";
  78069. import { Matrix } from "babylonjs/Maths/math.vector";
  78070. import { Camera } from "babylonjs/Cameras/camera";
  78071. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78072. import { Engine } from "babylonjs/Engines/engine";
  78073. import "babylonjs/Shaders/filter.fragment";
  78074. import { Scene } from "babylonjs/scene";
  78075. /**
  78076. * Applies a kernel filter to the image
  78077. */
  78078. export class FilterPostProcess extends PostProcess {
  78079. /** The matrix to be applied to the image */
  78080. kernelMatrix: Matrix;
  78081. /**
  78082. * Gets a string identifying the name of the class
  78083. * @returns "FilterPostProcess" string
  78084. */
  78085. getClassName(): string;
  78086. /**
  78087. *
  78088. * @param name The name of the effect.
  78089. * @param kernelMatrix The matrix to be applied to the image
  78090. * @param options The required width/height ratio to downsize to before computing the render pass.
  78091. * @param camera The camera to apply the render pass to.
  78092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78093. * @param engine The engine which the post process will be applied. (default: current engine)
  78094. * @param reusable If the post process can be reused on the same frame. (default: false)
  78095. */
  78096. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78097. /** @hidden */
  78098. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  78099. }
  78100. }
  78101. declare module "babylonjs/Shaders/fxaa.fragment" {
  78102. /** @hidden */
  78103. export var fxaaPixelShader: {
  78104. name: string;
  78105. shader: string;
  78106. };
  78107. }
  78108. declare module "babylonjs/Shaders/fxaa.vertex" {
  78109. /** @hidden */
  78110. export var fxaaVertexShader: {
  78111. name: string;
  78112. shader: string;
  78113. };
  78114. }
  78115. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  78116. import { Nullable } from "babylonjs/types";
  78117. import { Camera } from "babylonjs/Cameras/camera";
  78118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78119. import { Engine } from "babylonjs/Engines/engine";
  78120. import "babylonjs/Shaders/fxaa.fragment";
  78121. import "babylonjs/Shaders/fxaa.vertex";
  78122. import { Scene } from "babylonjs/scene";
  78123. /**
  78124. * Fxaa post process
  78125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  78126. */
  78127. export class FxaaPostProcess extends PostProcess {
  78128. /**
  78129. * Gets a string identifying the name of the class
  78130. * @returns "FxaaPostProcess" string
  78131. */
  78132. getClassName(): string;
  78133. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  78134. private _getDefines;
  78135. /** @hidden */
  78136. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  78137. }
  78138. }
  78139. declare module "babylonjs/Shaders/grain.fragment" {
  78140. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  78141. /** @hidden */
  78142. export var grainPixelShader: {
  78143. name: string;
  78144. shader: string;
  78145. };
  78146. }
  78147. declare module "babylonjs/PostProcesses/grainPostProcess" {
  78148. import { Nullable } from "babylonjs/types";
  78149. import { Camera } from "babylonjs/Cameras/camera";
  78150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78151. import { Engine } from "babylonjs/Engines/engine";
  78152. import "babylonjs/Shaders/grain.fragment";
  78153. import { Scene } from "babylonjs/scene";
  78154. /**
  78155. * The GrainPostProcess adds noise to the image at mid luminance levels
  78156. */
  78157. export class GrainPostProcess extends PostProcess {
  78158. /**
  78159. * The intensity of the grain added (default: 30)
  78160. */
  78161. intensity: number;
  78162. /**
  78163. * If the grain should be randomized on every frame
  78164. */
  78165. animated: boolean;
  78166. /**
  78167. * Gets a string identifying the name of the class
  78168. * @returns "GrainPostProcess" string
  78169. */
  78170. getClassName(): string;
  78171. /**
  78172. * Creates a new instance of @see GrainPostProcess
  78173. * @param name The name of the effect.
  78174. * @param options The required width/height ratio to downsize to before computing the render pass.
  78175. * @param camera The camera to apply the render pass to.
  78176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78177. * @param engine The engine which the post process will be applied. (default: current engine)
  78178. * @param reusable If the post process can be reused on the same frame. (default: false)
  78179. * @param textureType Type of textures used when performing the post process. (default: 0)
  78180. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  78181. */
  78182. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78183. /** @hidden */
  78184. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  78185. }
  78186. }
  78187. declare module "babylonjs/Shaders/highlights.fragment" {
  78188. /** @hidden */
  78189. export var highlightsPixelShader: {
  78190. name: string;
  78191. shader: string;
  78192. };
  78193. }
  78194. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  78195. import { Nullable } from "babylonjs/types";
  78196. import { Camera } from "babylonjs/Cameras/camera";
  78197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78198. import { Engine } from "babylonjs/Engines/engine";
  78199. import "babylonjs/Shaders/highlights.fragment";
  78200. /**
  78201. * Extracts highlights from the image
  78202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78203. */
  78204. export class HighlightsPostProcess extends PostProcess {
  78205. /**
  78206. * Gets a string identifying the name of the class
  78207. * @returns "HighlightsPostProcess" string
  78208. */
  78209. getClassName(): string;
  78210. /**
  78211. * Extracts highlights from the image
  78212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78213. * @param name The name of the effect.
  78214. * @param options The required width/height ratio to downsize to before computing the render pass.
  78215. * @param camera The camera to apply the render pass to.
  78216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78217. * @param engine The engine which the post process will be applied. (default: current engine)
  78218. * @param reusable If the post process can be reused on the same frame. (default: false)
  78219. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  78220. */
  78221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  78222. }
  78223. }
  78224. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  78225. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  78226. /**
  78227. * Contains all parameters needed for the prepass to perform
  78228. * motion blur
  78229. */
  78230. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  78231. /**
  78232. * Is motion blur enabled
  78233. */
  78234. enabled: boolean;
  78235. /**
  78236. * Name of the configuration
  78237. */
  78238. name: string;
  78239. /**
  78240. * Textures that should be present in the MRT for this effect to work
  78241. */
  78242. readonly texturesRequired: number[];
  78243. }
  78244. }
  78245. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  78246. import { Nullable } from "babylonjs/types";
  78247. import { Scene } from "babylonjs/scene";
  78248. import { ISceneComponent } from "babylonjs/sceneComponent";
  78249. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  78250. module "babylonjs/scene" {
  78251. interface Scene {
  78252. /** @hidden (Backing field) */
  78253. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  78254. /**
  78255. * Gets or Sets the current geometry buffer associated to the scene.
  78256. */
  78257. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  78258. /**
  78259. * Enables a GeometryBufferRender and associates it with the scene
  78260. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  78261. * @returns the GeometryBufferRenderer
  78262. */
  78263. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  78264. /**
  78265. * Disables the GeometryBufferRender associated with the scene
  78266. */
  78267. disableGeometryBufferRenderer(): void;
  78268. }
  78269. }
  78270. /**
  78271. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  78272. * in several rendering techniques.
  78273. */
  78274. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  78275. /**
  78276. * The component name helpful to identify the component in the list of scene components.
  78277. */
  78278. readonly name: string;
  78279. /**
  78280. * The scene the component belongs to.
  78281. */
  78282. scene: Scene;
  78283. /**
  78284. * Creates a new instance of the component for the given scene
  78285. * @param scene Defines the scene to register the component in
  78286. */
  78287. constructor(scene: Scene);
  78288. /**
  78289. * Registers the component in a given scene
  78290. */
  78291. register(): void;
  78292. /**
  78293. * Rebuilds the elements related to this component in case of
  78294. * context lost for instance.
  78295. */
  78296. rebuild(): void;
  78297. /**
  78298. * Disposes the component and the associated ressources
  78299. */
  78300. dispose(): void;
  78301. private _gatherRenderTargets;
  78302. }
  78303. }
  78304. declare module "babylonjs/Shaders/motionBlur.fragment" {
  78305. /** @hidden */
  78306. export var motionBlurPixelShader: {
  78307. name: string;
  78308. shader: string;
  78309. };
  78310. }
  78311. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  78312. import { Nullable } from "babylonjs/types";
  78313. import { Camera } from "babylonjs/Cameras/camera";
  78314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78316. import "babylonjs/Animations/animatable";
  78317. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  78318. import "babylonjs/Shaders/motionBlur.fragment";
  78319. import { Engine } from "babylonjs/Engines/engine";
  78320. import { Scene } from "babylonjs/scene";
  78321. /**
  78322. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  78323. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  78324. * As an example, all you have to do is to create the post-process:
  78325. * var mb = new BABYLON.MotionBlurPostProcess(
  78326. * 'mb', // The name of the effect.
  78327. * scene, // The scene containing the objects to blur according to their velocity.
  78328. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  78329. * camera // The camera to apply the render pass to.
  78330. * );
  78331. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  78332. */
  78333. export class MotionBlurPostProcess extends PostProcess {
  78334. /**
  78335. * Defines how much the image is blurred by the movement. Default value is equal to 1
  78336. */
  78337. motionStrength: number;
  78338. /**
  78339. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  78340. */
  78341. get motionBlurSamples(): number;
  78342. /**
  78343. * Sets the number of iterations to be used for motion blur quality
  78344. */
  78345. set motionBlurSamples(samples: number);
  78346. private _motionBlurSamples;
  78347. /**
  78348. * Gets wether or not the motion blur post-process is in object based mode.
  78349. */
  78350. get isObjectBased(): boolean;
  78351. /**
  78352. * Sets wether or not the motion blur post-process is in object based mode.
  78353. */
  78354. set isObjectBased(value: boolean);
  78355. private _isObjectBased;
  78356. private _forceGeometryBuffer;
  78357. private _geometryBufferRenderer;
  78358. private _prePassRenderer;
  78359. private _invViewProjection;
  78360. private _previousViewProjection;
  78361. /**
  78362. * Gets a string identifying the name of the class
  78363. * @returns "MotionBlurPostProcess" string
  78364. */
  78365. getClassName(): string;
  78366. /**
  78367. * Creates a new instance MotionBlurPostProcess
  78368. * @param name The name of the effect.
  78369. * @param scene The scene containing the objects to blur according to their velocity.
  78370. * @param options The required width/height ratio to downsize to before computing the render pass.
  78371. * @param camera The camera to apply the render pass to.
  78372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78373. * @param engine The engine which the post process will be applied. (default: current engine)
  78374. * @param reusable If the post process can be reused on the same frame. (default: false)
  78375. * @param textureType Type of textures used when performing the post process. (default: 0)
  78376. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  78377. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  78378. */
  78379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  78380. /**
  78381. * Excludes the given skinned mesh from computing bones velocities.
  78382. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  78383. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  78384. */
  78385. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  78386. /**
  78387. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  78388. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  78389. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  78390. */
  78391. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  78392. /**
  78393. * Disposes the post process.
  78394. * @param camera The camera to dispose the post process on.
  78395. */
  78396. dispose(camera?: Camera): void;
  78397. /**
  78398. * Called on the mode changed (object based or screen based).
  78399. */
  78400. private _applyMode;
  78401. /**
  78402. * Called on the effect is applied when the motion blur post-process is in object based mode.
  78403. */
  78404. private _onApplyObjectBased;
  78405. /**
  78406. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  78407. */
  78408. private _onApplyScreenBased;
  78409. /**
  78410. * Called on the effect must be updated (changed mode, samples count, etc.).
  78411. */
  78412. private _updateEffect;
  78413. /** @hidden */
  78414. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  78415. }
  78416. }
  78417. declare module "babylonjs/Shaders/refraction.fragment" {
  78418. /** @hidden */
  78419. export var refractionPixelShader: {
  78420. name: string;
  78421. shader: string;
  78422. };
  78423. }
  78424. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  78425. import { Color3 } from "babylonjs/Maths/math.color";
  78426. import { Camera } from "babylonjs/Cameras/camera";
  78427. import { Texture } from "babylonjs/Materials/Textures/texture";
  78428. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78429. import { Engine } from "babylonjs/Engines/engine";
  78430. import "babylonjs/Shaders/refraction.fragment";
  78431. import { Scene } from "babylonjs/scene";
  78432. /**
  78433. * Post process which applies a refractin texture
  78434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78435. */
  78436. export class RefractionPostProcess extends PostProcess {
  78437. private _refTexture;
  78438. private _ownRefractionTexture;
  78439. /** the base color of the refraction (used to taint the rendering) */
  78440. color: Color3;
  78441. /** simulated refraction depth */
  78442. depth: number;
  78443. /** the coefficient of the base color (0 to remove base color tainting) */
  78444. colorLevel: number;
  78445. /** Gets the url used to load the refraction texture */
  78446. refractionTextureUrl: string;
  78447. /**
  78448. * Gets or sets the refraction texture
  78449. * Please note that you are responsible for disposing the texture if you set it manually
  78450. */
  78451. get refractionTexture(): Texture;
  78452. set refractionTexture(value: Texture);
  78453. /**
  78454. * Gets a string identifying the name of the class
  78455. * @returns "RefractionPostProcess" string
  78456. */
  78457. getClassName(): string;
  78458. /**
  78459. * Initializes the RefractionPostProcess
  78460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78461. * @param name The name of the effect.
  78462. * @param refractionTextureUrl Url of the refraction texture to use
  78463. * @param color the base color of the refraction (used to taint the rendering)
  78464. * @param depth simulated refraction depth
  78465. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  78466. * @param camera The camera to apply the render pass to.
  78467. * @param options The required width/height ratio to downsize to before computing the render pass.
  78468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78469. * @param engine The engine which the post process will be applied. (default: current engine)
  78470. * @param reusable If the post process can be reused on the same frame. (default: false)
  78471. */
  78472. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78473. /**
  78474. * Disposes of the post process
  78475. * @param camera Camera to dispose post process on
  78476. */
  78477. dispose(camera: Camera): void;
  78478. /** @hidden */
  78479. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  78480. }
  78481. }
  78482. declare module "babylonjs/Shaders/sharpen.fragment" {
  78483. /** @hidden */
  78484. export var sharpenPixelShader: {
  78485. name: string;
  78486. shader: string;
  78487. };
  78488. }
  78489. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  78490. import { Nullable } from "babylonjs/types";
  78491. import { Camera } from "babylonjs/Cameras/camera";
  78492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78493. import "babylonjs/Shaders/sharpen.fragment";
  78494. import { Engine } from "babylonjs/Engines/engine";
  78495. import { Scene } from "babylonjs/scene";
  78496. /**
  78497. * The SharpenPostProcess applies a sharpen kernel to every pixel
  78498. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  78499. */
  78500. export class SharpenPostProcess extends PostProcess {
  78501. /**
  78502. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  78503. */
  78504. colorAmount: number;
  78505. /**
  78506. * How much sharpness should be applied (default: 0.3)
  78507. */
  78508. edgeAmount: number;
  78509. /**
  78510. * Gets a string identifying the name of the class
  78511. * @returns "SharpenPostProcess" string
  78512. */
  78513. getClassName(): string;
  78514. /**
  78515. * Creates a new instance ConvolutionPostProcess
  78516. * @param name The name of the effect.
  78517. * @param options The required width/height ratio to downsize to before computing the render pass.
  78518. * @param camera The camera to apply the render pass to.
  78519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78520. * @param engine The engine which the post process will be applied. (default: current engine)
  78521. * @param reusable If the post process can be reused on the same frame. (default: false)
  78522. * @param textureType Type of textures used when performing the post process. (default: 0)
  78523. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  78524. */
  78525. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78526. /** @hidden */
  78527. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  78528. }
  78529. }
  78530. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  78531. import { Nullable } from "babylonjs/types";
  78532. import { Camera } from "babylonjs/Cameras/camera";
  78533. import { Engine } from "babylonjs/Engines/engine";
  78534. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  78535. import { IInspectable } from "babylonjs/Misc/iInspectable";
  78536. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  78537. /**
  78538. * PostProcessRenderPipeline
  78539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78540. */
  78541. export class PostProcessRenderPipeline {
  78542. private engine;
  78543. private _renderEffects;
  78544. private _renderEffectsForIsolatedPass;
  78545. /**
  78546. * List of inspectable custom properties (used by the Inspector)
  78547. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78548. */
  78549. inspectableCustomProperties: IInspectable[];
  78550. /**
  78551. * @hidden
  78552. */
  78553. protected _cameras: Camera[];
  78554. /** @hidden */
  78555. _name: string;
  78556. /**
  78557. * Gets pipeline name
  78558. */
  78559. get name(): string;
  78560. /** Gets the list of attached cameras */
  78561. get cameras(): Camera[];
  78562. /**
  78563. * Initializes a PostProcessRenderPipeline
  78564. * @param engine engine to add the pipeline to
  78565. * @param name name of the pipeline
  78566. */
  78567. constructor(engine: Engine, name: string);
  78568. /**
  78569. * Gets the class name
  78570. * @returns "PostProcessRenderPipeline"
  78571. */
  78572. getClassName(): string;
  78573. /**
  78574. * If all the render effects in the pipeline are supported
  78575. */
  78576. get isSupported(): boolean;
  78577. /**
  78578. * Adds an effect to the pipeline
  78579. * @param renderEffect the effect to add
  78580. */
  78581. addEffect(renderEffect: PostProcessRenderEffect): void;
  78582. /** @hidden */
  78583. _rebuild(): void;
  78584. /** @hidden */
  78585. _enableEffect(renderEffectName: string, cameras: Camera): void;
  78586. /** @hidden */
  78587. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  78588. /** @hidden */
  78589. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78590. /** @hidden */
  78591. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78592. /** @hidden */
  78593. _attachCameras(cameras: Camera, unique: boolean): void;
  78594. /** @hidden */
  78595. _attachCameras(cameras: Camera[], unique: boolean): void;
  78596. /** @hidden */
  78597. _detachCameras(cameras: Camera): void;
  78598. /** @hidden */
  78599. _detachCameras(cameras: Nullable<Camera[]>): void;
  78600. /** @hidden */
  78601. _update(): void;
  78602. /** @hidden */
  78603. _reset(): void;
  78604. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  78605. /**
  78606. * Sets the required values to the prepass renderer.
  78607. * @param prePassRenderer defines the prepass renderer to setup.
  78608. * @returns true if the pre pass is needed.
  78609. */
  78610. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  78611. /**
  78612. * Disposes of the pipeline
  78613. */
  78614. dispose(): void;
  78615. }
  78616. }
  78617. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  78618. import { Camera } from "babylonjs/Cameras/camera";
  78619. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78620. /**
  78621. * PostProcessRenderPipelineManager class
  78622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78623. */
  78624. export class PostProcessRenderPipelineManager {
  78625. private _renderPipelines;
  78626. /**
  78627. * Initializes a PostProcessRenderPipelineManager
  78628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78629. */
  78630. constructor();
  78631. /**
  78632. * Gets the list of supported render pipelines
  78633. */
  78634. get supportedPipelines(): PostProcessRenderPipeline[];
  78635. /**
  78636. * Adds a pipeline to the manager
  78637. * @param renderPipeline The pipeline to add
  78638. */
  78639. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  78640. /**
  78641. * Attaches a camera to the pipeline
  78642. * @param renderPipelineName The name of the pipeline to attach to
  78643. * @param cameras the camera to attach
  78644. * @param unique if the camera can be attached multiple times to the pipeline
  78645. */
  78646. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  78647. /**
  78648. * Detaches a camera from the pipeline
  78649. * @param renderPipelineName The name of the pipeline to detach from
  78650. * @param cameras the camera to detach
  78651. */
  78652. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  78653. /**
  78654. * Enables an effect by name on a pipeline
  78655. * @param renderPipelineName the name of the pipeline to enable the effect in
  78656. * @param renderEffectName the name of the effect to enable
  78657. * @param cameras the cameras that the effect should be enabled on
  78658. */
  78659. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78660. /**
  78661. * Disables an effect by name on a pipeline
  78662. * @param renderPipelineName the name of the pipeline to disable the effect in
  78663. * @param renderEffectName the name of the effect to disable
  78664. * @param cameras the cameras that the effect should be disabled on
  78665. */
  78666. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78667. /**
  78668. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  78669. */
  78670. update(): void;
  78671. /** @hidden */
  78672. _rebuild(): void;
  78673. /**
  78674. * Disposes of the manager and pipelines
  78675. */
  78676. dispose(): void;
  78677. }
  78678. }
  78679. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  78680. import { ISceneComponent } from "babylonjs/sceneComponent";
  78681. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  78682. import { Scene } from "babylonjs/scene";
  78683. module "babylonjs/scene" {
  78684. interface Scene {
  78685. /** @hidden (Backing field) */
  78686. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78687. /**
  78688. * Gets the postprocess render pipeline manager
  78689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78690. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78691. */
  78692. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78693. }
  78694. }
  78695. /**
  78696. * Defines the Render Pipeline scene component responsible to rendering pipelines
  78697. */
  78698. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  78699. /**
  78700. * The component name helpfull to identify the component in the list of scene components.
  78701. */
  78702. readonly name: string;
  78703. /**
  78704. * The scene the component belongs to.
  78705. */
  78706. scene: Scene;
  78707. /**
  78708. * Creates a new instance of the component for the given scene
  78709. * @param scene Defines the scene to register the component in
  78710. */
  78711. constructor(scene: Scene);
  78712. /**
  78713. * Registers the component in a given scene
  78714. */
  78715. register(): void;
  78716. /**
  78717. * Rebuilds the elements related to this component in case of
  78718. * context lost for instance.
  78719. */
  78720. rebuild(): void;
  78721. /**
  78722. * Disposes the component and the associated ressources
  78723. */
  78724. dispose(): void;
  78725. private _gatherRenderTargets;
  78726. }
  78727. }
  78728. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  78729. import { Nullable } from "babylonjs/types";
  78730. import { Observable } from "babylonjs/Misc/observable";
  78731. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  78732. import { Camera } from "babylonjs/Cameras/camera";
  78733. import { IDisposable } from "babylonjs/scene";
  78734. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  78735. import { Scene } from "babylonjs/scene";
  78736. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  78737. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  78738. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  78739. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  78740. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  78741. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78742. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  78743. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78744. import { Animation } from "babylonjs/Animations/animation";
  78745. /**
  78746. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  78747. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78748. */
  78749. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  78750. private _scene;
  78751. private _camerasToBeAttached;
  78752. /**
  78753. * ID of the sharpen post process,
  78754. */
  78755. private readonly SharpenPostProcessId;
  78756. /**
  78757. * @ignore
  78758. * ID of the image processing post process;
  78759. */
  78760. readonly ImageProcessingPostProcessId: string;
  78761. /**
  78762. * @ignore
  78763. * ID of the Fast Approximate Anti-Aliasing post process;
  78764. */
  78765. readonly FxaaPostProcessId: string;
  78766. /**
  78767. * ID of the chromatic aberration post process,
  78768. */
  78769. private readonly ChromaticAberrationPostProcessId;
  78770. /**
  78771. * ID of the grain post process
  78772. */
  78773. private readonly GrainPostProcessId;
  78774. /**
  78775. * Sharpen post process which will apply a sharpen convolution to enhance edges
  78776. */
  78777. sharpen: SharpenPostProcess;
  78778. private _sharpenEffect;
  78779. private bloom;
  78780. /**
  78781. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  78782. */
  78783. depthOfField: DepthOfFieldEffect;
  78784. /**
  78785. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  78786. */
  78787. fxaa: FxaaPostProcess;
  78788. /**
  78789. * Image post processing pass used to perform operations such as tone mapping or color grading.
  78790. */
  78791. imageProcessing: ImageProcessingPostProcess;
  78792. /**
  78793. * Chromatic aberration post process which will shift rgb colors in the image
  78794. */
  78795. chromaticAberration: ChromaticAberrationPostProcess;
  78796. private _chromaticAberrationEffect;
  78797. /**
  78798. * Grain post process which add noise to the image
  78799. */
  78800. grain: GrainPostProcess;
  78801. private _grainEffect;
  78802. /**
  78803. * Glow post process which adds a glow to emissive areas of the image
  78804. */
  78805. private _glowLayer;
  78806. /**
  78807. * Animations which can be used to tweak settings over a period of time
  78808. */
  78809. animations: Animation[];
  78810. private _imageProcessingConfigurationObserver;
  78811. private _sharpenEnabled;
  78812. private _bloomEnabled;
  78813. private _depthOfFieldEnabled;
  78814. private _depthOfFieldBlurLevel;
  78815. private _fxaaEnabled;
  78816. private _imageProcessingEnabled;
  78817. private _defaultPipelineTextureType;
  78818. private _bloomScale;
  78819. private _chromaticAberrationEnabled;
  78820. private _grainEnabled;
  78821. private _buildAllowed;
  78822. /**
  78823. * This is triggered each time the pipeline has been built.
  78824. */
  78825. onBuildObservable: Observable<DefaultRenderingPipeline>;
  78826. /**
  78827. * Gets active scene
  78828. */
  78829. get scene(): Scene;
  78830. /**
  78831. * Enable or disable the sharpen process from the pipeline
  78832. */
  78833. set sharpenEnabled(enabled: boolean);
  78834. get sharpenEnabled(): boolean;
  78835. private _resizeObserver;
  78836. private _hardwareScaleLevel;
  78837. private _bloomKernel;
  78838. /**
  78839. * Specifies the size of the bloom blur kernel, relative to the final output size
  78840. */
  78841. get bloomKernel(): number;
  78842. set bloomKernel(value: number);
  78843. /**
  78844. * Specifies the weight of the bloom in the final rendering
  78845. */
  78846. private _bloomWeight;
  78847. /**
  78848. * Specifies the luma threshold for the area that will be blurred by the bloom
  78849. */
  78850. private _bloomThreshold;
  78851. private _hdr;
  78852. /**
  78853. * The strength of the bloom.
  78854. */
  78855. set bloomWeight(value: number);
  78856. get bloomWeight(): number;
  78857. /**
  78858. * The strength of the bloom.
  78859. */
  78860. set bloomThreshold(value: number);
  78861. get bloomThreshold(): number;
  78862. /**
  78863. * The scale of the bloom, lower value will provide better performance.
  78864. */
  78865. set bloomScale(value: number);
  78866. get bloomScale(): number;
  78867. /**
  78868. * Enable or disable the bloom from the pipeline
  78869. */
  78870. set bloomEnabled(enabled: boolean);
  78871. get bloomEnabled(): boolean;
  78872. private _rebuildBloom;
  78873. /**
  78874. * If the depth of field is enabled.
  78875. */
  78876. get depthOfFieldEnabled(): boolean;
  78877. set depthOfFieldEnabled(enabled: boolean);
  78878. /**
  78879. * Blur level of the depth of field effect. (Higher blur will effect performance)
  78880. */
  78881. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  78882. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  78883. /**
  78884. * If the anti aliasing is enabled.
  78885. */
  78886. set fxaaEnabled(enabled: boolean);
  78887. get fxaaEnabled(): boolean;
  78888. private _samples;
  78889. /**
  78890. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  78891. */
  78892. set samples(sampleCount: number);
  78893. get samples(): number;
  78894. /**
  78895. * If image processing is enabled.
  78896. */
  78897. set imageProcessingEnabled(enabled: boolean);
  78898. get imageProcessingEnabled(): boolean;
  78899. /**
  78900. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  78901. */
  78902. set glowLayerEnabled(enabled: boolean);
  78903. get glowLayerEnabled(): boolean;
  78904. /**
  78905. * Gets the glow layer (or null if not defined)
  78906. */
  78907. get glowLayer(): Nullable<GlowLayer>;
  78908. /**
  78909. * Enable or disable the chromaticAberration process from the pipeline
  78910. */
  78911. set chromaticAberrationEnabled(enabled: boolean);
  78912. get chromaticAberrationEnabled(): boolean;
  78913. /**
  78914. * Enable or disable the grain process from the pipeline
  78915. */
  78916. set grainEnabled(enabled: boolean);
  78917. get grainEnabled(): boolean;
  78918. /**
  78919. * @constructor
  78920. * @param name - The rendering pipeline name (default: "")
  78921. * @param hdr - If high dynamic range textures should be used (default: true)
  78922. * @param scene - The scene linked to this pipeline (default: the last created scene)
  78923. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  78924. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  78925. */
  78926. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  78927. /**
  78928. * Get the class name
  78929. * @returns "DefaultRenderingPipeline"
  78930. */
  78931. getClassName(): string;
  78932. /**
  78933. * Force the compilation of the entire pipeline.
  78934. */
  78935. prepare(): void;
  78936. private _hasCleared;
  78937. private _prevPostProcess;
  78938. private _prevPrevPostProcess;
  78939. private _setAutoClearAndTextureSharing;
  78940. private _depthOfFieldSceneObserver;
  78941. private _buildPipeline;
  78942. private _disposePostProcesses;
  78943. /**
  78944. * Adds a camera to the pipeline
  78945. * @param camera the camera to be added
  78946. */
  78947. addCamera(camera: Camera): void;
  78948. /**
  78949. * Removes a camera from the pipeline
  78950. * @param camera the camera to remove
  78951. */
  78952. removeCamera(camera: Camera): void;
  78953. /**
  78954. * Dispose of the pipeline and stop all post processes
  78955. */
  78956. dispose(): void;
  78957. /**
  78958. * Serialize the rendering pipeline (Used when exporting)
  78959. * @returns the serialized object
  78960. */
  78961. serialize(): any;
  78962. /**
  78963. * Parse the serialized pipeline
  78964. * @param source Source pipeline.
  78965. * @param scene The scene to load the pipeline to.
  78966. * @param rootUrl The URL of the serialized pipeline.
  78967. * @returns An instantiated pipeline from the serialized object.
  78968. */
  78969. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  78970. }
  78971. }
  78972. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  78973. /** @hidden */
  78974. export var lensHighlightsPixelShader: {
  78975. name: string;
  78976. shader: string;
  78977. };
  78978. }
  78979. declare module "babylonjs/Shaders/depthOfField.fragment" {
  78980. /** @hidden */
  78981. export var depthOfFieldPixelShader: {
  78982. name: string;
  78983. shader: string;
  78984. };
  78985. }
  78986. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  78987. import { Camera } from "babylonjs/Cameras/camera";
  78988. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78989. import { Scene } from "babylonjs/scene";
  78990. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78991. import "babylonjs/Shaders/chromaticAberration.fragment";
  78992. import "babylonjs/Shaders/lensHighlights.fragment";
  78993. import "babylonjs/Shaders/depthOfField.fragment";
  78994. /**
  78995. * BABYLON.JS Chromatic Aberration GLSL Shader
  78996. * Author: Olivier Guyot
  78997. * Separates very slightly R, G and B colors on the edges of the screen
  78998. * Inspired by Francois Tarlier & Martins Upitis
  78999. */
  79000. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  79001. /**
  79002. * @ignore
  79003. * The chromatic aberration PostProcess id in the pipeline
  79004. */
  79005. LensChromaticAberrationEffect: string;
  79006. /**
  79007. * @ignore
  79008. * The highlights enhancing PostProcess id in the pipeline
  79009. */
  79010. HighlightsEnhancingEffect: string;
  79011. /**
  79012. * @ignore
  79013. * The depth-of-field PostProcess id in the pipeline
  79014. */
  79015. LensDepthOfFieldEffect: string;
  79016. private _scene;
  79017. private _depthTexture;
  79018. private _grainTexture;
  79019. private _chromaticAberrationPostProcess;
  79020. private _highlightsPostProcess;
  79021. private _depthOfFieldPostProcess;
  79022. private _edgeBlur;
  79023. private _grainAmount;
  79024. private _chromaticAberration;
  79025. private _distortion;
  79026. private _highlightsGain;
  79027. private _highlightsThreshold;
  79028. private _dofDistance;
  79029. private _dofAperture;
  79030. private _dofDarken;
  79031. private _dofPentagon;
  79032. private _blurNoise;
  79033. /**
  79034. * @constructor
  79035. *
  79036. * Effect parameters are as follow:
  79037. * {
  79038. * chromatic_aberration: number; // from 0 to x (1 for realism)
  79039. * edge_blur: number; // from 0 to x (1 for realism)
  79040. * distortion: number; // from 0 to x (1 for realism)
  79041. * grain_amount: number; // from 0 to 1
  79042. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  79043. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  79044. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  79045. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  79046. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  79047. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  79048. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  79049. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  79050. * }
  79051. * Note: if an effect parameter is unset, effect is disabled
  79052. *
  79053. * @param name The rendering pipeline name
  79054. * @param parameters - An object containing all parameters (see above)
  79055. * @param scene The scene linked to this pipeline
  79056. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  79057. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79058. */
  79059. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  79060. /**
  79061. * Get the class name
  79062. * @returns "LensRenderingPipeline"
  79063. */
  79064. getClassName(): string;
  79065. /**
  79066. * Gets associated scene
  79067. */
  79068. get scene(): Scene;
  79069. /**
  79070. * Gets or sets the edge blur
  79071. */
  79072. get edgeBlur(): number;
  79073. set edgeBlur(value: number);
  79074. /**
  79075. * Gets or sets the grain amount
  79076. */
  79077. get grainAmount(): number;
  79078. set grainAmount(value: number);
  79079. /**
  79080. * Gets or sets the chromatic aberration amount
  79081. */
  79082. get chromaticAberration(): number;
  79083. set chromaticAberration(value: number);
  79084. /**
  79085. * Gets or sets the depth of field aperture
  79086. */
  79087. get dofAperture(): number;
  79088. set dofAperture(value: number);
  79089. /**
  79090. * Gets or sets the edge distortion
  79091. */
  79092. get edgeDistortion(): number;
  79093. set edgeDistortion(value: number);
  79094. /**
  79095. * Gets or sets the depth of field distortion
  79096. */
  79097. get dofDistortion(): number;
  79098. set dofDistortion(value: number);
  79099. /**
  79100. * Gets or sets the darken out of focus amount
  79101. */
  79102. get darkenOutOfFocus(): number;
  79103. set darkenOutOfFocus(value: number);
  79104. /**
  79105. * Gets or sets a boolean indicating if blur noise is enabled
  79106. */
  79107. get blurNoise(): boolean;
  79108. set blurNoise(value: boolean);
  79109. /**
  79110. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  79111. */
  79112. get pentagonBokeh(): boolean;
  79113. set pentagonBokeh(value: boolean);
  79114. /**
  79115. * Gets or sets the highlight grain amount
  79116. */
  79117. get highlightsGain(): number;
  79118. set highlightsGain(value: number);
  79119. /**
  79120. * Gets or sets the highlight threshold
  79121. */
  79122. get highlightsThreshold(): number;
  79123. set highlightsThreshold(value: number);
  79124. /**
  79125. * Sets the amount of blur at the edges
  79126. * @param amount blur amount
  79127. */
  79128. setEdgeBlur(amount: number): void;
  79129. /**
  79130. * Sets edge blur to 0
  79131. */
  79132. disableEdgeBlur(): void;
  79133. /**
  79134. * Sets the amout of grain
  79135. * @param amount Amount of grain
  79136. */
  79137. setGrainAmount(amount: number): void;
  79138. /**
  79139. * Set grain amount to 0
  79140. */
  79141. disableGrain(): void;
  79142. /**
  79143. * Sets the chromatic aberration amount
  79144. * @param amount amount of chromatic aberration
  79145. */
  79146. setChromaticAberration(amount: number): void;
  79147. /**
  79148. * Sets chromatic aberration amount to 0
  79149. */
  79150. disableChromaticAberration(): void;
  79151. /**
  79152. * Sets the EdgeDistortion amount
  79153. * @param amount amount of EdgeDistortion
  79154. */
  79155. setEdgeDistortion(amount: number): void;
  79156. /**
  79157. * Sets edge distortion to 0
  79158. */
  79159. disableEdgeDistortion(): void;
  79160. /**
  79161. * Sets the FocusDistance amount
  79162. * @param amount amount of FocusDistance
  79163. */
  79164. setFocusDistance(amount: number): void;
  79165. /**
  79166. * Disables depth of field
  79167. */
  79168. disableDepthOfField(): void;
  79169. /**
  79170. * Sets the Aperture amount
  79171. * @param amount amount of Aperture
  79172. */
  79173. setAperture(amount: number): void;
  79174. /**
  79175. * Sets the DarkenOutOfFocus amount
  79176. * @param amount amount of DarkenOutOfFocus
  79177. */
  79178. setDarkenOutOfFocus(amount: number): void;
  79179. private _pentagonBokehIsEnabled;
  79180. /**
  79181. * Creates a pentagon bokeh effect
  79182. */
  79183. enablePentagonBokeh(): void;
  79184. /**
  79185. * Disables the pentagon bokeh effect
  79186. */
  79187. disablePentagonBokeh(): void;
  79188. /**
  79189. * Enables noise blur
  79190. */
  79191. enableNoiseBlur(): void;
  79192. /**
  79193. * Disables noise blur
  79194. */
  79195. disableNoiseBlur(): void;
  79196. /**
  79197. * Sets the HighlightsGain amount
  79198. * @param amount amount of HighlightsGain
  79199. */
  79200. setHighlightsGain(amount: number): void;
  79201. /**
  79202. * Sets the HighlightsThreshold amount
  79203. * @param amount amount of HighlightsThreshold
  79204. */
  79205. setHighlightsThreshold(amount: number): void;
  79206. /**
  79207. * Disables highlights
  79208. */
  79209. disableHighlights(): void;
  79210. /**
  79211. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  79212. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  79213. */
  79214. dispose(disableDepthRender?: boolean): void;
  79215. private _createChromaticAberrationPostProcess;
  79216. private _createHighlightsPostProcess;
  79217. private _createDepthOfFieldPostProcess;
  79218. private _createGrainTexture;
  79219. }
  79220. }
  79221. declare module "babylonjs/Rendering/ssao2Configuration" {
  79222. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79223. /**
  79224. * Contains all parameters needed for the prepass to perform
  79225. * screen space subsurface scattering
  79226. */
  79227. export class SSAO2Configuration implements PrePassEffectConfiguration {
  79228. /**
  79229. * Is subsurface enabled
  79230. */
  79231. enabled: boolean;
  79232. /**
  79233. * Name of the configuration
  79234. */
  79235. name: string;
  79236. /**
  79237. * Textures that should be present in the MRT for this effect to work
  79238. */
  79239. readonly texturesRequired: number[];
  79240. }
  79241. }
  79242. declare module "babylonjs/Shaders/ssao2.fragment" {
  79243. /** @hidden */
  79244. export var ssao2PixelShader: {
  79245. name: string;
  79246. shader: string;
  79247. };
  79248. }
  79249. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  79250. /** @hidden */
  79251. export var ssaoCombinePixelShader: {
  79252. name: string;
  79253. shader: string;
  79254. };
  79255. }
  79256. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  79257. import { Camera } from "babylonjs/Cameras/camera";
  79258. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79259. import { Scene } from "babylonjs/scene";
  79260. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79261. import "babylonjs/Shaders/ssao2.fragment";
  79262. import "babylonjs/Shaders/ssaoCombine.fragment";
  79263. /**
  79264. * Render pipeline to produce ssao effect
  79265. */
  79266. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  79267. /**
  79268. * @ignore
  79269. * The PassPostProcess id in the pipeline that contains the original scene color
  79270. */
  79271. SSAOOriginalSceneColorEffect: string;
  79272. /**
  79273. * @ignore
  79274. * The SSAO PostProcess id in the pipeline
  79275. */
  79276. SSAORenderEffect: string;
  79277. /**
  79278. * @ignore
  79279. * The horizontal blur PostProcess id in the pipeline
  79280. */
  79281. SSAOBlurHRenderEffect: string;
  79282. /**
  79283. * @ignore
  79284. * The vertical blur PostProcess id in the pipeline
  79285. */
  79286. SSAOBlurVRenderEffect: string;
  79287. /**
  79288. * @ignore
  79289. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79290. */
  79291. SSAOCombineRenderEffect: string;
  79292. /**
  79293. * The output strength of the SSAO post-process. Default value is 1.0.
  79294. */
  79295. totalStrength: number;
  79296. /**
  79297. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  79298. */
  79299. maxZ: number;
  79300. /**
  79301. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  79302. */
  79303. minZAspect: number;
  79304. private _samples;
  79305. /**
  79306. * Number of samples used for the SSAO calculations. Default value is 8
  79307. */
  79308. set samples(n: number);
  79309. get samples(): number;
  79310. private _textureSamples;
  79311. /**
  79312. * Number of samples to use for antialiasing
  79313. */
  79314. set textureSamples(n: number);
  79315. get textureSamples(): number;
  79316. /**
  79317. * Force rendering the geometry through geometry buffer
  79318. */
  79319. private _forceGeometryBuffer;
  79320. /**
  79321. * Ratio object used for SSAO ratio and blur ratio
  79322. */
  79323. private _ratio;
  79324. /**
  79325. * Dynamically generated sphere sampler.
  79326. */
  79327. private _sampleSphere;
  79328. /**
  79329. * Blur filter offsets
  79330. */
  79331. private _samplerOffsets;
  79332. private _expensiveBlur;
  79333. /**
  79334. * If bilateral blur should be used
  79335. */
  79336. set expensiveBlur(b: boolean);
  79337. get expensiveBlur(): boolean;
  79338. /**
  79339. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  79340. */
  79341. radius: number;
  79342. /**
  79343. * The base color of the SSAO post-process
  79344. * The final result is "base + ssao" between [0, 1]
  79345. */
  79346. base: number;
  79347. /**
  79348. * Support test.
  79349. */
  79350. static get IsSupported(): boolean;
  79351. private _scene;
  79352. private _randomTexture;
  79353. private _originalColorPostProcess;
  79354. private _ssaoPostProcess;
  79355. private _blurHPostProcess;
  79356. private _blurVPostProcess;
  79357. private _ssaoCombinePostProcess;
  79358. private _prePassRenderer;
  79359. /**
  79360. * Gets active scene
  79361. */
  79362. get scene(): Scene;
  79363. /**
  79364. * @constructor
  79365. * @param name The rendering pipeline name
  79366. * @param scene The scene linked to this pipeline
  79367. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  79368. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79369. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  79370. */
  79371. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  79372. /**
  79373. * Get the class name
  79374. * @returns "SSAO2RenderingPipeline"
  79375. */
  79376. getClassName(): string;
  79377. /**
  79378. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  79379. */
  79380. dispose(disableGeometryBufferRenderer?: boolean): void;
  79381. private _createBlurPostProcess;
  79382. /** @hidden */
  79383. _rebuild(): void;
  79384. private _bits;
  79385. private _radicalInverse_VdC;
  79386. private _hammersley;
  79387. private _hemisphereSample_uniform;
  79388. private _generateHemisphere;
  79389. private _getDefinesForSSAO;
  79390. private static readonly ORTHO_DEPTH_PROJECTION;
  79391. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  79392. private _createSSAOPostProcess;
  79393. private _createSSAOCombinePostProcess;
  79394. private _createRandomTexture;
  79395. /**
  79396. * Serialize the rendering pipeline (Used when exporting)
  79397. * @returns the serialized object
  79398. */
  79399. serialize(): any;
  79400. /**
  79401. * Parse the serialized pipeline
  79402. * @param source Source pipeline.
  79403. * @param scene The scene to load the pipeline to.
  79404. * @param rootUrl The URL of the serialized pipeline.
  79405. * @returns An instantiated pipeline from the serialized object.
  79406. */
  79407. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  79408. }
  79409. }
  79410. declare module "babylonjs/Shaders/ssao.fragment" {
  79411. /** @hidden */
  79412. export var ssaoPixelShader: {
  79413. name: string;
  79414. shader: string;
  79415. };
  79416. }
  79417. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  79418. import { Camera } from "babylonjs/Cameras/camera";
  79419. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79420. import { Scene } from "babylonjs/scene";
  79421. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79422. import "babylonjs/Shaders/ssao.fragment";
  79423. import "babylonjs/Shaders/ssaoCombine.fragment";
  79424. /**
  79425. * Render pipeline to produce ssao effect
  79426. */
  79427. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  79428. /**
  79429. * @ignore
  79430. * The PassPostProcess id in the pipeline that contains the original scene color
  79431. */
  79432. SSAOOriginalSceneColorEffect: string;
  79433. /**
  79434. * @ignore
  79435. * The SSAO PostProcess id in the pipeline
  79436. */
  79437. SSAORenderEffect: string;
  79438. /**
  79439. * @ignore
  79440. * The horizontal blur PostProcess id in the pipeline
  79441. */
  79442. SSAOBlurHRenderEffect: string;
  79443. /**
  79444. * @ignore
  79445. * The vertical blur PostProcess id in the pipeline
  79446. */
  79447. SSAOBlurVRenderEffect: string;
  79448. /**
  79449. * @ignore
  79450. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79451. */
  79452. SSAOCombineRenderEffect: string;
  79453. /**
  79454. * The output strength of the SSAO post-process. Default value is 1.0.
  79455. */
  79456. totalStrength: number;
  79457. /**
  79458. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  79459. */
  79460. radius: number;
  79461. /**
  79462. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  79463. * Must not be equal to fallOff and superior to fallOff.
  79464. * Default value is 0.0075
  79465. */
  79466. area: number;
  79467. /**
  79468. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  79469. * Must not be equal to area and inferior to area.
  79470. * Default value is 0.000001
  79471. */
  79472. fallOff: number;
  79473. /**
  79474. * The base color of the SSAO post-process
  79475. * The final result is "base + ssao" between [0, 1]
  79476. */
  79477. base: number;
  79478. private _scene;
  79479. private _depthTexture;
  79480. private _randomTexture;
  79481. private _originalColorPostProcess;
  79482. private _ssaoPostProcess;
  79483. private _blurHPostProcess;
  79484. private _blurVPostProcess;
  79485. private _ssaoCombinePostProcess;
  79486. private _firstUpdate;
  79487. /**
  79488. * Gets active scene
  79489. */
  79490. get scene(): Scene;
  79491. /**
  79492. * @constructor
  79493. * @param name - The rendering pipeline name
  79494. * @param scene - The scene linked to this pipeline
  79495. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  79496. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  79497. */
  79498. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  79499. /**
  79500. * Get the class name
  79501. * @returns "SSAORenderingPipeline"
  79502. */
  79503. getClassName(): string;
  79504. /**
  79505. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  79506. */
  79507. dispose(disableDepthRender?: boolean): void;
  79508. private _createBlurPostProcess;
  79509. /** @hidden */
  79510. _rebuild(): void;
  79511. private _createSSAOPostProcess;
  79512. private _createSSAOCombinePostProcess;
  79513. private _createRandomTexture;
  79514. }
  79515. }
  79516. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  79517. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79518. /**
  79519. * Contains all parameters needed for the prepass to perform
  79520. * screen space reflections
  79521. */
  79522. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  79523. /**
  79524. * Is ssr enabled
  79525. */
  79526. enabled: boolean;
  79527. /**
  79528. * Name of the configuration
  79529. */
  79530. name: string;
  79531. /**
  79532. * Textures that should be present in the MRT for this effect to work
  79533. */
  79534. readonly texturesRequired: number[];
  79535. }
  79536. }
  79537. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  79538. /** @hidden */
  79539. export var screenSpaceReflectionPixelShader: {
  79540. name: string;
  79541. shader: string;
  79542. };
  79543. }
  79544. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  79545. import { Nullable } from "babylonjs/types";
  79546. import { Camera } from "babylonjs/Cameras/camera";
  79547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  79548. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  79549. import { Engine } from "babylonjs/Engines/engine";
  79550. import { Scene } from "babylonjs/scene";
  79551. /**
  79552. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  79553. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  79554. */
  79555. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  79556. /**
  79557. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  79558. */
  79559. threshold: number;
  79560. /**
  79561. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  79562. */
  79563. strength: number;
  79564. /**
  79565. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  79566. */
  79567. reflectionSpecularFalloffExponent: number;
  79568. /**
  79569. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  79570. */
  79571. step: number;
  79572. /**
  79573. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  79574. */
  79575. roughnessFactor: number;
  79576. private _forceGeometryBuffer;
  79577. private _geometryBufferRenderer;
  79578. private _prePassRenderer;
  79579. private _enableSmoothReflections;
  79580. private _reflectionSamples;
  79581. private _smoothSteps;
  79582. /**
  79583. * Gets a string identifying the name of the class
  79584. * @returns "ScreenSpaceReflectionPostProcess" string
  79585. */
  79586. getClassName(): string;
  79587. /**
  79588. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  79589. * @param name The name of the effect.
  79590. * @param scene The scene containing the objects to calculate reflections.
  79591. * @param options The required width/height ratio to downsize to before computing the render pass.
  79592. * @param camera The camera to apply the render pass to.
  79593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79594. * @param engine The engine which the post process will be applied. (default: current engine)
  79595. * @param reusable If the post process can be reused on the same frame. (default: false)
  79596. * @param textureType Type of textures used when performing the post process. (default: 0)
  79597. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  79598. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  79599. */
  79600. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  79601. /**
  79602. * Gets wether or not smoothing reflections is enabled.
  79603. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79604. */
  79605. get enableSmoothReflections(): boolean;
  79606. /**
  79607. * Sets wether or not smoothing reflections is enabled.
  79608. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79609. */
  79610. set enableSmoothReflections(enabled: boolean);
  79611. /**
  79612. * Gets the number of samples taken while computing reflections. More samples count is high,
  79613. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79614. */
  79615. get reflectionSamples(): number;
  79616. /**
  79617. * Sets the number of samples taken while computing reflections. More samples count is high,
  79618. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79619. */
  79620. set reflectionSamples(samples: number);
  79621. /**
  79622. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  79623. * more the post-process will require GPU power and can generate a drop in FPS.
  79624. * Default value (5.0) work pretty well in all cases but can be adjusted.
  79625. */
  79626. get smoothSteps(): number;
  79627. set smoothSteps(steps: number);
  79628. private _updateEffectDefines;
  79629. /** @hidden */
  79630. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  79631. }
  79632. }
  79633. declare module "babylonjs/Shaders/standard.fragment" {
  79634. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  79635. /** @hidden */
  79636. export var standardPixelShader: {
  79637. name: string;
  79638. shader: string;
  79639. };
  79640. }
  79641. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  79642. import { Nullable } from "babylonjs/types";
  79643. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  79644. import { Camera } from "babylonjs/Cameras/camera";
  79645. import { Texture } from "babylonjs/Materials/Textures/texture";
  79646. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79647. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79648. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  79649. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  79650. import { IDisposable } from "babylonjs/scene";
  79651. import { SpotLight } from "babylonjs/Lights/spotLight";
  79652. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  79653. import { Scene } from "babylonjs/scene";
  79654. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  79655. import { Animation } from "babylonjs/Animations/animation";
  79656. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79657. import "babylonjs/Shaders/standard.fragment";
  79658. /**
  79659. * Standard rendering pipeline
  79660. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79661. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  79662. */
  79663. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  79664. /**
  79665. * Public members
  79666. */
  79667. /**
  79668. * Post-process which contains the original scene color before the pipeline applies all the effects
  79669. */
  79670. originalPostProcess: Nullable<PostProcess>;
  79671. /**
  79672. * Post-process used to down scale an image x4
  79673. */
  79674. downSampleX4PostProcess: Nullable<PostProcess>;
  79675. /**
  79676. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  79677. */
  79678. brightPassPostProcess: Nullable<PostProcess>;
  79679. /**
  79680. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  79681. */
  79682. blurHPostProcesses: PostProcess[];
  79683. /**
  79684. * Post-process array storing all the vertical blur post-processes used by the pipeline
  79685. */
  79686. blurVPostProcesses: PostProcess[];
  79687. /**
  79688. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  79689. */
  79690. textureAdderPostProcess: Nullable<PostProcess>;
  79691. /**
  79692. * Post-process used to create volumetric lighting effect
  79693. */
  79694. volumetricLightPostProcess: Nullable<PostProcess>;
  79695. /**
  79696. * Post-process used to smooth the previous volumetric light post-process on the X axis
  79697. */
  79698. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  79699. /**
  79700. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  79701. */
  79702. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  79703. /**
  79704. * Post-process used to merge the volumetric light effect and the real scene color
  79705. */
  79706. volumetricLightMergePostProces: Nullable<PostProcess>;
  79707. /**
  79708. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  79709. */
  79710. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  79711. /**
  79712. * Base post-process used to calculate the average luminance of the final image for HDR
  79713. */
  79714. luminancePostProcess: Nullable<PostProcess>;
  79715. /**
  79716. * Post-processes used to create down sample post-processes in order to get
  79717. * the average luminance of the final image for HDR
  79718. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  79719. */
  79720. luminanceDownSamplePostProcesses: PostProcess[];
  79721. /**
  79722. * Post-process used to create a HDR effect (light adaptation)
  79723. */
  79724. hdrPostProcess: Nullable<PostProcess>;
  79725. /**
  79726. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  79727. */
  79728. textureAdderFinalPostProcess: Nullable<PostProcess>;
  79729. /**
  79730. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  79731. */
  79732. lensFlareFinalPostProcess: Nullable<PostProcess>;
  79733. /**
  79734. * Post-process used to merge the final HDR post-process and the real scene color
  79735. */
  79736. hdrFinalPostProcess: Nullable<PostProcess>;
  79737. /**
  79738. * Post-process used to create a lens flare effect
  79739. */
  79740. lensFlarePostProcess: Nullable<PostProcess>;
  79741. /**
  79742. * Post-process that merges the result of the lens flare post-process and the real scene color
  79743. */
  79744. lensFlareComposePostProcess: Nullable<PostProcess>;
  79745. /**
  79746. * Post-process used to create a motion blur effect
  79747. */
  79748. motionBlurPostProcess: Nullable<PostProcess>;
  79749. /**
  79750. * Post-process used to create a depth of field effect
  79751. */
  79752. depthOfFieldPostProcess: Nullable<PostProcess>;
  79753. /**
  79754. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  79755. */
  79756. fxaaPostProcess: Nullable<FxaaPostProcess>;
  79757. /**
  79758. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  79759. */
  79760. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  79761. /**
  79762. * Represents the brightness threshold in order to configure the illuminated surfaces
  79763. */
  79764. brightThreshold: number;
  79765. /**
  79766. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  79767. */
  79768. blurWidth: number;
  79769. /**
  79770. * Sets if the blur for highlighted surfaces must be only horizontal
  79771. */
  79772. horizontalBlur: boolean;
  79773. /**
  79774. * Gets the overall exposure used by the pipeline
  79775. */
  79776. get exposure(): number;
  79777. /**
  79778. * Sets the overall exposure used by the pipeline
  79779. */
  79780. set exposure(value: number);
  79781. /**
  79782. * Texture used typically to simulate "dirty" on camera lens
  79783. */
  79784. lensTexture: Nullable<Texture>;
  79785. /**
  79786. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  79787. */
  79788. volumetricLightCoefficient: number;
  79789. /**
  79790. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  79791. */
  79792. volumetricLightPower: number;
  79793. /**
  79794. * Used the set the blur intensity to smooth the volumetric lights
  79795. */
  79796. volumetricLightBlurScale: number;
  79797. /**
  79798. * Light (spot or directional) used to generate the volumetric lights rays
  79799. * The source light must have a shadow generate so the pipeline can get its
  79800. * depth map
  79801. */
  79802. sourceLight: Nullable<SpotLight | DirectionalLight>;
  79803. /**
  79804. * For eye adaptation, represents the minimum luminance the eye can see
  79805. */
  79806. hdrMinimumLuminance: number;
  79807. /**
  79808. * For eye adaptation, represents the decrease luminance speed
  79809. */
  79810. hdrDecreaseRate: number;
  79811. /**
  79812. * For eye adaptation, represents the increase luminance speed
  79813. */
  79814. hdrIncreaseRate: number;
  79815. /**
  79816. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79817. */
  79818. get hdrAutoExposure(): boolean;
  79819. /**
  79820. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79821. */
  79822. set hdrAutoExposure(value: boolean);
  79823. /**
  79824. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  79825. */
  79826. lensColorTexture: Nullable<Texture>;
  79827. /**
  79828. * The overall strengh for the lens flare effect
  79829. */
  79830. lensFlareStrength: number;
  79831. /**
  79832. * Dispersion coefficient for lens flare ghosts
  79833. */
  79834. lensFlareGhostDispersal: number;
  79835. /**
  79836. * Main lens flare halo width
  79837. */
  79838. lensFlareHaloWidth: number;
  79839. /**
  79840. * Based on the lens distortion effect, defines how much the lens flare result
  79841. * is distorted
  79842. */
  79843. lensFlareDistortionStrength: number;
  79844. /**
  79845. * Configures the blur intensity used for for lens flare (halo)
  79846. */
  79847. lensFlareBlurWidth: number;
  79848. /**
  79849. * Lens star texture must be used to simulate rays on the flares and is available
  79850. * in the documentation
  79851. */
  79852. lensStarTexture: Nullable<Texture>;
  79853. /**
  79854. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  79855. * flare effect by taking account of the dirt texture
  79856. */
  79857. lensFlareDirtTexture: Nullable<Texture>;
  79858. /**
  79859. * Represents the focal length for the depth of field effect
  79860. */
  79861. depthOfFieldDistance: number;
  79862. /**
  79863. * Represents the blur intensity for the blurred part of the depth of field effect
  79864. */
  79865. depthOfFieldBlurWidth: number;
  79866. /**
  79867. * Gets how much the image is blurred by the movement while using the motion blur post-process
  79868. */
  79869. get motionStrength(): number;
  79870. /**
  79871. * Sets how much the image is blurred by the movement while using the motion blur post-process
  79872. */
  79873. set motionStrength(strength: number);
  79874. /**
  79875. * Gets wether or not the motion blur post-process is object based or screen based.
  79876. */
  79877. get objectBasedMotionBlur(): boolean;
  79878. /**
  79879. * Sets wether or not the motion blur post-process should be object based or screen based
  79880. */
  79881. set objectBasedMotionBlur(value: boolean);
  79882. /**
  79883. * List of animations for the pipeline (IAnimatable implementation)
  79884. */
  79885. animations: Animation[];
  79886. /**
  79887. * Private members
  79888. */
  79889. private _scene;
  79890. private _currentDepthOfFieldSource;
  79891. private _basePostProcess;
  79892. private _fixedExposure;
  79893. private _currentExposure;
  79894. private _hdrAutoExposure;
  79895. private _hdrCurrentLuminance;
  79896. private _motionStrength;
  79897. private _isObjectBasedMotionBlur;
  79898. private _floatTextureType;
  79899. private _camerasToBeAttached;
  79900. private _ratio;
  79901. private _bloomEnabled;
  79902. private _depthOfFieldEnabled;
  79903. private _vlsEnabled;
  79904. private _lensFlareEnabled;
  79905. private _hdrEnabled;
  79906. private _motionBlurEnabled;
  79907. private _fxaaEnabled;
  79908. private _screenSpaceReflectionsEnabled;
  79909. private _motionBlurSamples;
  79910. private _volumetricLightStepsCount;
  79911. private _samples;
  79912. /**
  79913. * @ignore
  79914. * Specifies if the bloom pipeline is enabled
  79915. */
  79916. get BloomEnabled(): boolean;
  79917. set BloomEnabled(enabled: boolean);
  79918. /**
  79919. * @ignore
  79920. * Specifies if the depth of field pipeline is enabed
  79921. */
  79922. get DepthOfFieldEnabled(): boolean;
  79923. set DepthOfFieldEnabled(enabled: boolean);
  79924. /**
  79925. * @ignore
  79926. * Specifies if the lens flare pipeline is enabed
  79927. */
  79928. get LensFlareEnabled(): boolean;
  79929. set LensFlareEnabled(enabled: boolean);
  79930. /**
  79931. * @ignore
  79932. * Specifies if the HDR pipeline is enabled
  79933. */
  79934. get HDREnabled(): boolean;
  79935. set HDREnabled(enabled: boolean);
  79936. /**
  79937. * @ignore
  79938. * Specifies if the volumetric lights scattering effect is enabled
  79939. */
  79940. get VLSEnabled(): boolean;
  79941. set VLSEnabled(enabled: boolean);
  79942. /**
  79943. * @ignore
  79944. * Specifies if the motion blur effect is enabled
  79945. */
  79946. get MotionBlurEnabled(): boolean;
  79947. set MotionBlurEnabled(enabled: boolean);
  79948. /**
  79949. * Specifies if anti-aliasing is enabled
  79950. */
  79951. get fxaaEnabled(): boolean;
  79952. set fxaaEnabled(enabled: boolean);
  79953. /**
  79954. * Specifies if screen space reflections are enabled.
  79955. */
  79956. get screenSpaceReflectionsEnabled(): boolean;
  79957. set screenSpaceReflectionsEnabled(enabled: boolean);
  79958. /**
  79959. * Specifies the number of steps used to calculate the volumetric lights
  79960. * Typically in interval [50, 200]
  79961. */
  79962. get volumetricLightStepsCount(): number;
  79963. set volumetricLightStepsCount(count: number);
  79964. /**
  79965. * Specifies the number of samples used for the motion blur effect
  79966. * Typically in interval [16, 64]
  79967. */
  79968. get motionBlurSamples(): number;
  79969. set motionBlurSamples(samples: number);
  79970. /**
  79971. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  79972. */
  79973. get samples(): number;
  79974. set samples(sampleCount: number);
  79975. /**
  79976. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79977. * @constructor
  79978. * @param name The rendering pipeline name
  79979. * @param scene The scene linked to this pipeline
  79980. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  79981. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  79982. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79983. */
  79984. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  79985. private _buildPipeline;
  79986. private _createDownSampleX4PostProcess;
  79987. private _createBrightPassPostProcess;
  79988. private _createBlurPostProcesses;
  79989. private _createTextureAdderPostProcess;
  79990. private _createVolumetricLightPostProcess;
  79991. private _createLuminancePostProcesses;
  79992. private _createHdrPostProcess;
  79993. private _createLensFlarePostProcess;
  79994. private _createDepthOfFieldPostProcess;
  79995. private _createMotionBlurPostProcess;
  79996. private _getDepthTexture;
  79997. private _disposePostProcesses;
  79998. /**
  79999. * Dispose of the pipeline and stop all post processes
  80000. */
  80001. dispose(): void;
  80002. /**
  80003. * Serialize the rendering pipeline (Used when exporting)
  80004. * @returns the serialized object
  80005. */
  80006. serialize(): any;
  80007. /**
  80008. * Parse the serialized pipeline
  80009. * @param source Source pipeline.
  80010. * @param scene The scene to load the pipeline to.
  80011. * @param rootUrl The URL of the serialized pipeline.
  80012. * @returns An instantiated pipeline from the serialized object.
  80013. */
  80014. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  80015. /**
  80016. * Luminance steps
  80017. */
  80018. static LuminanceSteps: number;
  80019. }
  80020. }
  80021. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  80022. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  80023. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  80024. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  80025. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  80026. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  80027. }
  80028. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  80029. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  80030. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  80031. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  80032. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  80033. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  80034. }
  80035. declare module "babylonjs/Shaders/tonemap.fragment" {
  80036. /** @hidden */
  80037. export var tonemapPixelShader: {
  80038. name: string;
  80039. shader: string;
  80040. };
  80041. }
  80042. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  80043. import { Camera } from "babylonjs/Cameras/camera";
  80044. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  80045. import "babylonjs/Shaders/tonemap.fragment";
  80046. import { Engine } from "babylonjs/Engines/engine";
  80047. /** Defines operator used for tonemapping */
  80048. export enum TonemappingOperator {
  80049. /** Hable */
  80050. Hable = 0,
  80051. /** Reinhard */
  80052. Reinhard = 1,
  80053. /** HejiDawson */
  80054. HejiDawson = 2,
  80055. /** Photographic */
  80056. Photographic = 3
  80057. }
  80058. /**
  80059. * Defines a post process to apply tone mapping
  80060. */
  80061. export class TonemapPostProcess extends PostProcess {
  80062. private _operator;
  80063. /** Defines the required exposure adjustement */
  80064. exposureAdjustment: number;
  80065. /**
  80066. * Gets a string identifying the name of the class
  80067. * @returns "TonemapPostProcess" string
  80068. */
  80069. getClassName(): string;
  80070. /**
  80071. * Creates a new TonemapPostProcess
  80072. * @param name defines the name of the postprocess
  80073. * @param _operator defines the operator to use
  80074. * @param exposureAdjustment defines the required exposure adjustement
  80075. * @param camera defines the camera to use (can be null)
  80076. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  80077. * @param engine defines the hosting engine (can be ignore if camera is set)
  80078. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80079. */
  80080. constructor(name: string, _operator: TonemappingOperator,
  80081. /** Defines the required exposure adjustement */
  80082. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  80083. }
  80084. }
  80085. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  80086. /** @hidden */
  80087. export var volumetricLightScatteringPixelShader: {
  80088. name: string;
  80089. shader: string;
  80090. };
  80091. }
  80092. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  80093. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  80094. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  80095. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  80096. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  80097. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  80098. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  80099. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  80100. /** @hidden */
  80101. export var volumetricLightScatteringPassVertexShader: {
  80102. name: string;
  80103. shader: string;
  80104. };
  80105. }
  80106. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  80107. /** @hidden */
  80108. export var volumetricLightScatteringPassPixelShader: {
  80109. name: string;
  80110. shader: string;
  80111. };
  80112. }
  80113. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  80114. import { Vector3 } from "babylonjs/Maths/math.vector";
  80115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80116. import { Mesh } from "babylonjs/Meshes/mesh";
  80117. import { Camera } from "babylonjs/Cameras/camera";
  80118. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  80119. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  80120. import { Scene } from "babylonjs/scene";
  80121. import "babylonjs/Meshes/Builders/planeBuilder";
  80122. import "babylonjs/Shaders/depth.vertex";
  80123. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  80124. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  80125. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  80126. import { Engine } from "babylonjs/Engines/engine";
  80127. /**
  80128. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  80129. */
  80130. export class VolumetricLightScatteringPostProcess extends PostProcess {
  80131. private _volumetricLightScatteringPass;
  80132. private _volumetricLightScatteringRTT;
  80133. private _viewPort;
  80134. private _screenCoordinates;
  80135. private _cachedDefines;
  80136. /**
  80137. * If not undefined, the mesh position is computed from the attached node position
  80138. */
  80139. attachedNode: {
  80140. position: Vector3;
  80141. };
  80142. /**
  80143. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  80144. */
  80145. customMeshPosition: Vector3;
  80146. /**
  80147. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  80148. */
  80149. useCustomMeshPosition: boolean;
  80150. /**
  80151. * If the post-process should inverse the light scattering direction
  80152. */
  80153. invert: boolean;
  80154. /**
  80155. * The internal mesh used by the post-process
  80156. */
  80157. mesh: Mesh;
  80158. /**
  80159. * @hidden
  80160. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  80161. */
  80162. get useDiffuseColor(): boolean;
  80163. set useDiffuseColor(useDiffuseColor: boolean);
  80164. /**
  80165. * Array containing the excluded meshes not rendered in the internal pass
  80166. */
  80167. excludedMeshes: AbstractMesh[];
  80168. /**
  80169. * Controls the overall intensity of the post-process
  80170. */
  80171. exposure: number;
  80172. /**
  80173. * Dissipates each sample's contribution in range [0, 1]
  80174. */
  80175. decay: number;
  80176. /**
  80177. * Controls the overall intensity of each sample
  80178. */
  80179. weight: number;
  80180. /**
  80181. * Controls the density of each sample
  80182. */
  80183. density: number;
  80184. /**
  80185. * @constructor
  80186. * @param name The post-process name
  80187. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  80188. * @param camera The camera that the post-process will be attached to
  80189. * @param mesh The mesh used to create the light scattering
  80190. * @param samples The post-process quality, default 100
  80191. * @param samplingModeThe post-process filtering mode
  80192. * @param engine The babylon engine
  80193. * @param reusable If the post-process is reusable
  80194. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  80195. */
  80196. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  80197. /**
  80198. * Returns the string "VolumetricLightScatteringPostProcess"
  80199. * @returns "VolumetricLightScatteringPostProcess"
  80200. */
  80201. getClassName(): string;
  80202. private _isReady;
  80203. /**
  80204. * Sets the new light position for light scattering effect
  80205. * @param position The new custom light position
  80206. */
  80207. setCustomMeshPosition(position: Vector3): void;
  80208. /**
  80209. * Returns the light position for light scattering effect
  80210. * @return Vector3 The custom light position
  80211. */
  80212. getCustomMeshPosition(): Vector3;
  80213. /**
  80214. * Disposes the internal assets and detaches the post-process from the camera
  80215. */
  80216. dispose(camera: Camera): void;
  80217. /**
  80218. * Returns the render target texture used by the post-process
  80219. * @return the render target texture used by the post-process
  80220. */
  80221. getPass(): RenderTargetTexture;
  80222. private _meshExcluded;
  80223. private _createPass;
  80224. private _updateMeshScreenCoordinates;
  80225. /**
  80226. * Creates a default mesh for the Volumeric Light Scattering post-process
  80227. * @param name The mesh name
  80228. * @param scene The scene where to create the mesh
  80229. * @return the default mesh
  80230. */
  80231. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  80232. }
  80233. }
  80234. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  80235. /** @hidden */
  80236. export var screenSpaceCurvaturePixelShader: {
  80237. name: string;
  80238. shader: string;
  80239. };
  80240. }
  80241. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  80242. import { Nullable } from "babylonjs/types";
  80243. import { Camera } from "babylonjs/Cameras/camera";
  80244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  80245. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  80246. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  80247. import { Engine } from "babylonjs/Engines/engine";
  80248. import { Scene } from "babylonjs/scene";
  80249. /**
  80250. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  80251. */
  80252. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  80253. /**
  80254. * Defines how much ridge the curvature effect displays.
  80255. */
  80256. ridge: number;
  80257. /**
  80258. * Defines how much valley the curvature effect displays.
  80259. */
  80260. valley: number;
  80261. private _geometryBufferRenderer;
  80262. /**
  80263. * Gets a string identifying the name of the class
  80264. * @returns "ScreenSpaceCurvaturePostProcess" string
  80265. */
  80266. getClassName(): string;
  80267. /**
  80268. * Creates a new instance ScreenSpaceCurvaturePostProcess
  80269. * @param name The name of the effect.
  80270. * @param scene The scene containing the objects to blur according to their velocity.
  80271. * @param options The required width/height ratio to downsize to before computing the render pass.
  80272. * @param camera The camera to apply the render pass to.
  80273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80274. * @param engine The engine which the post process will be applied. (default: current engine)
  80275. * @param reusable If the post process can be reused on the same frame. (default: false)
  80276. * @param textureType Type of textures used when performing the post process. (default: 0)
  80277. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  80278. */
  80279. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  80280. /**
  80281. * Support test.
  80282. */
  80283. static get IsSupported(): boolean;
  80284. /** @hidden */
  80285. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  80286. }
  80287. }
  80288. declare module "babylonjs/PostProcesses/index" {
  80289. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  80290. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  80291. export * from "babylonjs/PostProcesses/bloomEffect";
  80292. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  80293. export * from "babylonjs/PostProcesses/blurPostProcess";
  80294. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  80295. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  80296. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  80297. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  80298. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  80299. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  80300. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  80301. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  80302. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  80303. export * from "babylonjs/PostProcesses/filterPostProcess";
  80304. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  80305. export * from "babylonjs/PostProcesses/grainPostProcess";
  80306. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  80307. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  80308. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  80309. export * from "babylonjs/PostProcesses/passPostProcess";
  80310. export * from "babylonjs/PostProcesses/postProcess";
  80311. export * from "babylonjs/PostProcesses/postProcessManager";
  80312. export * from "babylonjs/PostProcesses/refractionPostProcess";
  80313. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  80314. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  80315. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  80316. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  80317. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  80318. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  80319. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  80320. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  80321. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  80322. }
  80323. declare module "babylonjs/Probes/index" {
  80324. export * from "babylonjs/Probes/reflectionProbe";
  80325. }
  80326. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  80327. import { Scene } from "babylonjs/scene";
  80328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80329. import { SmartArray } from "babylonjs/Misc/smartArray";
  80330. import { ISceneComponent } from "babylonjs/sceneComponent";
  80331. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  80332. import "babylonjs/Meshes/Builders/boxBuilder";
  80333. import "babylonjs/Shaders/color.fragment";
  80334. import "babylonjs/Shaders/color.vertex";
  80335. import { Color3 } from "babylonjs/Maths/math.color";
  80336. import { Observable } from "babylonjs/Misc/observable";
  80337. module "babylonjs/scene" {
  80338. interface Scene {
  80339. /** @hidden (Backing field) */
  80340. _boundingBoxRenderer: BoundingBoxRenderer;
  80341. /** @hidden (Backing field) */
  80342. _forceShowBoundingBoxes: boolean;
  80343. /**
  80344. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  80345. */
  80346. forceShowBoundingBoxes: boolean;
  80347. /**
  80348. * Gets the bounding box renderer associated with the scene
  80349. * @returns a BoundingBoxRenderer
  80350. */
  80351. getBoundingBoxRenderer(): BoundingBoxRenderer;
  80352. }
  80353. }
  80354. module "babylonjs/Meshes/abstractMesh" {
  80355. interface AbstractMesh {
  80356. /** @hidden (Backing field) */
  80357. _showBoundingBox: boolean;
  80358. /**
  80359. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  80360. */
  80361. showBoundingBox: boolean;
  80362. }
  80363. }
  80364. /**
  80365. * Component responsible of rendering the bounding box of the meshes in a scene.
  80366. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  80367. */
  80368. export class BoundingBoxRenderer implements ISceneComponent {
  80369. /**
  80370. * The component name helpfull to identify the component in the list of scene components.
  80371. */
  80372. readonly name: string;
  80373. /**
  80374. * The scene the component belongs to.
  80375. */
  80376. scene: Scene;
  80377. /**
  80378. * Color of the bounding box lines placed in front of an object
  80379. */
  80380. frontColor: Color3;
  80381. /**
  80382. * Color of the bounding box lines placed behind an object
  80383. */
  80384. backColor: Color3;
  80385. /**
  80386. * Defines if the renderer should show the back lines or not
  80387. */
  80388. showBackLines: boolean;
  80389. /**
  80390. * Observable raised before rendering a bounding box
  80391. */
  80392. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  80393. /**
  80394. * Observable raised after rendering a bounding box
  80395. */
  80396. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  80397. /**
  80398. * Observable raised after resources are created
  80399. */
  80400. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  80401. /**
  80402. * When false, no bounding boxes will be rendered
  80403. */
  80404. enabled: boolean;
  80405. /**
  80406. * @hidden
  80407. */
  80408. renderList: SmartArray<BoundingBox>;
  80409. private _colorShader;
  80410. private _vertexBuffers;
  80411. private _indexBuffer;
  80412. private _fillIndexBuffer;
  80413. private _fillIndexData;
  80414. /**
  80415. * Instantiates a new bounding box renderer in a scene.
  80416. * @param scene the scene the renderer renders in
  80417. */
  80418. constructor(scene: Scene);
  80419. /**
  80420. * Registers the component in a given scene
  80421. */
  80422. register(): void;
  80423. private _evaluateSubMesh;
  80424. private _preActiveMesh;
  80425. private _prepareResources;
  80426. private _createIndexBuffer;
  80427. /**
  80428. * Rebuilds the elements related to this component in case of
  80429. * context lost for instance.
  80430. */
  80431. rebuild(): void;
  80432. /**
  80433. * @hidden
  80434. */
  80435. reset(): void;
  80436. /**
  80437. * Render the bounding boxes of a specific rendering group
  80438. * @param renderingGroupId defines the rendering group to render
  80439. */
  80440. render(renderingGroupId: number): void;
  80441. /**
  80442. * In case of occlusion queries, we can render the occlusion bounding box through this method
  80443. * @param mesh Define the mesh to render the occlusion bounding box for
  80444. */
  80445. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  80446. /**
  80447. * Dispose and release the resources attached to this renderer.
  80448. */
  80449. dispose(): void;
  80450. }
  80451. }
  80452. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  80453. import { Nullable } from "babylonjs/types";
  80454. import { Scene } from "babylonjs/scene";
  80455. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  80456. import { Camera } from "babylonjs/Cameras/camera";
  80457. import { ISceneComponent } from "babylonjs/sceneComponent";
  80458. module "babylonjs/scene" {
  80459. interface Scene {
  80460. /** @hidden (Backing field) */
  80461. _depthRenderer: {
  80462. [id: string]: DepthRenderer;
  80463. };
  80464. /**
  80465. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  80466. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  80467. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  80468. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  80469. * @returns the created depth renderer
  80470. */
  80471. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  80472. /**
  80473. * Disables a depth renderer for a given camera
  80474. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  80475. */
  80476. disableDepthRenderer(camera?: Nullable<Camera>): void;
  80477. }
  80478. }
  80479. /**
  80480. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  80481. * in several rendering techniques.
  80482. */
  80483. export class DepthRendererSceneComponent implements ISceneComponent {
  80484. /**
  80485. * The component name helpfull to identify the component in the list of scene components.
  80486. */
  80487. readonly name: string;
  80488. /**
  80489. * The scene the component belongs to.
  80490. */
  80491. scene: Scene;
  80492. /**
  80493. * Creates a new instance of the component for the given scene
  80494. * @param scene Defines the scene to register the component in
  80495. */
  80496. constructor(scene: Scene);
  80497. /**
  80498. * Registers the component in a given scene
  80499. */
  80500. register(): void;
  80501. /**
  80502. * Rebuilds the elements related to this component in case of
  80503. * context lost for instance.
  80504. */
  80505. rebuild(): void;
  80506. /**
  80507. * Disposes the component and the associated ressources
  80508. */
  80509. dispose(): void;
  80510. private _gatherRenderTargets;
  80511. private _gatherActiveCameraRenderTargets;
  80512. }
  80513. }
  80514. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  80515. import { Nullable } from "babylonjs/types";
  80516. import { Scene } from "babylonjs/scene";
  80517. import { ISceneComponent } from "babylonjs/sceneComponent";
  80518. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  80519. module "babylonjs/abstractScene" {
  80520. interface AbstractScene {
  80521. /** @hidden (Backing field) */
  80522. _prePassRenderer: Nullable<PrePassRenderer>;
  80523. /**
  80524. * Gets or Sets the current prepass renderer associated to the scene.
  80525. */
  80526. prePassRenderer: Nullable<PrePassRenderer>;
  80527. /**
  80528. * Enables the prepass and associates it with the scene
  80529. * @returns the PrePassRenderer
  80530. */
  80531. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  80532. /**
  80533. * Disables the prepass associated with the scene
  80534. */
  80535. disablePrePassRenderer(): void;
  80536. }
  80537. }
  80538. /**
  80539. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80540. * in several rendering techniques.
  80541. */
  80542. export class PrePassRendererSceneComponent implements ISceneComponent {
  80543. /**
  80544. * The component name helpful to identify the component in the list of scene components.
  80545. */
  80546. readonly name: string;
  80547. /**
  80548. * The scene the component belongs to.
  80549. */
  80550. scene: Scene;
  80551. /**
  80552. * Creates a new instance of the component for the given scene
  80553. * @param scene Defines the scene to register the component in
  80554. */
  80555. constructor(scene: Scene);
  80556. /**
  80557. * Registers the component in a given scene
  80558. */
  80559. register(): void;
  80560. private _beforeCameraDraw;
  80561. private _afterCameraDraw;
  80562. private _beforeClearStage;
  80563. private _beforeRenderingMeshStage;
  80564. private _afterRenderingMeshStage;
  80565. /**
  80566. * Rebuilds the elements related to this component in case of
  80567. * context lost for instance.
  80568. */
  80569. rebuild(): void;
  80570. /**
  80571. * Disposes the component and the associated ressources
  80572. */
  80573. dispose(): void;
  80574. }
  80575. }
  80576. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  80577. /** @hidden */
  80578. export var fibonacci: {
  80579. name: string;
  80580. shader: string;
  80581. };
  80582. }
  80583. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  80584. /** @hidden */
  80585. export var diffusionProfile: {
  80586. name: string;
  80587. shader: string;
  80588. };
  80589. }
  80590. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  80591. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  80592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  80593. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  80594. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  80595. /** @hidden */
  80596. export var subSurfaceScatteringPixelShader: {
  80597. name: string;
  80598. shader: string;
  80599. };
  80600. }
  80601. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  80602. import { Nullable } from "babylonjs/types";
  80603. import { Camera } from "babylonjs/Cameras/camera";
  80604. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  80605. import { Engine } from "babylonjs/Engines/engine";
  80606. import { Scene } from "babylonjs/scene";
  80607. import "babylonjs/Shaders/imageProcessing.fragment";
  80608. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  80609. import "babylonjs/Shaders/postprocess.vertex";
  80610. /**
  80611. * Sub surface scattering post process
  80612. */
  80613. export class SubSurfaceScatteringPostProcess extends PostProcess {
  80614. /**
  80615. * Gets a string identifying the name of the class
  80616. * @returns "SubSurfaceScatteringPostProcess" string
  80617. */
  80618. getClassName(): string;
  80619. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  80620. }
  80621. }
  80622. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  80623. import { Scene } from "babylonjs/scene";
  80624. import { Color3 } from "babylonjs/Maths/math.color";
  80625. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  80626. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  80627. /**
  80628. * Contains all parameters needed for the prepass to perform
  80629. * screen space subsurface scattering
  80630. */
  80631. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  80632. /** @hidden */
  80633. static _SceneComponentInitialization: (scene: Scene) => void;
  80634. private _ssDiffusionS;
  80635. private _ssFilterRadii;
  80636. private _ssDiffusionD;
  80637. /**
  80638. * Post process to attach for screen space subsurface scattering
  80639. */
  80640. postProcess: SubSurfaceScatteringPostProcess;
  80641. /**
  80642. * Diffusion profile color for subsurface scattering
  80643. */
  80644. get ssDiffusionS(): number[];
  80645. /**
  80646. * Diffusion profile max color channel value for subsurface scattering
  80647. */
  80648. get ssDiffusionD(): number[];
  80649. /**
  80650. * Diffusion profile filter radius for subsurface scattering
  80651. */
  80652. get ssFilterRadii(): number[];
  80653. /**
  80654. * Is subsurface enabled
  80655. */
  80656. enabled: boolean;
  80657. /**
  80658. * Name of the configuration
  80659. */
  80660. name: string;
  80661. /**
  80662. * Diffusion profile colors for subsurface scattering
  80663. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  80664. * See ...
  80665. * Note that you can only store up to 5 of them
  80666. */
  80667. ssDiffusionProfileColors: Color3[];
  80668. /**
  80669. * Defines the ratio real world => scene units.
  80670. * Used for subsurface scattering
  80671. */
  80672. metersPerUnit: number;
  80673. /**
  80674. * Textures that should be present in the MRT for this effect to work
  80675. */
  80676. readonly texturesRequired: number[];
  80677. private _scene;
  80678. /**
  80679. * Builds a subsurface configuration object
  80680. * @param scene The scene
  80681. */
  80682. constructor(scene: Scene);
  80683. /**
  80684. * Adds a new diffusion profile.
  80685. * Useful for more realistic subsurface scattering on diverse materials.
  80686. * @param color The color of the diffusion profile. Should be the average color of the material.
  80687. * @return The index of the diffusion profile for the material subsurface configuration
  80688. */
  80689. addDiffusionProfile(color: Color3): number;
  80690. /**
  80691. * Creates the sss post process
  80692. * @return The created post process
  80693. */
  80694. createPostProcess(): SubSurfaceScatteringPostProcess;
  80695. /**
  80696. * Deletes all diffusion profiles.
  80697. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  80698. */
  80699. clearAllDiffusionProfiles(): void;
  80700. /**
  80701. * Disposes this object
  80702. */
  80703. dispose(): void;
  80704. /**
  80705. * @hidden
  80706. * https://zero-radiance.github.io/post/sampling-diffusion/
  80707. *
  80708. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  80709. * ------------------------------------------------------------------------------------
  80710. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  80711. * PDF[r, phi, s] = r * R[r, phi, s]
  80712. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  80713. * ------------------------------------------------------------------------------------
  80714. * We importance sample the color channel with the widest scattering distance.
  80715. */
  80716. getDiffusionProfileParameters(color: Color3): number;
  80717. /**
  80718. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  80719. * 'u' is the random number (the value of the CDF): [0, 1).
  80720. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  80721. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  80722. */
  80723. private _sampleBurleyDiffusionProfile;
  80724. }
  80725. }
  80726. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  80727. import { Nullable } from "babylonjs/types";
  80728. import { Scene } from "babylonjs/scene";
  80729. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  80730. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  80731. import { AbstractScene } from "babylonjs/abstractScene";
  80732. module "babylonjs/abstractScene" {
  80733. interface AbstractScene {
  80734. /** @hidden (Backing field) */
  80735. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80736. /**
  80737. * Gets or Sets the current prepass renderer associated to the scene.
  80738. */
  80739. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80740. /**
  80741. * Enables the subsurface effect for prepass
  80742. * @returns the SubSurfaceConfiguration
  80743. */
  80744. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  80745. /**
  80746. * Disables the subsurface effect for prepass
  80747. */
  80748. disableSubSurfaceForPrePass(): void;
  80749. }
  80750. }
  80751. /**
  80752. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80753. * in several rendering techniques.
  80754. */
  80755. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  80756. /**
  80757. * The component name helpful to identify the component in the list of scene components.
  80758. */
  80759. readonly name: string;
  80760. /**
  80761. * The scene the component belongs to.
  80762. */
  80763. scene: Scene;
  80764. /**
  80765. * Creates a new instance of the component for the given scene
  80766. * @param scene Defines the scene to register the component in
  80767. */
  80768. constructor(scene: Scene);
  80769. /**
  80770. * Registers the component in a given scene
  80771. */
  80772. register(): void;
  80773. /**
  80774. * Serializes the component data to the specified json object
  80775. * @param serializationObject The object to serialize to
  80776. */
  80777. serialize(serializationObject: any): void;
  80778. /**
  80779. * Adds all the elements from the container to the scene
  80780. * @param container the container holding the elements
  80781. */
  80782. addFromContainer(container: AbstractScene): void;
  80783. /**
  80784. * Removes all the elements in the container from the scene
  80785. * @param container contains the elements to remove
  80786. * @param dispose if the removed element should be disposed (default: false)
  80787. */
  80788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80789. /**
  80790. * Rebuilds the elements related to this component in case of
  80791. * context lost for instance.
  80792. */
  80793. rebuild(): void;
  80794. /**
  80795. * Disposes the component and the associated ressources
  80796. */
  80797. dispose(): void;
  80798. }
  80799. }
  80800. declare module "babylonjs/Shaders/outline.fragment" {
  80801. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80802. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  80803. /** @hidden */
  80804. export var outlinePixelShader: {
  80805. name: string;
  80806. shader: string;
  80807. };
  80808. }
  80809. declare module "babylonjs/Shaders/outline.vertex" {
  80810. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  80811. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  80812. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  80813. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  80814. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  80816. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  80817. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  80818. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  80819. /** @hidden */
  80820. export var outlineVertexShader: {
  80821. name: string;
  80822. shader: string;
  80823. };
  80824. }
  80825. declare module "babylonjs/Rendering/outlineRenderer" {
  80826. import { SubMesh } from "babylonjs/Meshes/subMesh";
  80827. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  80828. import { Scene } from "babylonjs/scene";
  80829. import { ISceneComponent } from "babylonjs/sceneComponent";
  80830. import "babylonjs/Shaders/outline.fragment";
  80831. import "babylonjs/Shaders/outline.vertex";
  80832. module "babylonjs/scene" {
  80833. interface Scene {
  80834. /** @hidden */
  80835. _outlineRenderer: OutlineRenderer;
  80836. /**
  80837. * Gets the outline renderer associated with the scene
  80838. * @returns a OutlineRenderer
  80839. */
  80840. getOutlineRenderer(): OutlineRenderer;
  80841. }
  80842. }
  80843. module "babylonjs/Meshes/abstractMesh" {
  80844. interface AbstractMesh {
  80845. /** @hidden (Backing field) */
  80846. _renderOutline: boolean;
  80847. /**
  80848. * Gets or sets a boolean indicating if the outline must be rendered as well
  80849. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  80850. */
  80851. renderOutline: boolean;
  80852. /** @hidden (Backing field) */
  80853. _renderOverlay: boolean;
  80854. /**
  80855. * Gets or sets a boolean indicating if the overlay must be rendered as well
  80856. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  80857. */
  80858. renderOverlay: boolean;
  80859. }
  80860. }
  80861. /**
  80862. * This class is responsible to draw bothe outline/overlay of meshes.
  80863. * It should not be used directly but through the available method on mesh.
  80864. */
  80865. export class OutlineRenderer implements ISceneComponent {
  80866. /**
  80867. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  80868. */
  80869. private static _StencilReference;
  80870. /**
  80871. * The name of the component. Each component must have a unique name.
  80872. */
  80873. name: string;
  80874. /**
  80875. * The scene the component belongs to.
  80876. */
  80877. scene: Scene;
  80878. /**
  80879. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  80880. */
  80881. zOffset: number;
  80882. private _engine;
  80883. private _effect;
  80884. private _cachedDefines;
  80885. private _savedDepthWrite;
  80886. /**
  80887. * Instantiates a new outline renderer. (There could be only one per scene).
  80888. * @param scene Defines the scene it belongs to
  80889. */
  80890. constructor(scene: Scene);
  80891. /**
  80892. * Register the component to one instance of a scene.
  80893. */
  80894. register(): void;
  80895. /**
  80896. * Rebuilds the elements related to this component in case of
  80897. * context lost for instance.
  80898. */
  80899. rebuild(): void;
  80900. /**
  80901. * Disposes the component and the associated ressources.
  80902. */
  80903. dispose(): void;
  80904. /**
  80905. * Renders the outline in the canvas.
  80906. * @param subMesh Defines the sumesh to render
  80907. * @param batch Defines the batch of meshes in case of instances
  80908. * @param useOverlay Defines if the rendering is for the overlay or the outline
  80909. */
  80910. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  80911. /**
  80912. * Returns whether or not the outline renderer is ready for a given submesh.
  80913. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  80914. * @param subMesh Defines the submesh to check readyness for
  80915. * @param useInstances Defines wheter wee are trying to render instances or not
  80916. * @returns true if ready otherwise false
  80917. */
  80918. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80919. private _beforeRenderingMesh;
  80920. private _afterRenderingMesh;
  80921. }
  80922. }
  80923. declare module "babylonjs/Rendering/index" {
  80924. export * from "babylonjs/Rendering/boundingBoxRenderer";
  80925. export * from "babylonjs/Rendering/depthRenderer";
  80926. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  80927. export * from "babylonjs/Rendering/edgesRenderer";
  80928. export * from "babylonjs/Rendering/geometryBufferRenderer";
  80929. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  80930. export * from "babylonjs/Rendering/prePassRenderer";
  80931. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  80932. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  80933. export * from "babylonjs/Rendering/outlineRenderer";
  80934. export * from "babylonjs/Rendering/renderingGroup";
  80935. export * from "babylonjs/Rendering/renderingManager";
  80936. export * from "babylonjs/Rendering/utilityLayerRenderer";
  80937. }
  80938. declare module "babylonjs/Sprites/ISprites" {
  80939. /**
  80940. * Defines the basic options interface of a Sprite Frame Source Size.
  80941. */
  80942. export interface ISpriteJSONSpriteSourceSize {
  80943. /**
  80944. * number of the original width of the Frame
  80945. */
  80946. w: number;
  80947. /**
  80948. * number of the original height of the Frame
  80949. */
  80950. h: number;
  80951. }
  80952. /**
  80953. * Defines the basic options interface of a Sprite Frame Data.
  80954. */
  80955. export interface ISpriteJSONSpriteFrameData {
  80956. /**
  80957. * number of the x offset of the Frame
  80958. */
  80959. x: number;
  80960. /**
  80961. * number of the y offset of the Frame
  80962. */
  80963. y: number;
  80964. /**
  80965. * number of the width of the Frame
  80966. */
  80967. w: number;
  80968. /**
  80969. * number of the height of the Frame
  80970. */
  80971. h: number;
  80972. }
  80973. /**
  80974. * Defines the basic options interface of a JSON Sprite.
  80975. */
  80976. export interface ISpriteJSONSprite {
  80977. /**
  80978. * string name of the Frame
  80979. */
  80980. filename: string;
  80981. /**
  80982. * ISpriteJSONSpriteFrame basic object of the frame data
  80983. */
  80984. frame: ISpriteJSONSpriteFrameData;
  80985. /**
  80986. * boolean to flag is the frame was rotated.
  80987. */
  80988. rotated: boolean;
  80989. /**
  80990. * boolean to flag is the frame was trimmed.
  80991. */
  80992. trimmed: boolean;
  80993. /**
  80994. * ISpriteJSONSpriteFrame basic object of the source data
  80995. */
  80996. spriteSourceSize: ISpriteJSONSpriteFrameData;
  80997. /**
  80998. * ISpriteJSONSpriteFrame basic object of the source data
  80999. */
  81000. sourceSize: ISpriteJSONSpriteSourceSize;
  81001. }
  81002. /**
  81003. * Defines the basic options interface of a JSON atlas.
  81004. */
  81005. export interface ISpriteJSONAtlas {
  81006. /**
  81007. * Array of objects that contain the frame data.
  81008. */
  81009. frames: Array<ISpriteJSONSprite>;
  81010. /**
  81011. * object basic object containing the sprite meta data.
  81012. */
  81013. meta?: object;
  81014. }
  81015. }
  81016. declare module "babylonjs/Shaders/spriteMap.fragment" {
  81017. /** @hidden */
  81018. export var spriteMapPixelShader: {
  81019. name: string;
  81020. shader: string;
  81021. };
  81022. }
  81023. declare module "babylonjs/Shaders/spriteMap.vertex" {
  81024. /** @hidden */
  81025. export var spriteMapVertexShader: {
  81026. name: string;
  81027. shader: string;
  81028. };
  81029. }
  81030. declare module "babylonjs/Sprites/spriteMap" {
  81031. import { IDisposable, Scene } from "babylonjs/scene";
  81032. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  81033. import { Texture } from "babylonjs/Materials/Textures/texture";
  81034. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  81035. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  81036. import "babylonjs/Meshes/Builders/planeBuilder";
  81037. import "babylonjs/Shaders/spriteMap.fragment";
  81038. import "babylonjs/Shaders/spriteMap.vertex";
  81039. /**
  81040. * Defines the basic options interface of a SpriteMap
  81041. */
  81042. export interface ISpriteMapOptions {
  81043. /**
  81044. * Vector2 of the number of cells in the grid.
  81045. */
  81046. stageSize?: Vector2;
  81047. /**
  81048. * Vector2 of the size of the output plane in World Units.
  81049. */
  81050. outputSize?: Vector2;
  81051. /**
  81052. * Vector3 of the position of the output plane in World Units.
  81053. */
  81054. outputPosition?: Vector3;
  81055. /**
  81056. * Vector3 of the rotation of the output plane.
  81057. */
  81058. outputRotation?: Vector3;
  81059. /**
  81060. * number of layers that the system will reserve in resources.
  81061. */
  81062. layerCount?: number;
  81063. /**
  81064. * number of max animation frames a single cell will reserve in resources.
  81065. */
  81066. maxAnimationFrames?: number;
  81067. /**
  81068. * number cell index of the base tile when the system compiles.
  81069. */
  81070. baseTile?: number;
  81071. /**
  81072. * boolean flip the sprite after its been repositioned by the framing data.
  81073. */
  81074. flipU?: boolean;
  81075. /**
  81076. * Vector3 scalar of the global RGB values of the SpriteMap.
  81077. */
  81078. colorMultiply?: Vector3;
  81079. }
  81080. /**
  81081. * Defines the IDisposable interface in order to be cleanable from resources.
  81082. */
  81083. export interface ISpriteMap extends IDisposable {
  81084. /**
  81085. * String name of the SpriteMap.
  81086. */
  81087. name: string;
  81088. /**
  81089. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  81090. */
  81091. atlasJSON: ISpriteJSONAtlas;
  81092. /**
  81093. * Texture of the SpriteMap.
  81094. */
  81095. spriteSheet: Texture;
  81096. /**
  81097. * The parameters to initialize the SpriteMap with.
  81098. */
  81099. options: ISpriteMapOptions;
  81100. }
  81101. /**
  81102. * Class used to manage a grid restricted sprite deployment on an Output plane.
  81103. */
  81104. export class SpriteMap implements ISpriteMap {
  81105. /** The Name of the spriteMap */
  81106. name: string;
  81107. /** The JSON file with the frame and meta data */
  81108. atlasJSON: ISpriteJSONAtlas;
  81109. /** The systems Sprite Sheet Texture */
  81110. spriteSheet: Texture;
  81111. /** Arguments passed with the Constructor */
  81112. options: ISpriteMapOptions;
  81113. /** Public Sprite Storage array, parsed from atlasJSON */
  81114. sprites: Array<ISpriteJSONSprite>;
  81115. /** Returns the Number of Sprites in the System */
  81116. get spriteCount(): number;
  81117. /** Returns the Position of Output Plane*/
  81118. get position(): Vector3;
  81119. /** Returns the Position of Output Plane*/
  81120. set position(v: Vector3);
  81121. /** Returns the Rotation of Output Plane*/
  81122. get rotation(): Vector3;
  81123. /** Returns the Rotation of Output Plane*/
  81124. set rotation(v: Vector3);
  81125. /** Sets the AnimationMap*/
  81126. get animationMap(): RawTexture;
  81127. /** Sets the AnimationMap*/
  81128. set animationMap(v: RawTexture);
  81129. /** Scene that the SpriteMap was created in */
  81130. private _scene;
  81131. /** Texture Buffer of Float32 that holds tile frame data*/
  81132. private _frameMap;
  81133. /** Texture Buffers of Float32 that holds tileMap data*/
  81134. private _tileMaps;
  81135. /** Texture Buffer of Float32 that holds Animation Data*/
  81136. private _animationMap;
  81137. /** Custom ShaderMaterial Central to the System*/
  81138. private _material;
  81139. /** Custom ShaderMaterial Central to the System*/
  81140. private _output;
  81141. /** Systems Time Ticker*/
  81142. private _time;
  81143. /**
  81144. * Creates a new SpriteMap
  81145. * @param name defines the SpriteMaps Name
  81146. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  81147. * @param spriteSheet is the Texture that the Sprites are on.
  81148. * @param options a basic deployment configuration
  81149. * @param scene The Scene that the map is deployed on
  81150. */
  81151. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  81152. /**
  81153. * Returns tileID location
  81154. * @returns Vector2 the cell position ID
  81155. */
  81156. getTileID(): Vector2;
  81157. /**
  81158. * Gets the UV location of the mouse over the SpriteMap.
  81159. * @returns Vector2 the UV position of the mouse interaction
  81160. */
  81161. getMousePosition(): Vector2;
  81162. /**
  81163. * Creates the "frame" texture Buffer
  81164. * -------------------------------------
  81165. * Structure of frames
  81166. * "filename": "Falling-Water-2.png",
  81167. * "frame": {"x":69,"y":103,"w":24,"h":32},
  81168. * "rotated": true,
  81169. * "trimmed": true,
  81170. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  81171. * "sourceSize": {"w":32,"h":32}
  81172. * @returns RawTexture of the frameMap
  81173. */
  81174. private _createFrameBuffer;
  81175. /**
  81176. * Creates the tileMap texture Buffer
  81177. * @param buffer normally and array of numbers, or a false to generate from scratch
  81178. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  81179. * @returns RawTexture of the tileMap
  81180. */
  81181. private _createTileBuffer;
  81182. /**
  81183. * Modifies the data of the tileMaps
  81184. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  81185. * @param pos is the iVector2 Coordinates of the Tile
  81186. * @param tile The SpriteIndex of the new Tile
  81187. */
  81188. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  81189. /**
  81190. * Creates the animationMap texture Buffer
  81191. * @param buffer normally and array of numbers, or a false to generate from scratch
  81192. * @returns RawTexture of the animationMap
  81193. */
  81194. private _createTileAnimationBuffer;
  81195. /**
  81196. * Modifies the data of the animationMap
  81197. * @param cellID is the Index of the Sprite
  81198. * @param _frame is the target Animation frame
  81199. * @param toCell is the Target Index of the next frame of the animation
  81200. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  81201. * @param speed is a global scalar of the time variable on the map.
  81202. */
  81203. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  81204. /**
  81205. * Exports the .tilemaps file
  81206. */
  81207. saveTileMaps(): void;
  81208. /**
  81209. * Imports the .tilemaps file
  81210. * @param url of the .tilemaps file
  81211. */
  81212. loadTileMaps(url: string): void;
  81213. /**
  81214. * Release associated resources
  81215. */
  81216. dispose(): void;
  81217. }
  81218. }
  81219. declare module "babylonjs/Sprites/spritePackedManager" {
  81220. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  81221. import { Scene } from "babylonjs/scene";
  81222. /**
  81223. * Class used to manage multiple sprites of different sizes on the same spritesheet
  81224. * @see https://doc.babylonjs.com/babylon101/sprites
  81225. */
  81226. export class SpritePackedManager extends SpriteManager {
  81227. /** defines the packed manager's name */
  81228. name: string;
  81229. /**
  81230. * Creates a new sprite manager from a packed sprite sheet
  81231. * @param name defines the manager's name
  81232. * @param imgUrl defines the sprite sheet url
  81233. * @param capacity defines the maximum allowed number of sprites
  81234. * @param scene defines the hosting scene
  81235. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  81236. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  81237. * @param samplingMode defines the smapling mode to use with spritesheet
  81238. * @param fromPacked set to true; do not alter
  81239. */
  81240. constructor(
  81241. /** defines the packed manager's name */
  81242. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  81243. }
  81244. }
  81245. declare module "babylonjs/Sprites/index" {
  81246. export * from "babylonjs/Sprites/sprite";
  81247. export * from "babylonjs/Sprites/ISprites";
  81248. export * from "babylonjs/Sprites/spriteManager";
  81249. export * from "babylonjs/Sprites/spriteMap";
  81250. export * from "babylonjs/Sprites/spritePackedManager";
  81251. export * from "babylonjs/Sprites/spriteSceneComponent";
  81252. }
  81253. declare module "babylonjs/States/index" {
  81254. export * from "babylonjs/States/alphaCullingState";
  81255. export * from "babylonjs/States/depthCullingState";
  81256. export * from "babylonjs/States/stencilState";
  81257. }
  81258. declare module "babylonjs/Misc/assetsManager" {
  81259. import { Scene } from "babylonjs/scene";
  81260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81261. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  81262. import { Skeleton } from "babylonjs/Bones/skeleton";
  81263. import { Observable } from "babylonjs/Misc/observable";
  81264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  81265. import { Texture } from "babylonjs/Materials/Textures/texture";
  81266. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  81267. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  81268. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  81269. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  81270. import { AssetContainer } from "babylonjs/assetContainer";
  81271. /**
  81272. * Defines the list of states available for a task inside a AssetsManager
  81273. */
  81274. export enum AssetTaskState {
  81275. /**
  81276. * Initialization
  81277. */
  81278. INIT = 0,
  81279. /**
  81280. * Running
  81281. */
  81282. RUNNING = 1,
  81283. /**
  81284. * Done
  81285. */
  81286. DONE = 2,
  81287. /**
  81288. * Error
  81289. */
  81290. ERROR = 3
  81291. }
  81292. /**
  81293. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  81294. */
  81295. export abstract class AbstractAssetTask {
  81296. /**
  81297. * Task name
  81298. */ name: string;
  81299. /**
  81300. * Callback called when the task is successful
  81301. */
  81302. onSuccess: (task: any) => void;
  81303. /**
  81304. * Callback called when the task is not successful
  81305. */
  81306. onError: (task: any, message?: string, exception?: any) => void;
  81307. /**
  81308. * Creates a new AssetsManager
  81309. * @param name defines the name of the task
  81310. */
  81311. constructor(
  81312. /**
  81313. * Task name
  81314. */ name: string);
  81315. private _isCompleted;
  81316. private _taskState;
  81317. private _errorObject;
  81318. /**
  81319. * Get if the task is completed
  81320. */
  81321. get isCompleted(): boolean;
  81322. /**
  81323. * Gets the current state of the task
  81324. */
  81325. get taskState(): AssetTaskState;
  81326. /**
  81327. * Gets the current error object (if task is in error)
  81328. */
  81329. get errorObject(): {
  81330. message?: string;
  81331. exception?: any;
  81332. };
  81333. /**
  81334. * Internal only
  81335. * @hidden
  81336. */
  81337. _setErrorObject(message?: string, exception?: any): void;
  81338. /**
  81339. * Execute the current task
  81340. * @param scene defines the scene where you want your assets to be loaded
  81341. * @param onSuccess is a callback called when the task is successfully executed
  81342. * @param onError is a callback called if an error occurs
  81343. */
  81344. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81345. /**
  81346. * Execute the current task
  81347. * @param scene defines the scene where you want your assets to be loaded
  81348. * @param onSuccess is a callback called when the task is successfully executed
  81349. * @param onError is a callback called if an error occurs
  81350. */
  81351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81352. /**
  81353. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  81354. * This can be used with failed tasks that have the reason for failure fixed.
  81355. */
  81356. reset(): void;
  81357. private onErrorCallback;
  81358. private onDoneCallback;
  81359. }
  81360. /**
  81361. * Define the interface used by progress events raised during assets loading
  81362. */
  81363. export interface IAssetsProgressEvent {
  81364. /**
  81365. * Defines the number of remaining tasks to process
  81366. */
  81367. remainingCount: number;
  81368. /**
  81369. * Defines the total number of tasks
  81370. */
  81371. totalCount: number;
  81372. /**
  81373. * Defines the task that was just processed
  81374. */
  81375. task: AbstractAssetTask;
  81376. }
  81377. /**
  81378. * Class used to share progress information about assets loading
  81379. */
  81380. export class AssetsProgressEvent implements IAssetsProgressEvent {
  81381. /**
  81382. * Defines the number of remaining tasks to process
  81383. */
  81384. remainingCount: number;
  81385. /**
  81386. * Defines the total number of tasks
  81387. */
  81388. totalCount: number;
  81389. /**
  81390. * Defines the task that was just processed
  81391. */
  81392. task: AbstractAssetTask;
  81393. /**
  81394. * Creates a AssetsProgressEvent
  81395. * @param remainingCount defines the number of remaining tasks to process
  81396. * @param totalCount defines the total number of tasks
  81397. * @param task defines the task that was just processed
  81398. */
  81399. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  81400. }
  81401. /**
  81402. * Define a task used by AssetsManager to load assets into a container
  81403. */
  81404. export class ContainerAssetTask extends AbstractAssetTask {
  81405. /**
  81406. * Defines the name of the task
  81407. */
  81408. name: string;
  81409. /**
  81410. * Defines the list of mesh's names you want to load
  81411. */
  81412. meshesNames: any;
  81413. /**
  81414. * Defines the root url to use as a base to load your meshes and associated resources
  81415. */
  81416. rootUrl: string;
  81417. /**
  81418. * Defines the filename or File of the scene to load from
  81419. */
  81420. sceneFilename: string | File;
  81421. /**
  81422. * Get the loaded asset container
  81423. */
  81424. loadedContainer: AssetContainer;
  81425. /**
  81426. * Gets the list of loaded meshes
  81427. */
  81428. loadedMeshes: Array<AbstractMesh>;
  81429. /**
  81430. * Gets the list of loaded particle systems
  81431. */
  81432. loadedParticleSystems: Array<IParticleSystem>;
  81433. /**
  81434. * Gets the list of loaded skeletons
  81435. */
  81436. loadedSkeletons: Array<Skeleton>;
  81437. /**
  81438. * Gets the list of loaded animation groups
  81439. */
  81440. loadedAnimationGroups: Array<AnimationGroup>;
  81441. /**
  81442. * Callback called when the task is successful
  81443. */
  81444. onSuccess: (task: ContainerAssetTask) => void;
  81445. /**
  81446. * Callback called when the task is successful
  81447. */
  81448. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  81449. /**
  81450. * Creates a new ContainerAssetTask
  81451. * @param name defines the name of the task
  81452. * @param meshesNames defines the list of mesh's names you want to load
  81453. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81454. * @param sceneFilename defines the filename or File of the scene to load from
  81455. */
  81456. constructor(
  81457. /**
  81458. * Defines the name of the task
  81459. */
  81460. name: string,
  81461. /**
  81462. * Defines the list of mesh's names you want to load
  81463. */
  81464. meshesNames: any,
  81465. /**
  81466. * Defines the root url to use as a base to load your meshes and associated resources
  81467. */
  81468. rootUrl: string,
  81469. /**
  81470. * Defines the filename or File of the scene to load from
  81471. */
  81472. sceneFilename: string | File);
  81473. /**
  81474. * Execute the current task
  81475. * @param scene defines the scene where you want your assets to be loaded
  81476. * @param onSuccess is a callback called when the task is successfully executed
  81477. * @param onError is a callback called if an error occurs
  81478. */
  81479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81480. }
  81481. /**
  81482. * Define a task used by AssetsManager to load meshes
  81483. */
  81484. export class MeshAssetTask extends AbstractAssetTask {
  81485. /**
  81486. * Defines the name of the task
  81487. */
  81488. name: string;
  81489. /**
  81490. * Defines the list of mesh's names you want to load
  81491. */
  81492. meshesNames: any;
  81493. /**
  81494. * Defines the root url to use as a base to load your meshes and associated resources
  81495. */
  81496. rootUrl: string;
  81497. /**
  81498. * Defines the filename or File of the scene to load from
  81499. */
  81500. sceneFilename: string | File;
  81501. /**
  81502. * Gets the list of loaded meshes
  81503. */
  81504. loadedMeshes: Array<AbstractMesh>;
  81505. /**
  81506. * Gets the list of loaded particle systems
  81507. */
  81508. loadedParticleSystems: Array<IParticleSystem>;
  81509. /**
  81510. * Gets the list of loaded skeletons
  81511. */
  81512. loadedSkeletons: Array<Skeleton>;
  81513. /**
  81514. * Gets the list of loaded animation groups
  81515. */
  81516. loadedAnimationGroups: Array<AnimationGroup>;
  81517. /**
  81518. * Callback called when the task is successful
  81519. */
  81520. onSuccess: (task: MeshAssetTask) => void;
  81521. /**
  81522. * Callback called when the task is successful
  81523. */
  81524. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  81525. /**
  81526. * Creates a new MeshAssetTask
  81527. * @param name defines the name of the task
  81528. * @param meshesNames defines the list of mesh's names you want to load
  81529. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81530. * @param sceneFilename defines the filename or File of the scene to load from
  81531. */
  81532. constructor(
  81533. /**
  81534. * Defines the name of the task
  81535. */
  81536. name: string,
  81537. /**
  81538. * Defines the list of mesh's names you want to load
  81539. */
  81540. meshesNames: any,
  81541. /**
  81542. * Defines the root url to use as a base to load your meshes and associated resources
  81543. */
  81544. rootUrl: string,
  81545. /**
  81546. * Defines the filename or File of the scene to load from
  81547. */
  81548. sceneFilename: string | File);
  81549. /**
  81550. * Execute the current task
  81551. * @param scene defines the scene where you want your assets to be loaded
  81552. * @param onSuccess is a callback called when the task is successfully executed
  81553. * @param onError is a callback called if an error occurs
  81554. */
  81555. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81556. }
  81557. /**
  81558. * Define a task used by AssetsManager to load text content
  81559. */
  81560. export class TextFileAssetTask extends AbstractAssetTask {
  81561. /**
  81562. * Defines the name of the task
  81563. */
  81564. name: string;
  81565. /**
  81566. * Defines the location of the file to load
  81567. */
  81568. url: string;
  81569. /**
  81570. * Gets the loaded text string
  81571. */
  81572. text: string;
  81573. /**
  81574. * Callback called when the task is successful
  81575. */
  81576. onSuccess: (task: TextFileAssetTask) => void;
  81577. /**
  81578. * Callback called when the task is successful
  81579. */
  81580. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  81581. /**
  81582. * Creates a new TextFileAssetTask object
  81583. * @param name defines the name of the task
  81584. * @param url defines the location of the file to load
  81585. */
  81586. constructor(
  81587. /**
  81588. * Defines the name of the task
  81589. */
  81590. name: string,
  81591. /**
  81592. * Defines the location of the file to load
  81593. */
  81594. url: string);
  81595. /**
  81596. * Execute the current task
  81597. * @param scene defines the scene where you want your assets to be loaded
  81598. * @param onSuccess is a callback called when the task is successfully executed
  81599. * @param onError is a callback called if an error occurs
  81600. */
  81601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81602. }
  81603. /**
  81604. * Define a task used by AssetsManager to load binary data
  81605. */
  81606. export class BinaryFileAssetTask extends AbstractAssetTask {
  81607. /**
  81608. * Defines the name of the task
  81609. */
  81610. name: string;
  81611. /**
  81612. * Defines the location of the file to load
  81613. */
  81614. url: string;
  81615. /**
  81616. * Gets the lodaded data (as an array buffer)
  81617. */
  81618. data: ArrayBuffer;
  81619. /**
  81620. * Callback called when the task is successful
  81621. */
  81622. onSuccess: (task: BinaryFileAssetTask) => void;
  81623. /**
  81624. * Callback called when the task is successful
  81625. */
  81626. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  81627. /**
  81628. * Creates a new BinaryFileAssetTask object
  81629. * @param name defines the name of the new task
  81630. * @param url defines the location of the file to load
  81631. */
  81632. constructor(
  81633. /**
  81634. * Defines the name of the task
  81635. */
  81636. name: string,
  81637. /**
  81638. * Defines the location of the file to load
  81639. */
  81640. url: string);
  81641. /**
  81642. * Execute the current task
  81643. * @param scene defines the scene where you want your assets to be loaded
  81644. * @param onSuccess is a callback called when the task is successfully executed
  81645. * @param onError is a callback called if an error occurs
  81646. */
  81647. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81648. }
  81649. /**
  81650. * Define a task used by AssetsManager to load images
  81651. */
  81652. export class ImageAssetTask extends AbstractAssetTask {
  81653. /**
  81654. * Defines the name of the task
  81655. */
  81656. name: string;
  81657. /**
  81658. * Defines the location of the image to load
  81659. */
  81660. url: string;
  81661. /**
  81662. * Gets the loaded images
  81663. */
  81664. image: HTMLImageElement;
  81665. /**
  81666. * Callback called when the task is successful
  81667. */
  81668. onSuccess: (task: ImageAssetTask) => void;
  81669. /**
  81670. * Callback called when the task is successful
  81671. */
  81672. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  81673. /**
  81674. * Creates a new ImageAssetTask
  81675. * @param name defines the name of the task
  81676. * @param url defines the location of the image to load
  81677. */
  81678. constructor(
  81679. /**
  81680. * Defines the name of the task
  81681. */
  81682. name: string,
  81683. /**
  81684. * Defines the location of the image to load
  81685. */
  81686. url: string);
  81687. /**
  81688. * Execute the current task
  81689. * @param scene defines the scene where you want your assets to be loaded
  81690. * @param onSuccess is a callback called when the task is successfully executed
  81691. * @param onError is a callback called if an error occurs
  81692. */
  81693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81694. }
  81695. /**
  81696. * Defines the interface used by texture loading tasks
  81697. */
  81698. export interface ITextureAssetTask<TEX extends BaseTexture> {
  81699. /**
  81700. * Gets the loaded texture
  81701. */
  81702. texture: TEX;
  81703. }
  81704. /**
  81705. * Define a task used by AssetsManager to load 2D textures
  81706. */
  81707. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  81708. /**
  81709. * Defines the name of the task
  81710. */
  81711. name: string;
  81712. /**
  81713. * Defines the location of the file to load
  81714. */
  81715. url: string;
  81716. /**
  81717. * Defines if mipmap should not be generated (default is false)
  81718. */
  81719. noMipmap?: boolean | undefined;
  81720. /**
  81721. * Defines if texture must be inverted on Y axis (default is true)
  81722. */
  81723. invertY: boolean;
  81724. /**
  81725. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81726. */
  81727. samplingMode: number;
  81728. /**
  81729. * Gets the loaded texture
  81730. */
  81731. texture: Texture;
  81732. /**
  81733. * Callback called when the task is successful
  81734. */
  81735. onSuccess: (task: TextureAssetTask) => void;
  81736. /**
  81737. * Callback called when the task is successful
  81738. */
  81739. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  81740. /**
  81741. * Creates a new TextureAssetTask object
  81742. * @param name defines the name of the task
  81743. * @param url defines the location of the file to load
  81744. * @param noMipmap defines if mipmap should not be generated (default is false)
  81745. * @param invertY defines if texture must be inverted on Y axis (default is true)
  81746. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81747. */
  81748. constructor(
  81749. /**
  81750. * Defines the name of the task
  81751. */
  81752. name: string,
  81753. /**
  81754. * Defines the location of the file to load
  81755. */
  81756. url: string,
  81757. /**
  81758. * Defines if mipmap should not be generated (default is false)
  81759. */
  81760. noMipmap?: boolean | undefined,
  81761. /**
  81762. * Defines if texture must be inverted on Y axis (default is true)
  81763. */
  81764. invertY?: boolean,
  81765. /**
  81766. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81767. */
  81768. samplingMode?: number);
  81769. /**
  81770. * Execute the current task
  81771. * @param scene defines the scene where you want your assets to be loaded
  81772. * @param onSuccess is a callback called when the task is successfully executed
  81773. * @param onError is a callback called if an error occurs
  81774. */
  81775. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81776. }
  81777. /**
  81778. * Define a task used by AssetsManager to load cube textures
  81779. */
  81780. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  81781. /**
  81782. * Defines the name of the task
  81783. */
  81784. name: string;
  81785. /**
  81786. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81787. */
  81788. url: string;
  81789. /**
  81790. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81791. */
  81792. extensions?: string[] | undefined;
  81793. /**
  81794. * Defines if mipmaps should not be generated (default is false)
  81795. */
  81796. noMipmap?: boolean | undefined;
  81797. /**
  81798. * Defines the explicit list of files (undefined by default)
  81799. */
  81800. files?: string[] | undefined;
  81801. /**
  81802. * Gets the loaded texture
  81803. */
  81804. texture: CubeTexture;
  81805. /**
  81806. * Callback called when the task is successful
  81807. */
  81808. onSuccess: (task: CubeTextureAssetTask) => void;
  81809. /**
  81810. * Callback called when the task is successful
  81811. */
  81812. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  81813. /**
  81814. * Creates a new CubeTextureAssetTask
  81815. * @param name defines the name of the task
  81816. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81817. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81818. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81819. * @param files defines the explicit list of files (undefined by default)
  81820. */
  81821. constructor(
  81822. /**
  81823. * Defines the name of the task
  81824. */
  81825. name: string,
  81826. /**
  81827. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81828. */
  81829. url: string,
  81830. /**
  81831. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81832. */
  81833. extensions?: string[] | undefined,
  81834. /**
  81835. * Defines if mipmaps should not be generated (default is false)
  81836. */
  81837. noMipmap?: boolean | undefined,
  81838. /**
  81839. * Defines the explicit list of files (undefined by default)
  81840. */
  81841. files?: string[] | undefined);
  81842. /**
  81843. * Execute the current task
  81844. * @param scene defines the scene where you want your assets to be loaded
  81845. * @param onSuccess is a callback called when the task is successfully executed
  81846. * @param onError is a callback called if an error occurs
  81847. */
  81848. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81849. }
  81850. /**
  81851. * Define a task used by AssetsManager to load HDR cube textures
  81852. */
  81853. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  81854. /**
  81855. * Defines the name of the task
  81856. */
  81857. name: string;
  81858. /**
  81859. * Defines the location of the file to load
  81860. */
  81861. url: string;
  81862. /**
  81863. * Defines the desired size (the more it increases the longer the generation will be)
  81864. */
  81865. size: number;
  81866. /**
  81867. * Defines if mipmaps should not be generated (default is false)
  81868. */
  81869. noMipmap: boolean;
  81870. /**
  81871. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81872. */
  81873. generateHarmonics: boolean;
  81874. /**
  81875. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  81876. */
  81877. gammaSpace: boolean;
  81878. /**
  81879. * Internal Use Only
  81880. */
  81881. reserved: boolean;
  81882. /**
  81883. * Gets the loaded texture
  81884. */
  81885. texture: HDRCubeTexture;
  81886. /**
  81887. * Callback called when the task is successful
  81888. */
  81889. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  81890. /**
  81891. * Callback called when the task is successful
  81892. */
  81893. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  81894. /**
  81895. * Creates a new HDRCubeTextureAssetTask object
  81896. * @param name defines the name of the task
  81897. * @param url defines the location of the file to load
  81898. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  81899. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81900. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81901. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  81902. * @param reserved Internal use only
  81903. */
  81904. constructor(
  81905. /**
  81906. * Defines the name of the task
  81907. */
  81908. name: string,
  81909. /**
  81910. * Defines the location of the file to load
  81911. */
  81912. url: string,
  81913. /**
  81914. * Defines the desired size (the more it increases the longer the generation will be)
  81915. */
  81916. size: number,
  81917. /**
  81918. * Defines if mipmaps should not be generated (default is false)
  81919. */
  81920. noMipmap?: boolean,
  81921. /**
  81922. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81923. */
  81924. generateHarmonics?: boolean,
  81925. /**
  81926. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  81927. */
  81928. gammaSpace?: boolean,
  81929. /**
  81930. * Internal Use Only
  81931. */
  81932. reserved?: boolean);
  81933. /**
  81934. * Execute the current task
  81935. * @param scene defines the scene where you want your assets to be loaded
  81936. * @param onSuccess is a callback called when the task is successfully executed
  81937. * @param onError is a callback called if an error occurs
  81938. */
  81939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81940. }
  81941. /**
  81942. * Define a task used by AssetsManager to load Equirectangular cube textures
  81943. */
  81944. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  81945. /**
  81946. * Defines the name of the task
  81947. */
  81948. name: string;
  81949. /**
  81950. * Defines the location of the file to load
  81951. */
  81952. url: string;
  81953. /**
  81954. * Defines the desired size (the more it increases the longer the generation will be)
  81955. */
  81956. size: number;
  81957. /**
  81958. * Defines if mipmaps should not be generated (default is false)
  81959. */
  81960. noMipmap: boolean;
  81961. /**
  81962. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  81963. * but the standard material would require them in Gamma space) (default is true)
  81964. */
  81965. gammaSpace: boolean;
  81966. /**
  81967. * Gets the loaded texture
  81968. */
  81969. texture: EquiRectangularCubeTexture;
  81970. /**
  81971. * Callback called when the task is successful
  81972. */
  81973. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  81974. /**
  81975. * Callback called when the task is successful
  81976. */
  81977. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  81978. /**
  81979. * Creates a new EquiRectangularCubeTextureAssetTask object
  81980. * @param name defines the name of the task
  81981. * @param url defines the location of the file to load
  81982. * @param size defines the desired size (the more it increases the longer the generation will be)
  81983. * If the size is omitted this implies you are using a preprocessed cubemap.
  81984. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81985. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  81986. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  81987. * (default is true)
  81988. */
  81989. constructor(
  81990. /**
  81991. * Defines the name of the task
  81992. */
  81993. name: string,
  81994. /**
  81995. * Defines the location of the file to load
  81996. */
  81997. url: string,
  81998. /**
  81999. * Defines the desired size (the more it increases the longer the generation will be)
  82000. */
  82001. size: number,
  82002. /**
  82003. * Defines if mipmaps should not be generated (default is false)
  82004. */
  82005. noMipmap?: boolean,
  82006. /**
  82007. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  82008. * but the standard material would require them in Gamma space) (default is true)
  82009. */
  82010. gammaSpace?: boolean);
  82011. /**
  82012. * Execute the current task
  82013. * @param scene defines the scene where you want your assets to be loaded
  82014. * @param onSuccess is a callback called when the task is successfully executed
  82015. * @param onError is a callback called if an error occurs
  82016. */
  82017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82018. }
  82019. /**
  82020. * This class can be used to easily import assets into a scene
  82021. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  82022. */
  82023. export class AssetsManager {
  82024. private _scene;
  82025. private _isLoading;
  82026. protected _tasks: AbstractAssetTask[];
  82027. protected _waitingTasksCount: number;
  82028. protected _totalTasksCount: number;
  82029. /**
  82030. * Callback called when all tasks are processed
  82031. */
  82032. onFinish: (tasks: AbstractAssetTask[]) => void;
  82033. /**
  82034. * Callback called when a task is successful
  82035. */
  82036. onTaskSuccess: (task: AbstractAssetTask) => void;
  82037. /**
  82038. * Callback called when a task had an error
  82039. */
  82040. onTaskError: (task: AbstractAssetTask) => void;
  82041. /**
  82042. * Callback called when a task is done (whatever the result is)
  82043. */
  82044. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  82045. /**
  82046. * Observable called when all tasks are processed
  82047. */
  82048. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  82049. /**
  82050. * Observable called when a task had an error
  82051. */
  82052. onTaskErrorObservable: Observable<AbstractAssetTask>;
  82053. /**
  82054. * Observable called when all tasks were executed
  82055. */
  82056. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  82057. /**
  82058. * Observable called when a task is done (whatever the result is)
  82059. */
  82060. onProgressObservable: Observable<IAssetsProgressEvent>;
  82061. /**
  82062. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  82063. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82064. */
  82065. useDefaultLoadingScreen: boolean;
  82066. /**
  82067. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  82068. * when all assets have been downloaded.
  82069. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  82070. */
  82071. autoHideLoadingUI: boolean;
  82072. /**
  82073. * Creates a new AssetsManager
  82074. * @param scene defines the scene to work on
  82075. */
  82076. constructor(scene: Scene);
  82077. /**
  82078. * Add a ContainerAssetTask to the list of active tasks
  82079. * @param taskName defines the name of the new task
  82080. * @param meshesNames defines the name of meshes to load
  82081. * @param rootUrl defines the root url to use to locate files
  82082. * @param sceneFilename defines the filename of the scene file
  82083. * @returns a new ContainerAssetTask object
  82084. */
  82085. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  82086. /**
  82087. * Add a MeshAssetTask to the list of active tasks
  82088. * @param taskName defines the name of the new task
  82089. * @param meshesNames defines the name of meshes to load
  82090. * @param rootUrl defines the root url to use to locate files
  82091. * @param sceneFilename defines the filename of the scene file
  82092. * @returns a new MeshAssetTask object
  82093. */
  82094. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  82095. /**
  82096. * Add a TextFileAssetTask to the list of active tasks
  82097. * @param taskName defines the name of the new task
  82098. * @param url defines the url of the file to load
  82099. * @returns a new TextFileAssetTask object
  82100. */
  82101. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  82102. /**
  82103. * Add a BinaryFileAssetTask to the list of active tasks
  82104. * @param taskName defines the name of the new task
  82105. * @param url defines the url of the file to load
  82106. * @returns a new BinaryFileAssetTask object
  82107. */
  82108. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  82109. /**
  82110. * Add a ImageAssetTask to the list of active tasks
  82111. * @param taskName defines the name of the new task
  82112. * @param url defines the url of the file to load
  82113. * @returns a new ImageAssetTask object
  82114. */
  82115. addImageTask(taskName: string, url: string): ImageAssetTask;
  82116. /**
  82117. * Add a TextureAssetTask to the list of active tasks
  82118. * @param taskName defines the name of the new task
  82119. * @param url defines the url of the file to load
  82120. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82121. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  82122. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  82123. * @returns a new TextureAssetTask object
  82124. */
  82125. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  82126. /**
  82127. * Add a CubeTextureAssetTask to the list of active tasks
  82128. * @param taskName defines the name of the new task
  82129. * @param url defines the url of the file to load
  82130. * @param extensions defines the extension to use to load the cube map (can be null)
  82131. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82132. * @param files defines the list of files to load (can be null)
  82133. * @returns a new CubeTextureAssetTask object
  82134. */
  82135. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  82136. /**
  82137. *
  82138. * Add a HDRCubeTextureAssetTask to the list of active tasks
  82139. * @param taskName defines the name of the new task
  82140. * @param url defines the url of the file to load
  82141. * @param size defines the size you want for the cubemap (can be null)
  82142. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82143. * @param generateHarmonics defines if you want to automatically generate (true by default)
  82144. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  82145. * @param reserved Internal use only
  82146. * @returns a new HDRCubeTextureAssetTask object
  82147. */
  82148. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  82149. /**
  82150. *
  82151. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  82152. * @param taskName defines the name of the new task
  82153. * @param url defines the url of the file to load
  82154. * @param size defines the size you want for the cubemap (can be null)
  82155. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82156. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  82157. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  82158. * @returns a new EquiRectangularCubeTextureAssetTask object
  82159. */
  82160. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  82161. /**
  82162. * Remove a task from the assets manager.
  82163. * @param task the task to remove
  82164. */
  82165. removeTask(task: AbstractAssetTask): void;
  82166. private _decreaseWaitingTasksCount;
  82167. private _runTask;
  82168. /**
  82169. * Reset the AssetsManager and remove all tasks
  82170. * @return the current instance of the AssetsManager
  82171. */
  82172. reset(): AssetsManager;
  82173. /**
  82174. * Start the loading process
  82175. * @return the current instance of the AssetsManager
  82176. */
  82177. load(): AssetsManager;
  82178. /**
  82179. * Start the loading process as an async operation
  82180. * @return a promise returning the list of failed tasks
  82181. */
  82182. loadAsync(): Promise<void>;
  82183. }
  82184. }
  82185. declare module "babylonjs/Misc/deferred" {
  82186. /**
  82187. * Wrapper class for promise with external resolve and reject.
  82188. */
  82189. export class Deferred<T> {
  82190. /**
  82191. * The promise associated with this deferred object.
  82192. */
  82193. readonly promise: Promise<T>;
  82194. private _resolve;
  82195. private _reject;
  82196. /**
  82197. * The resolve method of the promise associated with this deferred object.
  82198. */
  82199. get resolve(): (value: T | PromiseLike<T>) => void;
  82200. /**
  82201. * The reject method of the promise associated with this deferred object.
  82202. */
  82203. get reject(): (reason?: any) => void;
  82204. /**
  82205. * Constructor for this deferred object.
  82206. */
  82207. constructor();
  82208. }
  82209. }
  82210. declare module "babylonjs/Misc/meshExploder" {
  82211. import { Mesh } from "babylonjs/Meshes/mesh";
  82212. /**
  82213. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  82214. */
  82215. export class MeshExploder {
  82216. private _centerMesh;
  82217. private _meshes;
  82218. private _meshesOrigins;
  82219. private _toCenterVectors;
  82220. private _scaledDirection;
  82221. private _newPosition;
  82222. private _centerPosition;
  82223. /**
  82224. * Explodes meshes from a center mesh.
  82225. * @param meshes The meshes to explode.
  82226. * @param centerMesh The mesh to be center of explosion.
  82227. */
  82228. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  82229. private _setCenterMesh;
  82230. /**
  82231. * Get class name
  82232. * @returns "MeshExploder"
  82233. */
  82234. getClassName(): string;
  82235. /**
  82236. * "Exploded meshes"
  82237. * @returns Array of meshes with the centerMesh at index 0.
  82238. */
  82239. getMeshes(): Array<Mesh>;
  82240. /**
  82241. * Explodes meshes giving a specific direction
  82242. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  82243. */
  82244. explode(direction?: number): void;
  82245. }
  82246. }
  82247. declare module "babylonjs/Misc/filesInput" {
  82248. import { Engine } from "babylonjs/Engines/engine";
  82249. import { Scene } from "babylonjs/scene";
  82250. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  82251. import { Nullable } from "babylonjs/types";
  82252. /**
  82253. * Class used to help managing file picking and drag'n'drop
  82254. */
  82255. export class FilesInput {
  82256. /**
  82257. * List of files ready to be loaded
  82258. */
  82259. static get FilesToLoad(): {
  82260. [key: string]: File;
  82261. };
  82262. /**
  82263. * Callback called when a file is processed
  82264. */
  82265. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  82266. /**
  82267. * Function used when loading the scene file
  82268. */
  82269. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  82270. private _engine;
  82271. private _currentScene;
  82272. private _sceneLoadedCallback;
  82273. private _progressCallback;
  82274. private _additionalRenderLoopLogicCallback;
  82275. private _textureLoadingCallback;
  82276. private _startingProcessingFilesCallback;
  82277. private _onReloadCallback;
  82278. private _errorCallback;
  82279. private _elementToMonitor;
  82280. private _sceneFileToLoad;
  82281. private _filesToLoad;
  82282. /**
  82283. * Creates a new FilesInput
  82284. * @param engine defines the rendering engine
  82285. * @param scene defines the hosting scene
  82286. * @param sceneLoadedCallback callback called when scene is loaded
  82287. * @param progressCallback callback called to track progress
  82288. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  82289. * @param textureLoadingCallback callback called when a texture is loading
  82290. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  82291. * @param onReloadCallback callback called when a reload is requested
  82292. * @param errorCallback callback call if an error occurs
  82293. */
  82294. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  82295. private _dragEnterHandler;
  82296. private _dragOverHandler;
  82297. private _dropHandler;
  82298. /**
  82299. * Calls this function to listen to drag'n'drop events on a specific DOM element
  82300. * @param elementToMonitor defines the DOM element to track
  82301. */
  82302. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  82303. /** Gets the current list of files to load */
  82304. get filesToLoad(): File[];
  82305. /**
  82306. * Release all associated resources
  82307. */
  82308. dispose(): void;
  82309. private renderFunction;
  82310. private drag;
  82311. private drop;
  82312. private _traverseFolder;
  82313. private _processFiles;
  82314. /**
  82315. * Load files from a drop event
  82316. * @param event defines the drop event to use as source
  82317. */
  82318. loadFiles(event: any): void;
  82319. private _processReload;
  82320. /**
  82321. * Reload the current scene from the loaded files
  82322. */
  82323. reload(): void;
  82324. }
  82325. }
  82326. declare module "babylonjs/Misc/HighDynamicRange/index" {
  82327. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  82328. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  82329. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  82330. }
  82331. declare module "babylonjs/Misc/sceneOptimizer" {
  82332. import { Scene, IDisposable } from "babylonjs/scene";
  82333. import { Observable } from "babylonjs/Misc/observable";
  82334. /**
  82335. * Defines the root class used to create scene optimization to use with SceneOptimizer
  82336. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82337. */
  82338. export class SceneOptimization {
  82339. /**
  82340. * Defines the priority of this optimization (0 by default which means first in the list)
  82341. */
  82342. priority: number;
  82343. /**
  82344. * Gets a string describing the action executed by the current optimization
  82345. * @returns description string
  82346. */
  82347. getDescription(): string;
  82348. /**
  82349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82350. * @param scene defines the current scene where to apply this optimization
  82351. * @param optimizer defines the current optimizer
  82352. * @returns true if everything that can be done was applied
  82353. */
  82354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82355. /**
  82356. * Creates the SceneOptimization object
  82357. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82358. * @param desc defines the description associated with the optimization
  82359. */
  82360. constructor(
  82361. /**
  82362. * Defines the priority of this optimization (0 by default which means first in the list)
  82363. */
  82364. priority?: number);
  82365. }
  82366. /**
  82367. * Defines an optimization used to reduce the size of render target textures
  82368. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82369. */
  82370. export class TextureOptimization extends SceneOptimization {
  82371. /**
  82372. * Defines the priority of this optimization (0 by default which means first in the list)
  82373. */
  82374. priority: number;
  82375. /**
  82376. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  82377. */
  82378. maximumSize: number;
  82379. /**
  82380. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82381. */
  82382. step: number;
  82383. /**
  82384. * Gets a string describing the action executed by the current optimization
  82385. * @returns description string
  82386. */
  82387. getDescription(): string;
  82388. /**
  82389. * Creates the TextureOptimization object
  82390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82391. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  82392. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82393. */
  82394. constructor(
  82395. /**
  82396. * Defines the priority of this optimization (0 by default which means first in the list)
  82397. */
  82398. priority?: number,
  82399. /**
  82400. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  82401. */
  82402. maximumSize?: number,
  82403. /**
  82404. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82405. */
  82406. step?: number);
  82407. /**
  82408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82409. * @param scene defines the current scene where to apply this optimization
  82410. * @param optimizer defines the current optimizer
  82411. * @returns true if everything that can be done was applied
  82412. */
  82413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82414. }
  82415. /**
  82416. * Defines an optimization used to increase or decrease the rendering resolution
  82417. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82418. */
  82419. export class HardwareScalingOptimization extends SceneOptimization {
  82420. /**
  82421. * Defines the priority of this optimization (0 by default which means first in the list)
  82422. */
  82423. priority: number;
  82424. /**
  82425. * Defines the maximum scale to use (2 by default)
  82426. */
  82427. maximumScale: number;
  82428. /**
  82429. * Defines the step to use between two passes (0.5 by default)
  82430. */
  82431. step: number;
  82432. private _currentScale;
  82433. private _directionOffset;
  82434. /**
  82435. * Gets a string describing the action executed by the current optimization
  82436. * @return description string
  82437. */
  82438. getDescription(): string;
  82439. /**
  82440. * Creates the HardwareScalingOptimization object
  82441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82442. * @param maximumScale defines the maximum scale to use (2 by default)
  82443. * @param step defines the step to use between two passes (0.5 by default)
  82444. */
  82445. constructor(
  82446. /**
  82447. * Defines the priority of this optimization (0 by default which means first in the list)
  82448. */
  82449. priority?: number,
  82450. /**
  82451. * Defines the maximum scale to use (2 by default)
  82452. */
  82453. maximumScale?: number,
  82454. /**
  82455. * Defines the step to use between two passes (0.5 by default)
  82456. */
  82457. step?: number);
  82458. /**
  82459. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82460. * @param scene defines the current scene where to apply this optimization
  82461. * @param optimizer defines the current optimizer
  82462. * @returns true if everything that can be done was applied
  82463. */
  82464. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82465. }
  82466. /**
  82467. * Defines an optimization used to remove shadows
  82468. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82469. */
  82470. export class ShadowsOptimization extends SceneOptimization {
  82471. /**
  82472. * Gets a string describing the action executed by the current optimization
  82473. * @return description string
  82474. */
  82475. getDescription(): string;
  82476. /**
  82477. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82478. * @param scene defines the current scene where to apply this optimization
  82479. * @param optimizer defines the current optimizer
  82480. * @returns true if everything that can be done was applied
  82481. */
  82482. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82483. }
  82484. /**
  82485. * Defines an optimization used to turn post-processes off
  82486. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82487. */
  82488. export class PostProcessesOptimization extends SceneOptimization {
  82489. /**
  82490. * Gets a string describing the action executed by the current optimization
  82491. * @return description string
  82492. */
  82493. getDescription(): string;
  82494. /**
  82495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82496. * @param scene defines the current scene where to apply this optimization
  82497. * @param optimizer defines the current optimizer
  82498. * @returns true if everything that can be done was applied
  82499. */
  82500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82501. }
  82502. /**
  82503. * Defines an optimization used to turn lens flares off
  82504. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82505. */
  82506. export class LensFlaresOptimization extends SceneOptimization {
  82507. /**
  82508. * Gets a string describing the action executed by the current optimization
  82509. * @return description string
  82510. */
  82511. getDescription(): string;
  82512. /**
  82513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82514. * @param scene defines the current scene where to apply this optimization
  82515. * @param optimizer defines the current optimizer
  82516. * @returns true if everything that can be done was applied
  82517. */
  82518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82519. }
  82520. /**
  82521. * Defines an optimization based on user defined callback.
  82522. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82523. */
  82524. export class CustomOptimization extends SceneOptimization {
  82525. /**
  82526. * Callback called to apply the custom optimization.
  82527. */
  82528. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  82529. /**
  82530. * Callback called to get custom description
  82531. */
  82532. onGetDescription: () => string;
  82533. /**
  82534. * Gets a string describing the action executed by the current optimization
  82535. * @returns description string
  82536. */
  82537. getDescription(): string;
  82538. /**
  82539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82540. * @param scene defines the current scene where to apply this optimization
  82541. * @param optimizer defines the current optimizer
  82542. * @returns true if everything that can be done was applied
  82543. */
  82544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82545. }
  82546. /**
  82547. * Defines an optimization used to turn particles off
  82548. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82549. */
  82550. export class ParticlesOptimization extends SceneOptimization {
  82551. /**
  82552. * Gets a string describing the action executed by the current optimization
  82553. * @return description string
  82554. */
  82555. getDescription(): string;
  82556. /**
  82557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82558. * @param scene defines the current scene where to apply this optimization
  82559. * @param optimizer defines the current optimizer
  82560. * @returns true if everything that can be done was applied
  82561. */
  82562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82563. }
  82564. /**
  82565. * Defines an optimization used to turn render targets off
  82566. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82567. */
  82568. export class RenderTargetsOptimization extends SceneOptimization {
  82569. /**
  82570. * Gets a string describing the action executed by the current optimization
  82571. * @return description string
  82572. */
  82573. getDescription(): string;
  82574. /**
  82575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82576. * @param scene defines the current scene where to apply this optimization
  82577. * @param optimizer defines the current optimizer
  82578. * @returns true if everything that can be done was applied
  82579. */
  82580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82581. }
  82582. /**
  82583. * Defines an optimization used to merge meshes with compatible materials
  82584. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82585. */
  82586. export class MergeMeshesOptimization extends SceneOptimization {
  82587. private static _UpdateSelectionTree;
  82588. /**
  82589. * Gets or sets a boolean which defines if optimization octree has to be updated
  82590. */
  82591. static get UpdateSelectionTree(): boolean;
  82592. /**
  82593. * Gets or sets a boolean which defines if optimization octree has to be updated
  82594. */
  82595. static set UpdateSelectionTree(value: boolean);
  82596. /**
  82597. * Gets a string describing the action executed by the current optimization
  82598. * @return description string
  82599. */
  82600. getDescription(): string;
  82601. private _canBeMerged;
  82602. /**
  82603. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82604. * @param scene defines the current scene where to apply this optimization
  82605. * @param optimizer defines the current optimizer
  82606. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  82607. * @returns true if everything that can be done was applied
  82608. */
  82609. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  82610. }
  82611. /**
  82612. * Defines a list of options used by SceneOptimizer
  82613. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82614. */
  82615. export class SceneOptimizerOptions {
  82616. /**
  82617. * Defines the target frame rate to reach (60 by default)
  82618. */
  82619. targetFrameRate: number;
  82620. /**
  82621. * Defines the interval between two checkes (2000ms by default)
  82622. */
  82623. trackerDuration: number;
  82624. /**
  82625. * Gets the list of optimizations to apply
  82626. */
  82627. optimizations: SceneOptimization[];
  82628. /**
  82629. * Creates a new list of options used by SceneOptimizer
  82630. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  82631. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  82632. */
  82633. constructor(
  82634. /**
  82635. * Defines the target frame rate to reach (60 by default)
  82636. */
  82637. targetFrameRate?: number,
  82638. /**
  82639. * Defines the interval between two checkes (2000ms by default)
  82640. */
  82641. trackerDuration?: number);
  82642. /**
  82643. * Add a new optimization
  82644. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  82645. * @returns the current SceneOptimizerOptions
  82646. */
  82647. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  82648. /**
  82649. * Add a new custom optimization
  82650. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  82651. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  82652. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82653. * @returns the current SceneOptimizerOptions
  82654. */
  82655. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  82656. /**
  82657. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  82658. * @param targetFrameRate defines the target frame rate (60 by default)
  82659. * @returns a SceneOptimizerOptions object
  82660. */
  82661. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82662. /**
  82663. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  82664. * @param targetFrameRate defines the target frame rate (60 by default)
  82665. * @returns a SceneOptimizerOptions object
  82666. */
  82667. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82668. /**
  82669. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  82670. * @param targetFrameRate defines the target frame rate (60 by default)
  82671. * @returns a SceneOptimizerOptions object
  82672. */
  82673. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82674. }
  82675. /**
  82676. * Class used to run optimizations in order to reach a target frame rate
  82677. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82678. */
  82679. export class SceneOptimizer implements IDisposable {
  82680. private _isRunning;
  82681. private _options;
  82682. private _scene;
  82683. private _currentPriorityLevel;
  82684. private _targetFrameRate;
  82685. private _trackerDuration;
  82686. private _currentFrameRate;
  82687. private _sceneDisposeObserver;
  82688. private _improvementMode;
  82689. /**
  82690. * Defines an observable called when the optimizer reaches the target frame rate
  82691. */
  82692. onSuccessObservable: Observable<SceneOptimizer>;
  82693. /**
  82694. * Defines an observable called when the optimizer enables an optimization
  82695. */
  82696. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  82697. /**
  82698. * Defines an observable called when the optimizer is not able to reach the target frame rate
  82699. */
  82700. onFailureObservable: Observable<SceneOptimizer>;
  82701. /**
  82702. * Gets a boolean indicating if the optimizer is in improvement mode
  82703. */
  82704. get isInImprovementMode(): boolean;
  82705. /**
  82706. * Gets the current priority level (0 at start)
  82707. */
  82708. get currentPriorityLevel(): number;
  82709. /**
  82710. * Gets the current frame rate checked by the SceneOptimizer
  82711. */
  82712. get currentFrameRate(): number;
  82713. /**
  82714. * Gets or sets the current target frame rate (60 by default)
  82715. */
  82716. get targetFrameRate(): number;
  82717. /**
  82718. * Gets or sets the current target frame rate (60 by default)
  82719. */
  82720. set targetFrameRate(value: number);
  82721. /**
  82722. * Gets or sets the current interval between two checks (every 2000ms by default)
  82723. */
  82724. get trackerDuration(): number;
  82725. /**
  82726. * Gets or sets the current interval between two checks (every 2000ms by default)
  82727. */
  82728. set trackerDuration(value: number);
  82729. /**
  82730. * Gets the list of active optimizations
  82731. */
  82732. get optimizations(): SceneOptimization[];
  82733. /**
  82734. * Creates a new SceneOptimizer
  82735. * @param scene defines the scene to work on
  82736. * @param options defines the options to use with the SceneOptimizer
  82737. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  82738. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  82739. */
  82740. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  82741. /**
  82742. * Stops the current optimizer
  82743. */
  82744. stop(): void;
  82745. /**
  82746. * Reset the optimizer to initial step (current priority level = 0)
  82747. */
  82748. reset(): void;
  82749. /**
  82750. * Start the optimizer. By default it will try to reach a specific framerate
  82751. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  82752. */
  82753. start(): void;
  82754. private _checkCurrentState;
  82755. /**
  82756. * Release all resources
  82757. */
  82758. dispose(): void;
  82759. /**
  82760. * Helper function to create a SceneOptimizer with one single line of code
  82761. * @param scene defines the scene to work on
  82762. * @param options defines the options to use with the SceneOptimizer
  82763. * @param onSuccess defines a callback to call on success
  82764. * @param onFailure defines a callback to call on failure
  82765. * @returns the new SceneOptimizer object
  82766. */
  82767. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  82768. }
  82769. }
  82770. declare module "babylonjs/Misc/sceneSerializer" {
  82771. import { Scene } from "babylonjs/scene";
  82772. /**
  82773. * Class used to serialize a scene into a string
  82774. */
  82775. export class SceneSerializer {
  82776. /**
  82777. * Clear cache used by a previous serialization
  82778. */
  82779. static ClearCache(): void;
  82780. /**
  82781. * Serialize a scene into a JSON compatible object
  82782. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  82783. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  82784. * @param scene defines the scene to serialize
  82785. * @returns a JSON compatible object
  82786. */
  82787. static Serialize(scene: Scene): any;
  82788. private static _Serialize;
  82789. /**
  82790. * Serialize a scene into a JSON compatible object
  82791. * @param scene defines the scene to serialize
  82792. * @returns a JSON promise compatible object
  82793. */
  82794. static SerializeAsync(scene: Scene): Promise<any>;
  82795. private static _CollectPromises;
  82796. /**
  82797. * Serialize a mesh into a JSON compatible object
  82798. * @param toSerialize defines the mesh to serialize
  82799. * @param withParents defines if parents must be serialized as well
  82800. * @param withChildren defines if children must be serialized as well
  82801. * @returns a JSON compatible object
  82802. */
  82803. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  82804. }
  82805. }
  82806. declare module "babylonjs/Misc/videoRecorder" {
  82807. import { Nullable } from "babylonjs/types";
  82808. import { Engine } from "babylonjs/Engines/engine";
  82809. /**
  82810. * This represents the different options available for the video capture.
  82811. */
  82812. export interface VideoRecorderOptions {
  82813. /** Defines the mime type of the video. */
  82814. mimeType: string;
  82815. /** Defines the FPS the video should be recorded at. */
  82816. fps: number;
  82817. /** Defines the chunk size for the recording data. */
  82818. recordChunckSize: number;
  82819. /** The audio tracks to attach to the recording. */
  82820. audioTracks?: MediaStreamTrack[];
  82821. }
  82822. /**
  82823. * This can help with recording videos from BabylonJS.
  82824. * This is based on the available WebRTC functionalities of the browser.
  82825. *
  82826. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  82827. */
  82828. export class VideoRecorder {
  82829. private static readonly _defaultOptions;
  82830. /**
  82831. * Returns whether or not the VideoRecorder is available in your browser.
  82832. * @param engine Defines the Babylon Engine.
  82833. * @returns true if supported otherwise false.
  82834. */
  82835. static IsSupported(engine: Engine): boolean;
  82836. private readonly _options;
  82837. private _canvas;
  82838. private _mediaRecorder;
  82839. private _recordedChunks;
  82840. private _fileName;
  82841. private _resolve;
  82842. private _reject;
  82843. /**
  82844. * True when a recording is already in progress.
  82845. */
  82846. get isRecording(): boolean;
  82847. /**
  82848. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  82849. * @param engine Defines the BabylonJS Engine you wish to record.
  82850. * @param options Defines options that can be used to customize the capture.
  82851. */
  82852. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  82853. /**
  82854. * Stops the current recording before the default capture timeout passed in the startRecording function.
  82855. */
  82856. stopRecording(): void;
  82857. /**
  82858. * Starts recording the canvas for a max duration specified in parameters.
  82859. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  82860. * If null no automatic download will start and you can rely on the promise to get the data back.
  82861. * @param maxDuration Defines the maximum recording time in seconds.
  82862. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  82863. * @return A promise callback at the end of the recording with the video data in Blob.
  82864. */
  82865. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  82866. /**
  82867. * Releases internal resources used during the recording.
  82868. */
  82869. dispose(): void;
  82870. private _handleDataAvailable;
  82871. private _handleError;
  82872. private _handleStop;
  82873. }
  82874. }
  82875. declare module "babylonjs/Misc/screenshotTools" {
  82876. import { Camera } from "babylonjs/Cameras/camera";
  82877. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  82878. import { Engine } from "babylonjs/Engines/engine";
  82879. /**
  82880. * Class containing a set of static utilities functions for screenshots
  82881. */
  82882. export class ScreenshotTools {
  82883. /**
  82884. * Captures a screenshot of the current rendering
  82885. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82886. * @param engine defines the rendering engine
  82887. * @param camera defines the source camera
  82888. * @param size This parameter can be set to a single number or to an object with the
  82889. * following (optional) properties: precision, width, height. If a single number is passed,
  82890. * it will be used for both width and height. If an object is passed, the screenshot size
  82891. * will be derived from the parameters. The precision property is a multiplier allowing
  82892. * rendering at a higher or lower resolution
  82893. * @param successCallback defines the callback receives a single parameter which contains the
  82894. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82895. * src parameter of an <img> to display it
  82896. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82897. * Check your browser for supported MIME types
  82898. * @param forceDownload force the system to download the image even if a successCallback is provided
  82899. */
  82900. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  82901. /**
  82902. * Captures a screenshot of the current rendering
  82903. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82904. * @param engine defines the rendering engine
  82905. * @param camera defines the source camera
  82906. * @param size This parameter can be set to a single number or to an object with the
  82907. * following (optional) properties: precision, width, height. If a single number is passed,
  82908. * it will be used for both width and height. If an object is passed, the screenshot size
  82909. * will be derived from the parameters. The precision property is a multiplier allowing
  82910. * rendering at a higher or lower resolution
  82911. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82912. * Check your browser for supported MIME types
  82913. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82914. * to the src parameter of an <img> to display it
  82915. */
  82916. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  82917. /**
  82918. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  82919. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82920. * @param engine defines the rendering engine
  82921. * @param camera defines the source camera
  82922. * @param width defines the expected width
  82923. * @param height defines the expected height
  82924. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82925. * Check your browser for supported MIME types
  82926. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82927. * to the src parameter of an <img> to display it
  82928. */
  82929. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  82930. /**
  82931. * Generates an image screenshot from the specified camera.
  82932. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82933. * @param engine The engine to use for rendering
  82934. * @param camera The camera to use for rendering
  82935. * @param size This parameter can be set to a single number or to an object with the
  82936. * following (optional) properties: precision, width, height. If a single number is passed,
  82937. * it will be used for both width and height. If an object is passed, the screenshot size
  82938. * will be derived from the parameters. The precision property is a multiplier allowing
  82939. * rendering at a higher or lower resolution
  82940. * @param successCallback The callback receives a single parameter which contains the
  82941. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82942. * src parameter of an <img> to display it
  82943. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82944. * Check your browser for supported MIME types
  82945. * @param samples Texture samples (default: 1)
  82946. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82947. * @param fileName A name for for the downloaded file.
  82948. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82949. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  82950. */
  82951. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  82952. /**
  82953. * Generates an image screenshot from the specified camera.
  82954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82955. * @param engine The engine to use for rendering
  82956. * @param camera The camera to use for rendering
  82957. * @param size This parameter can be set to a single number or to an object with the
  82958. * following (optional) properties: precision, width, height. If a single number is passed,
  82959. * it will be used for both width and height. If an object is passed, the screenshot size
  82960. * will be derived from the parameters. The precision property is a multiplier allowing
  82961. * rendering at a higher or lower resolution
  82962. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82963. * Check your browser for supported MIME types
  82964. * @param samples Texture samples (default: 1)
  82965. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82966. * @param fileName A name for for the downloaded file.
  82967. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82968. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82969. * to the src parameter of an <img> to display it
  82970. */
  82971. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  82972. /**
  82973. * Gets height and width for screenshot size
  82974. * @private
  82975. */
  82976. private static _getScreenshotSize;
  82977. }
  82978. }
  82979. declare module "babylonjs/Misc/dataReader" {
  82980. /**
  82981. * Interface for a data buffer
  82982. */
  82983. export interface IDataBuffer {
  82984. /**
  82985. * Reads bytes from the data buffer.
  82986. * @param byteOffset The byte offset to read
  82987. * @param byteLength The byte length to read
  82988. * @returns A promise that resolves when the bytes are read
  82989. */
  82990. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  82991. /**
  82992. * The byte length of the buffer.
  82993. */
  82994. readonly byteLength: number;
  82995. }
  82996. /**
  82997. * Utility class for reading from a data buffer
  82998. */
  82999. export class DataReader {
  83000. /**
  83001. * The data buffer associated with this data reader.
  83002. */
  83003. readonly buffer: IDataBuffer;
  83004. /**
  83005. * The current byte offset from the beginning of the data buffer.
  83006. */
  83007. byteOffset: number;
  83008. private _dataView;
  83009. private _dataByteOffset;
  83010. /**
  83011. * Constructor
  83012. * @param buffer The buffer to read
  83013. */
  83014. constructor(buffer: IDataBuffer);
  83015. /**
  83016. * Loads the given byte length.
  83017. * @param byteLength The byte length to load
  83018. * @returns A promise that resolves when the load is complete
  83019. */
  83020. loadAsync(byteLength: number): Promise<void>;
  83021. /**
  83022. * Read a unsigned 32-bit integer from the currently loaded data range.
  83023. * @returns The 32-bit integer read
  83024. */
  83025. readUint32(): number;
  83026. /**
  83027. * Read a byte array from the currently loaded data range.
  83028. * @param byteLength The byte length to read
  83029. * @returns The byte array read
  83030. */
  83031. readUint8Array(byteLength: number): Uint8Array;
  83032. /**
  83033. * Read a string from the currently loaded data range.
  83034. * @param byteLength The byte length to read
  83035. * @returns The string read
  83036. */
  83037. readString(byteLength: number): string;
  83038. /**
  83039. * Skips the given byte length the currently loaded data range.
  83040. * @param byteLength The byte length to skip
  83041. */
  83042. skipBytes(byteLength: number): void;
  83043. }
  83044. }
  83045. declare module "babylonjs/Misc/dataStorage" {
  83046. /**
  83047. * Class for storing data to local storage if available or in-memory storage otherwise
  83048. */
  83049. export class DataStorage {
  83050. private static _Storage;
  83051. private static _GetStorage;
  83052. /**
  83053. * Reads a string from the data storage
  83054. * @param key The key to read
  83055. * @param defaultValue The value if the key doesn't exist
  83056. * @returns The string value
  83057. */
  83058. static ReadString(key: string, defaultValue: string): string;
  83059. /**
  83060. * Writes a string to the data storage
  83061. * @param key The key to write
  83062. * @param value The value to write
  83063. */
  83064. static WriteString(key: string, value: string): void;
  83065. /**
  83066. * Reads a boolean from the data storage
  83067. * @param key The key to read
  83068. * @param defaultValue The value if the key doesn't exist
  83069. * @returns The boolean value
  83070. */
  83071. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  83072. /**
  83073. * Writes a boolean to the data storage
  83074. * @param key The key to write
  83075. * @param value The value to write
  83076. */
  83077. static WriteBoolean(key: string, value: boolean): void;
  83078. /**
  83079. * Reads a number from the data storage
  83080. * @param key The key to read
  83081. * @param defaultValue The value if the key doesn't exist
  83082. * @returns The number value
  83083. */
  83084. static ReadNumber(key: string, defaultValue: number): number;
  83085. /**
  83086. * Writes a number to the data storage
  83087. * @param key The key to write
  83088. * @param value The value to write
  83089. */
  83090. static WriteNumber(key: string, value: number): void;
  83091. }
  83092. }
  83093. declare module "babylonjs/Misc/sceneRecorder" {
  83094. import { Scene } from "babylonjs/scene";
  83095. /**
  83096. * Class used to record delta files between 2 scene states
  83097. */
  83098. export class SceneRecorder {
  83099. private _trackedScene;
  83100. private _savedJSON;
  83101. /**
  83102. * Track a given scene. This means the current scene state will be considered the original state
  83103. * @param scene defines the scene to track
  83104. */
  83105. track(scene: Scene): void;
  83106. /**
  83107. * Get the delta between current state and original state
  83108. * @returns a any containing the delta
  83109. */
  83110. getDelta(): any;
  83111. private _compareArray;
  83112. private _compareObjects;
  83113. private _compareCollections;
  83114. private static GetShadowGeneratorById;
  83115. /**
  83116. * Apply a given delta to a given scene
  83117. * @param deltaJSON defines the JSON containing the delta
  83118. * @param scene defines the scene to apply the delta to
  83119. */
  83120. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  83121. private static _ApplyPropertiesToEntity;
  83122. private static _ApplyDeltaForEntity;
  83123. }
  83124. }
  83125. declare module "babylonjs/Misc/trajectoryClassifier" {
  83126. import { DeepImmutable, Nullable } from "babylonjs/types";
  83127. import { Vector3 } from "babylonjs/Maths/math.vector";
  83128. /**
  83129. * A 3D trajectory consisting of an order list of vectors describing a
  83130. * path of motion through 3D space.
  83131. */
  83132. export class Trajectory {
  83133. private _points;
  83134. private readonly _segmentLength;
  83135. /**
  83136. * Serialize to JSON.
  83137. * @returns serialized JSON string
  83138. */
  83139. serialize(): string;
  83140. /**
  83141. * Deserialize from JSON.
  83142. * @param json serialized JSON string
  83143. * @returns deserialized Trajectory
  83144. */
  83145. static Deserialize(json: string): Trajectory;
  83146. /**
  83147. * Create a new empty Trajectory.
  83148. * @param segmentLength radius of discretization for Trajectory points
  83149. */
  83150. constructor(segmentLength?: number);
  83151. /**
  83152. * Get the length of the Trajectory.
  83153. * @returns length of the Trajectory
  83154. */
  83155. getLength(): number;
  83156. /**
  83157. * Append a new point to the Trajectory.
  83158. * NOTE: This implementation has many allocations.
  83159. * @param point point to append to the Trajectory
  83160. */
  83161. add(point: DeepImmutable<Vector3>): void;
  83162. /**
  83163. * Create a new Trajectory with a segment length chosen to make it
  83164. * probable that the new Trajectory will have a specified number of
  83165. * segments. This operation is imprecise.
  83166. * @param targetResolution number of segments desired
  83167. * @returns new Trajectory with approximately the requested number of segments
  83168. */
  83169. resampleAtTargetResolution(targetResolution: number): Trajectory;
  83170. /**
  83171. * Convert Trajectory segments into tokenized representation. This
  83172. * representation is an array of numbers where each nth number is the
  83173. * index of the token which is most similar to the nth segment of the
  83174. * Trajectory.
  83175. * @param tokens list of vectors which serve as discrete tokens
  83176. * @returns list of indices of most similar token per segment
  83177. */
  83178. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  83179. private static _forwardDir;
  83180. private static _inverseFromVec;
  83181. private static _upDir;
  83182. private static _fromToVec;
  83183. private static _lookMatrix;
  83184. /**
  83185. * Transform the rotation (i.e., direction) of a segment to isolate
  83186. * the relative transformation represented by the segment. This operation
  83187. * may or may not succeed due to singularities in the equations that define
  83188. * motion relativity in this context.
  83189. * @param priorVec the origin of the prior segment
  83190. * @param fromVec the origin of the current segment
  83191. * @param toVec the destination of the current segment
  83192. * @param result reference to output variable
  83193. * @returns whether or not transformation was successful
  83194. */
  83195. private static _transformSegmentDirToRef;
  83196. private static _bestMatch;
  83197. private static _score;
  83198. private static _bestScore;
  83199. /**
  83200. * Determine which token vector is most similar to the
  83201. * segment vector.
  83202. * @param segment segment vector
  83203. * @param tokens token vector list
  83204. * @returns index of the most similar token to the segment
  83205. */
  83206. private static _tokenizeSegment;
  83207. }
  83208. /**
  83209. * Class representing a set of known, named trajectories to which Trajectories can be
  83210. * added and using which Trajectories can be recognized.
  83211. */
  83212. export class TrajectoryClassifier {
  83213. private _maximumAllowableMatchCost;
  83214. private _vector3Alphabet;
  83215. private _levenshteinAlphabet;
  83216. private _nameToDescribedTrajectory;
  83217. /**
  83218. * Serialize to JSON.
  83219. * @returns JSON serialization
  83220. */
  83221. serialize(): string;
  83222. /**
  83223. * Deserialize from JSON.
  83224. * @param json JSON serialization
  83225. * @returns deserialized TrajectorySet
  83226. */
  83227. static Deserialize(json: string): TrajectoryClassifier;
  83228. /**
  83229. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  83230. * VERY naive, need to be generating these things from known
  83231. * sets. Better version later, probably eliminating this one.
  83232. * @returns auto-generated TrajectorySet
  83233. */
  83234. static Generate(): TrajectoryClassifier;
  83235. private constructor();
  83236. /**
  83237. * Add a new Trajectory to the set with a given name.
  83238. * @param trajectory new Trajectory to be added
  83239. * @param classification name to which to add the Trajectory
  83240. */
  83241. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  83242. /**
  83243. * Remove a known named trajectory and all Trajectories associated with it.
  83244. * @param classification name to remove
  83245. * @returns whether anything was removed
  83246. */
  83247. deleteClassification(classification: string): boolean;
  83248. /**
  83249. * Attempt to recognize a Trajectory from among all the classifications
  83250. * already known to the classifier.
  83251. * @param trajectory Trajectory to be recognized
  83252. * @returns classification of Trajectory if recognized, null otherwise
  83253. */
  83254. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  83255. }
  83256. }
  83257. declare module "babylonjs/Misc/index" {
  83258. export * from "babylonjs/Misc/andOrNotEvaluator";
  83259. export * from "babylonjs/Misc/assetsManager";
  83260. export * from "babylonjs/Misc/basis";
  83261. export * from "babylonjs/Misc/dds";
  83262. export * from "babylonjs/Misc/decorators";
  83263. export * from "babylonjs/Misc/deferred";
  83264. export * from "babylonjs/Misc/environmentTextureTools";
  83265. export * from "babylonjs/Misc/meshExploder";
  83266. export * from "babylonjs/Misc/filesInput";
  83267. export * from "babylonjs/Misc/HighDynamicRange/index";
  83268. export * from "babylonjs/Misc/khronosTextureContainer";
  83269. export * from "babylonjs/Misc/observable";
  83270. export * from "babylonjs/Misc/performanceMonitor";
  83271. export * from "babylonjs/Misc/promise";
  83272. export * from "babylonjs/Misc/sceneOptimizer";
  83273. export * from "babylonjs/Misc/sceneSerializer";
  83274. export * from "babylonjs/Misc/smartArray";
  83275. export * from "babylonjs/Misc/stringDictionary";
  83276. export * from "babylonjs/Misc/tags";
  83277. export * from "babylonjs/Misc/textureTools";
  83278. export * from "babylonjs/Misc/tga";
  83279. export * from "babylonjs/Misc/tools";
  83280. export * from "babylonjs/Misc/videoRecorder";
  83281. export * from "babylonjs/Misc/virtualJoystick";
  83282. export * from "babylonjs/Misc/workerPool";
  83283. export * from "babylonjs/Misc/logger";
  83284. export * from "babylonjs/Misc/typeStore";
  83285. export * from "babylonjs/Misc/filesInputStore";
  83286. export * from "babylonjs/Misc/deepCopier";
  83287. export * from "babylonjs/Misc/pivotTools";
  83288. export * from "babylonjs/Misc/precisionDate";
  83289. export * from "babylonjs/Misc/screenshotTools";
  83290. export * from "babylonjs/Misc/typeStore";
  83291. export * from "babylonjs/Misc/webRequest";
  83292. export * from "babylonjs/Misc/iInspectable";
  83293. export * from "babylonjs/Misc/brdfTextureTools";
  83294. export * from "babylonjs/Misc/rgbdTextureTools";
  83295. export * from "babylonjs/Misc/gradients";
  83296. export * from "babylonjs/Misc/perfCounter";
  83297. export * from "babylonjs/Misc/fileRequest";
  83298. export * from "babylonjs/Misc/customAnimationFrameRequester";
  83299. export * from "babylonjs/Misc/retryStrategy";
  83300. export * from "babylonjs/Misc/interfaces/screenshotSize";
  83301. export * from "babylonjs/Misc/canvasGenerator";
  83302. export * from "babylonjs/Misc/fileTools";
  83303. export * from "babylonjs/Misc/stringTools";
  83304. export * from "babylonjs/Misc/dataReader";
  83305. export * from "babylonjs/Misc/minMaxReducer";
  83306. export * from "babylonjs/Misc/depthReducer";
  83307. export * from "babylonjs/Misc/dataStorage";
  83308. export * from "babylonjs/Misc/sceneRecorder";
  83309. export * from "babylonjs/Misc/khronosTextureContainer2";
  83310. export * from "babylonjs/Misc/trajectoryClassifier";
  83311. export * from "babylonjs/Misc/timer";
  83312. export * from "babylonjs/Misc/copyTools";
  83313. }
  83314. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  83315. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  83316. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83317. import { Observable } from "babylonjs/Misc/observable";
  83318. import { Matrix } from "babylonjs/Maths/math.vector";
  83319. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83320. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83321. /**
  83322. * An interface for all Hit test features
  83323. */
  83324. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  83325. /**
  83326. * Triggered when new babylon (transformed) hit test results are available
  83327. */
  83328. onHitTestResultObservable: Observable<T[]>;
  83329. }
  83330. /**
  83331. * Options used for hit testing
  83332. */
  83333. export interface IWebXRLegacyHitTestOptions {
  83334. /**
  83335. * Only test when user interacted with the scene. Default - hit test every frame
  83336. */
  83337. testOnPointerDownOnly?: boolean;
  83338. /**
  83339. * The node to use to transform the local results to world coordinates
  83340. */
  83341. worldParentNode?: TransformNode;
  83342. }
  83343. /**
  83344. * Interface defining the babylon result of raycasting/hit-test
  83345. */
  83346. export interface IWebXRLegacyHitResult {
  83347. /**
  83348. * Transformation matrix that can be applied to a node that will put it in the hit point location
  83349. */
  83350. transformationMatrix: Matrix;
  83351. /**
  83352. * The native hit test result
  83353. */
  83354. xrHitResult: XRHitResult | XRHitTestResult;
  83355. }
  83356. /**
  83357. * The currently-working hit-test module.
  83358. * Hit test (or Ray-casting) is used to interact with the real world.
  83359. * For further information read here - https://github.com/immersive-web/hit-test
  83360. */
  83361. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  83362. /**
  83363. * options to use when constructing this feature
  83364. */
  83365. readonly options: IWebXRLegacyHitTestOptions;
  83366. private _direction;
  83367. private _mat;
  83368. private _onSelectEnabled;
  83369. private _origin;
  83370. /**
  83371. * The module's name
  83372. */
  83373. static readonly Name: string;
  83374. /**
  83375. * The (Babylon) version of this module.
  83376. * This is an integer representing the implementation version.
  83377. * This number does not correspond to the WebXR specs version
  83378. */
  83379. static readonly Version: number;
  83380. /**
  83381. * Populated with the last native XR Hit Results
  83382. */
  83383. lastNativeXRHitResults: XRHitResult[];
  83384. /**
  83385. * Triggered when new babylon (transformed) hit test results are available
  83386. */
  83387. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  83388. /**
  83389. * Creates a new instance of the (legacy version) hit test feature
  83390. * @param _xrSessionManager an instance of WebXRSessionManager
  83391. * @param options options to use when constructing this feature
  83392. */
  83393. constructor(_xrSessionManager: WebXRSessionManager,
  83394. /**
  83395. * options to use when constructing this feature
  83396. */
  83397. options?: IWebXRLegacyHitTestOptions);
  83398. /**
  83399. * execute a hit test with an XR Ray
  83400. *
  83401. * @param xrSession a native xrSession that will execute this hit test
  83402. * @param xrRay the ray (position and direction) to use for ray-casting
  83403. * @param referenceSpace native XR reference space to use for the hit-test
  83404. * @param filter filter function that will filter the results
  83405. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83406. */
  83407. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  83408. /**
  83409. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  83410. * @param event the (select) event to use to select with
  83411. * @param referenceSpace the reference space to use for this hit test
  83412. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83413. */
  83414. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  83415. /**
  83416. * attach this feature
  83417. * Will usually be called by the features manager
  83418. *
  83419. * @returns true if successful.
  83420. */
  83421. attach(): boolean;
  83422. /**
  83423. * detach this feature.
  83424. * Will usually be called by the features manager
  83425. *
  83426. * @returns true if successful.
  83427. */
  83428. detach(): boolean;
  83429. /**
  83430. * Dispose this feature and all of the resources attached
  83431. */
  83432. dispose(): void;
  83433. protected _onXRFrame(frame: XRFrame): void;
  83434. private _onHitTestResults;
  83435. private _onSelect;
  83436. }
  83437. }
  83438. declare module "babylonjs/XR/features/WebXRHitTest" {
  83439. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83440. import { Observable } from "babylonjs/Misc/observable";
  83441. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83442. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83443. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  83444. /**
  83445. * Options used for hit testing (version 2)
  83446. */
  83447. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  83448. /**
  83449. * Do not create a permanent hit test. Will usually be used when only
  83450. * transient inputs are needed.
  83451. */
  83452. disablePermanentHitTest?: boolean;
  83453. /**
  83454. * Enable transient (for example touch-based) hit test inspections
  83455. */
  83456. enableTransientHitTest?: boolean;
  83457. /**
  83458. * Offset ray for the permanent hit test
  83459. */
  83460. offsetRay?: Vector3;
  83461. /**
  83462. * Offset ray for the transient hit test
  83463. */
  83464. transientOffsetRay?: Vector3;
  83465. /**
  83466. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  83467. */
  83468. useReferenceSpace?: boolean;
  83469. /**
  83470. * Override the default entity type(s) of the hit-test result
  83471. */
  83472. entityTypes?: XRHitTestTrackableType[];
  83473. }
  83474. /**
  83475. * Interface defining the babylon result of hit-test
  83476. */
  83477. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  83478. /**
  83479. * The input source that generated this hit test (if transient)
  83480. */
  83481. inputSource?: XRInputSource;
  83482. /**
  83483. * Is this a transient hit test
  83484. */
  83485. isTransient?: boolean;
  83486. /**
  83487. * Position of the hit test result
  83488. */
  83489. position: Vector3;
  83490. /**
  83491. * Rotation of the hit test result
  83492. */
  83493. rotationQuaternion: Quaternion;
  83494. /**
  83495. * The native hit test result
  83496. */
  83497. xrHitResult: XRHitTestResult;
  83498. }
  83499. /**
  83500. * The currently-working hit-test module.
  83501. * Hit test (or Ray-casting) is used to interact with the real world.
  83502. * For further information read here - https://github.com/immersive-web/hit-test
  83503. *
  83504. * Tested on chrome (mobile) 80.
  83505. */
  83506. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  83507. /**
  83508. * options to use when constructing this feature
  83509. */
  83510. readonly options: IWebXRHitTestOptions;
  83511. private _tmpMat;
  83512. private _tmpPos;
  83513. private _tmpQuat;
  83514. private _transientXrHitTestSource;
  83515. private _xrHitTestSource;
  83516. private initHitTestSource;
  83517. /**
  83518. * The module's name
  83519. */
  83520. static readonly Name: string;
  83521. /**
  83522. * The (Babylon) version of this module.
  83523. * This is an integer representing the implementation version.
  83524. * This number does not correspond to the WebXR specs version
  83525. */
  83526. static readonly Version: number;
  83527. /**
  83528. * When set to true, each hit test will have its own position/rotation objects
  83529. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  83530. * the developers will clone them or copy them as they see fit.
  83531. */
  83532. autoCloneTransformation: boolean;
  83533. /**
  83534. * Triggered when new babylon (transformed) hit test results are available
  83535. * Note - this will be called when results come back from the device. It can be an empty array!!
  83536. */
  83537. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  83538. /**
  83539. * Use this to temporarily pause hit test checks.
  83540. */
  83541. paused: boolean;
  83542. /**
  83543. * Creates a new instance of the hit test feature
  83544. * @param _xrSessionManager an instance of WebXRSessionManager
  83545. * @param options options to use when constructing this feature
  83546. */
  83547. constructor(_xrSessionManager: WebXRSessionManager,
  83548. /**
  83549. * options to use when constructing this feature
  83550. */
  83551. options?: IWebXRHitTestOptions);
  83552. /**
  83553. * attach this feature
  83554. * Will usually be called by the features manager
  83555. *
  83556. * @returns true if successful.
  83557. */
  83558. attach(): boolean;
  83559. /**
  83560. * detach this feature.
  83561. * Will usually be called by the features manager
  83562. *
  83563. * @returns true if successful.
  83564. */
  83565. detach(): boolean;
  83566. /**
  83567. * Dispose this feature and all of the resources attached
  83568. */
  83569. dispose(): void;
  83570. protected _onXRFrame(frame: XRFrame): void;
  83571. private _processWebXRHitTestResult;
  83572. }
  83573. }
  83574. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  83575. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83576. import { Observable } from "babylonjs/Misc/observable";
  83577. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83579. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83580. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  83581. /**
  83582. * Configuration options of the anchor system
  83583. */
  83584. export interface IWebXRAnchorSystemOptions {
  83585. /**
  83586. * a node that will be used to convert local to world coordinates
  83587. */
  83588. worldParentNode?: TransformNode;
  83589. /**
  83590. * If set to true a reference of the created anchors will be kept until the next session starts
  83591. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  83592. */
  83593. doNotRemoveAnchorsOnSessionEnded?: boolean;
  83594. }
  83595. /**
  83596. * A babylon container for an XR Anchor
  83597. */
  83598. export interface IWebXRAnchor {
  83599. /**
  83600. * A babylon-assigned ID for this anchor
  83601. */
  83602. id: number;
  83603. /**
  83604. * Transformation matrix to apply to an object attached to this anchor
  83605. */
  83606. transformationMatrix: Matrix;
  83607. /**
  83608. * The native anchor object
  83609. */
  83610. xrAnchor: XRAnchor;
  83611. /**
  83612. * if defined, this object will be constantly updated by the anchor's position and rotation
  83613. */
  83614. attachedNode?: TransformNode;
  83615. /**
  83616. * Remove this anchor from the scene
  83617. */
  83618. remove(): void;
  83619. }
  83620. /**
  83621. * An implementation of the anchor system for WebXR.
  83622. * For further information see https://github.com/immersive-web/anchors/
  83623. */
  83624. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  83625. private _options;
  83626. private _lastFrameDetected;
  83627. private _trackedAnchors;
  83628. private _referenceSpaceForFrameAnchors;
  83629. private _futureAnchors;
  83630. /**
  83631. * The module's name
  83632. */
  83633. static readonly Name: string;
  83634. /**
  83635. * The (Babylon) version of this module.
  83636. * This is an integer representing the implementation version.
  83637. * This number does not correspond to the WebXR specs version
  83638. */
  83639. static readonly Version: number;
  83640. /**
  83641. * Observers registered here will be executed when a new anchor was added to the session
  83642. */
  83643. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  83644. /**
  83645. * Observers registered here will be executed when an anchor was removed from the session
  83646. */
  83647. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  83648. /**
  83649. * Observers registered here will be executed when an existing anchor updates
  83650. * This can execute N times every frame
  83651. */
  83652. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  83653. /**
  83654. * Set the reference space to use for anchor creation, when not using a hit test.
  83655. * Will default to the session's reference space if not defined
  83656. */
  83657. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  83658. /**
  83659. * constructs a new anchor system
  83660. * @param _xrSessionManager an instance of WebXRSessionManager
  83661. * @param _options configuration object for this feature
  83662. */
  83663. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  83664. private _tmpVector;
  83665. private _tmpQuaternion;
  83666. private _populateTmpTransformation;
  83667. /**
  83668. * Create a new anchor point using a hit test result at a specific point in the scene
  83669. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83670. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83671. *
  83672. * @param hitTestResult The hit test result to use for this anchor creation
  83673. * @param position an optional position offset for this anchor
  83674. * @param rotationQuaternion an optional rotation offset for this anchor
  83675. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83676. */
  83677. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  83678. /**
  83679. * Add a new anchor at a specific position and rotation
  83680. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  83681. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  83682. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83683. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83684. *
  83685. * @param position the position in which to add an anchor
  83686. * @param rotationQuaternion an optional rotation for the anchor transformation
  83687. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  83688. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83689. */
  83690. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  83691. /**
  83692. * Get the list of anchors currently being tracked by the system
  83693. */
  83694. get anchors(): IWebXRAnchor[];
  83695. /**
  83696. * detach this feature.
  83697. * Will usually be called by the features manager
  83698. *
  83699. * @returns true if successful.
  83700. */
  83701. detach(): boolean;
  83702. /**
  83703. * Dispose this feature and all of the resources attached
  83704. */
  83705. dispose(): void;
  83706. protected _onXRFrame(frame: XRFrame): void;
  83707. /**
  83708. * avoiding using Array.find for global support.
  83709. * @param xrAnchor the plane to find in the array
  83710. */
  83711. private _findIndexInAnchorArray;
  83712. private _updateAnchorWithXRFrame;
  83713. private _createAnchorAtTransformation;
  83714. }
  83715. }
  83716. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  83717. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83718. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83719. import { Observable } from "babylonjs/Misc/observable";
  83720. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  83721. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83722. /**
  83723. * Options used in the plane detector module
  83724. */
  83725. export interface IWebXRPlaneDetectorOptions {
  83726. /**
  83727. * The node to use to transform the local results to world coordinates
  83728. */
  83729. worldParentNode?: TransformNode;
  83730. /**
  83731. * If set to true a reference of the created planes will be kept until the next session starts
  83732. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  83733. */
  83734. doNotRemovePlanesOnSessionEnded?: boolean;
  83735. /**
  83736. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  83737. */
  83738. preferredDetectorOptions?: XRGeometryDetectorOptions;
  83739. }
  83740. /**
  83741. * A babylon interface for a WebXR plane.
  83742. * A Plane is actually a polygon, built from N points in space
  83743. *
  83744. * Supported in chrome 79, not supported in canary 81 ATM
  83745. */
  83746. export interface IWebXRPlane {
  83747. /**
  83748. * a babylon-assigned ID for this polygon
  83749. */
  83750. id: number;
  83751. /**
  83752. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  83753. */
  83754. polygonDefinition: Array<Vector3>;
  83755. /**
  83756. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  83757. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  83758. */
  83759. transformationMatrix: Matrix;
  83760. /**
  83761. * the native xr-plane object
  83762. */
  83763. xrPlane: XRPlane;
  83764. }
  83765. /**
  83766. * The plane detector is used to detect planes in the real world when in AR
  83767. * For more information see https://github.com/immersive-web/real-world-geometry/
  83768. */
  83769. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  83770. private _options;
  83771. private _detectedPlanes;
  83772. private _enabled;
  83773. private _lastFrameDetected;
  83774. /**
  83775. * The module's name
  83776. */
  83777. static readonly Name: string;
  83778. /**
  83779. * The (Babylon) version of this module.
  83780. * This is an integer representing the implementation version.
  83781. * This number does not correspond to the WebXR specs version
  83782. */
  83783. static readonly Version: number;
  83784. /**
  83785. * Observers registered here will be executed when a new plane was added to the session
  83786. */
  83787. onPlaneAddedObservable: Observable<IWebXRPlane>;
  83788. /**
  83789. * Observers registered here will be executed when a plane is no longer detected in the session
  83790. */
  83791. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  83792. /**
  83793. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  83794. * This can execute N times every frame
  83795. */
  83796. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  83797. /**
  83798. * construct a new Plane Detector
  83799. * @param _xrSessionManager an instance of xr Session manager
  83800. * @param _options configuration to use when constructing this feature
  83801. */
  83802. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  83803. /**
  83804. * detach this feature.
  83805. * Will usually be called by the features manager
  83806. *
  83807. * @returns true if successful.
  83808. */
  83809. detach(): boolean;
  83810. /**
  83811. * Dispose this feature and all of the resources attached
  83812. */
  83813. dispose(): void;
  83814. /**
  83815. * Check if the needed objects are defined.
  83816. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  83817. */
  83818. isCompatible(): boolean;
  83819. protected _onXRFrame(frame: XRFrame): void;
  83820. private _init;
  83821. private _updatePlaneWithXRPlane;
  83822. /**
  83823. * avoiding using Array.find for global support.
  83824. * @param xrPlane the plane to find in the array
  83825. */
  83826. private _findIndexInPlaneArray;
  83827. }
  83828. }
  83829. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  83830. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  83832. import { Observable } from "babylonjs/Misc/observable";
  83833. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83834. /**
  83835. * Options interface for the background remover plugin
  83836. */
  83837. export interface IWebXRBackgroundRemoverOptions {
  83838. /**
  83839. * Further background meshes to disable when entering AR
  83840. */
  83841. backgroundMeshes?: AbstractMesh[];
  83842. /**
  83843. * flags to configure the removal of the environment helper.
  83844. * If not set, the entire background will be removed. If set, flags should be set as well.
  83845. */
  83846. environmentHelperRemovalFlags?: {
  83847. /**
  83848. * Should the skybox be removed (default false)
  83849. */
  83850. skyBox?: boolean;
  83851. /**
  83852. * Should the ground be removed (default false)
  83853. */
  83854. ground?: boolean;
  83855. };
  83856. /**
  83857. * don't disable the environment helper
  83858. */
  83859. ignoreEnvironmentHelper?: boolean;
  83860. }
  83861. /**
  83862. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  83863. */
  83864. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  83865. /**
  83866. * read-only options to be used in this module
  83867. */
  83868. readonly options: IWebXRBackgroundRemoverOptions;
  83869. /**
  83870. * The module's name
  83871. */
  83872. static readonly Name: string;
  83873. /**
  83874. * The (Babylon) version of this module.
  83875. * This is an integer representing the implementation version.
  83876. * This number does not correspond to the WebXR specs version
  83877. */
  83878. static readonly Version: number;
  83879. /**
  83880. * registered observers will be triggered when the background state changes
  83881. */
  83882. onBackgroundStateChangedObservable: Observable<boolean>;
  83883. /**
  83884. * constructs a new background remover module
  83885. * @param _xrSessionManager the session manager for this module
  83886. * @param options read-only options to be used in this module
  83887. */
  83888. constructor(_xrSessionManager: WebXRSessionManager,
  83889. /**
  83890. * read-only options to be used in this module
  83891. */
  83892. options?: IWebXRBackgroundRemoverOptions);
  83893. /**
  83894. * attach this feature
  83895. * Will usually be called by the features manager
  83896. *
  83897. * @returns true if successful.
  83898. */
  83899. attach(): boolean;
  83900. /**
  83901. * detach this feature.
  83902. * Will usually be called by the features manager
  83903. *
  83904. * @returns true if successful.
  83905. */
  83906. detach(): boolean;
  83907. /**
  83908. * Dispose this feature and all of the resources attached
  83909. */
  83910. dispose(): void;
  83911. protected _onXRFrame(_xrFrame: XRFrame): void;
  83912. private _setBackgroundState;
  83913. }
  83914. }
  83915. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  83916. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83917. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  83918. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  83919. import { WebXRInput } from "babylonjs/XR/webXRInput";
  83920. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83921. import { Nullable } from "babylonjs/types";
  83922. /**
  83923. * Options for the controller physics feature
  83924. */
  83925. export class IWebXRControllerPhysicsOptions {
  83926. /**
  83927. * Should the headset get its own impostor
  83928. */
  83929. enableHeadsetImpostor?: boolean;
  83930. /**
  83931. * Optional parameters for the headset impostor
  83932. */
  83933. headsetImpostorParams?: {
  83934. /**
  83935. * The type of impostor to create. Default is sphere
  83936. */
  83937. impostorType: number;
  83938. /**
  83939. * the size of the impostor. Defaults to 10cm
  83940. */
  83941. impostorSize?: number | {
  83942. width: number;
  83943. height: number;
  83944. depth: number;
  83945. };
  83946. /**
  83947. * Friction definitions
  83948. */
  83949. friction?: number;
  83950. /**
  83951. * Restitution
  83952. */
  83953. restitution?: number;
  83954. };
  83955. /**
  83956. * The physics properties of the future impostors
  83957. */
  83958. physicsProperties?: {
  83959. /**
  83960. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  83961. * Note that this requires a physics engine that supports mesh impostors!
  83962. */
  83963. useControllerMesh?: boolean;
  83964. /**
  83965. * The type of impostor to create. Default is sphere
  83966. */
  83967. impostorType?: number;
  83968. /**
  83969. * the size of the impostor. Defaults to 10cm
  83970. */
  83971. impostorSize?: number | {
  83972. width: number;
  83973. height: number;
  83974. depth: number;
  83975. };
  83976. /**
  83977. * Friction definitions
  83978. */
  83979. friction?: number;
  83980. /**
  83981. * Restitution
  83982. */
  83983. restitution?: number;
  83984. };
  83985. /**
  83986. * the xr input to use with this pointer selection
  83987. */
  83988. xrInput: WebXRInput;
  83989. }
  83990. /**
  83991. * Add physics impostor to your webxr controllers,
  83992. * including naive calculation of their linear and angular velocity
  83993. */
  83994. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  83995. private readonly _options;
  83996. private _attachController;
  83997. private _controllers;
  83998. private _debugMode;
  83999. private _delta;
  84000. private _headsetImpostor?;
  84001. private _headsetMesh?;
  84002. private _lastTimestamp;
  84003. private _tmpQuaternion;
  84004. private _tmpVector;
  84005. /**
  84006. * The module's name
  84007. */
  84008. static readonly Name: string;
  84009. /**
  84010. * The (Babylon) version of this module.
  84011. * This is an integer representing the implementation version.
  84012. * This number does not correspond to the webxr specs version
  84013. */
  84014. static readonly Version: number;
  84015. /**
  84016. * Construct a new Controller Physics Feature
  84017. * @param _xrSessionManager the corresponding xr session manager
  84018. * @param _options options to create this feature with
  84019. */
  84020. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  84021. /**
  84022. * @hidden
  84023. * enable debugging - will show console outputs and the impostor mesh
  84024. */
  84025. _enablePhysicsDebug(): void;
  84026. /**
  84027. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  84028. * @param xrController the controller to add
  84029. */
  84030. addController(xrController: WebXRInputSource): void;
  84031. /**
  84032. * attach this feature
  84033. * Will usually be called by the features manager
  84034. *
  84035. * @returns true if successful.
  84036. */
  84037. attach(): boolean;
  84038. /**
  84039. * detach this feature.
  84040. * Will usually be called by the features manager
  84041. *
  84042. * @returns true if successful.
  84043. */
  84044. detach(): boolean;
  84045. /**
  84046. * Get the headset impostor, if enabled
  84047. * @returns the impostor
  84048. */
  84049. getHeadsetImpostor(): PhysicsImpostor | undefined;
  84050. /**
  84051. * Get the physics impostor of a specific controller.
  84052. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  84053. * @param controller the controller or the controller id of which to get the impostor
  84054. * @returns the impostor or null
  84055. */
  84056. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  84057. /**
  84058. * Update the physics properties provided in the constructor
  84059. * @param newProperties the new properties object
  84060. */
  84061. setPhysicsProperties(newProperties: {
  84062. impostorType?: number;
  84063. impostorSize?: number | {
  84064. width: number;
  84065. height: number;
  84066. depth: number;
  84067. };
  84068. friction?: number;
  84069. restitution?: number;
  84070. }): void;
  84071. protected _onXRFrame(_xrFrame: any): void;
  84072. private _detachController;
  84073. }
  84074. }
  84075. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  84076. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84077. import { Observable } from "babylonjs/Misc/observable";
  84078. import { Vector3 } from "babylonjs/Maths/math.vector";
  84079. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84080. /**
  84081. * A babylon interface for a "WebXR" feature point.
  84082. * Represents the position and confidence value of a given feature point.
  84083. */
  84084. export interface IWebXRFeaturePoint {
  84085. /**
  84086. * Represents the position of the feature point in world space.
  84087. */
  84088. position: Vector3;
  84089. /**
  84090. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  84091. */
  84092. confidenceValue: number;
  84093. }
  84094. /**
  84095. * The feature point system is used to detect feature points from real world geometry.
  84096. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  84097. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  84098. */
  84099. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  84100. private _enabled;
  84101. private _featurePointCloud;
  84102. /**
  84103. * The module's name
  84104. */
  84105. static readonly Name: string;
  84106. /**
  84107. * The (Babylon) version of this module.
  84108. * This is an integer representing the implementation version.
  84109. * This number does not correspond to the WebXR specs version
  84110. */
  84111. static readonly Version: number;
  84112. /**
  84113. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  84114. * Will notify the observers about which feature points have been added.
  84115. */
  84116. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  84117. /**
  84118. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  84119. * Will notify the observers about which feature points have been updated.
  84120. */
  84121. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  84122. /**
  84123. * The current feature point cloud maintained across frames.
  84124. */
  84125. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  84126. /**
  84127. * construct the feature point system
  84128. * @param _xrSessionManager an instance of xr Session manager
  84129. */
  84130. constructor(_xrSessionManager: WebXRSessionManager);
  84131. /**
  84132. * Detach this feature.
  84133. * Will usually be called by the features manager
  84134. *
  84135. * @returns true if successful.
  84136. */
  84137. detach(): boolean;
  84138. /**
  84139. * Dispose this feature and all of the resources attached
  84140. */
  84141. dispose(): void;
  84142. /**
  84143. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  84144. */
  84145. protected _onXRFrame(frame: XRFrame): void;
  84146. /**
  84147. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  84148. */
  84149. private _init;
  84150. }
  84151. }
  84152. declare module "babylonjs/XR/features/WebXRHandTracking" {
  84153. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84154. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84156. import { Mesh } from "babylonjs/Meshes/mesh";
  84157. import { WebXRInput } from "babylonjs/XR/webXRInput";
  84158. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  84159. import { Nullable } from "babylonjs/types";
  84160. import { IDisposable } from "babylonjs/scene";
  84161. import { Observable } from "babylonjs/Misc/observable";
  84162. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  84163. /**
  84164. * Configuration interface for the hand tracking feature
  84165. */
  84166. export interface IWebXRHandTrackingOptions {
  84167. /**
  84168. * The xrInput that will be used as source for new hands
  84169. */
  84170. xrInput: WebXRInput;
  84171. /**
  84172. * Configuration object for the joint meshes
  84173. */
  84174. jointMeshes?: {
  84175. /**
  84176. * Should the meshes created be invisible (defaults to false)
  84177. */
  84178. invisible?: boolean;
  84179. /**
  84180. * A source mesh to be used to create instances. Defaults to a sphere.
  84181. * This mesh will be the source for all other (25) meshes.
  84182. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  84183. */
  84184. sourceMesh?: Mesh;
  84185. /**
  84186. * This function will be called after a mesh was created for a specific joint.
  84187. * Using this function you can either manipulate the instance or return a new mesh.
  84188. * When returning a new mesh the instance created before will be disposed
  84189. */
  84190. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  84191. /**
  84192. * Should the source mesh stay visible. Defaults to false
  84193. */
  84194. keepOriginalVisible?: boolean;
  84195. /**
  84196. * Scale factor for all instances (defaults to 2)
  84197. */
  84198. scaleFactor?: number;
  84199. /**
  84200. * Should each instance have its own physics impostor
  84201. */
  84202. enablePhysics?: boolean;
  84203. /**
  84204. * If enabled, override default physics properties
  84205. */
  84206. physicsProps?: {
  84207. friction?: number;
  84208. restitution?: number;
  84209. impostorType?: number;
  84210. };
  84211. /**
  84212. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  84213. */
  84214. disableDefaultHandMesh?: boolean;
  84215. /**
  84216. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  84217. */
  84218. handMeshes?: {
  84219. right: AbstractMesh;
  84220. left: AbstractMesh;
  84221. };
  84222. /**
  84223. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  84224. */
  84225. rigMapping?: {
  84226. right: string[];
  84227. left: string[];
  84228. };
  84229. };
  84230. }
  84231. /**
  84232. * Parts of the hands divided to writs and finger names
  84233. */
  84234. export const enum HandPart {
  84235. /**
  84236. * HandPart - Wrist
  84237. */
  84238. WRIST = "wrist",
  84239. /**
  84240. * HandPart - The THumb
  84241. */
  84242. THUMB = "thumb",
  84243. /**
  84244. * HandPart - Index finger
  84245. */
  84246. INDEX = "index",
  84247. /**
  84248. * HandPart - Middle finger
  84249. */
  84250. MIDDLE = "middle",
  84251. /**
  84252. * HandPart - Ring finger
  84253. */
  84254. RING = "ring",
  84255. /**
  84256. * HandPart - Little finger
  84257. */
  84258. LITTLE = "little"
  84259. }
  84260. /**
  84261. * Representing a single hand (with its corresponding native XRHand object)
  84262. */
  84263. export class WebXRHand implements IDisposable {
  84264. /** the controller to which the hand correlates */
  84265. readonly xrController: WebXRInputSource;
  84266. /** the meshes to be used to track the hand joints */
  84267. readonly trackedMeshes: AbstractMesh[];
  84268. private _handMesh?;
  84269. private _rigMapping?;
  84270. private _scene;
  84271. private _defaultHandMesh;
  84272. private _transformNodeMapping;
  84273. /**
  84274. * Hand-parts definition (key is HandPart)
  84275. */
  84276. handPartsDefinition: {
  84277. [key: string]: number[];
  84278. };
  84279. /**
  84280. * Observers will be triggered when the mesh for this hand was initialized.
  84281. */
  84282. onHandMeshReadyObservable: Observable<WebXRHand>;
  84283. /**
  84284. * Populate the HandPartsDefinition object.
  84285. * This is called as a side effect since certain browsers don't have XRHand defined.
  84286. */
  84287. private generateHandPartsDefinition;
  84288. /**
  84289. * Construct a new hand object
  84290. * @param xrController the controller to which the hand correlates
  84291. * @param trackedMeshes the meshes to be used to track the hand joints
  84292. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  84293. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  84294. * @param disableDefaultHandMesh should the default mesh creation be disabled
  84295. */
  84296. constructor(
  84297. /** the controller to which the hand correlates */
  84298. xrController: WebXRInputSource,
  84299. /** the meshes to be used to track the hand joints */
  84300. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  84301. /**
  84302. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  84303. */
  84304. get handMesh(): AbstractMesh | undefined;
  84305. /**
  84306. * Update this hand from the latest xr frame
  84307. * @param xrFrame xrFrame to update from
  84308. * @param referenceSpace The current viewer reference space
  84309. * @param scaleFactor optional scale factor for the meshes
  84310. */
  84311. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  84312. /**
  84313. * Get meshes of part of the hand
  84314. * @param part the part of hand to get
  84315. * @returns An array of meshes that correlate to the hand part requested
  84316. */
  84317. getHandPartMeshes(part: HandPart): AbstractMesh[];
  84318. /**
  84319. * Dispose this Hand object
  84320. */
  84321. dispose(): void;
  84322. private _generateDefaultHandMesh;
  84323. }
  84324. /**
  84325. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  84326. */
  84327. export class WebXRHandTracking extends WebXRAbstractFeature {
  84328. /**
  84329. * options to use when constructing this feature
  84330. */
  84331. readonly options: IWebXRHandTrackingOptions;
  84332. private static _idCounter;
  84333. /**
  84334. * The module's name
  84335. */
  84336. static readonly Name: string;
  84337. /**
  84338. * The (Babylon) version of this module.
  84339. * This is an integer representing the implementation version.
  84340. * This number does not correspond to the WebXR specs version
  84341. */
  84342. static readonly Version: number;
  84343. /**
  84344. * This observable will notify registered observers when a new hand object was added and initialized
  84345. */
  84346. onHandAddedObservable: Observable<WebXRHand>;
  84347. /**
  84348. * This observable will notify its observers right before the hand object is disposed
  84349. */
  84350. onHandRemovedObservable: Observable<WebXRHand>;
  84351. private _hands;
  84352. /**
  84353. * Creates a new instance of the hit test feature
  84354. * @param _xrSessionManager an instance of WebXRSessionManager
  84355. * @param options options to use when constructing this feature
  84356. */
  84357. constructor(_xrSessionManager: WebXRSessionManager,
  84358. /**
  84359. * options to use when constructing this feature
  84360. */
  84361. options: IWebXRHandTrackingOptions);
  84362. /**
  84363. * Check if the needed objects are defined.
  84364. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  84365. */
  84366. isCompatible(): boolean;
  84367. /**
  84368. * attach this feature
  84369. * Will usually be called by the features manager
  84370. *
  84371. * @returns true if successful.
  84372. */
  84373. attach(): boolean;
  84374. /**
  84375. * detach this feature.
  84376. * Will usually be called by the features manager
  84377. *
  84378. * @returns true if successful.
  84379. */
  84380. detach(): boolean;
  84381. /**
  84382. * Dispose this feature and all of the resources attached
  84383. */
  84384. dispose(): void;
  84385. /**
  84386. * Get the hand object according to the controller id
  84387. * @param controllerId the controller id to which we want to get the hand
  84388. * @returns null if not found or the WebXRHand object if found
  84389. */
  84390. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  84391. /**
  84392. * Get a hand object according to the requested handedness
  84393. * @param handedness the handedness to request
  84394. * @returns null if not found or the WebXRHand object if found
  84395. */
  84396. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  84397. protected _onXRFrame(_xrFrame: XRFrame): void;
  84398. private _attachHand;
  84399. private _detachHand;
  84400. }
  84401. }
  84402. declare module "babylonjs/XR/features/WebXRMeshDetector" {
  84403. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84404. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  84406. import { Matrix } from "babylonjs/Maths/math";
  84407. import { Observable } from "babylonjs/Misc/observable";
  84408. /**
  84409. * Options used in the mesh detector module
  84410. */
  84411. export interface IWebXRMeshDetectorOptions {
  84412. /**
  84413. * The node to use to transform the local results to world coordinates
  84414. */
  84415. worldParentNode?: TransformNode;
  84416. /**
  84417. * If set to true a reference of the created meshes will be kept until the next session starts
  84418. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  84419. */
  84420. doNotRemoveMeshesOnSessionEnded?: boolean;
  84421. /**
  84422. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  84423. */
  84424. preferredDetectorOptions?: XRGeometryDetectorOptions;
  84425. /**
  84426. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  84427. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  84428. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  84429. */
  84430. convertCoordinateSystems?: boolean;
  84431. }
  84432. /**
  84433. * A babylon interface for a XR mesh's vertex data.
  84434. *
  84435. * Currently not supported by WebXR, available only with BabylonNative
  84436. */
  84437. export interface IWebXRVertexData {
  84438. /**
  84439. * A babylon-assigned ID for this mesh
  84440. */
  84441. id: number;
  84442. /**
  84443. * Data required for constructing a mesh in Babylon.js.
  84444. */
  84445. xrMesh: XRMesh;
  84446. /**
  84447. * The node to use to transform the local results to world coordinates.
  84448. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  84449. */
  84450. worldParentNode?: TransformNode;
  84451. /**
  84452. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  84453. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84454. */
  84455. positions?: Float32Array;
  84456. /**
  84457. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  84458. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84459. */
  84460. indices?: Uint32Array;
  84461. /**
  84462. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  84463. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  84464. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  84465. */
  84466. normals?: Float32Array;
  84467. /**
  84468. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  84469. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  84470. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84471. */
  84472. transformationMatrix?: Matrix;
  84473. }
  84474. /**
  84475. * The mesh detector is used to detect meshes in the real world when in AR
  84476. */
  84477. export class WebXRMeshDetector extends WebXRAbstractFeature {
  84478. private _options;
  84479. private _detectedMeshes;
  84480. /**
  84481. * The module's name
  84482. */
  84483. static readonly Name: string;
  84484. /**
  84485. * The (Babylon) version of this module.
  84486. * This is an integer representing the implementation version.
  84487. * This number does not correspond to the WebXR specs version
  84488. */
  84489. static readonly Version: number;
  84490. /**
  84491. * Observers registered here will be executed when a new mesh was added to the session
  84492. */
  84493. onMeshAddedObservable: Observable<IWebXRVertexData>;
  84494. /**
  84495. * Observers registered here will be executed when a mesh is no longer detected in the session
  84496. */
  84497. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  84498. /**
  84499. * Observers registered here will be executed when an existing mesh updates
  84500. */
  84501. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  84502. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  84503. detach(): boolean;
  84504. dispose(): void;
  84505. protected _onXRFrame(frame: XRFrame): void;
  84506. private _init;
  84507. private _updateVertexDataWithXRMesh;
  84508. }
  84509. }
  84510. declare module "babylonjs/XR/features/WebXRImageTracking" {
  84511. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84512. import { Observable } from "babylonjs/Misc/observable";
  84513. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84514. import { Matrix } from "babylonjs/Maths/math.vector";
  84515. import { Nullable } from "babylonjs/types";
  84516. /**
  84517. * Options interface for the background remover plugin
  84518. */
  84519. export interface IWebXRImageTrackingOptions {
  84520. /**
  84521. * A required array with images to track
  84522. */
  84523. images: {
  84524. /**
  84525. * The source of the image. can be a URL or an image bitmap
  84526. */
  84527. src: string | ImageBitmap;
  84528. /**
  84529. * The estimated width in the real world (in meters)
  84530. */
  84531. estimatedRealWorldWidth: number;
  84532. }[];
  84533. }
  84534. /**
  84535. * An object representing an image tracked by the system
  84536. */
  84537. export interface IWebXRTrackedImage {
  84538. /**
  84539. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  84540. */
  84541. id: number;
  84542. /**
  84543. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  84544. */
  84545. emulated?: boolean;
  84546. /**
  84547. * Just in case it is needed - the image bitmap that is being tracked
  84548. */
  84549. originalBitmap: ImageBitmap;
  84550. /**
  84551. * The native XR result image tracking result, untouched
  84552. */
  84553. xrTrackingResult?: XRImageTrackingResult;
  84554. /**
  84555. * Width in real world (meters)
  84556. */
  84557. realWorldWidth?: number;
  84558. /**
  84559. * A transformation matrix of this current image in the current reference space.
  84560. */
  84561. transformationMatrix: Matrix;
  84562. /**
  84563. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  84564. */
  84565. ratio?: number;
  84566. }
  84567. /**
  84568. * Image tracking for immersive AR sessions.
  84569. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  84570. */
  84571. export class WebXRImageTracking extends WebXRAbstractFeature {
  84572. /**
  84573. * read-only options to be used in this module
  84574. */
  84575. readonly options: IWebXRImageTrackingOptions;
  84576. /**
  84577. * The module's name
  84578. */
  84579. static readonly Name: string;
  84580. /**
  84581. * The (Babylon) version of this module.
  84582. * This is an integer representing the implementation version.
  84583. * This number does not correspond to the WebXR specs version
  84584. */
  84585. static readonly Version: number;
  84586. /**
  84587. * This will be triggered if the underlying system deems an image untrackable.
  84588. * The index is the index of the image from the array used to initialize the feature.
  84589. */
  84590. onUntrackableImageFoundObservable: Observable<number>;
  84591. /**
  84592. * An image was deemed trackable, and the system will start tracking it.
  84593. */
  84594. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  84595. /**
  84596. * The image was found and its state was updated.
  84597. */
  84598. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  84599. private _trackedImages;
  84600. private _originalTrackingRequest;
  84601. /**
  84602. * constructs the image tracking feature
  84603. * @param _xrSessionManager the session manager for this module
  84604. * @param options read-only options to be used in this module
  84605. */
  84606. constructor(_xrSessionManager: WebXRSessionManager,
  84607. /**
  84608. * read-only options to be used in this module
  84609. */
  84610. options: IWebXRImageTrackingOptions);
  84611. /**
  84612. * attach this feature
  84613. * Will usually be called by the features manager
  84614. *
  84615. * @returns true if successful.
  84616. */
  84617. attach(): boolean;
  84618. /**
  84619. * detach this feature.
  84620. * Will usually be called by the features manager
  84621. *
  84622. * @returns true if successful.
  84623. */
  84624. detach(): boolean;
  84625. /**
  84626. * Check if the needed objects are defined.
  84627. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  84628. */
  84629. isCompatible(): boolean;
  84630. /**
  84631. * Get a tracked image by its ID.
  84632. *
  84633. * @param id the id of the image to load (position in the init array)
  84634. * @returns a trackable image, if exists in this location
  84635. */
  84636. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  84637. /**
  84638. * Dispose this feature and all of the resources attached
  84639. */
  84640. dispose(): void;
  84641. /**
  84642. * Extends the session init object if needed
  84643. * @returns augmentation object fo the xr session init object.
  84644. */
  84645. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  84646. protected _onXRFrame(_xrFrame: XRFrame): void;
  84647. private _init;
  84648. }
  84649. }
  84650. declare module "babylonjs/XR/features/index" {
  84651. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  84652. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  84653. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  84654. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  84655. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  84656. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  84657. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  84658. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  84659. export * from "babylonjs/XR/features/WebXRHitTest";
  84660. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  84661. export * from "babylonjs/XR/features/WebXRHandTracking";
  84662. export * from "babylonjs/XR/features/WebXRMeshDetector";
  84663. export * from "babylonjs/XR/features/WebXRImageTracking";
  84664. }
  84665. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  84666. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84668. import { Scene } from "babylonjs/scene";
  84669. /**
  84670. * The motion controller class for all microsoft mixed reality controllers
  84671. */
  84672. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  84673. protected readonly _mapping: {
  84674. defaultButton: {
  84675. valueNodeName: string;
  84676. unpressedNodeName: string;
  84677. pressedNodeName: string;
  84678. };
  84679. defaultAxis: {
  84680. valueNodeName: string;
  84681. minNodeName: string;
  84682. maxNodeName: string;
  84683. };
  84684. buttons: {
  84685. "xr-standard-trigger": {
  84686. rootNodeName: string;
  84687. componentProperty: string;
  84688. states: string[];
  84689. };
  84690. "xr-standard-squeeze": {
  84691. rootNodeName: string;
  84692. componentProperty: string;
  84693. states: string[];
  84694. };
  84695. "xr-standard-touchpad": {
  84696. rootNodeName: string;
  84697. labelAnchorNodeName: string;
  84698. touchPointNodeName: string;
  84699. };
  84700. "xr-standard-thumbstick": {
  84701. rootNodeName: string;
  84702. componentProperty: string;
  84703. states: string[];
  84704. };
  84705. };
  84706. axes: {
  84707. "xr-standard-touchpad": {
  84708. "x-axis": {
  84709. rootNodeName: string;
  84710. };
  84711. "y-axis": {
  84712. rootNodeName: string;
  84713. };
  84714. };
  84715. "xr-standard-thumbstick": {
  84716. "x-axis": {
  84717. rootNodeName: string;
  84718. };
  84719. "y-axis": {
  84720. rootNodeName: string;
  84721. };
  84722. };
  84723. };
  84724. };
  84725. /**
  84726. * The base url used to load the left and right controller models
  84727. */
  84728. static MODEL_BASE_URL: string;
  84729. /**
  84730. * The name of the left controller model file
  84731. */
  84732. static MODEL_LEFT_FILENAME: string;
  84733. /**
  84734. * The name of the right controller model file
  84735. */
  84736. static MODEL_RIGHT_FILENAME: string;
  84737. profileId: string;
  84738. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84739. protected _getFilenameAndPath(): {
  84740. filename: string;
  84741. path: string;
  84742. };
  84743. protected _getModelLoadingConstraints(): boolean;
  84744. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84745. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84746. protected _updateModel(): void;
  84747. }
  84748. }
  84749. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  84750. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84752. import { Scene } from "babylonjs/scene";
  84753. /**
  84754. * The motion controller class for oculus touch (quest, rift).
  84755. * This class supports legacy mapping as well the standard xr mapping
  84756. */
  84757. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  84758. private _forceLegacyControllers;
  84759. private _modelRootNode;
  84760. /**
  84761. * The base url used to load the left and right controller models
  84762. */
  84763. static MODEL_BASE_URL: string;
  84764. /**
  84765. * The name of the left controller model file
  84766. */
  84767. static MODEL_LEFT_FILENAME: string;
  84768. /**
  84769. * The name of the right controller model file
  84770. */
  84771. static MODEL_RIGHT_FILENAME: string;
  84772. /**
  84773. * Base Url for the Quest controller model.
  84774. */
  84775. static QUEST_MODEL_BASE_URL: string;
  84776. profileId: string;
  84777. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  84778. protected _getFilenameAndPath(): {
  84779. filename: string;
  84780. path: string;
  84781. };
  84782. protected _getModelLoadingConstraints(): boolean;
  84783. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84784. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84785. protected _updateModel(): void;
  84786. /**
  84787. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  84788. * between the touch and touch 2.
  84789. */
  84790. private _isQuest;
  84791. }
  84792. }
  84793. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  84794. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84795. import { Scene } from "babylonjs/scene";
  84796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84797. /**
  84798. * The motion controller class for the standard HTC-Vive controllers
  84799. */
  84800. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  84801. private _modelRootNode;
  84802. /**
  84803. * The base url used to load the left and right controller models
  84804. */
  84805. static MODEL_BASE_URL: string;
  84806. /**
  84807. * File name for the controller model.
  84808. */
  84809. static MODEL_FILENAME: string;
  84810. profileId: string;
  84811. /**
  84812. * Create a new Vive motion controller object
  84813. * @param scene the scene to use to create this controller
  84814. * @param gamepadObject the corresponding gamepad object
  84815. * @param handedness the handedness of the controller
  84816. */
  84817. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84818. protected _getFilenameAndPath(): {
  84819. filename: string;
  84820. path: string;
  84821. };
  84822. protected _getModelLoadingConstraints(): boolean;
  84823. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84824. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84825. protected _updateModel(): void;
  84826. }
  84827. }
  84828. declare module "babylonjs/XR/motionController/index" {
  84829. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84830. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  84831. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  84832. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  84833. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  84834. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  84835. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  84836. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  84837. }
  84838. declare module "babylonjs/XR/index" {
  84839. export * from "babylonjs/XR/webXRCamera";
  84840. export * from "babylonjs/XR/webXREnterExitUI";
  84841. export * from "babylonjs/XR/webXRExperienceHelper";
  84842. export * from "babylonjs/XR/webXRInput";
  84843. export * from "babylonjs/XR/webXRInputSource";
  84844. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  84845. export * from "babylonjs/XR/webXRTypes";
  84846. export * from "babylonjs/XR/webXRSessionManager";
  84847. export * from "babylonjs/XR/webXRDefaultExperience";
  84848. export * from "babylonjs/XR/webXRFeaturesManager";
  84849. export * from "babylonjs/XR/features/index";
  84850. export * from "babylonjs/XR/motionController/index";
  84851. }
  84852. declare module "babylonjs/index" {
  84853. export * from "babylonjs/abstractScene";
  84854. export * from "babylonjs/Actions/index";
  84855. export * from "babylonjs/Animations/index";
  84856. export * from "babylonjs/assetContainer";
  84857. export * from "babylonjs/Audio/index";
  84858. export * from "babylonjs/Behaviors/index";
  84859. export * from "babylonjs/Bones/index";
  84860. export * from "babylonjs/Cameras/index";
  84861. export * from "babylonjs/Collisions/index";
  84862. export * from "babylonjs/Culling/index";
  84863. export * from "babylonjs/Debug/index";
  84864. export * from "babylonjs/DeviceInput/index";
  84865. export * from "babylonjs/Engines/index";
  84866. export * from "babylonjs/Events/index";
  84867. export * from "babylonjs/Gamepads/index";
  84868. export * from "babylonjs/Gizmos/index";
  84869. export * from "babylonjs/Helpers/index";
  84870. export * from "babylonjs/Instrumentation/index";
  84871. export * from "babylonjs/Layers/index";
  84872. export * from "babylonjs/LensFlares/index";
  84873. export * from "babylonjs/Lights/index";
  84874. export * from "babylonjs/Loading/index";
  84875. export * from "babylonjs/Materials/index";
  84876. export * from "babylonjs/Maths/index";
  84877. export * from "babylonjs/Meshes/index";
  84878. export * from "babylonjs/Morph/index";
  84879. export * from "babylonjs/Navigation/index";
  84880. export * from "babylonjs/node";
  84881. export * from "babylonjs/Offline/index";
  84882. export * from "babylonjs/Particles/index";
  84883. export * from "babylonjs/Physics/index";
  84884. export * from "babylonjs/PostProcesses/index";
  84885. export * from "babylonjs/Probes/index";
  84886. export * from "babylonjs/Rendering/index";
  84887. export * from "babylonjs/scene";
  84888. export * from "babylonjs/sceneComponent";
  84889. export * from "babylonjs/Sprites/index";
  84890. export * from "babylonjs/States/index";
  84891. export * from "babylonjs/Misc/index";
  84892. export * from "babylonjs/XR/index";
  84893. export * from "babylonjs/types";
  84894. }
  84895. declare module "babylonjs/Animations/pathCursor" {
  84896. import { Vector3 } from "babylonjs/Maths/math.vector";
  84897. import { Path2 } from "babylonjs/Maths/math.path";
  84898. /**
  84899. * A cursor which tracks a point on a path
  84900. */
  84901. export class PathCursor {
  84902. private path;
  84903. /**
  84904. * Stores path cursor callbacks for when an onchange event is triggered
  84905. */
  84906. private _onchange;
  84907. /**
  84908. * The value of the path cursor
  84909. */
  84910. value: number;
  84911. /**
  84912. * The animation array of the path cursor
  84913. */
  84914. animations: Animation[];
  84915. /**
  84916. * Initializes the path cursor
  84917. * @param path The path to track
  84918. */
  84919. constructor(path: Path2);
  84920. /**
  84921. * Gets the cursor point on the path
  84922. * @returns A point on the path cursor at the cursor location
  84923. */
  84924. getPoint(): Vector3;
  84925. /**
  84926. * Moves the cursor ahead by the step amount
  84927. * @param step The amount to move the cursor forward
  84928. * @returns This path cursor
  84929. */
  84930. moveAhead(step?: number): PathCursor;
  84931. /**
  84932. * Moves the cursor behind by the step amount
  84933. * @param step The amount to move the cursor back
  84934. * @returns This path cursor
  84935. */
  84936. moveBack(step?: number): PathCursor;
  84937. /**
  84938. * Moves the cursor by the step amount
  84939. * If the step amount is greater than one, an exception is thrown
  84940. * @param step The amount to move the cursor
  84941. * @returns This path cursor
  84942. */
  84943. move(step: number): PathCursor;
  84944. /**
  84945. * Ensures that the value is limited between zero and one
  84946. * @returns This path cursor
  84947. */
  84948. private ensureLimits;
  84949. /**
  84950. * Runs onchange callbacks on change (used by the animation engine)
  84951. * @returns This path cursor
  84952. */
  84953. private raiseOnChange;
  84954. /**
  84955. * Executes a function on change
  84956. * @param f A path cursor onchange callback
  84957. * @returns This path cursor
  84958. */
  84959. onchange(f: (cursor: PathCursor) => void): PathCursor;
  84960. }
  84961. }
  84962. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  84963. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  84964. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  84965. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  84966. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  84967. }
  84968. declare module "babylonjs/Engines/Processors/Expressions/index" {
  84969. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  84970. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  84971. }
  84972. declare module "babylonjs/Engines/Processors/index" {
  84973. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  84974. export * from "babylonjs/Engines/Processors/Expressions/index";
  84975. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  84976. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  84977. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  84978. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  84979. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  84980. export * from "babylonjs/Engines/Processors/shaderProcessor";
  84981. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  84982. }
  84983. declare module "babylonjs/Legacy/legacy" {
  84984. import * as Babylon from "babylonjs/index";
  84985. export * from "babylonjs/index";
  84986. }
  84987. declare module "babylonjs/Shaders/blur.fragment" {
  84988. /** @hidden */
  84989. export var blurPixelShader: {
  84990. name: string;
  84991. shader: string;
  84992. };
  84993. }
  84994. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  84995. /** @hidden */
  84996. export var pointCloudVertexDeclaration: {
  84997. name: string;
  84998. shader: string;
  84999. };
  85000. }
  85001. declare module "babylonjs" {
  85002. export * from "babylonjs/Legacy/legacy";
  85003. }
  85004. declare module BABYLON {
  85005. /** Alias type for value that can be null */
  85006. export type Nullable<T> = T | null;
  85007. /**
  85008. * Alias type for number that are floats
  85009. * @ignorenaming
  85010. */
  85011. export type float = number;
  85012. /**
  85013. * Alias type for number that are doubles.
  85014. * @ignorenaming
  85015. */
  85016. export type double = number;
  85017. /**
  85018. * Alias type for number that are integer
  85019. * @ignorenaming
  85020. */
  85021. export type int = number;
  85022. /** Alias type for number array or Float32Array */
  85023. export type FloatArray = number[] | Float32Array;
  85024. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  85025. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  85026. /**
  85027. * Alias for types that can be used by a Buffer or VertexBuffer.
  85028. */
  85029. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  85030. /**
  85031. * Alias type for primitive types
  85032. * @ignorenaming
  85033. */
  85034. type Primitive = undefined | null | boolean | string | number | Function;
  85035. /**
  85036. * Type modifier to make all the properties of an object Readonly
  85037. */
  85038. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  85039. /**
  85040. * Type modifier to make all the properties of an object Readonly recursively
  85041. */
  85042. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  85043. /**
  85044. * Type modifier to make object properties readonly.
  85045. */
  85046. export type DeepImmutableObject<T> = {
  85047. readonly [K in keyof T]: DeepImmutable<T[K]>;
  85048. };
  85049. /** @hidden */
  85050. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  85051. }
  85052. }
  85053. declare module BABYLON {
  85054. /**
  85055. * A class serves as a medium between the observable and its observers
  85056. */
  85057. export class EventState {
  85058. /**
  85059. * Create a new EventState
  85060. * @param mask defines the mask associated with this state
  85061. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  85062. * @param target defines the original target of the state
  85063. * @param currentTarget defines the current target of the state
  85064. */
  85065. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  85066. /**
  85067. * Initialize the current event state
  85068. * @param mask defines the mask associated with this state
  85069. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  85070. * @param target defines the original target of the state
  85071. * @param currentTarget defines the current target of the state
  85072. * @returns the current event state
  85073. */
  85074. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  85075. /**
  85076. * An Observer can set this property to true to prevent subsequent observers of being notified
  85077. */
  85078. skipNextObservers: boolean;
  85079. /**
  85080. * Get the mask value that were used to trigger the event corresponding to this EventState object
  85081. */
  85082. mask: number;
  85083. /**
  85084. * The object that originally notified the event
  85085. */
  85086. target?: any;
  85087. /**
  85088. * The current object in the bubbling phase
  85089. */
  85090. currentTarget?: any;
  85091. /**
  85092. * This will be populated with the return value of the last function that was executed.
  85093. * If it is the first function in the callback chain it will be the event data.
  85094. */
  85095. lastReturnValue?: any;
  85096. /**
  85097. * User defined information that will be sent to observers
  85098. */
  85099. userInfo?: any;
  85100. }
  85101. /**
  85102. * Represent an Observer registered to a given Observable object.
  85103. */
  85104. export class Observer<T> {
  85105. /**
  85106. * Defines the callback to call when the observer is notified
  85107. */
  85108. callback: (eventData: T, eventState: EventState) => void;
  85109. /**
  85110. * Defines the mask of the observer (used to filter notifications)
  85111. */
  85112. mask: number;
  85113. /**
  85114. * Defines the current scope used to restore the JS context
  85115. */
  85116. scope: any;
  85117. /** @hidden */
  85118. _willBeUnregistered: boolean;
  85119. /**
  85120. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  85121. */
  85122. unregisterOnNextCall: boolean;
  85123. /**
  85124. * Creates a new observer
  85125. * @param callback defines the callback to call when the observer is notified
  85126. * @param mask defines the mask of the observer (used to filter notifications)
  85127. * @param scope defines the current scope used to restore the JS context
  85128. */
  85129. constructor(
  85130. /**
  85131. * Defines the callback to call when the observer is notified
  85132. */
  85133. callback: (eventData: T, eventState: EventState) => void,
  85134. /**
  85135. * Defines the mask of the observer (used to filter notifications)
  85136. */
  85137. mask: number,
  85138. /**
  85139. * Defines the current scope used to restore the JS context
  85140. */
  85141. scope?: any);
  85142. }
  85143. /**
  85144. * Represent a list of observers registered to multiple Observables object.
  85145. */
  85146. export class MultiObserver<T> {
  85147. private _observers;
  85148. private _observables;
  85149. /**
  85150. * Release associated resources
  85151. */
  85152. dispose(): void;
  85153. /**
  85154. * Raise a callback when one of the observable will notify
  85155. * @param observables defines a list of observables to watch
  85156. * @param callback defines the callback to call on notification
  85157. * @param mask defines the mask used to filter notifications
  85158. * @param scope defines the current scope used to restore the JS context
  85159. * @returns the new MultiObserver
  85160. */
  85161. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  85162. }
  85163. /**
  85164. * The Observable class is a simple implementation of the Observable pattern.
  85165. *
  85166. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  85167. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  85168. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  85169. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  85170. */
  85171. export class Observable<T> {
  85172. private _observers;
  85173. private _eventState;
  85174. private _onObserverAdded;
  85175. /**
  85176. * Gets the list of observers
  85177. */
  85178. get observers(): Array<Observer<T>>;
  85179. /**
  85180. * Creates a new observable
  85181. * @param onObserverAdded defines a callback to call when a new observer is added
  85182. */
  85183. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  85184. /**
  85185. * Create a new Observer with the specified callback
  85186. * @param callback the callback that will be executed for that Observer
  85187. * @param mask the mask used to filter observers
  85188. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  85189. * @param scope optional scope for the callback to be called from
  85190. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  85191. * @returns the new observer created for the callback
  85192. */
  85193. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  85194. /**
  85195. * Create a new Observer with the specified callback and unregisters after the next notification
  85196. * @param callback the callback that will be executed for that Observer
  85197. * @returns the new observer created for the callback
  85198. */
  85199. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  85200. /**
  85201. * Remove an Observer from the Observable object
  85202. * @param observer the instance of the Observer to remove
  85203. * @returns false if it doesn't belong to this Observable
  85204. */
  85205. remove(observer: Nullable<Observer<T>>): boolean;
  85206. /**
  85207. * Remove a callback from the Observable object
  85208. * @param callback the callback to remove
  85209. * @param scope optional scope. If used only the callbacks with this scope will be removed
  85210. * @returns false if it doesn't belong to this Observable
  85211. */
  85212. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  85213. private _deferUnregister;
  85214. private _remove;
  85215. /**
  85216. * Moves the observable to the top of the observer list making it get called first when notified
  85217. * @param observer the observer to move
  85218. */
  85219. makeObserverTopPriority(observer: Observer<T>): void;
  85220. /**
  85221. * Moves the observable to the bottom of the observer list making it get called last when notified
  85222. * @param observer the observer to move
  85223. */
  85224. makeObserverBottomPriority(observer: Observer<T>): void;
  85225. /**
  85226. * Notify all Observers by calling their respective callback with the given data
  85227. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  85228. * @param eventData defines the data to send to all observers
  85229. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  85230. * @param target defines the original target of the state
  85231. * @param currentTarget defines the current target of the state
  85232. * @param userInfo defines any user info to send to observers
  85233. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  85234. */
  85235. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  85236. /**
  85237. * Calling this will execute each callback, expecting it to be a promise or return a value.
  85238. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  85239. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  85240. * and it is crucial that all callbacks will be executed.
  85241. * The order of the callbacks is kept, callbacks are not executed parallel.
  85242. *
  85243. * @param eventData The data to be sent to each callback
  85244. * @param mask is used to filter observers defaults to -1
  85245. * @param target defines the callback target (see EventState)
  85246. * @param currentTarget defines he current object in the bubbling phase
  85247. * @param userInfo defines any user info to send to observers
  85248. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  85249. */
  85250. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  85251. /**
  85252. * Notify a specific observer
  85253. * @param observer defines the observer to notify
  85254. * @param eventData defines the data to be sent to each callback
  85255. * @param mask is used to filter observers defaults to -1
  85256. */
  85257. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  85258. /**
  85259. * Gets a boolean indicating if the observable has at least one observer
  85260. * @returns true is the Observable has at least one Observer registered
  85261. */
  85262. hasObservers(): boolean;
  85263. /**
  85264. * Clear the list of observers
  85265. */
  85266. clear(): void;
  85267. /**
  85268. * Clone the current observable
  85269. * @returns a new observable
  85270. */
  85271. clone(): Observable<T>;
  85272. /**
  85273. * Does this observable handles observer registered with a given mask
  85274. * @param mask defines the mask to be tested
  85275. * @return whether or not one observer registered with the given mask is handeled
  85276. **/
  85277. hasSpecificMask(mask?: number): boolean;
  85278. }
  85279. }
  85280. declare module BABYLON {
  85281. /**
  85282. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  85283. * Babylon.js
  85284. */
  85285. export class DomManagement {
  85286. /**
  85287. * Checks if the window object exists
  85288. * @returns true if the window object exists
  85289. */
  85290. static IsWindowObjectExist(): boolean;
  85291. /**
  85292. * Checks if the navigator object exists
  85293. * @returns true if the navigator object exists
  85294. */
  85295. static IsNavigatorAvailable(): boolean;
  85296. /**
  85297. * Check if the document object exists
  85298. * @returns true if the document object exists
  85299. */
  85300. static IsDocumentAvailable(): boolean;
  85301. /**
  85302. * Extracts text content from a DOM element hierarchy
  85303. * @param element defines the root element
  85304. * @returns a string
  85305. */
  85306. static GetDOMTextContent(element: HTMLElement): string;
  85307. }
  85308. }
  85309. declare module BABYLON {
  85310. /**
  85311. * Logger used througouht the application to allow configuration of
  85312. * the log level required for the messages.
  85313. */
  85314. export class Logger {
  85315. /**
  85316. * No log
  85317. */
  85318. static readonly NoneLogLevel: number;
  85319. /**
  85320. * Only message logs
  85321. */
  85322. static readonly MessageLogLevel: number;
  85323. /**
  85324. * Only warning logs
  85325. */
  85326. static readonly WarningLogLevel: number;
  85327. /**
  85328. * Only error logs
  85329. */
  85330. static readonly ErrorLogLevel: number;
  85331. /**
  85332. * All logs
  85333. */
  85334. static readonly AllLogLevel: number;
  85335. /**
  85336. * Message to display when a message has been logged too many times
  85337. */
  85338. static MessageLimitReached: string;
  85339. private static _LogCache;
  85340. private static _LogLimitOutputs;
  85341. /**
  85342. * Gets a value indicating the number of loading errors
  85343. * @ignorenaming
  85344. */
  85345. static errorsCount: number;
  85346. /**
  85347. * Callback called when a new log is added
  85348. */
  85349. static OnNewCacheEntry: (entry: string) => void;
  85350. private static _CheckLimit;
  85351. private static _GenerateLimitMessage;
  85352. private static _AddLogEntry;
  85353. private static _FormatMessage;
  85354. private static _LogDisabled;
  85355. private static _LogEnabled;
  85356. private static _WarnDisabled;
  85357. private static _WarnEnabled;
  85358. private static _ErrorDisabled;
  85359. private static _ErrorEnabled;
  85360. /**
  85361. * Log a message to the console
  85362. */
  85363. static Log: (message: string, limit?: number) => void;
  85364. /**
  85365. * Write a warning message to the console
  85366. */
  85367. static Warn: (message: string, limit?: number) => void;
  85368. /**
  85369. * Write an error message to the console
  85370. */
  85371. static Error: (message: string, limit?: number) => void;
  85372. /**
  85373. * Gets current log cache (list of logs)
  85374. */
  85375. static get LogCache(): string;
  85376. /**
  85377. * Clears the log cache
  85378. */
  85379. static ClearLogCache(): void;
  85380. /**
  85381. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  85382. */
  85383. static set LogLevels(level: number);
  85384. }
  85385. }
  85386. declare module BABYLON {
  85387. /** @hidden */
  85388. export class _TypeStore {
  85389. /** @hidden */
  85390. static RegisteredTypes: {
  85391. [key: string]: Object;
  85392. };
  85393. /** @hidden */
  85394. static GetClass(fqdn: string): any;
  85395. }
  85396. }
  85397. declare module BABYLON {
  85398. /**
  85399. * Helper to manipulate strings
  85400. */
  85401. export class StringTools {
  85402. /**
  85403. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  85404. * @param str Source string
  85405. * @param suffix Suffix to search for in the source string
  85406. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  85407. */
  85408. static EndsWith(str: string, suffix: string): boolean;
  85409. /**
  85410. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  85411. * @param str Source string
  85412. * @param suffix Suffix to search for in the source string
  85413. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  85414. */
  85415. static StartsWith(str: string, suffix: string): boolean;
  85416. /**
  85417. * Decodes a buffer into a string
  85418. * @param buffer The buffer to decode
  85419. * @returns The decoded string
  85420. */
  85421. static Decode(buffer: Uint8Array | Uint16Array): string;
  85422. /**
  85423. * Encode a buffer to a base64 string
  85424. * @param buffer defines the buffer to encode
  85425. * @returns the encoded string
  85426. */
  85427. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  85428. /**
  85429. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  85430. * @param num the number to convert and pad
  85431. * @param length the expected length of the string
  85432. * @returns the padded string
  85433. */
  85434. static PadNumber(num: number, length: number): string;
  85435. }
  85436. }
  85437. declare module BABYLON {
  85438. /**
  85439. * Class containing a set of static utilities functions for deep copy.
  85440. */
  85441. export class DeepCopier {
  85442. /**
  85443. * Tries to copy an object by duplicating every property
  85444. * @param source defines the source object
  85445. * @param destination defines the target object
  85446. * @param doNotCopyList defines a list of properties to avoid
  85447. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  85448. */
  85449. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  85450. }
  85451. }
  85452. declare module BABYLON {
  85453. /**
  85454. * Class containing a set of static utilities functions for precision date
  85455. */
  85456. export class PrecisionDate {
  85457. /**
  85458. * Gets either window.performance.now() if supported or Date.now() else
  85459. */
  85460. static get Now(): number;
  85461. }
  85462. }
  85463. declare module BABYLON {
  85464. /** @hidden */
  85465. export class _DevTools {
  85466. static WarnImport(name: string): string;
  85467. }
  85468. }
  85469. declare module BABYLON {
  85470. /**
  85471. * Interface used to define the mechanism to get data from the network
  85472. */
  85473. export interface IWebRequest {
  85474. /**
  85475. * Returns client's response url
  85476. */
  85477. responseURL: string;
  85478. /**
  85479. * Returns client's status
  85480. */
  85481. status: number;
  85482. /**
  85483. * Returns client's status as a text
  85484. */
  85485. statusText: string;
  85486. }
  85487. }
  85488. declare module BABYLON {
  85489. /**
  85490. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  85491. */
  85492. export class WebRequest implements IWebRequest {
  85493. private readonly _xhr;
  85494. /**
  85495. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  85496. * i.e. when loading files, where the server/service expects an Authorization header
  85497. */
  85498. static CustomRequestHeaders: {
  85499. [key: string]: string;
  85500. };
  85501. /**
  85502. * Add callback functions in this array to update all the requests before they get sent to the network
  85503. */
  85504. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  85505. private _injectCustomRequestHeaders;
  85506. /**
  85507. * Gets or sets a function to be called when loading progress changes
  85508. */
  85509. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  85510. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  85511. /**
  85512. * Returns client's state
  85513. */
  85514. get readyState(): number;
  85515. /**
  85516. * Returns client's status
  85517. */
  85518. get status(): number;
  85519. /**
  85520. * Returns client's status as a text
  85521. */
  85522. get statusText(): string;
  85523. /**
  85524. * Returns client's response
  85525. */
  85526. get response(): any;
  85527. /**
  85528. * Returns client's response url
  85529. */
  85530. get responseURL(): string;
  85531. /**
  85532. * Returns client's response as text
  85533. */
  85534. get responseText(): string;
  85535. /**
  85536. * Gets or sets the expected response type
  85537. */
  85538. get responseType(): XMLHttpRequestResponseType;
  85539. set responseType(value: XMLHttpRequestResponseType);
  85540. /** @hidden */
  85541. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  85542. /** @hidden */
  85543. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  85544. /**
  85545. * Cancels any network activity
  85546. */
  85547. abort(): void;
  85548. /**
  85549. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  85550. * @param body defines an optional request body
  85551. */
  85552. send(body?: Document | BodyInit | null): void;
  85553. /**
  85554. * Sets the request method, request URL
  85555. * @param method defines the method to use (GET, POST, etc..)
  85556. * @param url defines the url to connect with
  85557. */
  85558. open(method: string, url: string): void;
  85559. /**
  85560. * Sets the value of a request header.
  85561. * @param name The name of the header whose value is to be set
  85562. * @param value The value to set as the body of the header
  85563. */
  85564. setRequestHeader(name: string, value: string): void;
  85565. /**
  85566. * Get the string containing the text of a particular header's value.
  85567. * @param name The name of the header
  85568. * @returns The string containing the text of the given header name
  85569. */
  85570. getResponseHeader(name: string): Nullable<string>;
  85571. }
  85572. }
  85573. declare module BABYLON {
  85574. /**
  85575. * File request interface
  85576. */
  85577. export interface IFileRequest {
  85578. /**
  85579. * Raised when the request is complete (success or error).
  85580. */
  85581. onCompleteObservable: Observable<IFileRequest>;
  85582. /**
  85583. * Aborts the request for a file.
  85584. */
  85585. abort: () => void;
  85586. }
  85587. }
  85588. declare module BABYLON {
  85589. /**
  85590. * Define options used to create a render target texture
  85591. */
  85592. export class RenderTargetCreationOptions {
  85593. /**
  85594. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  85595. */
  85596. createMipMaps?: boolean;
  85597. /**
  85598. * Specifies if mipmaps must be generated
  85599. */
  85600. generateMipMaps?: boolean;
  85601. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  85602. generateDepthBuffer?: boolean;
  85603. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  85604. generateStencilBuffer?: boolean;
  85605. /** Defines texture type (int by default) */
  85606. type?: number;
  85607. /** Defines sampling mode (trilinear by default) */
  85608. samplingMode?: number;
  85609. /** Defines format (RGBA by default) */
  85610. format?: number;
  85611. /** Defines sample count (1 by default) */
  85612. samples?: number;
  85613. }
  85614. }
  85615. declare module BABYLON {
  85616. /** Defines the cross module used constants to avoid circular dependncies */
  85617. export class Constants {
  85618. /** Defines that alpha blending is disabled */
  85619. static readonly ALPHA_DISABLE: number;
  85620. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  85621. static readonly ALPHA_ADD: number;
  85622. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85623. static readonly ALPHA_COMBINE: number;
  85624. /** Defines that alpha blending is DEST - SRC * DEST */
  85625. static readonly ALPHA_SUBTRACT: number;
  85626. /** Defines that alpha blending is SRC * DEST */
  85627. static readonly ALPHA_MULTIPLY: number;
  85628. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  85629. static readonly ALPHA_MAXIMIZED: number;
  85630. /** Defines that alpha blending is SRC + DEST */
  85631. static readonly ALPHA_ONEONE: number;
  85632. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  85633. static readonly ALPHA_PREMULTIPLIED: number;
  85634. /**
  85635. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  85636. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85637. */
  85638. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85639. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  85640. static readonly ALPHA_INTERPOLATE: number;
  85641. /**
  85642. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  85643. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85644. */
  85645. static readonly ALPHA_SCREENMODE: number;
  85646. /**
  85647. * Defines that alpha blending is SRC + DST
  85648. * Alpha will be set to SRC ALPHA + DST ALPHA
  85649. */
  85650. static readonly ALPHA_ONEONE_ONEONE: number;
  85651. /**
  85652. * Defines that alpha blending is SRC * DST ALPHA + DST
  85653. * Alpha will be set to 0
  85654. */
  85655. static readonly ALPHA_ALPHATOCOLOR: number;
  85656. /**
  85657. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85658. */
  85659. static readonly ALPHA_REVERSEONEMINUS: number;
  85660. /**
  85661. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  85662. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  85663. */
  85664. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  85665. /**
  85666. * Defines that alpha blending is SRC + DST
  85667. * Alpha will be set to SRC ALPHA
  85668. */
  85669. static readonly ALPHA_ONEONE_ONEZERO: number;
  85670. /**
  85671. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85672. * Alpha will be set to DST ALPHA
  85673. */
  85674. static readonly ALPHA_EXCLUSION: number;
  85675. /** Defines that alpha blending equation a SUM */
  85676. static readonly ALPHA_EQUATION_ADD: number;
  85677. /** Defines that alpha blending equation a SUBSTRACTION */
  85678. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  85679. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  85680. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  85681. /** Defines that alpha blending equation a MAX operation */
  85682. static readonly ALPHA_EQUATION_MAX: number;
  85683. /** Defines that alpha blending equation a MIN operation */
  85684. static readonly ALPHA_EQUATION_MIN: number;
  85685. /**
  85686. * Defines that alpha blending equation a DARKEN operation:
  85687. * It takes the min of the src and sums the alpha channels.
  85688. */
  85689. static readonly ALPHA_EQUATION_DARKEN: number;
  85690. /** Defines that the ressource is not delayed*/
  85691. static readonly DELAYLOADSTATE_NONE: number;
  85692. /** Defines that the ressource was successfully delay loaded */
  85693. static readonly DELAYLOADSTATE_LOADED: number;
  85694. /** Defines that the ressource is currently delay loading */
  85695. static readonly DELAYLOADSTATE_LOADING: number;
  85696. /** Defines that the ressource is delayed and has not started loading */
  85697. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85699. static readonly NEVER: number;
  85700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  85701. static readonly ALWAYS: number;
  85702. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85703. static readonly LESS: number;
  85704. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85705. static readonly EQUAL: number;
  85706. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  85707. static readonly LEQUAL: number;
  85708. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85709. static readonly GREATER: number;
  85710. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  85711. static readonly GEQUAL: number;
  85712. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  85713. static readonly NOTEQUAL: number;
  85714. /** Passed to stencilOperation to specify that stencil value must be kept */
  85715. static readonly KEEP: number;
  85716. /** Passed to stencilOperation to specify that stencil value must be zero */
  85717. static readonly ZERO: number;
  85718. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85719. static readonly REPLACE: number;
  85720. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85721. static readonly INCR: number;
  85722. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85723. static readonly DECR: number;
  85724. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85725. static readonly INVERT: number;
  85726. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85727. static readonly INCR_WRAP: number;
  85728. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85729. static readonly DECR_WRAP: number;
  85730. /** Texture is not repeating outside of 0..1 UVs */
  85731. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85732. /** Texture is repeating outside of 0..1 UVs */
  85733. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85734. /** Texture is repeating and mirrored */
  85735. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85736. /** ALPHA */
  85737. static readonly TEXTUREFORMAT_ALPHA: number;
  85738. /** LUMINANCE */
  85739. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85740. /** LUMINANCE_ALPHA */
  85741. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85742. /** RGB */
  85743. static readonly TEXTUREFORMAT_RGB: number;
  85744. /** RGBA */
  85745. static readonly TEXTUREFORMAT_RGBA: number;
  85746. /** RED */
  85747. static readonly TEXTUREFORMAT_RED: number;
  85748. /** RED (2nd reference) */
  85749. static readonly TEXTUREFORMAT_R: number;
  85750. /** RG */
  85751. static readonly TEXTUREFORMAT_RG: number;
  85752. /** RED_INTEGER */
  85753. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85754. /** RED_INTEGER (2nd reference) */
  85755. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85756. /** RG_INTEGER */
  85757. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85758. /** RGB_INTEGER */
  85759. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85760. /** RGBA_INTEGER */
  85761. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85762. /** BGRA */
  85763. static readonly TEXTUREFORMAT_BGRA: number;
  85764. /** Depth 24 bits + Stencil 8 bits */
  85765. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  85766. /** Depth 32 bits float */
  85767. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  85768. /** Compressed BC7 */
  85769. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  85770. /** Compressed BC6 unsigned float */
  85771. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  85772. /** Compressed BC6 signed float */
  85773. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  85774. /** Compressed BC3 */
  85775. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  85776. /** Compressed BC2 */
  85777. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  85778. /** Compressed BC1 */
  85779. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  85780. /** UNSIGNED_BYTE */
  85781. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85782. /** UNSIGNED_BYTE (2nd reference) */
  85783. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85784. /** FLOAT */
  85785. static readonly TEXTURETYPE_FLOAT: number;
  85786. /** HALF_FLOAT */
  85787. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85788. /** BYTE */
  85789. static readonly TEXTURETYPE_BYTE: number;
  85790. /** SHORT */
  85791. static readonly TEXTURETYPE_SHORT: number;
  85792. /** UNSIGNED_SHORT */
  85793. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85794. /** INT */
  85795. static readonly TEXTURETYPE_INT: number;
  85796. /** UNSIGNED_INT */
  85797. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85798. /** UNSIGNED_SHORT_4_4_4_4 */
  85799. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85800. /** UNSIGNED_SHORT_5_5_5_1 */
  85801. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85802. /** UNSIGNED_SHORT_5_6_5 */
  85803. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85804. /** UNSIGNED_INT_2_10_10_10_REV */
  85805. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85806. /** UNSIGNED_INT_24_8 */
  85807. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85808. /** UNSIGNED_INT_10F_11F_11F_REV */
  85809. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85810. /** UNSIGNED_INT_5_9_9_9_REV */
  85811. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85812. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85813. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85814. /** nearest is mag = nearest and min = nearest and no mip */
  85815. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85816. /** mag = nearest and min = nearest and mip = none */
  85817. static readonly TEXTURE_NEAREST_NEAREST: number;
  85818. /** Bilinear is mag = linear and min = linear and no mip */
  85819. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85820. /** mag = linear and min = linear and mip = none */
  85821. static readonly TEXTURE_LINEAR_LINEAR: number;
  85822. /** Trilinear is mag = linear and min = linear and mip = linear */
  85823. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85824. /** Trilinear is mag = linear and min = linear and mip = linear */
  85825. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85826. /** mag = nearest and min = nearest and mip = nearest */
  85827. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85828. /** mag = nearest and min = linear and mip = nearest */
  85829. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85830. /** mag = nearest and min = linear and mip = linear */
  85831. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85832. /** mag = nearest and min = linear and mip = none */
  85833. static readonly TEXTURE_NEAREST_LINEAR: number;
  85834. /** nearest is mag = nearest and min = nearest and mip = linear */
  85835. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85836. /** mag = linear and min = nearest and mip = nearest */
  85837. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85838. /** mag = linear and min = nearest and mip = linear */
  85839. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85840. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85841. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85842. /** mag = linear and min = nearest and mip = none */
  85843. static readonly TEXTURE_LINEAR_NEAREST: number;
  85844. /** Explicit coordinates mode */
  85845. static readonly TEXTURE_EXPLICIT_MODE: number;
  85846. /** Spherical coordinates mode */
  85847. static readonly TEXTURE_SPHERICAL_MODE: number;
  85848. /** Planar coordinates mode */
  85849. static readonly TEXTURE_PLANAR_MODE: number;
  85850. /** Cubic coordinates mode */
  85851. static readonly TEXTURE_CUBIC_MODE: number;
  85852. /** Projection coordinates mode */
  85853. static readonly TEXTURE_PROJECTION_MODE: number;
  85854. /** Skybox coordinates mode */
  85855. static readonly TEXTURE_SKYBOX_MODE: number;
  85856. /** Inverse Cubic coordinates mode */
  85857. static readonly TEXTURE_INVCUBIC_MODE: number;
  85858. /** Equirectangular coordinates mode */
  85859. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85860. /** Equirectangular Fixed coordinates mode */
  85861. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85862. /** Equirectangular Fixed Mirrored coordinates mode */
  85863. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85864. /** Offline (baking) quality for texture filtering */
  85865. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  85866. /** High quality for texture filtering */
  85867. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  85868. /** Medium quality for texture filtering */
  85869. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  85870. /** Low quality for texture filtering */
  85871. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  85872. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85873. static readonly SCALEMODE_FLOOR: number;
  85874. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85875. static readonly SCALEMODE_NEAREST: number;
  85876. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85877. static readonly SCALEMODE_CEILING: number;
  85878. /**
  85879. * The dirty texture flag value
  85880. */
  85881. static readonly MATERIAL_TextureDirtyFlag: number;
  85882. /**
  85883. * The dirty light flag value
  85884. */
  85885. static readonly MATERIAL_LightDirtyFlag: number;
  85886. /**
  85887. * The dirty fresnel flag value
  85888. */
  85889. static readonly MATERIAL_FresnelDirtyFlag: number;
  85890. /**
  85891. * The dirty attribute flag value
  85892. */
  85893. static readonly MATERIAL_AttributesDirtyFlag: number;
  85894. /**
  85895. * The dirty misc flag value
  85896. */
  85897. static readonly MATERIAL_MiscDirtyFlag: number;
  85898. /**
  85899. * The dirty prepass flag value
  85900. */
  85901. static readonly MATERIAL_PrePassDirtyFlag: number;
  85902. /**
  85903. * The all dirty flag value
  85904. */
  85905. static readonly MATERIAL_AllDirtyFlag: number;
  85906. /**
  85907. * Returns the triangle fill mode
  85908. */
  85909. static readonly MATERIAL_TriangleFillMode: number;
  85910. /**
  85911. * Returns the wireframe mode
  85912. */
  85913. static readonly MATERIAL_WireFrameFillMode: number;
  85914. /**
  85915. * Returns the point fill mode
  85916. */
  85917. static readonly MATERIAL_PointFillMode: number;
  85918. /**
  85919. * Returns the point list draw mode
  85920. */
  85921. static readonly MATERIAL_PointListDrawMode: number;
  85922. /**
  85923. * Returns the line list draw mode
  85924. */
  85925. static readonly MATERIAL_LineListDrawMode: number;
  85926. /**
  85927. * Returns the line loop draw mode
  85928. */
  85929. static readonly MATERIAL_LineLoopDrawMode: number;
  85930. /**
  85931. * Returns the line strip draw mode
  85932. */
  85933. static readonly MATERIAL_LineStripDrawMode: number;
  85934. /**
  85935. * Returns the triangle strip draw mode
  85936. */
  85937. static readonly MATERIAL_TriangleStripDrawMode: number;
  85938. /**
  85939. * Returns the triangle fan draw mode
  85940. */
  85941. static readonly MATERIAL_TriangleFanDrawMode: number;
  85942. /**
  85943. * Stores the clock-wise side orientation
  85944. */
  85945. static readonly MATERIAL_ClockWiseSideOrientation: number;
  85946. /**
  85947. * Stores the counter clock-wise side orientation
  85948. */
  85949. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  85950. /**
  85951. * Nothing
  85952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85953. */
  85954. static readonly ACTION_NothingTrigger: number;
  85955. /**
  85956. * On pick
  85957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85958. */
  85959. static readonly ACTION_OnPickTrigger: number;
  85960. /**
  85961. * On left pick
  85962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85963. */
  85964. static readonly ACTION_OnLeftPickTrigger: number;
  85965. /**
  85966. * On right pick
  85967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85968. */
  85969. static readonly ACTION_OnRightPickTrigger: number;
  85970. /**
  85971. * On center pick
  85972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85973. */
  85974. static readonly ACTION_OnCenterPickTrigger: number;
  85975. /**
  85976. * On pick down
  85977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85978. */
  85979. static readonly ACTION_OnPickDownTrigger: number;
  85980. /**
  85981. * On double pick
  85982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85983. */
  85984. static readonly ACTION_OnDoublePickTrigger: number;
  85985. /**
  85986. * On pick up
  85987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85988. */
  85989. static readonly ACTION_OnPickUpTrigger: number;
  85990. /**
  85991. * On pick out.
  85992. * This trigger will only be raised if you also declared a OnPickDown
  85993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85994. */
  85995. static readonly ACTION_OnPickOutTrigger: number;
  85996. /**
  85997. * On long press
  85998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85999. */
  86000. static readonly ACTION_OnLongPressTrigger: number;
  86001. /**
  86002. * On pointer over
  86003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86004. */
  86005. static readonly ACTION_OnPointerOverTrigger: number;
  86006. /**
  86007. * On pointer out
  86008. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86009. */
  86010. static readonly ACTION_OnPointerOutTrigger: number;
  86011. /**
  86012. * On every frame
  86013. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86014. */
  86015. static readonly ACTION_OnEveryFrameTrigger: number;
  86016. /**
  86017. * On intersection enter
  86018. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86019. */
  86020. static readonly ACTION_OnIntersectionEnterTrigger: number;
  86021. /**
  86022. * On intersection exit
  86023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86024. */
  86025. static readonly ACTION_OnIntersectionExitTrigger: number;
  86026. /**
  86027. * On key down
  86028. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86029. */
  86030. static readonly ACTION_OnKeyDownTrigger: number;
  86031. /**
  86032. * On key up
  86033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86034. */
  86035. static readonly ACTION_OnKeyUpTrigger: number;
  86036. /**
  86037. * Billboard mode will only apply to Y axis
  86038. */
  86039. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  86040. /**
  86041. * Billboard mode will apply to all axes
  86042. */
  86043. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  86044. /**
  86045. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86046. */
  86047. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  86048. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86049. * Test order :
  86050. * Is the bounding sphere outside the frustum ?
  86051. * If not, are the bounding box vertices outside the frustum ?
  86052. * It not, then the cullable object is in the frustum.
  86053. */
  86054. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  86055. /** Culling strategy : Bounding Sphere Only.
  86056. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86057. * It's also less accurate than the standard because some not visible objects can still be selected.
  86058. * Test : is the bounding sphere outside the frustum ?
  86059. * If not, then the cullable object is in the frustum.
  86060. */
  86061. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86062. /** Culling strategy : Optimistic Inclusion.
  86063. * This in an inclusion test first, then the standard exclusion test.
  86064. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86065. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  86066. * Anyway, it's as accurate as the standard strategy.
  86067. * Test :
  86068. * Is the cullable object bounding sphere center in the frustum ?
  86069. * If not, apply the default culling strategy.
  86070. */
  86071. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  86072. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  86073. * This in an inclusion test first, then the bounding sphere only exclusion test.
  86074. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  86075. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  86076. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  86077. * Test :
  86078. * Is the cullable object bounding sphere center in the frustum ?
  86079. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  86080. */
  86081. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  86082. /**
  86083. * No logging while loading
  86084. */
  86085. static readonly SCENELOADER_NO_LOGGING: number;
  86086. /**
  86087. * Minimal logging while loading
  86088. */
  86089. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  86090. /**
  86091. * Summary logging while loading
  86092. */
  86093. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  86094. /**
  86095. * Detailled logging while loading
  86096. */
  86097. static readonly SCENELOADER_DETAILED_LOGGING: number;
  86098. /**
  86099. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  86100. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  86101. */
  86102. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  86103. /**
  86104. * Constant used to retrieve the position texture index in the textures array in the prepass
  86105. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  86106. */
  86107. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  86108. /**
  86109. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  86110. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  86111. */
  86112. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  86113. /**
  86114. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  86115. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  86116. */
  86117. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  86118. /**
  86119. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  86120. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  86121. */
  86122. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  86123. /**
  86124. * Constant used to retrieve depth + normal index in the textures array in the prepass
  86125. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  86126. */
  86127. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  86128. /**
  86129. * Constant used to retrieve albedo index in the textures array in the prepass
  86130. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  86131. */
  86132. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  86133. /**
  86134. * Prefixes used by the engine for custom effects
  86135. */
  86136. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  86137. }
  86138. }
  86139. declare module BABYLON {
  86140. /** @hidden */
  86141. export interface HardwareTextureWrapper {
  86142. underlyingResource: any;
  86143. set(hardwareTexture: any): void;
  86144. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  86145. reset(): void;
  86146. release(): void;
  86147. }
  86148. }
  86149. declare module BABYLON {
  86150. /**
  86151. * This represents the required contract to create a new type of texture loader.
  86152. */
  86153. export interface IInternalTextureLoader {
  86154. /**
  86155. * Defines wether the loader supports cascade loading the different faces.
  86156. */
  86157. supportCascades: boolean;
  86158. /**
  86159. * This returns if the loader support the current file information.
  86160. * @param extension defines the file extension of the file being loaded
  86161. * @param mimeType defines the optional mime type of the file being loaded
  86162. * @returns true if the loader can load the specified file
  86163. */
  86164. canLoad(extension: string, mimeType?: string): boolean;
  86165. /**
  86166. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  86167. * @param data contains the texture data
  86168. * @param texture defines the BabylonJS internal texture
  86169. * @param createPolynomials will be true if polynomials have been requested
  86170. * @param onLoad defines the callback to trigger once the texture is ready
  86171. * @param onError defines the callback to trigger in case of error
  86172. * @param options options to be passed to the loader
  86173. */
  86174. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  86175. /**
  86176. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  86177. * @param data contains the texture data
  86178. * @param texture defines the BabylonJS internal texture
  86179. * @param callback defines the method to call once ready to upload
  86180. * @param options options to be passed to the loader
  86181. */
  86182. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  86183. }
  86184. }
  86185. declare module BABYLON {
  86186. /**
  86187. * @hidden
  86188. */
  86189. export interface IColor4Like {
  86190. r: float;
  86191. g: float;
  86192. b: float;
  86193. a: float;
  86194. }
  86195. /**
  86196. * @hidden
  86197. */
  86198. export interface IColor3Like {
  86199. r: float;
  86200. g: float;
  86201. b: float;
  86202. }
  86203. /**
  86204. * @hidden
  86205. */
  86206. export interface IVector4Like {
  86207. x: float;
  86208. y: float;
  86209. z: float;
  86210. w: float;
  86211. }
  86212. /**
  86213. * @hidden
  86214. */
  86215. export interface IVector3Like {
  86216. x: float;
  86217. y: float;
  86218. z: float;
  86219. }
  86220. /**
  86221. * @hidden
  86222. */
  86223. export interface IVector2Like {
  86224. x: float;
  86225. y: float;
  86226. }
  86227. /**
  86228. * @hidden
  86229. */
  86230. export interface IMatrixLike {
  86231. toArray(): DeepImmutable<Float32Array | Array<number>>;
  86232. updateFlag: int;
  86233. }
  86234. /**
  86235. * @hidden
  86236. */
  86237. export interface IViewportLike {
  86238. x: float;
  86239. y: float;
  86240. width: float;
  86241. height: float;
  86242. }
  86243. /**
  86244. * @hidden
  86245. */
  86246. export interface IPlaneLike {
  86247. normal: IVector3Like;
  86248. d: float;
  86249. normalize(): void;
  86250. }
  86251. }
  86252. declare module BABYLON {
  86253. /**
  86254. * Class used to store and describe the pipeline context associated with an effect
  86255. */
  86256. export interface IPipelineContext {
  86257. /**
  86258. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  86259. */
  86260. isAsync: boolean;
  86261. /**
  86262. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  86263. */
  86264. isReady: boolean;
  86265. /** @hidden */
  86266. _name?: string;
  86267. /** @hidden */
  86268. _getVertexShaderCode(): string | null;
  86269. /** @hidden */
  86270. _getFragmentShaderCode(): string | null;
  86271. /** @hidden */
  86272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  86273. /** @hidden */
  86274. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  86275. [key: string]: number;
  86276. }, uniformsNames: string[], uniforms: {
  86277. [key: string]: Nullable<WebGLUniformLocation>;
  86278. }, samplerList: string[], samplers: {
  86279. [key: string]: number;
  86280. }, attributesNames: string[], attributes: number[]): void;
  86281. /** Releases the resources associated with the pipeline. */
  86282. dispose(): void;
  86283. /**
  86284. * Sets an integer value on a uniform variable.
  86285. * @param uniformName Name of the variable.
  86286. * @param value Value to be set.
  86287. */
  86288. setInt(uniformName: string, value: number): void;
  86289. /**
  86290. * Sets an int2 value on a uniform variable.
  86291. * @param uniformName Name of the variable.
  86292. * @param x First int in int2.
  86293. * @param y Second int in int2.
  86294. */
  86295. setInt2(uniformName: string, x: number, y: number): void;
  86296. /**
  86297. * Sets an int3 value on a uniform variable.
  86298. * @param uniformName Name of the variable.
  86299. * @param x First int in int3.
  86300. * @param y Second int in int3.
  86301. * @param z Third int in int3.
  86302. */
  86303. setInt3(uniformName: string, x: number, y: number, z: number): void;
  86304. /**
  86305. * Sets an int4 value on a uniform variable.
  86306. * @param uniformName Name of the variable.
  86307. * @param x First int in int4.
  86308. * @param y Second int in int4.
  86309. * @param z Third int in int4.
  86310. * @param w Fourth int in int4.
  86311. */
  86312. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  86313. /**
  86314. * Sets an int array on a uniform variable.
  86315. * @param uniformName Name of the variable.
  86316. * @param array array to be set.
  86317. */
  86318. setIntArray(uniformName: string, array: Int32Array): void;
  86319. /**
  86320. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  86321. * @param uniformName Name of the variable.
  86322. * @param array array to be set.
  86323. */
  86324. setIntArray2(uniformName: string, array: Int32Array): void;
  86325. /**
  86326. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  86327. * @param uniformName Name of the variable.
  86328. * @param array array to be set.
  86329. */
  86330. setIntArray3(uniformName: string, array: Int32Array): void;
  86331. /**
  86332. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  86333. * @param uniformName Name of the variable.
  86334. * @param array array to be set.
  86335. */
  86336. setIntArray4(uniformName: string, array: Int32Array): void;
  86337. /**
  86338. * Sets an array on a uniform variable.
  86339. * @param uniformName Name of the variable.
  86340. * @param array array to be set.
  86341. */
  86342. setArray(uniformName: string, array: number[] | Float32Array): void;
  86343. /**
  86344. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  86345. * @param uniformName Name of the variable.
  86346. * @param array array to be set.
  86347. */
  86348. setArray2(uniformName: string, array: number[] | Float32Array): void;
  86349. /**
  86350. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  86351. * @param uniformName Name of the variable.
  86352. * @param array array to be set.
  86353. */
  86354. setArray3(uniformName: string, array: number[] | Float32Array): void;
  86355. /**
  86356. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  86357. * @param uniformName Name of the variable.
  86358. * @param array array to be set.
  86359. */
  86360. setArray4(uniformName: string, array: number[] | Float32Array): void;
  86361. /**
  86362. * Sets matrices on a uniform variable.
  86363. * @param uniformName Name of the variable.
  86364. * @param matrices matrices to be set.
  86365. */
  86366. setMatrices(uniformName: string, matrices: Float32Array): void;
  86367. /**
  86368. * Sets matrix on a uniform variable.
  86369. * @param uniformName Name of the variable.
  86370. * @param matrix matrix to be set.
  86371. */
  86372. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  86373. /**
  86374. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  86375. * @param uniformName Name of the variable.
  86376. * @param matrix matrix to be set.
  86377. */
  86378. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  86379. /**
  86380. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86381. * @param uniformName Name of the variable.
  86382. * @param matrix matrix to be set.
  86383. */
  86384. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  86385. /**
  86386. * Sets a float on a uniform variable.
  86387. * @param uniformName Name of the variable.
  86388. * @param value value to be set.
  86389. */
  86390. setFloat(uniformName: string, value: number): void;
  86391. /**
  86392. * Sets a Vector2 on a uniform variable.
  86393. * @param uniformName Name of the variable.
  86394. * @param vector2 vector2 to be set.
  86395. */
  86396. setVector2(uniformName: string, vector2: IVector2Like): void;
  86397. /**
  86398. * Sets a float2 on a uniform variable.
  86399. * @param uniformName Name of the variable.
  86400. * @param x First float in float2.
  86401. * @param y Second float in float2.
  86402. */
  86403. setFloat2(uniformName: string, x: number, y: number): void;
  86404. /**
  86405. * Sets a Vector3 on a uniform variable.
  86406. * @param uniformName Name of the variable.
  86407. * @param vector3 Value to be set.
  86408. */
  86409. setVector3(uniformName: string, vector3: IVector3Like): void;
  86410. /**
  86411. * Sets a float3 on a uniform variable.
  86412. * @param uniformName Name of the variable.
  86413. * @param x First float in float3.
  86414. * @param y Second float in float3.
  86415. * @param z Third float in float3.
  86416. */
  86417. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  86418. /**
  86419. * Sets a Vector4 on a uniform variable.
  86420. * @param uniformName Name of the variable.
  86421. * @param vector4 Value to be set.
  86422. */
  86423. setVector4(uniformName: string, vector4: IVector4Like): void;
  86424. /**
  86425. * Sets a float4 on a uniform variable.
  86426. * @param uniformName Name of the variable.
  86427. * @param x First float in float4.
  86428. * @param y Second float in float4.
  86429. * @param z Third float in float4.
  86430. * @param w Fourth float in float4.
  86431. */
  86432. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  86433. /**
  86434. * Sets a Color3 on a uniform variable.
  86435. * @param uniformName Name of the variable.
  86436. * @param color3 Value to be set.
  86437. */
  86438. setColor3(uniformName: string, color3: IColor3Like): void;
  86439. /**
  86440. * Sets a Color4 on a uniform variable.
  86441. * @param uniformName Name of the variable.
  86442. * @param color3 Value to be set.
  86443. * @param alpha Alpha value to be set.
  86444. */
  86445. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  86446. /**
  86447. * Sets a Color4 on a uniform variable
  86448. * @param uniformName defines the name of the variable
  86449. * @param color4 defines the value to be set
  86450. */
  86451. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  86452. }
  86453. }
  86454. declare module BABYLON {
  86455. /**
  86456. * Class used to store gfx data (like WebGLBuffer)
  86457. */
  86458. export class DataBuffer {
  86459. private static _Counter;
  86460. /**
  86461. * Gets or sets the number of objects referencing this buffer
  86462. */
  86463. references: number;
  86464. /** Gets or sets the size of the underlying buffer */
  86465. capacity: number;
  86466. /**
  86467. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  86468. */
  86469. is32Bits: boolean;
  86470. /**
  86471. * Gets the underlying buffer
  86472. */
  86473. get underlyingResource(): any;
  86474. /**
  86475. * Gets the unique id of this buffer
  86476. */
  86477. readonly uniqueId: number;
  86478. /**
  86479. * Constructs the buffer
  86480. */
  86481. constructor();
  86482. }
  86483. }
  86484. declare module BABYLON {
  86485. /** @hidden */
  86486. export interface IShaderProcessor {
  86487. attributeProcessor?: (attribute: string, preProcessors: {
  86488. [key: string]: string;
  86489. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86490. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  86491. [key: string]: string;
  86492. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86493. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  86494. [key: string]: string;
  86495. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86496. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86497. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86498. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86499. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86500. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  86501. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  86502. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  86503. vertexCode: string;
  86504. fragmentCode: string;
  86505. };
  86506. }
  86507. }
  86508. declare module BABYLON {
  86509. /** @hidden */
  86510. export interface ShaderProcessingContext {
  86511. }
  86512. /** @hidden */
  86513. export interface ProcessingOptions {
  86514. defines: string[];
  86515. indexParameters: any;
  86516. isFragment: boolean;
  86517. shouldUseHighPrecisionShader: boolean;
  86518. supportsUniformBuffers: boolean;
  86519. shadersRepository: string;
  86520. includesShadersStore: {
  86521. [key: string]: string;
  86522. };
  86523. processor: Nullable<IShaderProcessor>;
  86524. version: string;
  86525. platformName: string;
  86526. lookForClosingBracketForUniformBuffer?: boolean;
  86527. processingContext: Nullable<ShaderProcessingContext>;
  86528. }
  86529. }
  86530. declare module BABYLON {
  86531. /** @hidden */
  86532. export class ShaderCodeNode {
  86533. line: string;
  86534. children: ShaderCodeNode[];
  86535. additionalDefineKey?: string;
  86536. additionalDefineValue?: string;
  86537. isValid(preprocessors: {
  86538. [key: string]: string;
  86539. }): boolean;
  86540. process(preprocessors: {
  86541. [key: string]: string;
  86542. }, options: ProcessingOptions): string;
  86543. }
  86544. }
  86545. declare module BABYLON {
  86546. /** @hidden */
  86547. export class ShaderCodeCursor {
  86548. private _lines;
  86549. lineIndex: number;
  86550. get currentLine(): string;
  86551. get canRead(): boolean;
  86552. set lines(value: string[]);
  86553. }
  86554. }
  86555. declare module BABYLON {
  86556. /** @hidden */
  86557. export class ShaderCodeConditionNode extends ShaderCodeNode {
  86558. process(preprocessors: {
  86559. [key: string]: string;
  86560. }, options: ProcessingOptions): string;
  86561. }
  86562. }
  86563. declare module BABYLON {
  86564. /** @hidden */
  86565. export class ShaderDefineExpression {
  86566. isTrue(preprocessors: {
  86567. [key: string]: string;
  86568. }): boolean;
  86569. private static _OperatorPriority;
  86570. private static _Stack;
  86571. static postfixToInfix(postfix: string[]): string;
  86572. static infixToPostfix(infix: string): string[];
  86573. }
  86574. }
  86575. declare module BABYLON {
  86576. /** @hidden */
  86577. export class ShaderCodeTestNode extends ShaderCodeNode {
  86578. testExpression: ShaderDefineExpression;
  86579. isValid(preprocessors: {
  86580. [key: string]: string;
  86581. }): boolean;
  86582. }
  86583. }
  86584. declare module BABYLON {
  86585. /** @hidden */
  86586. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  86587. define: string;
  86588. not: boolean;
  86589. constructor(define: string, not?: boolean);
  86590. isTrue(preprocessors: {
  86591. [key: string]: string;
  86592. }): boolean;
  86593. }
  86594. }
  86595. declare module BABYLON {
  86596. /** @hidden */
  86597. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  86598. leftOperand: ShaderDefineExpression;
  86599. rightOperand: ShaderDefineExpression;
  86600. isTrue(preprocessors: {
  86601. [key: string]: string;
  86602. }): boolean;
  86603. }
  86604. }
  86605. declare module BABYLON {
  86606. /** @hidden */
  86607. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  86608. leftOperand: ShaderDefineExpression;
  86609. rightOperand: ShaderDefineExpression;
  86610. isTrue(preprocessors: {
  86611. [key: string]: string;
  86612. }): boolean;
  86613. }
  86614. }
  86615. declare module BABYLON {
  86616. /** @hidden */
  86617. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  86618. define: string;
  86619. operand: string;
  86620. testValue: string;
  86621. constructor(define: string, operand: string, testValue: string);
  86622. isTrue(preprocessors: {
  86623. [key: string]: string;
  86624. }): boolean;
  86625. }
  86626. }
  86627. declare module BABYLON {
  86628. /**
  86629. * Class used to enable access to offline support
  86630. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  86631. */
  86632. export interface IOfflineProvider {
  86633. /**
  86634. * Gets a boolean indicating if scene must be saved in the database
  86635. */
  86636. enableSceneOffline: boolean;
  86637. /**
  86638. * Gets a boolean indicating if textures must be saved in the database
  86639. */
  86640. enableTexturesOffline: boolean;
  86641. /**
  86642. * Open the offline support and make it available
  86643. * @param successCallback defines the callback to call on success
  86644. * @param errorCallback defines the callback to call on error
  86645. */
  86646. open(successCallback: () => void, errorCallback: () => void): void;
  86647. /**
  86648. * Loads an image from the offline support
  86649. * @param url defines the url to load from
  86650. * @param image defines the target DOM image
  86651. */
  86652. loadImage(url: string, image: HTMLImageElement): void;
  86653. /**
  86654. * Loads a file from offline support
  86655. * @param url defines the URL to load from
  86656. * @param sceneLoaded defines a callback to call on success
  86657. * @param progressCallBack defines a callback to call when progress changed
  86658. * @param errorCallback defines a callback to call on error
  86659. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  86660. */
  86661. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  86662. }
  86663. }
  86664. declare module BABYLON {
  86665. /**
  86666. * Class used to help managing file picking and drag'n'drop
  86667. * File Storage
  86668. */
  86669. export class FilesInputStore {
  86670. /**
  86671. * List of files ready to be loaded
  86672. */
  86673. static FilesToLoad: {
  86674. [key: string]: File;
  86675. };
  86676. }
  86677. }
  86678. declare module BABYLON {
  86679. /**
  86680. * Class used to define a retry strategy when error happens while loading assets
  86681. */
  86682. export class RetryStrategy {
  86683. /**
  86684. * Function used to defines an exponential back off strategy
  86685. * @param maxRetries defines the maximum number of retries (3 by default)
  86686. * @param baseInterval defines the interval between retries
  86687. * @returns the strategy function to use
  86688. */
  86689. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  86690. }
  86691. }
  86692. declare module BABYLON {
  86693. /**
  86694. * @ignore
  86695. * Application error to support additional information when loading a file
  86696. */
  86697. export abstract class BaseError extends Error {
  86698. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  86699. }
  86700. }
  86701. declare module BABYLON {
  86702. /** @ignore */
  86703. export class LoadFileError extends BaseError {
  86704. request?: WebRequest;
  86705. file?: File;
  86706. /**
  86707. * Creates a new LoadFileError
  86708. * @param message defines the message of the error
  86709. * @param request defines the optional web request
  86710. * @param file defines the optional file
  86711. */
  86712. constructor(message: string, object?: WebRequest | File);
  86713. }
  86714. /** @ignore */
  86715. export class RequestFileError extends BaseError {
  86716. request: WebRequest;
  86717. /**
  86718. * Creates a new LoadFileError
  86719. * @param message defines the message of the error
  86720. * @param request defines the optional web request
  86721. */
  86722. constructor(message: string, request: WebRequest);
  86723. }
  86724. /** @ignore */
  86725. export class ReadFileError extends BaseError {
  86726. file: File;
  86727. /**
  86728. * Creates a new ReadFileError
  86729. * @param message defines the message of the error
  86730. * @param file defines the optional file
  86731. */
  86732. constructor(message: string, file: File);
  86733. }
  86734. /**
  86735. * @hidden
  86736. */
  86737. export class FileTools {
  86738. /**
  86739. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86740. */
  86741. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  86742. /**
  86743. * Gets or sets the base URL to use to load assets
  86744. */
  86745. static BaseUrl: string;
  86746. /**
  86747. * Default behaviour for cors in the application.
  86748. * It can be a string if the expected behavior is identical in the entire app.
  86749. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86750. */
  86751. static CorsBehavior: string | ((url: string | string[]) => string);
  86752. /**
  86753. * Gets or sets a function used to pre-process url before using them to load assets
  86754. */
  86755. static PreprocessUrl: (url: string) => string;
  86756. /**
  86757. * Removes unwanted characters from an url
  86758. * @param url defines the url to clean
  86759. * @returns the cleaned url
  86760. */
  86761. private static _CleanUrl;
  86762. /**
  86763. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86764. * @param url define the url we are trying
  86765. * @param element define the dom element where to configure the cors policy
  86766. */
  86767. static SetCorsBehavior(url: string | string[], element: {
  86768. crossOrigin: string | null;
  86769. }): void;
  86770. /**
  86771. * Loads an image as an HTMLImageElement.
  86772. * @param input url string, ArrayBuffer, or Blob to load
  86773. * @param onLoad callback called when the image successfully loads
  86774. * @param onError callback called when the image fails to load
  86775. * @param offlineProvider offline provider for caching
  86776. * @param mimeType optional mime type
  86777. * @returns the HTMLImageElement of the loaded image
  86778. */
  86779. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  86780. /**
  86781. * Reads a file from a File object
  86782. * @param file defines the file to load
  86783. * @param onSuccess defines the callback to call when data is loaded
  86784. * @param onProgress defines the callback to call during loading process
  86785. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86786. * @param onError defines the callback to call when an error occurs
  86787. * @returns a file request object
  86788. */
  86789. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  86790. /**
  86791. * Loads a file from a url
  86792. * @param url url to load
  86793. * @param onSuccess callback called when the file successfully loads
  86794. * @param onProgress callback called while file is loading (if the server supports this mode)
  86795. * @param offlineProvider defines the offline provider for caching
  86796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86797. * @param onError callback called when the file fails to load
  86798. * @returns a file request object
  86799. */
  86800. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  86801. /**
  86802. * Loads a file
  86803. * @param url url to load
  86804. * @param onSuccess callback called when the file successfully loads
  86805. * @param onProgress callback called while file is loading (if the server supports this mode)
  86806. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86807. * @param onError callback called when the file fails to load
  86808. * @param onOpened callback called when the web request is opened
  86809. * @returns a file request object
  86810. */
  86811. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86812. /**
  86813. * Checks if the loaded document was accessed via `file:`-Protocol.
  86814. * @returns boolean
  86815. */
  86816. static IsFileURL(): boolean;
  86817. }
  86818. }
  86819. declare module BABYLON {
  86820. /** @hidden */
  86821. export class ShaderProcessor {
  86822. static Initialize(options: ProcessingOptions): void;
  86823. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  86824. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  86825. vertexCode: string;
  86826. fragmentCode: string;
  86827. };
  86828. private static _ProcessPrecision;
  86829. private static _ExtractOperation;
  86830. private static _BuildSubExpression;
  86831. private static _BuildExpression;
  86832. private static _MoveCursorWithinIf;
  86833. private static _MoveCursor;
  86834. private static _EvaluatePreProcessors;
  86835. private static _PreparePreProcessors;
  86836. private static _ProcessShaderConversion;
  86837. private static _ProcessIncludes;
  86838. /**
  86839. * Loads a file from a url
  86840. * @param url url to load
  86841. * @param onSuccess callback called when the file successfully loads
  86842. * @param onProgress callback called while file is loading (if the server supports this mode)
  86843. * @param offlineProvider defines the offline provider for caching
  86844. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86845. * @param onError callback called when the file fails to load
  86846. * @returns a file request object
  86847. * @hidden
  86848. */
  86849. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  86850. }
  86851. }
  86852. declare module BABYLON {
  86853. /**
  86854. * Interface used to define common properties for effect fallbacks
  86855. */
  86856. export interface IEffectFallbacks {
  86857. /**
  86858. * Removes the defines that should be removed when falling back.
  86859. * @param currentDefines defines the current define statements for the shader.
  86860. * @param effect defines the current effect we try to compile
  86861. * @returns The resulting defines with defines of the current rank removed.
  86862. */
  86863. reduce(currentDefines: string, effect: Effect): string;
  86864. /**
  86865. * Removes the fallback from the bound mesh.
  86866. */
  86867. unBindMesh(): void;
  86868. /**
  86869. * Checks to see if more fallbacks are still availible.
  86870. */
  86871. hasMoreFallbacks: boolean;
  86872. }
  86873. }
  86874. declare module BABYLON {
  86875. /**
  86876. * Interface for the size containing width and height
  86877. */
  86878. export interface ISize {
  86879. /**
  86880. * Width
  86881. */
  86882. width: number;
  86883. /**
  86884. * Heighht
  86885. */
  86886. height: number;
  86887. }
  86888. /**
  86889. * Size containing widht and height
  86890. */
  86891. export class Size implements ISize {
  86892. /**
  86893. * Width
  86894. */
  86895. width: number;
  86896. /**
  86897. * Height
  86898. */
  86899. height: number;
  86900. /**
  86901. * Creates a Size object from the given width and height (floats).
  86902. * @param width width of the new size
  86903. * @param height height of the new size
  86904. */
  86905. constructor(width: number, height: number);
  86906. /**
  86907. * Returns a string with the Size width and height
  86908. * @returns a string with the Size width and height
  86909. */
  86910. toString(): string;
  86911. /**
  86912. * "Size"
  86913. * @returns the string "Size"
  86914. */
  86915. getClassName(): string;
  86916. /**
  86917. * Returns the Size hash code.
  86918. * @returns a hash code for a unique width and height
  86919. */
  86920. getHashCode(): number;
  86921. /**
  86922. * Updates the current size from the given one.
  86923. * @param src the given size
  86924. */
  86925. copyFrom(src: Size): void;
  86926. /**
  86927. * Updates in place the current Size from the given floats.
  86928. * @param width width of the new size
  86929. * @param height height of the new size
  86930. * @returns the updated Size.
  86931. */
  86932. copyFromFloats(width: number, height: number): Size;
  86933. /**
  86934. * Updates in place the current Size from the given floats.
  86935. * @param width width to set
  86936. * @param height height to set
  86937. * @returns the updated Size.
  86938. */
  86939. set(width: number, height: number): Size;
  86940. /**
  86941. * Multiplies the width and height by numbers
  86942. * @param w factor to multiple the width by
  86943. * @param h factor to multiple the height by
  86944. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86945. */
  86946. multiplyByFloats(w: number, h: number): Size;
  86947. /**
  86948. * Clones the size
  86949. * @returns a new Size copied from the given one.
  86950. */
  86951. clone(): Size;
  86952. /**
  86953. * True if the current Size and the given one width and height are strictly equal.
  86954. * @param other the other size to compare against
  86955. * @returns True if the current Size and the given one width and height are strictly equal.
  86956. */
  86957. equals(other: Size): boolean;
  86958. /**
  86959. * The surface of the Size : width * height (float).
  86960. */
  86961. get surface(): number;
  86962. /**
  86963. * Create a new size of zero
  86964. * @returns a new Size set to (0.0, 0.0)
  86965. */
  86966. static Zero(): Size;
  86967. /**
  86968. * Sums the width and height of two sizes
  86969. * @param otherSize size to add to this size
  86970. * @returns a new Size set as the addition result of the current Size and the given one.
  86971. */
  86972. add(otherSize: Size): Size;
  86973. /**
  86974. * Subtracts the width and height of two
  86975. * @param otherSize size to subtract to this size
  86976. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86977. */
  86978. subtract(otherSize: Size): Size;
  86979. /**
  86980. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86981. * @param start starting size to lerp between
  86982. * @param end end size to lerp between
  86983. * @param amount amount to lerp between the start and end values
  86984. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86985. */
  86986. static Lerp(start: Size, end: Size, amount: number): Size;
  86987. }
  86988. }
  86989. declare module BABYLON {
  86990. /**
  86991. * Base class of all the textures in babylon.
  86992. * It groups all the common properties required to work with Thin Engine.
  86993. */
  86994. export class ThinTexture {
  86995. protected _wrapU: number;
  86996. /**
  86997. * | Value | Type | Description |
  86998. * | ----- | ------------------ | ----------- |
  86999. * | 0 | CLAMP_ADDRESSMODE | |
  87000. * | 1 | WRAP_ADDRESSMODE | |
  87001. * | 2 | MIRROR_ADDRESSMODE | |
  87002. */
  87003. get wrapU(): number;
  87004. set wrapU(value: number);
  87005. protected _wrapV: number;
  87006. /**
  87007. * | Value | Type | Description |
  87008. * | ----- | ------------------ | ----------- |
  87009. * | 0 | CLAMP_ADDRESSMODE | |
  87010. * | 1 | WRAP_ADDRESSMODE | |
  87011. * | 2 | MIRROR_ADDRESSMODE | |
  87012. */
  87013. get wrapV(): number;
  87014. set wrapV(value: number);
  87015. /**
  87016. * | Value | Type | Description |
  87017. * | ----- | ------------------ | ----------- |
  87018. * | 0 | CLAMP_ADDRESSMODE | |
  87019. * | 1 | WRAP_ADDRESSMODE | |
  87020. * | 2 | MIRROR_ADDRESSMODE | |
  87021. */
  87022. wrapR: number;
  87023. /**
  87024. * With compliant hardware and browser (supporting anisotropic filtering)
  87025. * this defines the level of anisotropic filtering in the texture.
  87026. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  87027. */
  87028. anisotropicFilteringLevel: number;
  87029. /**
  87030. * Define the current state of the loading sequence when in delayed load mode.
  87031. */
  87032. delayLoadState: number;
  87033. /**
  87034. * How a texture is mapped.
  87035. * Unused in thin texture mode.
  87036. */
  87037. get coordinatesMode(): number;
  87038. /**
  87039. * Define if the texture is a cube texture or if false a 2d texture.
  87040. */
  87041. get isCube(): boolean;
  87042. set isCube(value: boolean);
  87043. /**
  87044. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  87045. */
  87046. get is3D(): boolean;
  87047. set is3D(value: boolean);
  87048. /**
  87049. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  87050. */
  87051. get is2DArray(): boolean;
  87052. set is2DArray(value: boolean);
  87053. /**
  87054. * Get the class name of the texture.
  87055. * @returns "ThinTexture"
  87056. */
  87057. getClassName(): string;
  87058. /** @hidden */
  87059. _texture: Nullable<InternalTexture>;
  87060. protected _engine: Nullable<ThinEngine>;
  87061. private _cachedSize;
  87062. private _cachedBaseSize;
  87063. /**
  87064. * Instantiates a new ThinTexture.
  87065. * Base class of all the textures in babylon.
  87066. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  87067. * @param internalTexture Define the internalTexture to wrap
  87068. */
  87069. constructor(internalTexture: Nullable<InternalTexture>);
  87070. /**
  87071. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  87072. * @returns true if fully ready
  87073. */
  87074. isReady(): boolean;
  87075. /**
  87076. * Triggers the load sequence in delayed load mode.
  87077. */
  87078. delayLoad(): void;
  87079. /**
  87080. * Get the underlying lower level texture from Babylon.
  87081. * @returns the insternal texture
  87082. */
  87083. getInternalTexture(): Nullable<InternalTexture>;
  87084. /**
  87085. * Get the size of the texture.
  87086. * @returns the texture size.
  87087. */
  87088. getSize(): ISize;
  87089. /**
  87090. * Get the base size of the texture.
  87091. * It can be different from the size if the texture has been resized for POT for instance
  87092. * @returns the base size
  87093. */
  87094. getBaseSize(): ISize;
  87095. /**
  87096. * Update the sampling mode of the texture.
  87097. * Default is Trilinear mode.
  87098. *
  87099. * | Value | Type | Description |
  87100. * | ----- | ------------------ | ----------- |
  87101. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  87102. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  87103. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  87104. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  87105. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  87106. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  87107. * | 7 | NEAREST_LINEAR | |
  87108. * | 8 | NEAREST_NEAREST | |
  87109. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  87110. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  87111. * | 11 | LINEAR_LINEAR | |
  87112. * | 12 | LINEAR_NEAREST | |
  87113. *
  87114. * > _mag_: magnification filter (close to the viewer)
  87115. * > _min_: minification filter (far from the viewer)
  87116. * > _mip_: filter used between mip map levels
  87117. *@param samplingMode Define the new sampling mode of the texture
  87118. */
  87119. updateSamplingMode(samplingMode: number): void;
  87120. /**
  87121. * Release and destroy the underlying lower level texture aka internalTexture.
  87122. */
  87123. releaseInternalTexture(): void;
  87124. /**
  87125. * Dispose the texture and release its associated resources.
  87126. */
  87127. dispose(): void;
  87128. }
  87129. }
  87130. declare module BABYLON {
  87131. /**
  87132. * Defines an array and its length.
  87133. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87134. */
  87135. export interface ISmartArrayLike<T> {
  87136. /**
  87137. * The data of the array.
  87138. */
  87139. data: Array<T>;
  87140. /**
  87141. * The active length of the array.
  87142. */
  87143. length: number;
  87144. }
  87145. /**
  87146. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87147. */
  87148. export class SmartArray<T> implements ISmartArrayLike<T> {
  87149. /**
  87150. * The full set of data from the array.
  87151. */
  87152. data: Array<T>;
  87153. /**
  87154. * The active length of the array.
  87155. */
  87156. length: number;
  87157. protected _id: number;
  87158. /**
  87159. * Instantiates a Smart Array.
  87160. * @param capacity defines the default capacity of the array.
  87161. */
  87162. constructor(capacity: number);
  87163. /**
  87164. * Pushes a value at the end of the active data.
  87165. * @param value defines the object to push in the array.
  87166. */
  87167. push(value: T): void;
  87168. /**
  87169. * Iterates over the active data and apply the lambda to them.
  87170. * @param func defines the action to apply on each value.
  87171. */
  87172. forEach(func: (content: T) => void): void;
  87173. /**
  87174. * Sorts the full sets of data.
  87175. * @param compareFn defines the comparison function to apply.
  87176. */
  87177. sort(compareFn: (a: T, b: T) => number): void;
  87178. /**
  87179. * Resets the active data to an empty array.
  87180. */
  87181. reset(): void;
  87182. /**
  87183. * Releases all the data from the array as well as the array.
  87184. */
  87185. dispose(): void;
  87186. /**
  87187. * Concats the active data with a given array.
  87188. * @param array defines the data to concatenate with.
  87189. */
  87190. concat(array: any): void;
  87191. /**
  87192. * Returns the position of a value in the active data.
  87193. * @param value defines the value to find the index for
  87194. * @returns the index if found in the active data otherwise -1
  87195. */
  87196. indexOf(value: T): number;
  87197. /**
  87198. * Returns whether an element is part of the active data.
  87199. * @param value defines the value to look for
  87200. * @returns true if found in the active data otherwise false
  87201. */
  87202. contains(value: T): boolean;
  87203. private static _GlobalId;
  87204. }
  87205. /**
  87206. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87207. * The data in this array can only be present once
  87208. */
  87209. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87210. private _duplicateId;
  87211. /**
  87212. * Pushes a value at the end of the active data.
  87213. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87214. * @param value defines the object to push in the array.
  87215. */
  87216. push(value: T): void;
  87217. /**
  87218. * Pushes a value at the end of the active data.
  87219. * If the data is already present, it won t be added again
  87220. * @param value defines the object to push in the array.
  87221. * @returns true if added false if it was already present
  87222. */
  87223. pushNoDuplicate(value: T): boolean;
  87224. /**
  87225. * Resets the active data to an empty array.
  87226. */
  87227. reset(): void;
  87228. /**
  87229. * Concats the active data with a given array.
  87230. * This ensures no dupplicate will be present in the result.
  87231. * @param array defines the data to concatenate with.
  87232. */
  87233. concatWithNoDuplicate(array: any): void;
  87234. }
  87235. }
  87236. declare module BABYLON {
  87237. /**
  87238. * Class used to evalaute queries containing `and` and `or` operators
  87239. */
  87240. export class AndOrNotEvaluator {
  87241. /**
  87242. * Evaluate a query
  87243. * @param query defines the query to evaluate
  87244. * @param evaluateCallback defines the callback used to filter result
  87245. * @returns true if the query matches
  87246. */
  87247. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  87248. private static _HandleParenthesisContent;
  87249. private static _SimplifyNegation;
  87250. }
  87251. }
  87252. declare module BABYLON {
  87253. /**
  87254. * Class used to store custom tags
  87255. */
  87256. export class Tags {
  87257. /**
  87258. * Adds support for tags on the given object
  87259. * @param obj defines the object to use
  87260. */
  87261. static EnableFor(obj: any): void;
  87262. /**
  87263. * Removes tags support
  87264. * @param obj defines the object to use
  87265. */
  87266. static DisableFor(obj: any): void;
  87267. /**
  87268. * Gets a boolean indicating if the given object has tags
  87269. * @param obj defines the object to use
  87270. * @returns a boolean
  87271. */
  87272. static HasTags(obj: any): boolean;
  87273. /**
  87274. * Gets the tags available on a given object
  87275. * @param obj defines the object to use
  87276. * @param asString defines if the tags must be returned as a string instead of an array of strings
  87277. * @returns the tags
  87278. */
  87279. static GetTags(obj: any, asString?: boolean): any;
  87280. /**
  87281. * Adds tags to an object
  87282. * @param obj defines the object to use
  87283. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  87284. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  87285. */
  87286. static AddTagsTo(obj: any, tagsString: string): void;
  87287. /**
  87288. * @hidden
  87289. */
  87290. static _AddTagTo(obj: any, tag: string): void;
  87291. /**
  87292. * Removes specific tags from a specific object
  87293. * @param obj defines the object to use
  87294. * @param tagsString defines the tags to remove
  87295. */
  87296. static RemoveTagsFrom(obj: any, tagsString: string): void;
  87297. /**
  87298. * @hidden
  87299. */
  87300. static _RemoveTagFrom(obj: any, tag: string): void;
  87301. /**
  87302. * Defines if tags hosted on an object match a given query
  87303. * @param obj defines the object to use
  87304. * @param tagsQuery defines the tag query
  87305. * @returns a boolean
  87306. */
  87307. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  87308. }
  87309. }
  87310. declare module BABYLON {
  87311. /**
  87312. * Scalar computation library
  87313. */
  87314. export class Scalar {
  87315. /**
  87316. * Two pi constants convenient for computation.
  87317. */
  87318. static TwoPi: number;
  87319. /**
  87320. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  87321. * @param a number
  87322. * @param b number
  87323. * @param epsilon (default = 1.401298E-45)
  87324. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  87325. */
  87326. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  87327. /**
  87328. * Returns a string : the upper case translation of the number i to hexadecimal.
  87329. * @param i number
  87330. * @returns the upper case translation of the number i to hexadecimal.
  87331. */
  87332. static ToHex(i: number): string;
  87333. /**
  87334. * Returns -1 if value is negative and +1 is value is positive.
  87335. * @param value the value
  87336. * @returns the value itself if it's equal to zero.
  87337. */
  87338. static Sign(value: number): number;
  87339. /**
  87340. * Returns the value itself if it's between min and max.
  87341. * Returns min if the value is lower than min.
  87342. * Returns max if the value is greater than max.
  87343. * @param value the value to clmap
  87344. * @param min the min value to clamp to (default: 0)
  87345. * @param max the max value to clamp to (default: 1)
  87346. * @returns the clamped value
  87347. */
  87348. static Clamp(value: number, min?: number, max?: number): number;
  87349. /**
  87350. * the log2 of value.
  87351. * @param value the value to compute log2 of
  87352. * @returns the log2 of value.
  87353. */
  87354. static Log2(value: number): number;
  87355. /**
  87356. * the floor part of a log2 value.
  87357. * @param value the value to compute log2 of
  87358. * @returns the log2 of value.
  87359. */
  87360. static ILog2(value: number): number;
  87361. /**
  87362. * Loops the value, so that it is never larger than length and never smaller than 0.
  87363. *
  87364. * This is similar to the modulo operator but it works with floating point numbers.
  87365. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  87366. * With t = 5 and length = 2.5, the result would be 0.0.
  87367. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  87368. * @param value the value
  87369. * @param length the length
  87370. * @returns the looped value
  87371. */
  87372. static Repeat(value: number, length: number): number;
  87373. /**
  87374. * Normalize the value between 0.0 and 1.0 using min and max values
  87375. * @param value value to normalize
  87376. * @param min max to normalize between
  87377. * @param max min to normalize between
  87378. * @returns the normalized value
  87379. */
  87380. static Normalize(value: number, min: number, max: number): number;
  87381. /**
  87382. * Denormalize the value from 0.0 and 1.0 using min and max values
  87383. * @param normalized value to denormalize
  87384. * @param min max to denormalize between
  87385. * @param max min to denormalize between
  87386. * @returns the denormalized value
  87387. */
  87388. static Denormalize(normalized: number, min: number, max: number): number;
  87389. /**
  87390. * Calculates the shortest difference between two given angles given in degrees.
  87391. * @param current current angle in degrees
  87392. * @param target target angle in degrees
  87393. * @returns the delta
  87394. */
  87395. static DeltaAngle(current: number, target: number): number;
  87396. /**
  87397. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  87398. * @param tx value
  87399. * @param length length
  87400. * @returns The returned value will move back and forth between 0 and length
  87401. */
  87402. static PingPong(tx: number, length: number): number;
  87403. /**
  87404. * Interpolates between min and max with smoothing at the limits.
  87405. *
  87406. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  87407. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  87408. * @param from from
  87409. * @param to to
  87410. * @param tx value
  87411. * @returns the smooth stepped value
  87412. */
  87413. static SmoothStep(from: number, to: number, tx: number): number;
  87414. /**
  87415. * Moves a value current towards target.
  87416. *
  87417. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  87418. * Negative values of maxDelta pushes the value away from target.
  87419. * @param current current value
  87420. * @param target target value
  87421. * @param maxDelta max distance to move
  87422. * @returns resulting value
  87423. */
  87424. static MoveTowards(current: number, target: number, maxDelta: number): number;
  87425. /**
  87426. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  87427. *
  87428. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  87429. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  87430. * @param current current value
  87431. * @param target target value
  87432. * @param maxDelta max distance to move
  87433. * @returns resulting angle
  87434. */
  87435. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  87436. /**
  87437. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  87438. * @param start start value
  87439. * @param end target value
  87440. * @param amount amount to lerp between
  87441. * @returns the lerped value
  87442. */
  87443. static Lerp(start: number, end: number, amount: number): number;
  87444. /**
  87445. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  87446. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  87447. * @param start start value
  87448. * @param end target value
  87449. * @param amount amount to lerp between
  87450. * @returns the lerped value
  87451. */
  87452. static LerpAngle(start: number, end: number, amount: number): number;
  87453. /**
  87454. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  87455. * @param a start value
  87456. * @param b target value
  87457. * @param value value between a and b
  87458. * @returns the inverseLerp value
  87459. */
  87460. static InverseLerp(a: number, b: number, value: number): number;
  87461. /**
  87462. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  87463. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  87464. * @param value1 spline value
  87465. * @param tangent1 spline value
  87466. * @param value2 spline value
  87467. * @param tangent2 spline value
  87468. * @param amount input value
  87469. * @returns hermite result
  87470. */
  87471. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  87472. /**
  87473. * Returns a random float number between and min and max values
  87474. * @param min min value of random
  87475. * @param max max value of random
  87476. * @returns random value
  87477. */
  87478. static RandomRange(min: number, max: number): number;
  87479. /**
  87480. * This function returns percentage of a number in a given range.
  87481. *
  87482. * RangeToPercent(40,20,60) will return 0.5 (50%)
  87483. * RangeToPercent(34,0,100) will return 0.34 (34%)
  87484. * @param number to convert to percentage
  87485. * @param min min range
  87486. * @param max max range
  87487. * @returns the percentage
  87488. */
  87489. static RangeToPercent(number: number, min: number, max: number): number;
  87490. /**
  87491. * This function returns number that corresponds to the percentage in a given range.
  87492. *
  87493. * PercentToRange(0.34,0,100) will return 34.
  87494. * @param percent to convert to number
  87495. * @param min min range
  87496. * @param max max range
  87497. * @returns the number
  87498. */
  87499. static PercentToRange(percent: number, min: number, max: number): number;
  87500. /**
  87501. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  87502. * @param angle The angle to normalize in radian.
  87503. * @return The converted angle.
  87504. */
  87505. static NormalizeRadians(angle: number): number;
  87506. }
  87507. }
  87508. declare module BABYLON {
  87509. /**
  87510. * Constant used to convert a value to gamma space
  87511. * @ignorenaming
  87512. */
  87513. export const ToGammaSpace: number;
  87514. /**
  87515. * Constant used to convert a value to linear space
  87516. * @ignorenaming
  87517. */
  87518. export const ToLinearSpace = 2.2;
  87519. /**
  87520. * Constant used to define the minimal number value in Babylon.js
  87521. * @ignorenaming
  87522. */
  87523. let Epsilon: number;
  87524. }
  87525. declare module BABYLON {
  87526. /**
  87527. * Class used to represent a viewport on screen
  87528. */
  87529. export class Viewport {
  87530. /** viewport left coordinate */
  87531. x: number;
  87532. /** viewport top coordinate */
  87533. y: number;
  87534. /**viewport width */
  87535. width: number;
  87536. /** viewport height */
  87537. height: number;
  87538. /**
  87539. * Creates a Viewport object located at (x, y) and sized (width, height)
  87540. * @param x defines viewport left coordinate
  87541. * @param y defines viewport top coordinate
  87542. * @param width defines the viewport width
  87543. * @param height defines the viewport height
  87544. */
  87545. constructor(
  87546. /** viewport left coordinate */
  87547. x: number,
  87548. /** viewport top coordinate */
  87549. y: number,
  87550. /**viewport width */
  87551. width: number,
  87552. /** viewport height */
  87553. height: number);
  87554. /**
  87555. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  87556. * @param renderWidth defines the rendering width
  87557. * @param renderHeight defines the rendering height
  87558. * @returns a new Viewport
  87559. */
  87560. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  87561. /**
  87562. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  87563. * @param renderWidth defines the rendering width
  87564. * @param renderHeight defines the rendering height
  87565. * @param ref defines the target viewport
  87566. * @returns the current viewport
  87567. */
  87568. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  87569. /**
  87570. * Returns a new Viewport copied from the current one
  87571. * @returns a new Viewport
  87572. */
  87573. clone(): Viewport;
  87574. }
  87575. }
  87576. declare module BABYLON {
  87577. /**
  87578. * Class containing a set of static utilities functions for arrays.
  87579. */
  87580. export class ArrayTools {
  87581. /**
  87582. * Returns an array of the given size filled with element built from the given constructor and the paramters
  87583. * @param size the number of element to construct and put in the array
  87584. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  87585. * @returns a new array filled with new objects
  87586. */
  87587. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  87588. }
  87589. }
  87590. declare module BABYLON {
  87591. /**
  87592. * Represents a plane by the equation ax + by + cz + d = 0
  87593. */
  87594. export class Plane {
  87595. private static _TmpMatrix;
  87596. /**
  87597. * Normal of the plane (a,b,c)
  87598. */
  87599. normal: Vector3;
  87600. /**
  87601. * d component of the plane
  87602. */
  87603. d: number;
  87604. /**
  87605. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  87606. * @param a a component of the plane
  87607. * @param b b component of the plane
  87608. * @param c c component of the plane
  87609. * @param d d component of the plane
  87610. */
  87611. constructor(a: number, b: number, c: number, d: number);
  87612. /**
  87613. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  87614. */
  87615. asArray(): number[];
  87616. /**
  87617. * @returns a new plane copied from the current Plane.
  87618. */
  87619. clone(): Plane;
  87620. /**
  87621. * @returns the string "Plane".
  87622. */
  87623. getClassName(): string;
  87624. /**
  87625. * @returns the Plane hash code.
  87626. */
  87627. getHashCode(): number;
  87628. /**
  87629. * Normalize the current Plane in place.
  87630. * @returns the updated Plane.
  87631. */
  87632. normalize(): Plane;
  87633. /**
  87634. * Applies a transformation the plane and returns the result
  87635. * @param transformation the transformation matrix to be applied to the plane
  87636. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  87637. */
  87638. transform(transformation: DeepImmutable<Matrix>): Plane;
  87639. /**
  87640. * Compute the dot product between the point and the plane normal
  87641. * @param point point to calculate the dot product with
  87642. * @returns the dot product (float) of the point coordinates and the plane normal.
  87643. */
  87644. dotCoordinate(point: DeepImmutable<Vector3>): number;
  87645. /**
  87646. * Updates the current Plane from the plane defined by the three given points.
  87647. * @param point1 one of the points used to contruct the plane
  87648. * @param point2 one of the points used to contruct the plane
  87649. * @param point3 one of the points used to contruct the plane
  87650. * @returns the updated Plane.
  87651. */
  87652. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87653. /**
  87654. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  87655. * Note that for this function to work as expected you should make sure that:
  87656. * - direction and the plane normal are normalized
  87657. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  87658. * @param direction the direction to check if the plane is facing
  87659. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  87660. * @returns True if the plane is facing the given direction
  87661. */
  87662. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  87663. /**
  87664. * Calculates the distance to a point
  87665. * @param point point to calculate distance to
  87666. * @returns the signed distance (float) from the given point to the Plane.
  87667. */
  87668. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  87669. /**
  87670. * Creates a plane from an array
  87671. * @param array the array to create a plane from
  87672. * @returns a new Plane from the given array.
  87673. */
  87674. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  87675. /**
  87676. * Creates a plane from three points
  87677. * @param point1 point used to create the plane
  87678. * @param point2 point used to create the plane
  87679. * @param point3 point used to create the plane
  87680. * @returns a new Plane defined by the three given points.
  87681. */
  87682. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87683. /**
  87684. * Creates a plane from an origin point and a normal
  87685. * @param origin origin of the plane to be constructed
  87686. * @param normal normal of the plane to be constructed
  87687. * @returns a new Plane the normal vector to this plane at the given origin point.
  87688. * Note : the vector "normal" is updated because normalized.
  87689. */
  87690. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  87691. /**
  87692. * Calculates the distance from a plane and a point
  87693. * @param origin origin of the plane to be constructed
  87694. * @param normal normal of the plane to be constructed
  87695. * @param point point to calculate distance to
  87696. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  87697. */
  87698. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  87699. }
  87700. }
  87701. declare module BABYLON {
  87702. /** @hidden */
  87703. export class PerformanceConfigurator {
  87704. /** @hidden */
  87705. static MatrixUse64Bits: boolean;
  87706. /** @hidden */
  87707. static MatrixTrackPrecisionChange: boolean;
  87708. /** @hidden */
  87709. static MatrixCurrentType: any;
  87710. /** @hidden */
  87711. static MatrixTrackedMatrices: Array<any> | null;
  87712. /** @hidden */
  87713. static SetMatrixPrecision(use64bits: boolean): void;
  87714. }
  87715. }
  87716. declare module BABYLON {
  87717. /**
  87718. * Class representing a vector containing 2 coordinates
  87719. */
  87720. export class Vector2 {
  87721. /** defines the first coordinate */
  87722. x: number;
  87723. /** defines the second coordinate */
  87724. y: number;
  87725. /**
  87726. * Creates a new Vector2 from the given x and y coordinates
  87727. * @param x defines the first coordinate
  87728. * @param y defines the second coordinate
  87729. */
  87730. constructor(
  87731. /** defines the first coordinate */
  87732. x?: number,
  87733. /** defines the second coordinate */
  87734. y?: number);
  87735. /**
  87736. * Gets a string with the Vector2 coordinates
  87737. * @returns a string with the Vector2 coordinates
  87738. */
  87739. toString(): string;
  87740. /**
  87741. * Gets class name
  87742. * @returns the string "Vector2"
  87743. */
  87744. getClassName(): string;
  87745. /**
  87746. * Gets current vector hash code
  87747. * @returns the Vector2 hash code as a number
  87748. */
  87749. getHashCode(): number;
  87750. /**
  87751. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  87752. * @param array defines the source array
  87753. * @param index defines the offset in source array
  87754. * @returns the current Vector2
  87755. */
  87756. toArray(array: FloatArray, index?: number): Vector2;
  87757. /**
  87758. * Update the current vector from an array
  87759. * @param array defines the destination array
  87760. * @param index defines the offset in the destination array
  87761. * @returns the current Vector3
  87762. */
  87763. fromArray(array: FloatArray, index?: number): Vector2;
  87764. /**
  87765. * Copy the current vector to an array
  87766. * @returns a new array with 2 elements: the Vector2 coordinates.
  87767. */
  87768. asArray(): number[];
  87769. /**
  87770. * Sets the Vector2 coordinates with the given Vector2 coordinates
  87771. * @param source defines the source Vector2
  87772. * @returns the current updated Vector2
  87773. */
  87774. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  87775. /**
  87776. * Sets the Vector2 coordinates with the given floats
  87777. * @param x defines the first coordinate
  87778. * @param y defines the second coordinate
  87779. * @returns the current updated Vector2
  87780. */
  87781. copyFromFloats(x: number, y: number): Vector2;
  87782. /**
  87783. * Sets the Vector2 coordinates with the given floats
  87784. * @param x defines the first coordinate
  87785. * @param y defines the second coordinate
  87786. * @returns the current updated Vector2
  87787. */
  87788. set(x: number, y: number): Vector2;
  87789. /**
  87790. * Add another vector with the current one
  87791. * @param otherVector defines the other vector
  87792. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  87793. */
  87794. add(otherVector: DeepImmutable<Vector2>): Vector2;
  87795. /**
  87796. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  87797. * @param otherVector defines the other vector
  87798. * @param result defines the target vector
  87799. * @returns the unmodified current Vector2
  87800. */
  87801. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87802. /**
  87803. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  87804. * @param otherVector defines the other vector
  87805. * @returns the current updated Vector2
  87806. */
  87807. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87808. /**
  87809. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  87810. * @param otherVector defines the other vector
  87811. * @returns a new Vector2
  87812. */
  87813. addVector3(otherVector: Vector3): Vector2;
  87814. /**
  87815. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  87816. * @param otherVector defines the other vector
  87817. * @returns a new Vector2
  87818. */
  87819. subtract(otherVector: Vector2): Vector2;
  87820. /**
  87821. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  87822. * @param otherVector defines the other vector
  87823. * @param result defines the target vector
  87824. * @returns the unmodified current Vector2
  87825. */
  87826. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87827. /**
  87828. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  87829. * @param otherVector defines the other vector
  87830. * @returns the current updated Vector2
  87831. */
  87832. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87833. /**
  87834. * Multiplies in place the current Vector2 coordinates by the given ones
  87835. * @param otherVector defines the other vector
  87836. * @returns the current updated Vector2
  87837. */
  87838. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87839. /**
  87840. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  87841. * @param otherVector defines the other vector
  87842. * @returns a new Vector2
  87843. */
  87844. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  87845. /**
  87846. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  87847. * @param otherVector defines the other vector
  87848. * @param result defines the target vector
  87849. * @returns the unmodified current Vector2
  87850. */
  87851. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87852. /**
  87853. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  87854. * @param x defines the first coordinate
  87855. * @param y defines the second coordinate
  87856. * @returns a new Vector2
  87857. */
  87858. multiplyByFloats(x: number, y: number): Vector2;
  87859. /**
  87860. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  87861. * @param otherVector defines the other vector
  87862. * @returns a new Vector2
  87863. */
  87864. divide(otherVector: Vector2): Vector2;
  87865. /**
  87866. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  87867. * @param otherVector defines the other vector
  87868. * @param result defines the target vector
  87869. * @returns the unmodified current Vector2
  87870. */
  87871. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87872. /**
  87873. * Divides the current Vector2 coordinates by the given ones
  87874. * @param otherVector defines the other vector
  87875. * @returns the current updated Vector2
  87876. */
  87877. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87878. /**
  87879. * Gets a new Vector2 with current Vector2 negated coordinates
  87880. * @returns a new Vector2
  87881. */
  87882. negate(): Vector2;
  87883. /**
  87884. * Negate this vector in place
  87885. * @returns this
  87886. */
  87887. negateInPlace(): Vector2;
  87888. /**
  87889. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  87890. * @param result defines the Vector3 object where to store the result
  87891. * @returns the current Vector2
  87892. */
  87893. negateToRef(result: Vector2): Vector2;
  87894. /**
  87895. * Multiply the Vector2 coordinates by scale
  87896. * @param scale defines the scaling factor
  87897. * @returns the current updated Vector2
  87898. */
  87899. scaleInPlace(scale: number): Vector2;
  87900. /**
  87901. * Returns a new Vector2 scaled by "scale" from the current Vector2
  87902. * @param scale defines the scaling factor
  87903. * @returns a new Vector2
  87904. */
  87905. scale(scale: number): Vector2;
  87906. /**
  87907. * Scale the current Vector2 values by a factor to a given Vector2
  87908. * @param scale defines the scale factor
  87909. * @param result defines the Vector2 object where to store the result
  87910. * @returns the unmodified current Vector2
  87911. */
  87912. scaleToRef(scale: number, result: Vector2): Vector2;
  87913. /**
  87914. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  87915. * @param scale defines the scale factor
  87916. * @param result defines the Vector2 object where to store the result
  87917. * @returns the unmodified current Vector2
  87918. */
  87919. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  87920. /**
  87921. * Gets a boolean if two vectors are equals
  87922. * @param otherVector defines the other vector
  87923. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  87924. */
  87925. equals(otherVector: DeepImmutable<Vector2>): boolean;
  87926. /**
  87927. * Gets a boolean if two vectors are equals (using an epsilon value)
  87928. * @param otherVector defines the other vector
  87929. * @param epsilon defines the minimal distance to consider equality
  87930. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  87931. */
  87932. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  87933. /**
  87934. * Gets a new Vector2 from current Vector2 floored values
  87935. * @returns a new Vector2
  87936. */
  87937. floor(): Vector2;
  87938. /**
  87939. * Gets a new Vector2 from current Vector2 floored values
  87940. * @returns a new Vector2
  87941. */
  87942. fract(): Vector2;
  87943. /**
  87944. * Gets the length of the vector
  87945. * @returns the vector length (float)
  87946. */
  87947. length(): number;
  87948. /**
  87949. * Gets the vector squared length
  87950. * @returns the vector squared length (float)
  87951. */
  87952. lengthSquared(): number;
  87953. /**
  87954. * Normalize the vector
  87955. * @returns the current updated Vector2
  87956. */
  87957. normalize(): Vector2;
  87958. /**
  87959. * Gets a new Vector2 copied from the Vector2
  87960. * @returns a new Vector2
  87961. */
  87962. clone(): Vector2;
  87963. /**
  87964. * Gets a new Vector2(0, 0)
  87965. * @returns a new Vector2
  87966. */
  87967. static Zero(): Vector2;
  87968. /**
  87969. * Gets a new Vector2(1, 1)
  87970. * @returns a new Vector2
  87971. */
  87972. static One(): Vector2;
  87973. /**
  87974. * Gets a new Vector2 set from the given index element of the given array
  87975. * @param array defines the data source
  87976. * @param offset defines the offset in the data source
  87977. * @returns a new Vector2
  87978. */
  87979. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  87980. /**
  87981. * Sets "result" from the given index element of the given array
  87982. * @param array defines the data source
  87983. * @param offset defines the offset in the data source
  87984. * @param result defines the target vector
  87985. */
  87986. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  87987. /**
  87988. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  87989. * @param value1 defines 1st point of control
  87990. * @param value2 defines 2nd point of control
  87991. * @param value3 defines 3rd point of control
  87992. * @param value4 defines 4th point of control
  87993. * @param amount defines the interpolation factor
  87994. * @returns a new Vector2
  87995. */
  87996. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  87997. /**
  87998. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  87999. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  88000. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  88001. * @param value defines the value to clamp
  88002. * @param min defines the lower limit
  88003. * @param max defines the upper limit
  88004. * @returns a new Vector2
  88005. */
  88006. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  88007. /**
  88008. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  88009. * @param value1 defines the 1st control point
  88010. * @param tangent1 defines the outgoing tangent
  88011. * @param value2 defines the 2nd control point
  88012. * @param tangent2 defines the incoming tangent
  88013. * @param amount defines the interpolation factor
  88014. * @returns a new Vector2
  88015. */
  88016. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  88017. /**
  88018. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  88019. * @param start defines the start vector
  88020. * @param end defines the end vector
  88021. * @param amount defines the interpolation factor
  88022. * @returns a new Vector2
  88023. */
  88024. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  88025. /**
  88026. * Gets the dot product of the vector "left" and the vector "right"
  88027. * @param left defines first vector
  88028. * @param right defines second vector
  88029. * @returns the dot product (float)
  88030. */
  88031. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  88032. /**
  88033. * Returns a new Vector2 equal to the normalized given vector
  88034. * @param vector defines the vector to normalize
  88035. * @returns a new Vector2
  88036. */
  88037. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  88038. /**
  88039. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  88040. * @param left defines 1st vector
  88041. * @param right defines 2nd vector
  88042. * @returns a new Vector2
  88043. */
  88044. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  88045. /**
  88046. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  88047. * @param left defines 1st vector
  88048. * @param right defines 2nd vector
  88049. * @returns a new Vector2
  88050. */
  88051. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  88052. /**
  88053. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  88054. * @param vector defines the vector to transform
  88055. * @param transformation defines the matrix to apply
  88056. * @returns a new Vector2
  88057. */
  88058. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  88059. /**
  88060. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  88061. * @param vector defines the vector to transform
  88062. * @param transformation defines the matrix to apply
  88063. * @param result defines the target vector
  88064. */
  88065. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  88066. /**
  88067. * Determines if a given vector is included in a triangle
  88068. * @param p defines the vector to test
  88069. * @param p0 defines 1st triangle point
  88070. * @param p1 defines 2nd triangle point
  88071. * @param p2 defines 3rd triangle point
  88072. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  88073. */
  88074. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  88075. /**
  88076. * Gets the distance between the vectors "value1" and "value2"
  88077. * @param value1 defines first vector
  88078. * @param value2 defines second vector
  88079. * @returns the distance between vectors
  88080. */
  88081. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  88082. /**
  88083. * Returns the squared distance between the vectors "value1" and "value2"
  88084. * @param value1 defines first vector
  88085. * @param value2 defines second vector
  88086. * @returns the squared distance between vectors
  88087. */
  88088. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  88089. /**
  88090. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  88091. * @param value1 defines first vector
  88092. * @param value2 defines second vector
  88093. * @returns a new Vector2
  88094. */
  88095. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  88096. /**
  88097. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88098. * @param value1 defines first vector
  88099. * @param value2 defines second vector
  88100. * @param ref defines third vector
  88101. * @returns ref
  88102. */
  88103. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  88104. /**
  88105. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  88106. * @param p defines the middle point
  88107. * @param segA defines one point of the segment
  88108. * @param segB defines the other point of the segment
  88109. * @returns the shortest distance
  88110. */
  88111. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  88112. }
  88113. /**
  88114. * Class used to store (x,y,z) vector representation
  88115. * A Vector3 is the main object used in 3D geometry
  88116. * It can represent etiher the coordinates of a point the space, either a direction
  88117. * Reminder: js uses a left handed forward facing system
  88118. */
  88119. export class Vector3 {
  88120. private static _UpReadOnly;
  88121. private static _ZeroReadOnly;
  88122. /** @hidden */
  88123. _x: number;
  88124. /** @hidden */
  88125. _y: number;
  88126. /** @hidden */
  88127. _z: number;
  88128. /** @hidden */
  88129. _isDirty: boolean;
  88130. /** Gets or sets the x coordinate */
  88131. get x(): number;
  88132. set x(value: number);
  88133. /** Gets or sets the y coordinate */
  88134. get y(): number;
  88135. set y(value: number);
  88136. /** Gets or sets the z coordinate */
  88137. get z(): number;
  88138. set z(value: number);
  88139. /**
  88140. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  88141. * @param x defines the first coordinates (on X axis)
  88142. * @param y defines the second coordinates (on Y axis)
  88143. * @param z defines the third coordinates (on Z axis)
  88144. */
  88145. constructor(x?: number, y?: number, z?: number);
  88146. /**
  88147. * Creates a string representation of the Vector3
  88148. * @returns a string with the Vector3 coordinates.
  88149. */
  88150. toString(): string;
  88151. /**
  88152. * Gets the class name
  88153. * @returns the string "Vector3"
  88154. */
  88155. getClassName(): string;
  88156. /**
  88157. * Creates the Vector3 hash code
  88158. * @returns a number which tends to be unique between Vector3 instances
  88159. */
  88160. getHashCode(): number;
  88161. /**
  88162. * Creates an array containing three elements : the coordinates of the Vector3
  88163. * @returns a new array of numbers
  88164. */
  88165. asArray(): number[];
  88166. /**
  88167. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  88168. * @param array defines the destination array
  88169. * @param index defines the offset in the destination array
  88170. * @returns the current Vector3
  88171. */
  88172. toArray(array: FloatArray, index?: number): Vector3;
  88173. /**
  88174. * Update the current vector from an array
  88175. * @param array defines the destination array
  88176. * @param index defines the offset in the destination array
  88177. * @returns the current Vector3
  88178. */
  88179. fromArray(array: FloatArray, index?: number): Vector3;
  88180. /**
  88181. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  88182. * @returns a new Quaternion object, computed from the Vector3 coordinates
  88183. */
  88184. toQuaternion(): Quaternion;
  88185. /**
  88186. * Adds the given vector to the current Vector3
  88187. * @param otherVector defines the second operand
  88188. * @returns the current updated Vector3
  88189. */
  88190. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88191. /**
  88192. * Adds the given coordinates to the current Vector3
  88193. * @param x defines the x coordinate of the operand
  88194. * @param y defines the y coordinate of the operand
  88195. * @param z defines the z coordinate of the operand
  88196. * @returns the current updated Vector3
  88197. */
  88198. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88199. /**
  88200. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  88201. * @param otherVector defines the second operand
  88202. * @returns the resulting Vector3
  88203. */
  88204. add(otherVector: DeepImmutable<Vector3>): Vector3;
  88205. /**
  88206. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  88207. * @param otherVector defines the second operand
  88208. * @param result defines the Vector3 object where to store the result
  88209. * @returns the current Vector3
  88210. */
  88211. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88212. /**
  88213. * Subtract the given vector from the current Vector3
  88214. * @param otherVector defines the second operand
  88215. * @returns the current updated Vector3
  88216. */
  88217. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88218. /**
  88219. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  88220. * @param otherVector defines the second operand
  88221. * @returns the resulting Vector3
  88222. */
  88223. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  88224. /**
  88225. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  88226. * @param otherVector defines the second operand
  88227. * @param result defines the Vector3 object where to store the result
  88228. * @returns the current Vector3
  88229. */
  88230. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88231. /**
  88232. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  88233. * @param x defines the x coordinate of the operand
  88234. * @param y defines the y coordinate of the operand
  88235. * @param z defines the z coordinate of the operand
  88236. * @returns the resulting Vector3
  88237. */
  88238. subtractFromFloats(x: number, y: number, z: number): Vector3;
  88239. /**
  88240. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  88241. * @param x defines the x coordinate of the operand
  88242. * @param y defines the y coordinate of the operand
  88243. * @param z defines the z coordinate of the operand
  88244. * @param result defines the Vector3 object where to store the result
  88245. * @returns the current Vector3
  88246. */
  88247. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  88248. /**
  88249. * Gets a new Vector3 set with the current Vector3 negated coordinates
  88250. * @returns a new Vector3
  88251. */
  88252. negate(): Vector3;
  88253. /**
  88254. * Negate this vector in place
  88255. * @returns this
  88256. */
  88257. negateInPlace(): Vector3;
  88258. /**
  88259. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  88260. * @param result defines the Vector3 object where to store the result
  88261. * @returns the current Vector3
  88262. */
  88263. negateToRef(result: Vector3): Vector3;
  88264. /**
  88265. * Multiplies the Vector3 coordinates by the float "scale"
  88266. * @param scale defines the multiplier factor
  88267. * @returns the current updated Vector3
  88268. */
  88269. scaleInPlace(scale: number): Vector3;
  88270. /**
  88271. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  88272. * @param scale defines the multiplier factor
  88273. * @returns a new Vector3
  88274. */
  88275. scale(scale: number): Vector3;
  88276. /**
  88277. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  88278. * @param scale defines the multiplier factor
  88279. * @param result defines the Vector3 object where to store the result
  88280. * @returns the current Vector3
  88281. */
  88282. scaleToRef(scale: number, result: Vector3): Vector3;
  88283. /**
  88284. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  88285. * @param scale defines the scale factor
  88286. * @param result defines the Vector3 object where to store the result
  88287. * @returns the unmodified current Vector3
  88288. */
  88289. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  88290. /**
  88291. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  88292. * @param origin defines the origin of the projection ray
  88293. * @param plane defines the plane to project to
  88294. * @returns the projected vector3
  88295. */
  88296. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  88297. /**
  88298. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  88299. * @param origin defines the origin of the projection ray
  88300. * @param plane defines the plane to project to
  88301. * @param result defines the Vector3 where to store the result
  88302. */
  88303. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  88304. /**
  88305. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  88306. * @param otherVector defines the second operand
  88307. * @returns true if both vectors are equals
  88308. */
  88309. equals(otherVector: DeepImmutable<Vector3>): boolean;
  88310. /**
  88311. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  88312. * @param otherVector defines the second operand
  88313. * @param epsilon defines the minimal distance to define values as equals
  88314. * @returns true if both vectors are distant less than epsilon
  88315. */
  88316. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  88317. /**
  88318. * Returns true if the current Vector3 coordinates equals the given floats
  88319. * @param x defines the x coordinate of the operand
  88320. * @param y defines the y coordinate of the operand
  88321. * @param z defines the z coordinate of the operand
  88322. * @returns true if both vectors are equals
  88323. */
  88324. equalsToFloats(x: number, y: number, z: number): boolean;
  88325. /**
  88326. * Multiplies the current Vector3 coordinates by the given ones
  88327. * @param otherVector defines the second operand
  88328. * @returns the current updated Vector3
  88329. */
  88330. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88331. /**
  88332. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  88333. * @param otherVector defines the second operand
  88334. * @returns the new Vector3
  88335. */
  88336. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  88337. /**
  88338. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  88339. * @param otherVector defines the second operand
  88340. * @param result defines the Vector3 object where to store the result
  88341. * @returns the current Vector3
  88342. */
  88343. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88344. /**
  88345. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  88346. * @param x defines the x coordinate of the operand
  88347. * @param y defines the y coordinate of the operand
  88348. * @param z defines the z coordinate of the operand
  88349. * @returns the new Vector3
  88350. */
  88351. multiplyByFloats(x: number, y: number, z: number): Vector3;
  88352. /**
  88353. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  88354. * @param otherVector defines the second operand
  88355. * @returns the new Vector3
  88356. */
  88357. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  88358. /**
  88359. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  88360. * @param otherVector defines the second operand
  88361. * @param result defines the Vector3 object where to store the result
  88362. * @returns the current Vector3
  88363. */
  88364. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88365. /**
  88366. * Divides the current Vector3 coordinates by the given ones.
  88367. * @param otherVector defines the second operand
  88368. * @returns the current updated Vector3
  88369. */
  88370. divideInPlace(otherVector: Vector3): Vector3;
  88371. /**
  88372. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  88373. * @param other defines the second operand
  88374. * @returns the current updated Vector3
  88375. */
  88376. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  88377. /**
  88378. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  88379. * @param other defines the second operand
  88380. * @returns the current updated Vector3
  88381. */
  88382. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  88383. /**
  88384. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  88385. * @param x defines the x coordinate of the operand
  88386. * @param y defines the y coordinate of the operand
  88387. * @param z defines the z coordinate of the operand
  88388. * @returns the current updated Vector3
  88389. */
  88390. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88391. /**
  88392. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  88393. * @param x defines the x coordinate of the operand
  88394. * @param y defines the y coordinate of the operand
  88395. * @param z defines the z coordinate of the operand
  88396. * @returns the current updated Vector3
  88397. */
  88398. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88399. /**
  88400. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  88401. * Check if is non uniform within a certain amount of decimal places to account for this
  88402. * @param epsilon the amount the values can differ
  88403. * @returns if the the vector is non uniform to a certain number of decimal places
  88404. */
  88405. isNonUniformWithinEpsilon(epsilon: number): boolean;
  88406. /**
  88407. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  88408. */
  88409. get isNonUniform(): boolean;
  88410. /**
  88411. * Gets a new Vector3 from current Vector3 floored values
  88412. * @returns a new Vector3
  88413. */
  88414. floor(): Vector3;
  88415. /**
  88416. * Gets a new Vector3 from current Vector3 floored values
  88417. * @returns a new Vector3
  88418. */
  88419. fract(): Vector3;
  88420. /**
  88421. * Gets the length of the Vector3
  88422. * @returns the length of the Vector3
  88423. */
  88424. length(): number;
  88425. /**
  88426. * Gets the squared length of the Vector3
  88427. * @returns squared length of the Vector3
  88428. */
  88429. lengthSquared(): number;
  88430. /**
  88431. * Normalize the current Vector3.
  88432. * Please note that this is an in place operation.
  88433. * @returns the current updated Vector3
  88434. */
  88435. normalize(): Vector3;
  88436. /**
  88437. * Reorders the x y z properties of the vector in place
  88438. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  88439. * @returns the current updated vector
  88440. */
  88441. reorderInPlace(order: string): this;
  88442. /**
  88443. * Rotates the vector around 0,0,0 by a quaternion
  88444. * @param quaternion the rotation quaternion
  88445. * @param result vector to store the result
  88446. * @returns the resulting vector
  88447. */
  88448. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  88449. /**
  88450. * Rotates a vector around a given point
  88451. * @param quaternion the rotation quaternion
  88452. * @param point the point to rotate around
  88453. * @param result vector to store the result
  88454. * @returns the resulting vector
  88455. */
  88456. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  88457. /**
  88458. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  88459. * The cross product is then orthogonal to both current and "other"
  88460. * @param other defines the right operand
  88461. * @returns the cross product
  88462. */
  88463. cross(other: Vector3): Vector3;
  88464. /**
  88465. * Normalize the current Vector3 with the given input length.
  88466. * Please note that this is an in place operation.
  88467. * @param len the length of the vector
  88468. * @returns the current updated Vector3
  88469. */
  88470. normalizeFromLength(len: number): Vector3;
  88471. /**
  88472. * Normalize the current Vector3 to a new vector
  88473. * @returns the new Vector3
  88474. */
  88475. normalizeToNew(): Vector3;
  88476. /**
  88477. * Normalize the current Vector3 to the reference
  88478. * @param reference define the Vector3 to update
  88479. * @returns the updated Vector3
  88480. */
  88481. normalizeToRef(reference: Vector3): Vector3;
  88482. /**
  88483. * Creates a new Vector3 copied from the current Vector3
  88484. * @returns the new Vector3
  88485. */
  88486. clone(): Vector3;
  88487. /**
  88488. * Copies the given vector coordinates to the current Vector3 ones
  88489. * @param source defines the source Vector3
  88490. * @returns the current updated Vector3
  88491. */
  88492. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  88493. /**
  88494. * Copies the given floats to the current Vector3 coordinates
  88495. * @param x defines the x coordinate of the operand
  88496. * @param y defines the y coordinate of the operand
  88497. * @param z defines the z coordinate of the operand
  88498. * @returns the current updated Vector3
  88499. */
  88500. copyFromFloats(x: number, y: number, z: number): Vector3;
  88501. /**
  88502. * Copies the given floats to the current Vector3 coordinates
  88503. * @param x defines the x coordinate of the operand
  88504. * @param y defines the y coordinate of the operand
  88505. * @param z defines the z coordinate of the operand
  88506. * @returns the current updated Vector3
  88507. */
  88508. set(x: number, y: number, z: number): Vector3;
  88509. /**
  88510. * Copies the given float to the current Vector3 coordinates
  88511. * @param v defines the x, y and z coordinates of the operand
  88512. * @returns the current updated Vector3
  88513. */
  88514. setAll(v: number): Vector3;
  88515. /**
  88516. * Get the clip factor between two vectors
  88517. * @param vector0 defines the first operand
  88518. * @param vector1 defines the second operand
  88519. * @param axis defines the axis to use
  88520. * @param size defines the size along the axis
  88521. * @returns the clip factor
  88522. */
  88523. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  88524. /**
  88525. * Get angle between two vectors
  88526. * @param vector0 angle between vector0 and vector1
  88527. * @param vector1 angle between vector0 and vector1
  88528. * @param normal direction of the normal
  88529. * @return the angle between vector0 and vector1
  88530. */
  88531. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  88532. /**
  88533. * Returns a new Vector3 set from the index "offset" of the given array
  88534. * @param array defines the source array
  88535. * @param offset defines the offset in the source array
  88536. * @returns the new Vector3
  88537. */
  88538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  88539. /**
  88540. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  88541. * @param array defines the source array
  88542. * @param offset defines the offset in the source array
  88543. * @returns the new Vector3
  88544. * @deprecated Please use FromArray instead.
  88545. */
  88546. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  88547. /**
  88548. * Sets the given vector "result" with the element values from the index "offset" of the given array
  88549. * @param array defines the source array
  88550. * @param offset defines the offset in the source array
  88551. * @param result defines the Vector3 where to store the result
  88552. */
  88553. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  88554. /**
  88555. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  88556. * @param array defines the source array
  88557. * @param offset defines the offset in the source array
  88558. * @param result defines the Vector3 where to store the result
  88559. * @deprecated Please use FromArrayToRef instead.
  88560. */
  88561. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  88562. /**
  88563. * Sets the given vector "result" with the given floats.
  88564. * @param x defines the x coordinate of the source
  88565. * @param y defines the y coordinate of the source
  88566. * @param z defines the z coordinate of the source
  88567. * @param result defines the Vector3 where to store the result
  88568. */
  88569. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  88570. /**
  88571. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  88572. * @returns a new empty Vector3
  88573. */
  88574. static Zero(): Vector3;
  88575. /**
  88576. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  88577. * @returns a new unit Vector3
  88578. */
  88579. static One(): Vector3;
  88580. /**
  88581. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  88582. * @returns a new up Vector3
  88583. */
  88584. static Up(): Vector3;
  88585. /**
  88586. * Gets a up Vector3 that must not be updated
  88587. */
  88588. static get UpReadOnly(): DeepImmutable<Vector3>;
  88589. /**
  88590. * Gets a zero Vector3 that must not be updated
  88591. */
  88592. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  88593. /**
  88594. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  88595. * @returns a new down Vector3
  88596. */
  88597. static Down(): Vector3;
  88598. /**
  88599. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  88600. * @param rightHandedSystem is the scene right-handed (negative z)
  88601. * @returns a new forward Vector3
  88602. */
  88603. static Forward(rightHandedSystem?: boolean): Vector3;
  88604. /**
  88605. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  88606. * @param rightHandedSystem is the scene right-handed (negative-z)
  88607. * @returns a new forward Vector3
  88608. */
  88609. static Backward(rightHandedSystem?: boolean): Vector3;
  88610. /**
  88611. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  88612. * @returns a new right Vector3
  88613. */
  88614. static Right(): Vector3;
  88615. /**
  88616. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  88617. * @returns a new left Vector3
  88618. */
  88619. static Left(): Vector3;
  88620. /**
  88621. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  88622. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88623. * @param vector defines the Vector3 to transform
  88624. * @param transformation defines the transformation matrix
  88625. * @returns the transformed Vector3
  88626. */
  88627. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88628. /**
  88629. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  88630. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88631. * @param vector defines the Vector3 to transform
  88632. * @param transformation defines the transformation matrix
  88633. * @param result defines the Vector3 where to store the result
  88634. */
  88635. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88636. /**
  88637. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  88638. * This method computes tranformed coordinates only, not transformed direction vectors
  88639. * @param x define the x coordinate of the source vector
  88640. * @param y define the y coordinate of the source vector
  88641. * @param z define the z coordinate of the source vector
  88642. * @param transformation defines the transformation matrix
  88643. * @param result defines the Vector3 where to store the result
  88644. */
  88645. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88646. /**
  88647. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  88648. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88649. * @param vector defines the Vector3 to transform
  88650. * @param transformation defines the transformation matrix
  88651. * @returns the new Vector3
  88652. */
  88653. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88654. /**
  88655. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  88656. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88657. * @param vector defines the Vector3 to transform
  88658. * @param transformation defines the transformation matrix
  88659. * @param result defines the Vector3 where to store the result
  88660. */
  88661. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88662. /**
  88663. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  88664. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88665. * @param x define the x coordinate of the source vector
  88666. * @param y define the y coordinate of the source vector
  88667. * @param z define the z coordinate of the source vector
  88668. * @param transformation defines the transformation matrix
  88669. * @param result defines the Vector3 where to store the result
  88670. */
  88671. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88672. /**
  88673. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  88674. * @param value1 defines the first control point
  88675. * @param value2 defines the second control point
  88676. * @param value3 defines the third control point
  88677. * @param value4 defines the fourth control point
  88678. * @param amount defines the amount on the spline to use
  88679. * @returns the new Vector3
  88680. */
  88681. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  88682. /**
  88683. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  88684. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88685. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88686. * @param value defines the current value
  88687. * @param min defines the lower range value
  88688. * @param max defines the upper range value
  88689. * @returns the new Vector3
  88690. */
  88691. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  88692. /**
  88693. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  88694. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88695. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88696. * @param value defines the current value
  88697. * @param min defines the lower range value
  88698. * @param max defines the upper range value
  88699. * @param result defines the Vector3 where to store the result
  88700. */
  88701. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  88702. /**
  88703. * Checks if a given vector is inside a specific range
  88704. * @param v defines the vector to test
  88705. * @param min defines the minimum range
  88706. * @param max defines the maximum range
  88707. */
  88708. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88709. /**
  88710. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  88711. * @param value1 defines the first control point
  88712. * @param tangent1 defines the first tangent vector
  88713. * @param value2 defines the second control point
  88714. * @param tangent2 defines the second tangent vector
  88715. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  88716. * @returns the new Vector3
  88717. */
  88718. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  88719. /**
  88720. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  88721. * @param start defines the start value
  88722. * @param end defines the end value
  88723. * @param amount max defines amount between both (between 0 and 1)
  88724. * @returns the new Vector3
  88725. */
  88726. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  88727. /**
  88728. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  88729. * @param start defines the start value
  88730. * @param end defines the end value
  88731. * @param amount max defines amount between both (between 0 and 1)
  88732. * @param result defines the Vector3 where to store the result
  88733. */
  88734. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  88735. /**
  88736. * Returns the dot product (float) between the vectors "left" and "right"
  88737. * @param left defines the left operand
  88738. * @param right defines the right operand
  88739. * @returns the dot product
  88740. */
  88741. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  88742. /**
  88743. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  88744. * The cross product is then orthogonal to both "left" and "right"
  88745. * @param left defines the left operand
  88746. * @param right defines the right operand
  88747. * @returns the cross product
  88748. */
  88749. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88750. /**
  88751. * Sets the given vector "result" with the cross product of "left" and "right"
  88752. * The cross product is then orthogonal to both "left" and "right"
  88753. * @param left defines the left operand
  88754. * @param right defines the right operand
  88755. * @param result defines the Vector3 where to store the result
  88756. */
  88757. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  88758. /**
  88759. * Returns a new Vector3 as the normalization of the given vector
  88760. * @param vector defines the Vector3 to normalize
  88761. * @returns the new Vector3
  88762. */
  88763. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  88764. /**
  88765. * Sets the given vector "result" with the normalization of the given first vector
  88766. * @param vector defines the Vector3 to normalize
  88767. * @param result defines the Vector3 where to store the result
  88768. */
  88769. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  88770. /**
  88771. * Project a Vector3 onto screen space
  88772. * @param vector defines the Vector3 to project
  88773. * @param world defines the world matrix to use
  88774. * @param transform defines the transform (view x projection) matrix to use
  88775. * @param viewport defines the screen viewport to use
  88776. * @returns the new Vector3
  88777. */
  88778. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  88779. /**
  88780. * Project a Vector3 onto screen space to reference
  88781. * @param vector defines the Vector3 to project
  88782. * @param world defines the world matrix to use
  88783. * @param transform defines the transform (view x projection) matrix to use
  88784. * @param viewport defines the screen viewport to use
  88785. * @param result the vector in which the screen space will be stored
  88786. * @returns the new Vector3
  88787. */
  88788. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  88789. /** @hidden */
  88790. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  88791. /**
  88792. * Unproject from screen space to object space
  88793. * @param source defines the screen space Vector3 to use
  88794. * @param viewportWidth defines the current width of the viewport
  88795. * @param viewportHeight defines the current height of the viewport
  88796. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88797. * @param transform defines the transform (view x projection) matrix to use
  88798. * @returns the new Vector3
  88799. */
  88800. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  88801. /**
  88802. * Unproject from screen space to object space
  88803. * @param source defines the screen space Vector3 to use
  88804. * @param viewportWidth defines the current width of the viewport
  88805. * @param viewportHeight defines the current height of the viewport
  88806. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88807. * @param view defines the view matrix to use
  88808. * @param projection defines the projection matrix to use
  88809. * @returns the new Vector3
  88810. */
  88811. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  88812. /**
  88813. * Unproject from screen space to object space
  88814. * @param source defines the screen space Vector3 to use
  88815. * @param viewportWidth defines the current width of the viewport
  88816. * @param viewportHeight defines the current height of the viewport
  88817. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88818. * @param view defines the view matrix to use
  88819. * @param projection defines the projection matrix to use
  88820. * @param result defines the Vector3 where to store the result
  88821. */
  88822. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88823. /**
  88824. * Unproject from screen space to object space
  88825. * @param sourceX defines the screen space x coordinate to use
  88826. * @param sourceY defines the screen space y coordinate to use
  88827. * @param sourceZ defines the screen space z coordinate to use
  88828. * @param viewportWidth defines the current width of the viewport
  88829. * @param viewportHeight defines the current height of the viewport
  88830. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88831. * @param view defines the view matrix to use
  88832. * @param projection defines the projection matrix to use
  88833. * @param result defines the Vector3 where to store the result
  88834. */
  88835. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88836. /**
  88837. * Gets the minimal coordinate values between two Vector3
  88838. * @param left defines the first operand
  88839. * @param right defines the second operand
  88840. * @returns the new Vector3
  88841. */
  88842. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88843. /**
  88844. * Gets the maximal coordinate values between two Vector3
  88845. * @param left defines the first operand
  88846. * @param right defines the second operand
  88847. * @returns the new Vector3
  88848. */
  88849. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88850. /**
  88851. * Returns the distance between the vectors "value1" and "value2"
  88852. * @param value1 defines the first operand
  88853. * @param value2 defines the second operand
  88854. * @returns the distance
  88855. */
  88856. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88857. /**
  88858. * Returns the squared distance between the vectors "value1" and "value2"
  88859. * @param value1 defines the first operand
  88860. * @param value2 defines the second operand
  88861. * @returns the squared distance
  88862. */
  88863. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88864. /**
  88865. * Returns a new Vector3 located at the center between "value1" and "value2"
  88866. * @param value1 defines the first operand
  88867. * @param value2 defines the second operand
  88868. * @returns the new Vector3
  88869. */
  88870. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  88871. /**
  88872. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88873. * @param value1 defines first vector
  88874. * @param value2 defines second vector
  88875. * @param ref defines third vector
  88876. * @returns ref
  88877. */
  88878. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  88879. /**
  88880. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  88881. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  88882. * to something in order to rotate it from its local system to the given target system
  88883. * Note: axis1, axis2 and axis3 are normalized during this operation
  88884. * @param axis1 defines the first axis
  88885. * @param axis2 defines the second axis
  88886. * @param axis3 defines the third axis
  88887. * @returns a new Vector3
  88888. */
  88889. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  88890. /**
  88891. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  88892. * @param axis1 defines the first axis
  88893. * @param axis2 defines the second axis
  88894. * @param axis3 defines the third axis
  88895. * @param ref defines the Vector3 where to store the result
  88896. */
  88897. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  88898. }
  88899. /**
  88900. * Vector4 class created for EulerAngle class conversion to Quaternion
  88901. */
  88902. export class Vector4 {
  88903. /** x value of the vector */
  88904. x: number;
  88905. /** y value of the vector */
  88906. y: number;
  88907. /** z value of the vector */
  88908. z: number;
  88909. /** w value of the vector */
  88910. w: number;
  88911. /**
  88912. * Creates a Vector4 object from the given floats.
  88913. * @param x x value of the vector
  88914. * @param y y value of the vector
  88915. * @param z z value of the vector
  88916. * @param w w value of the vector
  88917. */
  88918. constructor(
  88919. /** x value of the vector */
  88920. x: number,
  88921. /** y value of the vector */
  88922. y: number,
  88923. /** z value of the vector */
  88924. z: number,
  88925. /** w value of the vector */
  88926. w: number);
  88927. /**
  88928. * Returns the string with the Vector4 coordinates.
  88929. * @returns a string containing all the vector values
  88930. */
  88931. toString(): string;
  88932. /**
  88933. * Returns the string "Vector4".
  88934. * @returns "Vector4"
  88935. */
  88936. getClassName(): string;
  88937. /**
  88938. * Returns the Vector4 hash code.
  88939. * @returns a unique hash code
  88940. */
  88941. getHashCode(): number;
  88942. /**
  88943. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  88944. * @returns the resulting array
  88945. */
  88946. asArray(): number[];
  88947. /**
  88948. * Populates the given array from the given index with the Vector4 coordinates.
  88949. * @param array array to populate
  88950. * @param index index of the array to start at (default: 0)
  88951. * @returns the Vector4.
  88952. */
  88953. toArray(array: FloatArray, index?: number): Vector4;
  88954. /**
  88955. * Update the current vector from an array
  88956. * @param array defines the destination array
  88957. * @param index defines the offset in the destination array
  88958. * @returns the current Vector3
  88959. */
  88960. fromArray(array: FloatArray, index?: number): Vector4;
  88961. /**
  88962. * Adds the given vector to the current Vector4.
  88963. * @param otherVector the vector to add
  88964. * @returns the updated Vector4.
  88965. */
  88966. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88967. /**
  88968. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  88969. * @param otherVector the vector to add
  88970. * @returns the resulting vector
  88971. */
  88972. add(otherVector: DeepImmutable<Vector4>): Vector4;
  88973. /**
  88974. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  88975. * @param otherVector the vector to add
  88976. * @param result the vector to store the result
  88977. * @returns the current Vector4.
  88978. */
  88979. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88980. /**
  88981. * Subtract in place the given vector from the current Vector4.
  88982. * @param otherVector the vector to subtract
  88983. * @returns the updated Vector4.
  88984. */
  88985. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88986. /**
  88987. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  88988. * @param otherVector the vector to add
  88989. * @returns the new vector with the result
  88990. */
  88991. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  88992. /**
  88993. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  88994. * @param otherVector the vector to subtract
  88995. * @param result the vector to store the result
  88996. * @returns the current Vector4.
  88997. */
  88998. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88999. /**
  89000. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  89001. */
  89002. /**
  89003. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  89004. * @param x value to subtract
  89005. * @param y value to subtract
  89006. * @param z value to subtract
  89007. * @param w value to subtract
  89008. * @returns new vector containing the result
  89009. */
  89010. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  89011. /**
  89012. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  89013. * @param x value to subtract
  89014. * @param y value to subtract
  89015. * @param z value to subtract
  89016. * @param w value to subtract
  89017. * @param result the vector to store the result in
  89018. * @returns the current Vector4.
  89019. */
  89020. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  89021. /**
  89022. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  89023. * @returns a new vector with the negated values
  89024. */
  89025. negate(): Vector4;
  89026. /**
  89027. * Negate this vector in place
  89028. * @returns this
  89029. */
  89030. negateInPlace(): Vector4;
  89031. /**
  89032. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  89033. * @param result defines the Vector3 object where to store the result
  89034. * @returns the current Vector4
  89035. */
  89036. negateToRef(result: Vector4): Vector4;
  89037. /**
  89038. * Multiplies the current Vector4 coordinates by scale (float).
  89039. * @param scale the number to scale with
  89040. * @returns the updated Vector4.
  89041. */
  89042. scaleInPlace(scale: number): Vector4;
  89043. /**
  89044. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  89045. * @param scale the number to scale with
  89046. * @returns a new vector with the result
  89047. */
  89048. scale(scale: number): Vector4;
  89049. /**
  89050. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  89051. * @param scale the number to scale with
  89052. * @param result a vector to store the result in
  89053. * @returns the current Vector4.
  89054. */
  89055. scaleToRef(scale: number, result: Vector4): Vector4;
  89056. /**
  89057. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  89058. * @param scale defines the scale factor
  89059. * @param result defines the Vector4 object where to store the result
  89060. * @returns the unmodified current Vector4
  89061. */
  89062. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  89063. /**
  89064. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  89065. * @param otherVector the vector to compare against
  89066. * @returns true if they are equal
  89067. */
  89068. equals(otherVector: DeepImmutable<Vector4>): boolean;
  89069. /**
  89070. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  89071. * @param otherVector vector to compare against
  89072. * @param epsilon (Default: very small number)
  89073. * @returns true if they are equal
  89074. */
  89075. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  89076. /**
  89077. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  89078. * @param x x value to compare against
  89079. * @param y y value to compare against
  89080. * @param z z value to compare against
  89081. * @param w w value to compare against
  89082. * @returns true if equal
  89083. */
  89084. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  89085. /**
  89086. * Multiplies in place the current Vector4 by the given one.
  89087. * @param otherVector vector to multiple with
  89088. * @returns the updated Vector4.
  89089. */
  89090. multiplyInPlace(otherVector: Vector4): Vector4;
  89091. /**
  89092. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  89093. * @param otherVector vector to multiple with
  89094. * @returns resulting new vector
  89095. */
  89096. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  89097. /**
  89098. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  89099. * @param otherVector vector to multiple with
  89100. * @param result vector to store the result
  89101. * @returns the current Vector4.
  89102. */
  89103. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  89104. /**
  89105. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  89106. * @param x x value multiply with
  89107. * @param y y value multiply with
  89108. * @param z z value multiply with
  89109. * @param w w value multiply with
  89110. * @returns resulting new vector
  89111. */
  89112. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  89113. /**
  89114. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  89115. * @param otherVector vector to devide with
  89116. * @returns resulting new vector
  89117. */
  89118. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  89119. /**
  89120. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  89121. * @param otherVector vector to devide with
  89122. * @param result vector to store the result
  89123. * @returns the current Vector4.
  89124. */
  89125. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  89126. /**
  89127. * Divides the current Vector3 coordinates by the given ones.
  89128. * @param otherVector vector to devide with
  89129. * @returns the updated Vector3.
  89130. */
  89131. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  89132. /**
  89133. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  89134. * @param other defines the second operand
  89135. * @returns the current updated Vector4
  89136. */
  89137. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  89138. /**
  89139. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  89140. * @param other defines the second operand
  89141. * @returns the current updated Vector4
  89142. */
  89143. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  89144. /**
  89145. * Gets a new Vector4 from current Vector4 floored values
  89146. * @returns a new Vector4
  89147. */
  89148. floor(): Vector4;
  89149. /**
  89150. * Gets a new Vector4 from current Vector3 floored values
  89151. * @returns a new Vector4
  89152. */
  89153. fract(): Vector4;
  89154. /**
  89155. * Returns the Vector4 length (float).
  89156. * @returns the length
  89157. */
  89158. length(): number;
  89159. /**
  89160. * Returns the Vector4 squared length (float).
  89161. * @returns the length squared
  89162. */
  89163. lengthSquared(): number;
  89164. /**
  89165. * Normalizes in place the Vector4.
  89166. * @returns the updated Vector4.
  89167. */
  89168. normalize(): Vector4;
  89169. /**
  89170. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  89171. * @returns this converted to a new vector3
  89172. */
  89173. toVector3(): Vector3;
  89174. /**
  89175. * Returns a new Vector4 copied from the current one.
  89176. * @returns the new cloned vector
  89177. */
  89178. clone(): Vector4;
  89179. /**
  89180. * Updates the current Vector4 with the given one coordinates.
  89181. * @param source the source vector to copy from
  89182. * @returns the updated Vector4.
  89183. */
  89184. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  89185. /**
  89186. * Updates the current Vector4 coordinates with the given floats.
  89187. * @param x float to copy from
  89188. * @param y float to copy from
  89189. * @param z float to copy from
  89190. * @param w float to copy from
  89191. * @returns the updated Vector4.
  89192. */
  89193. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  89194. /**
  89195. * Updates the current Vector4 coordinates with the given floats.
  89196. * @param x float to set from
  89197. * @param y float to set from
  89198. * @param z float to set from
  89199. * @param w float to set from
  89200. * @returns the updated Vector4.
  89201. */
  89202. set(x: number, y: number, z: number, w: number): Vector4;
  89203. /**
  89204. * Copies the given float to the current Vector3 coordinates
  89205. * @param v defines the x, y, z and w coordinates of the operand
  89206. * @returns the current updated Vector3
  89207. */
  89208. setAll(v: number): Vector4;
  89209. /**
  89210. * Returns a new Vector4 set from the starting index of the given array.
  89211. * @param array the array to pull values from
  89212. * @param offset the offset into the array to start at
  89213. * @returns the new vector
  89214. */
  89215. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  89216. /**
  89217. * Updates the given vector "result" from the starting index of the given array.
  89218. * @param array the array to pull values from
  89219. * @param offset the offset into the array to start at
  89220. * @param result the vector to store the result in
  89221. */
  89222. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  89223. /**
  89224. * Updates the given vector "result" from the starting index of the given Float32Array.
  89225. * @param array the array to pull values from
  89226. * @param offset the offset into the array to start at
  89227. * @param result the vector to store the result in
  89228. */
  89229. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  89230. /**
  89231. * Updates the given vector "result" coordinates from the given floats.
  89232. * @param x float to set from
  89233. * @param y float to set from
  89234. * @param z float to set from
  89235. * @param w float to set from
  89236. * @param result the vector to the floats in
  89237. */
  89238. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  89239. /**
  89240. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  89241. * @returns the new vector
  89242. */
  89243. static Zero(): Vector4;
  89244. /**
  89245. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  89246. * @returns the new vector
  89247. */
  89248. static One(): Vector4;
  89249. /**
  89250. * Returns a new normalized Vector4 from the given one.
  89251. * @param vector the vector to normalize
  89252. * @returns the vector
  89253. */
  89254. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  89255. /**
  89256. * Updates the given vector "result" from the normalization of the given one.
  89257. * @param vector the vector to normalize
  89258. * @param result the vector to store the result in
  89259. */
  89260. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  89261. /**
  89262. * Returns a vector with the minimum values from the left and right vectors
  89263. * @param left left vector to minimize
  89264. * @param right right vector to minimize
  89265. * @returns a new vector with the minimum of the left and right vector values
  89266. */
  89267. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  89268. /**
  89269. * Returns a vector with the maximum values from the left and right vectors
  89270. * @param left left vector to maximize
  89271. * @param right right vector to maximize
  89272. * @returns a new vector with the maximum of the left and right vector values
  89273. */
  89274. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  89275. /**
  89276. * Returns the distance (float) between the vectors "value1" and "value2".
  89277. * @param value1 value to calulate the distance between
  89278. * @param value2 value to calulate the distance between
  89279. * @return the distance between the two vectors
  89280. */
  89281. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  89282. /**
  89283. * Returns the squared distance (float) between the vectors "value1" and "value2".
  89284. * @param value1 value to calulate the distance between
  89285. * @param value2 value to calulate the distance between
  89286. * @return the distance between the two vectors squared
  89287. */
  89288. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  89289. /**
  89290. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  89291. * @param value1 value to calulate the center between
  89292. * @param value2 value to calulate the center between
  89293. * @return the center between the two vectors
  89294. */
  89295. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  89296. /**
  89297. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  89298. * @param value1 defines first vector
  89299. * @param value2 defines second vector
  89300. * @param ref defines third vector
  89301. * @returns ref
  89302. */
  89303. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  89304. /**
  89305. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  89306. * This methods computes transformed normalized direction vectors only.
  89307. * @param vector the vector to transform
  89308. * @param transformation the transformation matrix to apply
  89309. * @returns the new vector
  89310. */
  89311. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  89312. /**
  89313. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  89314. * This methods computes transformed normalized direction vectors only.
  89315. * @param vector the vector to transform
  89316. * @param transformation the transformation matrix to apply
  89317. * @param result the vector to store the result in
  89318. */
  89319. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  89320. /**
  89321. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  89322. * This methods computes transformed normalized direction vectors only.
  89323. * @param x value to transform
  89324. * @param y value to transform
  89325. * @param z value to transform
  89326. * @param w value to transform
  89327. * @param transformation the transformation matrix to apply
  89328. * @param result the vector to store the results in
  89329. */
  89330. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  89331. /**
  89332. * Creates a new Vector4 from a Vector3
  89333. * @param source defines the source data
  89334. * @param w defines the 4th component (default is 0)
  89335. * @returns a new Vector4
  89336. */
  89337. static FromVector3(source: Vector3, w?: number): Vector4;
  89338. }
  89339. /**
  89340. * Class used to store quaternion data
  89341. * @see https://en.wikipedia.org/wiki/Quaternion
  89342. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  89343. */
  89344. export class Quaternion {
  89345. /** @hidden */
  89346. _x: number;
  89347. /** @hidden */
  89348. _y: number;
  89349. /** @hidden */
  89350. _z: number;
  89351. /** @hidden */
  89352. _w: number;
  89353. /** @hidden */
  89354. _isDirty: boolean;
  89355. /** Gets or sets the x coordinate */
  89356. get x(): number;
  89357. set x(value: number);
  89358. /** Gets or sets the y coordinate */
  89359. get y(): number;
  89360. set y(value: number);
  89361. /** Gets or sets the z coordinate */
  89362. get z(): number;
  89363. set z(value: number);
  89364. /** Gets or sets the w coordinate */
  89365. get w(): number;
  89366. set w(value: number);
  89367. /**
  89368. * Creates a new Quaternion from the given floats
  89369. * @param x defines the first component (0 by default)
  89370. * @param y defines the second component (0 by default)
  89371. * @param z defines the third component (0 by default)
  89372. * @param w defines the fourth component (1.0 by default)
  89373. */
  89374. constructor(x?: number, y?: number, z?: number, w?: number);
  89375. /**
  89376. * Gets a string representation for the current quaternion
  89377. * @returns a string with the Quaternion coordinates
  89378. */
  89379. toString(): string;
  89380. /**
  89381. * Gets the class name of the quaternion
  89382. * @returns the string "Quaternion"
  89383. */
  89384. getClassName(): string;
  89385. /**
  89386. * Gets a hash code for this quaternion
  89387. * @returns the quaternion hash code
  89388. */
  89389. getHashCode(): number;
  89390. /**
  89391. * Copy the quaternion to an array
  89392. * @returns a new array populated with 4 elements from the quaternion coordinates
  89393. */
  89394. asArray(): number[];
  89395. /**
  89396. * Check if two quaternions are equals
  89397. * @param otherQuaternion defines the second operand
  89398. * @return true if the current quaternion and the given one coordinates are strictly equals
  89399. */
  89400. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  89401. /**
  89402. * Gets a boolean if two quaternions are equals (using an epsilon value)
  89403. * @param otherQuaternion defines the other quaternion
  89404. * @param epsilon defines the minimal distance to consider equality
  89405. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  89406. */
  89407. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  89408. /**
  89409. * Clone the current quaternion
  89410. * @returns a new quaternion copied from the current one
  89411. */
  89412. clone(): Quaternion;
  89413. /**
  89414. * Copy a quaternion to the current one
  89415. * @param other defines the other quaternion
  89416. * @returns the updated current quaternion
  89417. */
  89418. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  89419. /**
  89420. * Updates the current quaternion with the given float coordinates
  89421. * @param x defines the x coordinate
  89422. * @param y defines the y coordinate
  89423. * @param z defines the z coordinate
  89424. * @param w defines the w coordinate
  89425. * @returns the updated current quaternion
  89426. */
  89427. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  89428. /**
  89429. * Updates the current quaternion from the given float coordinates
  89430. * @param x defines the x coordinate
  89431. * @param y defines the y coordinate
  89432. * @param z defines the z coordinate
  89433. * @param w defines the w coordinate
  89434. * @returns the updated current quaternion
  89435. */
  89436. set(x: number, y: number, z: number, w: number): Quaternion;
  89437. /**
  89438. * Adds two quaternions
  89439. * @param other defines the second operand
  89440. * @returns a new quaternion as the addition result of the given one and the current quaternion
  89441. */
  89442. add(other: DeepImmutable<Quaternion>): Quaternion;
  89443. /**
  89444. * Add a quaternion to the current one
  89445. * @param other defines the quaternion to add
  89446. * @returns the current quaternion
  89447. */
  89448. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  89449. /**
  89450. * Subtract two quaternions
  89451. * @param other defines the second operand
  89452. * @returns a new quaternion as the subtraction result of the given one from the current one
  89453. */
  89454. subtract(other: Quaternion): Quaternion;
  89455. /**
  89456. * Multiplies the current quaternion by a scale factor
  89457. * @param value defines the scale factor
  89458. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  89459. */
  89460. scale(value: number): Quaternion;
  89461. /**
  89462. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  89463. * @param scale defines the scale factor
  89464. * @param result defines the Quaternion object where to store the result
  89465. * @returns the unmodified current quaternion
  89466. */
  89467. scaleToRef(scale: number, result: Quaternion): Quaternion;
  89468. /**
  89469. * Multiplies in place the current quaternion by a scale factor
  89470. * @param value defines the scale factor
  89471. * @returns the current modified quaternion
  89472. */
  89473. scaleInPlace(value: number): Quaternion;
  89474. /**
  89475. * Scale the current quaternion values by a factor and add the result to a given quaternion
  89476. * @param scale defines the scale factor
  89477. * @param result defines the Quaternion object where to store the result
  89478. * @returns the unmodified current quaternion
  89479. */
  89480. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  89481. /**
  89482. * Multiplies two quaternions
  89483. * @param q1 defines the second operand
  89484. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  89485. */
  89486. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  89487. /**
  89488. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  89489. * @param q1 defines the second operand
  89490. * @param result defines the target quaternion
  89491. * @returns the current quaternion
  89492. */
  89493. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  89494. /**
  89495. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  89496. * @param q1 defines the second operand
  89497. * @returns the currentupdated quaternion
  89498. */
  89499. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  89500. /**
  89501. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  89502. * @param ref defines the target quaternion
  89503. * @returns the current quaternion
  89504. */
  89505. conjugateToRef(ref: Quaternion): Quaternion;
  89506. /**
  89507. * Conjugates in place (1-q) the current quaternion
  89508. * @returns the current updated quaternion
  89509. */
  89510. conjugateInPlace(): Quaternion;
  89511. /**
  89512. * Conjugates in place (1-q) the current quaternion
  89513. * @returns a new quaternion
  89514. */
  89515. conjugate(): Quaternion;
  89516. /**
  89517. * Gets length of current quaternion
  89518. * @returns the quaternion length (float)
  89519. */
  89520. length(): number;
  89521. /**
  89522. * Normalize in place the current quaternion
  89523. * @returns the current updated quaternion
  89524. */
  89525. normalize(): Quaternion;
  89526. /**
  89527. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  89528. * @param order is a reserved parameter and is ignored for now
  89529. * @returns a new Vector3 containing the Euler angles
  89530. */
  89531. toEulerAngles(order?: string): Vector3;
  89532. /**
  89533. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  89534. * @param result defines the vector which will be filled with the Euler angles
  89535. * @returns the current unchanged quaternion
  89536. */
  89537. toEulerAnglesToRef(result: Vector3): Quaternion;
  89538. /**
  89539. * Updates the given rotation matrix with the current quaternion values
  89540. * @param result defines the target matrix
  89541. * @returns the current unchanged quaternion
  89542. */
  89543. toRotationMatrix(result: Matrix): Quaternion;
  89544. /**
  89545. * Updates the current quaternion from the given rotation matrix values
  89546. * @param matrix defines the source matrix
  89547. * @returns the current updated quaternion
  89548. */
  89549. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89550. /**
  89551. * Creates a new quaternion from a rotation matrix
  89552. * @param matrix defines the source matrix
  89553. * @returns a new quaternion created from the given rotation matrix values
  89554. */
  89555. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89556. /**
  89557. * Updates the given quaternion with the given rotation matrix values
  89558. * @param matrix defines the source matrix
  89559. * @param result defines the target quaternion
  89560. */
  89561. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  89562. /**
  89563. * Returns the dot product (float) between the quaternions "left" and "right"
  89564. * @param left defines the left operand
  89565. * @param right defines the right operand
  89566. * @returns the dot product
  89567. */
  89568. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  89569. /**
  89570. * Checks if the two quaternions are close to each other
  89571. * @param quat0 defines the first quaternion to check
  89572. * @param quat1 defines the second quaternion to check
  89573. * @returns true if the two quaternions are close to each other
  89574. */
  89575. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  89576. /**
  89577. * Creates an empty quaternion
  89578. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  89579. */
  89580. static Zero(): Quaternion;
  89581. /**
  89582. * Inverse a given quaternion
  89583. * @param q defines the source quaternion
  89584. * @returns a new quaternion as the inverted current quaternion
  89585. */
  89586. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  89587. /**
  89588. * Inverse a given quaternion
  89589. * @param q defines the source quaternion
  89590. * @param result the quaternion the result will be stored in
  89591. * @returns the result quaternion
  89592. */
  89593. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  89594. /**
  89595. * Creates an identity quaternion
  89596. * @returns the identity quaternion
  89597. */
  89598. static Identity(): Quaternion;
  89599. /**
  89600. * Gets a boolean indicating if the given quaternion is identity
  89601. * @param quaternion defines the quaternion to check
  89602. * @returns true if the quaternion is identity
  89603. */
  89604. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  89605. /**
  89606. * Creates a quaternion from a rotation around an axis
  89607. * @param axis defines the axis to use
  89608. * @param angle defines the angle to use
  89609. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  89610. */
  89611. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  89612. /**
  89613. * Creates a rotation around an axis and stores it into the given quaternion
  89614. * @param axis defines the axis to use
  89615. * @param angle defines the angle to use
  89616. * @param result defines the target quaternion
  89617. * @returns the target quaternion
  89618. */
  89619. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  89620. /**
  89621. * Creates a new quaternion from data stored into an array
  89622. * @param array defines the data source
  89623. * @param offset defines the offset in the source array where the data starts
  89624. * @returns a new quaternion
  89625. */
  89626. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  89627. /**
  89628. * Updates the given quaternion "result" from the starting index of the given array.
  89629. * @param array the array to pull values from
  89630. * @param offset the offset into the array to start at
  89631. * @param result the quaternion to store the result in
  89632. */
  89633. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  89634. /**
  89635. * Create a quaternion from Euler rotation angles
  89636. * @param x Pitch
  89637. * @param y Yaw
  89638. * @param z Roll
  89639. * @returns the new Quaternion
  89640. */
  89641. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  89642. /**
  89643. * Updates a quaternion from Euler rotation angles
  89644. * @param x Pitch
  89645. * @param y Yaw
  89646. * @param z Roll
  89647. * @param result the quaternion to store the result
  89648. * @returns the updated quaternion
  89649. */
  89650. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  89651. /**
  89652. * Create a quaternion from Euler rotation vector
  89653. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89654. * @returns the new Quaternion
  89655. */
  89656. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  89657. /**
  89658. * Updates a quaternion from Euler rotation vector
  89659. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89660. * @param result the quaternion to store the result
  89661. * @returns the updated quaternion
  89662. */
  89663. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  89664. /**
  89665. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  89666. * @param vecFrom defines the direction vector from which to rotate
  89667. * @param vecTo defines the direction vector to which to rotate
  89668. * @param result the quaternion to store the result
  89669. * @returns the updated quaternion
  89670. */
  89671. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  89672. /**
  89673. * Creates a new quaternion from the given Euler float angles (y, x, z)
  89674. * @param yaw defines the rotation around Y axis
  89675. * @param pitch defines the rotation around X axis
  89676. * @param roll defines the rotation around Z axis
  89677. * @returns the new quaternion
  89678. */
  89679. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  89680. /**
  89681. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  89682. * @param yaw defines the rotation around Y axis
  89683. * @param pitch defines the rotation around X axis
  89684. * @param roll defines the rotation around Z axis
  89685. * @param result defines the target quaternion
  89686. */
  89687. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  89688. /**
  89689. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  89690. * @param alpha defines the rotation around first axis
  89691. * @param beta defines the rotation around second axis
  89692. * @param gamma defines the rotation around third axis
  89693. * @returns the new quaternion
  89694. */
  89695. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  89696. /**
  89697. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  89698. * @param alpha defines the rotation around first axis
  89699. * @param beta defines the rotation around second axis
  89700. * @param gamma defines the rotation around third axis
  89701. * @param result defines the target quaternion
  89702. */
  89703. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  89704. /**
  89705. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  89706. * @param axis1 defines the first axis
  89707. * @param axis2 defines the second axis
  89708. * @param axis3 defines the third axis
  89709. * @returns the new quaternion
  89710. */
  89711. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  89712. /**
  89713. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  89714. * @param axis1 defines the first axis
  89715. * @param axis2 defines the second axis
  89716. * @param axis3 defines the third axis
  89717. * @param ref defines the target quaternion
  89718. */
  89719. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  89720. /**
  89721. * Interpolates between two quaternions
  89722. * @param left defines first quaternion
  89723. * @param right defines second quaternion
  89724. * @param amount defines the gradient to use
  89725. * @returns the new interpolated quaternion
  89726. */
  89727. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89728. /**
  89729. * Interpolates between two quaternions and stores it into a target quaternion
  89730. * @param left defines first quaternion
  89731. * @param right defines second quaternion
  89732. * @param amount defines the gradient to use
  89733. * @param result defines the target quaternion
  89734. */
  89735. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  89736. /**
  89737. * Interpolate between two quaternions using Hermite interpolation
  89738. * @param value1 defines first quaternion
  89739. * @param tangent1 defines the incoming tangent
  89740. * @param value2 defines second quaternion
  89741. * @param tangent2 defines the outgoing tangent
  89742. * @param amount defines the target quaternion
  89743. * @returns the new interpolated quaternion
  89744. */
  89745. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89746. }
  89747. /**
  89748. * Class used to store matrix data (4x4)
  89749. */
  89750. export class Matrix {
  89751. /**
  89752. * Gets the precision of matrix computations
  89753. */
  89754. static get Use64Bits(): boolean;
  89755. private static _updateFlagSeed;
  89756. private static _identityReadOnly;
  89757. private _isIdentity;
  89758. private _isIdentityDirty;
  89759. private _isIdentity3x2;
  89760. private _isIdentity3x2Dirty;
  89761. /**
  89762. * Gets the update flag of the matrix which is an unique number for the matrix.
  89763. * It will be incremented every time the matrix data change.
  89764. * You can use it to speed the comparison between two versions of the same matrix.
  89765. */
  89766. updateFlag: number;
  89767. private readonly _m;
  89768. /**
  89769. * Gets the internal data of the matrix
  89770. */
  89771. get m(): DeepImmutable<Float32Array | Array<number>>;
  89772. /** @hidden */
  89773. _markAsUpdated(): void;
  89774. /** @hidden */
  89775. private _updateIdentityStatus;
  89776. /**
  89777. * Creates an empty matrix (filled with zeros)
  89778. */
  89779. constructor();
  89780. /**
  89781. * Check if the current matrix is identity
  89782. * @returns true is the matrix is the identity matrix
  89783. */
  89784. isIdentity(): boolean;
  89785. /**
  89786. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  89787. * @returns true is the matrix is the identity matrix
  89788. */
  89789. isIdentityAs3x2(): boolean;
  89790. /**
  89791. * Gets the determinant of the matrix
  89792. * @returns the matrix determinant
  89793. */
  89794. determinant(): number;
  89795. /**
  89796. * Returns the matrix as a Float32Array or Array<number>
  89797. * @returns the matrix underlying array
  89798. */
  89799. toArray(): DeepImmutable<Float32Array | Array<number>>;
  89800. /**
  89801. * Returns the matrix as a Float32Array or Array<number>
  89802. * @returns the matrix underlying array.
  89803. */
  89804. asArray(): DeepImmutable<Float32Array | Array<number>>;
  89805. /**
  89806. * Inverts the current matrix in place
  89807. * @returns the current inverted matrix
  89808. */
  89809. invert(): Matrix;
  89810. /**
  89811. * Sets all the matrix elements to zero
  89812. * @returns the current matrix
  89813. */
  89814. reset(): Matrix;
  89815. /**
  89816. * Adds the current matrix with a second one
  89817. * @param other defines the matrix to add
  89818. * @returns a new matrix as the addition of the current matrix and the given one
  89819. */
  89820. add(other: DeepImmutable<Matrix>): Matrix;
  89821. /**
  89822. * Sets the given matrix "result" to the addition of the current matrix and the given one
  89823. * @param other defines the matrix to add
  89824. * @param result defines the target matrix
  89825. * @returns the current matrix
  89826. */
  89827. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89828. /**
  89829. * Adds in place the given matrix to the current matrix
  89830. * @param other defines the second operand
  89831. * @returns the current updated matrix
  89832. */
  89833. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  89834. /**
  89835. * Sets the given matrix to the current inverted Matrix
  89836. * @param other defines the target matrix
  89837. * @returns the unmodified current matrix
  89838. */
  89839. invertToRef(other: Matrix): Matrix;
  89840. /**
  89841. * add a value at the specified position in the current Matrix
  89842. * @param index the index of the value within the matrix. between 0 and 15.
  89843. * @param value the value to be added
  89844. * @returns the current updated matrix
  89845. */
  89846. addAtIndex(index: number, value: number): Matrix;
  89847. /**
  89848. * mutiply the specified position in the current Matrix by a value
  89849. * @param index the index of the value within the matrix. between 0 and 15.
  89850. * @param value the value to be added
  89851. * @returns the current updated matrix
  89852. */
  89853. multiplyAtIndex(index: number, value: number): Matrix;
  89854. /**
  89855. * Inserts the translation vector (using 3 floats) in the current matrix
  89856. * @param x defines the 1st component of the translation
  89857. * @param y defines the 2nd component of the translation
  89858. * @param z defines the 3rd component of the translation
  89859. * @returns the current updated matrix
  89860. */
  89861. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89862. /**
  89863. * Adds the translation vector (using 3 floats) in the current matrix
  89864. * @param x defines the 1st component of the translation
  89865. * @param y defines the 2nd component of the translation
  89866. * @param z defines the 3rd component of the translation
  89867. * @returns the current updated matrix
  89868. */
  89869. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89870. /**
  89871. * Inserts the translation vector in the current matrix
  89872. * @param vector3 defines the translation to insert
  89873. * @returns the current updated matrix
  89874. */
  89875. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  89876. /**
  89877. * Gets the translation value of the current matrix
  89878. * @returns a new Vector3 as the extracted translation from the matrix
  89879. */
  89880. getTranslation(): Vector3;
  89881. /**
  89882. * Fill a Vector3 with the extracted translation from the matrix
  89883. * @param result defines the Vector3 where to store the translation
  89884. * @returns the current matrix
  89885. */
  89886. getTranslationToRef(result: Vector3): Matrix;
  89887. /**
  89888. * Remove rotation and scaling part from the matrix
  89889. * @returns the updated matrix
  89890. */
  89891. removeRotationAndScaling(): Matrix;
  89892. /**
  89893. * Multiply two matrices
  89894. * @param other defines the second operand
  89895. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  89896. */
  89897. multiply(other: DeepImmutable<Matrix>): Matrix;
  89898. /**
  89899. * Copy the current matrix from the given one
  89900. * @param other defines the source matrix
  89901. * @returns the current updated matrix
  89902. */
  89903. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  89904. /**
  89905. * Populates the given array from the starting index with the current matrix values
  89906. * @param array defines the target array
  89907. * @param offset defines the offset in the target array where to start storing values
  89908. * @returns the current matrix
  89909. */
  89910. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  89911. /**
  89912. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  89913. * @param other defines the second operand
  89914. * @param result defines the matrix where to store the multiplication
  89915. * @returns the current matrix
  89916. */
  89917. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89918. /**
  89919. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  89920. * @param other defines the second operand
  89921. * @param result defines the array where to store the multiplication
  89922. * @param offset defines the offset in the target array where to start storing values
  89923. * @returns the current matrix
  89924. */
  89925. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  89926. /**
  89927. * Check equality between this matrix and a second one
  89928. * @param value defines the second matrix to compare
  89929. * @returns true is the current matrix and the given one values are strictly equal
  89930. */
  89931. equals(value: DeepImmutable<Matrix>): boolean;
  89932. /**
  89933. * Clone the current matrix
  89934. * @returns a new matrix from the current matrix
  89935. */
  89936. clone(): Matrix;
  89937. /**
  89938. * Returns the name of the current matrix class
  89939. * @returns the string "Matrix"
  89940. */
  89941. getClassName(): string;
  89942. /**
  89943. * Gets the hash code of the current matrix
  89944. * @returns the hash code
  89945. */
  89946. getHashCode(): number;
  89947. /**
  89948. * Decomposes the current Matrix into a translation, rotation and scaling components
  89949. * @param scale defines the scale vector3 given as a reference to update
  89950. * @param rotation defines the rotation quaternion given as a reference to update
  89951. * @param translation defines the translation vector3 given as a reference to update
  89952. * @returns true if operation was successful
  89953. */
  89954. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  89955. /**
  89956. * Gets specific row of the matrix
  89957. * @param index defines the number of the row to get
  89958. * @returns the index-th row of the current matrix as a new Vector4
  89959. */
  89960. getRow(index: number): Nullable<Vector4>;
  89961. /**
  89962. * Sets the index-th row of the current matrix to the vector4 values
  89963. * @param index defines the number of the row to set
  89964. * @param row defines the target vector4
  89965. * @returns the updated current matrix
  89966. */
  89967. setRow(index: number, row: Vector4): Matrix;
  89968. /**
  89969. * Compute the transpose of the matrix
  89970. * @returns the new transposed matrix
  89971. */
  89972. transpose(): Matrix;
  89973. /**
  89974. * Compute the transpose of the matrix and store it in a given matrix
  89975. * @param result defines the target matrix
  89976. * @returns the current matrix
  89977. */
  89978. transposeToRef(result: Matrix): Matrix;
  89979. /**
  89980. * Sets the index-th row of the current matrix with the given 4 x float values
  89981. * @param index defines the row index
  89982. * @param x defines the x component to set
  89983. * @param y defines the y component to set
  89984. * @param z defines the z component to set
  89985. * @param w defines the w component to set
  89986. * @returns the updated current matrix
  89987. */
  89988. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  89989. /**
  89990. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  89991. * @param scale defines the scale factor
  89992. * @returns a new matrix
  89993. */
  89994. scale(scale: number): Matrix;
  89995. /**
  89996. * Scale the current matrix values by a factor to a given result matrix
  89997. * @param scale defines the scale factor
  89998. * @param result defines the matrix to store the result
  89999. * @returns the current matrix
  90000. */
  90001. scaleToRef(scale: number, result: Matrix): Matrix;
  90002. /**
  90003. * Scale the current matrix values by a factor and add the result to a given matrix
  90004. * @param scale defines the scale factor
  90005. * @param result defines the Matrix to store the result
  90006. * @returns the current matrix
  90007. */
  90008. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  90009. /**
  90010. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  90011. * @param ref matrix to store the result
  90012. */
  90013. toNormalMatrix(ref: Matrix): void;
  90014. /**
  90015. * Gets only rotation part of the current matrix
  90016. * @returns a new matrix sets to the extracted rotation matrix from the current one
  90017. */
  90018. getRotationMatrix(): Matrix;
  90019. /**
  90020. * Extracts the rotation matrix from the current one and sets it as the given "result"
  90021. * @param result defines the target matrix to store data to
  90022. * @returns the current matrix
  90023. */
  90024. getRotationMatrixToRef(result: Matrix): Matrix;
  90025. /**
  90026. * Toggles model matrix from being right handed to left handed in place and vice versa
  90027. */
  90028. toggleModelMatrixHandInPlace(): void;
  90029. /**
  90030. * Toggles projection matrix from being right handed to left handed in place and vice versa
  90031. */
  90032. toggleProjectionMatrixHandInPlace(): void;
  90033. /**
  90034. * Creates a matrix from an array
  90035. * @param array defines the source array
  90036. * @param offset defines an offset in the source array
  90037. * @returns a new Matrix set from the starting index of the given array
  90038. */
  90039. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  90040. /**
  90041. * Copy the content of an array into a given matrix
  90042. * @param array defines the source array
  90043. * @param offset defines an offset in the source array
  90044. * @param result defines the target matrix
  90045. */
  90046. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  90047. /**
  90048. * Stores an array into a matrix after having multiplied each component by a given factor
  90049. * @param array defines the source array
  90050. * @param offset defines the offset in the source array
  90051. * @param scale defines the scaling factor
  90052. * @param result defines the target matrix
  90053. */
  90054. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  90055. /**
  90056. * Gets an identity matrix that must not be updated
  90057. */
  90058. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  90059. /**
  90060. * Stores a list of values (16) inside a given matrix
  90061. * @param initialM11 defines 1st value of 1st row
  90062. * @param initialM12 defines 2nd value of 1st row
  90063. * @param initialM13 defines 3rd value of 1st row
  90064. * @param initialM14 defines 4th value of 1st row
  90065. * @param initialM21 defines 1st value of 2nd row
  90066. * @param initialM22 defines 2nd value of 2nd row
  90067. * @param initialM23 defines 3rd value of 2nd row
  90068. * @param initialM24 defines 4th value of 2nd row
  90069. * @param initialM31 defines 1st value of 3rd row
  90070. * @param initialM32 defines 2nd value of 3rd row
  90071. * @param initialM33 defines 3rd value of 3rd row
  90072. * @param initialM34 defines 4th value of 3rd row
  90073. * @param initialM41 defines 1st value of 4th row
  90074. * @param initialM42 defines 2nd value of 4th row
  90075. * @param initialM43 defines 3rd value of 4th row
  90076. * @param initialM44 defines 4th value of 4th row
  90077. * @param result defines the target matrix
  90078. */
  90079. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  90080. /**
  90081. * Creates new matrix from a list of values (16)
  90082. * @param initialM11 defines 1st value of 1st row
  90083. * @param initialM12 defines 2nd value of 1st row
  90084. * @param initialM13 defines 3rd value of 1st row
  90085. * @param initialM14 defines 4th value of 1st row
  90086. * @param initialM21 defines 1st value of 2nd row
  90087. * @param initialM22 defines 2nd value of 2nd row
  90088. * @param initialM23 defines 3rd value of 2nd row
  90089. * @param initialM24 defines 4th value of 2nd row
  90090. * @param initialM31 defines 1st value of 3rd row
  90091. * @param initialM32 defines 2nd value of 3rd row
  90092. * @param initialM33 defines 3rd value of 3rd row
  90093. * @param initialM34 defines 4th value of 3rd row
  90094. * @param initialM41 defines 1st value of 4th row
  90095. * @param initialM42 defines 2nd value of 4th row
  90096. * @param initialM43 defines 3rd value of 4th row
  90097. * @param initialM44 defines 4th value of 4th row
  90098. * @returns the new matrix
  90099. */
  90100. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  90101. /**
  90102. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  90103. * @param scale defines the scale vector3
  90104. * @param rotation defines the rotation quaternion
  90105. * @param translation defines the translation vector3
  90106. * @returns a new matrix
  90107. */
  90108. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  90109. /**
  90110. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  90111. * @param scale defines the scale vector3
  90112. * @param rotation defines the rotation quaternion
  90113. * @param translation defines the translation vector3
  90114. * @param result defines the target matrix
  90115. */
  90116. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  90117. /**
  90118. * Creates a new identity matrix
  90119. * @returns a new identity matrix
  90120. */
  90121. static Identity(): Matrix;
  90122. /**
  90123. * Creates a new identity matrix and stores the result in a given matrix
  90124. * @param result defines the target matrix
  90125. */
  90126. static IdentityToRef(result: Matrix): void;
  90127. /**
  90128. * Creates a new zero matrix
  90129. * @returns a new zero matrix
  90130. */
  90131. static Zero(): Matrix;
  90132. /**
  90133. * Creates a new rotation matrix for "angle" radians around the X axis
  90134. * @param angle defines the angle (in radians) to use
  90135. * @return the new matrix
  90136. */
  90137. static RotationX(angle: number): Matrix;
  90138. /**
  90139. * Creates a new matrix as the invert of a given matrix
  90140. * @param source defines the source matrix
  90141. * @returns the new matrix
  90142. */
  90143. static Invert(source: DeepImmutable<Matrix>): Matrix;
  90144. /**
  90145. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  90146. * @param angle defines the angle (in radians) to use
  90147. * @param result defines the target matrix
  90148. */
  90149. static RotationXToRef(angle: number, result: Matrix): void;
  90150. /**
  90151. * Creates a new rotation matrix for "angle" radians around the Y axis
  90152. * @param angle defines the angle (in radians) to use
  90153. * @return the new matrix
  90154. */
  90155. static RotationY(angle: number): Matrix;
  90156. /**
  90157. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  90158. * @param angle defines the angle (in radians) to use
  90159. * @param result defines the target matrix
  90160. */
  90161. static RotationYToRef(angle: number, result: Matrix): void;
  90162. /**
  90163. * Creates a new rotation matrix for "angle" radians around the Z axis
  90164. * @param angle defines the angle (in radians) to use
  90165. * @return the new matrix
  90166. */
  90167. static RotationZ(angle: number): Matrix;
  90168. /**
  90169. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  90170. * @param angle defines the angle (in radians) to use
  90171. * @param result defines the target matrix
  90172. */
  90173. static RotationZToRef(angle: number, result: Matrix): void;
  90174. /**
  90175. * Creates a new rotation matrix for "angle" radians around the given axis
  90176. * @param axis defines the axis to use
  90177. * @param angle defines the angle (in radians) to use
  90178. * @return the new matrix
  90179. */
  90180. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  90181. /**
  90182. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  90183. * @param axis defines the axis to use
  90184. * @param angle defines the angle (in radians) to use
  90185. * @param result defines the target matrix
  90186. */
  90187. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  90188. /**
  90189. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  90190. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  90191. * @param from defines the vector to align
  90192. * @param to defines the vector to align to
  90193. * @param result defines the target matrix
  90194. */
  90195. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  90196. /**
  90197. * Creates a rotation matrix
  90198. * @param yaw defines the yaw angle in radians (Y axis)
  90199. * @param pitch defines the pitch angle in radians (X axis)
  90200. * @param roll defines the roll angle in radians (Z axis)
  90201. * @returns the new rotation matrix
  90202. */
  90203. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  90204. /**
  90205. * Creates a rotation matrix and stores it in a given matrix
  90206. * @param yaw defines the yaw angle in radians (Y axis)
  90207. * @param pitch defines the pitch angle in radians (X axis)
  90208. * @param roll defines the roll angle in radians (Z axis)
  90209. * @param result defines the target matrix
  90210. */
  90211. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  90212. /**
  90213. * Creates a scaling matrix
  90214. * @param x defines the scale factor on X axis
  90215. * @param y defines the scale factor on Y axis
  90216. * @param z defines the scale factor on Z axis
  90217. * @returns the new matrix
  90218. */
  90219. static Scaling(x: number, y: number, z: number): Matrix;
  90220. /**
  90221. * Creates a scaling matrix and stores it in a given matrix
  90222. * @param x defines the scale factor on X axis
  90223. * @param y defines the scale factor on Y axis
  90224. * @param z defines the scale factor on Z axis
  90225. * @param result defines the target matrix
  90226. */
  90227. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  90228. /**
  90229. * Creates a translation matrix
  90230. * @param x defines the translation on X axis
  90231. * @param y defines the translation on Y axis
  90232. * @param z defines the translationon Z axis
  90233. * @returns the new matrix
  90234. */
  90235. static Translation(x: number, y: number, z: number): Matrix;
  90236. /**
  90237. * Creates a translation matrix and stores it in a given matrix
  90238. * @param x defines the translation on X axis
  90239. * @param y defines the translation on Y axis
  90240. * @param z defines the translationon Z axis
  90241. * @param result defines the target matrix
  90242. */
  90243. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  90244. /**
  90245. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  90246. * @param startValue defines the start value
  90247. * @param endValue defines the end value
  90248. * @param gradient defines the gradient factor
  90249. * @returns the new matrix
  90250. */
  90251. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  90252. /**
  90253. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  90254. * @param startValue defines the start value
  90255. * @param endValue defines the end value
  90256. * @param gradient defines the gradient factor
  90257. * @param result defines the Matrix object where to store data
  90258. */
  90259. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  90260. /**
  90261. * Builds a new matrix whose values are computed by:
  90262. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  90263. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  90264. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  90265. * @param startValue defines the first matrix
  90266. * @param endValue defines the second matrix
  90267. * @param gradient defines the gradient between the two matrices
  90268. * @returns the new matrix
  90269. */
  90270. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  90271. /**
  90272. * Update a matrix to values which are computed by:
  90273. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  90274. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  90275. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  90276. * @param startValue defines the first matrix
  90277. * @param endValue defines the second matrix
  90278. * @param gradient defines the gradient between the two matrices
  90279. * @param result defines the target matrix
  90280. */
  90281. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  90282. /**
  90283. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  90284. * This function works in left handed mode
  90285. * @param eye defines the final position of the entity
  90286. * @param target defines where the entity should look at
  90287. * @param up defines the up vector for the entity
  90288. * @returns the new matrix
  90289. */
  90290. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  90291. /**
  90292. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  90293. * This function works in left handed mode
  90294. * @param eye defines the final position of the entity
  90295. * @param target defines where the entity should look at
  90296. * @param up defines the up vector for the entity
  90297. * @param result defines the target matrix
  90298. */
  90299. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  90300. /**
  90301. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  90302. * This function works in right handed mode
  90303. * @param eye defines the final position of the entity
  90304. * @param target defines where the entity should look at
  90305. * @param up defines the up vector for the entity
  90306. * @returns the new matrix
  90307. */
  90308. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  90309. /**
  90310. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  90311. * This function works in right handed mode
  90312. * @param eye defines the final position of the entity
  90313. * @param target defines where the entity should look at
  90314. * @param up defines the up vector for the entity
  90315. * @param result defines the target matrix
  90316. */
  90317. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  90318. /**
  90319. * Create a left-handed orthographic projection matrix
  90320. * @param width defines the viewport width
  90321. * @param height defines the viewport height
  90322. * @param znear defines the near clip plane
  90323. * @param zfar defines the far clip plane
  90324. * @returns a new matrix as a left-handed orthographic projection matrix
  90325. */
  90326. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  90327. /**
  90328. * Store a left-handed orthographic projection to a given matrix
  90329. * @param width defines the viewport width
  90330. * @param height defines the viewport height
  90331. * @param znear defines the near clip plane
  90332. * @param zfar defines the far clip plane
  90333. * @param result defines the target matrix
  90334. */
  90335. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  90336. /**
  90337. * Create a left-handed orthographic projection matrix
  90338. * @param left defines the viewport left coordinate
  90339. * @param right defines the viewport right coordinate
  90340. * @param bottom defines the viewport bottom coordinate
  90341. * @param top defines the viewport top coordinate
  90342. * @param znear defines the near clip plane
  90343. * @param zfar defines the far clip plane
  90344. * @returns a new matrix as a left-handed orthographic projection matrix
  90345. */
  90346. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  90347. /**
  90348. * Stores a left-handed orthographic projection into a given matrix
  90349. * @param left defines the viewport left coordinate
  90350. * @param right defines the viewport right coordinate
  90351. * @param bottom defines the viewport bottom coordinate
  90352. * @param top defines the viewport top coordinate
  90353. * @param znear defines the near clip plane
  90354. * @param zfar defines the far clip plane
  90355. * @param result defines the target matrix
  90356. */
  90357. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  90358. /**
  90359. * Creates a right-handed orthographic projection matrix
  90360. * @param left defines the viewport left coordinate
  90361. * @param right defines the viewport right coordinate
  90362. * @param bottom defines the viewport bottom coordinate
  90363. * @param top defines the viewport top coordinate
  90364. * @param znear defines the near clip plane
  90365. * @param zfar defines the far clip plane
  90366. * @returns a new matrix as a right-handed orthographic projection matrix
  90367. */
  90368. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  90369. /**
  90370. * Stores a right-handed orthographic projection into a given matrix
  90371. * @param left defines the viewport left coordinate
  90372. * @param right defines the viewport right coordinate
  90373. * @param bottom defines the viewport bottom coordinate
  90374. * @param top defines the viewport top coordinate
  90375. * @param znear defines the near clip plane
  90376. * @param zfar defines the far clip plane
  90377. * @param result defines the target matrix
  90378. */
  90379. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  90380. /**
  90381. * Creates a left-handed perspective projection matrix
  90382. * @param width defines the viewport width
  90383. * @param height defines the viewport height
  90384. * @param znear defines the near clip plane
  90385. * @param zfar defines the far clip plane
  90386. * @returns a new matrix as a left-handed perspective projection matrix
  90387. */
  90388. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  90389. /**
  90390. * Creates a left-handed perspective projection matrix
  90391. * @param fov defines the horizontal field of view
  90392. * @param aspect defines the aspect ratio
  90393. * @param znear defines the near clip plane
  90394. * @param zfar defines the far clip plane
  90395. * @returns a new matrix as a left-handed perspective projection matrix
  90396. */
  90397. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  90398. /**
  90399. * Stores a left-handed perspective projection into a given matrix
  90400. * @param fov defines the horizontal field of view
  90401. * @param aspect defines the aspect ratio
  90402. * @param znear defines the near clip plane
  90403. * @param zfar defines the far clip plane
  90404. * @param result defines the target matrix
  90405. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90406. */
  90407. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90408. /**
  90409. * Stores a left-handed perspective projection into a given matrix with depth reversed
  90410. * @param fov defines the horizontal field of view
  90411. * @param aspect defines the aspect ratio
  90412. * @param znear defines the near clip plane
  90413. * @param zfar not used as infinity is used as far clip
  90414. * @param result defines the target matrix
  90415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90416. */
  90417. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90418. /**
  90419. * Creates a right-handed perspective projection matrix
  90420. * @param fov defines the horizontal field of view
  90421. * @param aspect defines the aspect ratio
  90422. * @param znear defines the near clip plane
  90423. * @param zfar defines the far clip plane
  90424. * @returns a new matrix as a right-handed perspective projection matrix
  90425. */
  90426. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  90427. /**
  90428. * Stores a right-handed perspective projection into a given matrix
  90429. * @param fov defines the horizontal field of view
  90430. * @param aspect defines the aspect ratio
  90431. * @param znear defines the near clip plane
  90432. * @param zfar defines the far clip plane
  90433. * @param result defines the target matrix
  90434. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90435. */
  90436. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90437. /**
  90438. * Stores a right-handed perspective projection into a given matrix
  90439. * @param fov defines the horizontal field of view
  90440. * @param aspect defines the aspect ratio
  90441. * @param znear defines the near clip plane
  90442. * @param zfar not used as infinity is used as far clip
  90443. * @param result defines the target matrix
  90444. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90445. */
  90446. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90447. /**
  90448. * Stores a perspective projection for WebVR info a given matrix
  90449. * @param fov defines the field of view
  90450. * @param znear defines the near clip plane
  90451. * @param zfar defines the far clip plane
  90452. * @param result defines the target matrix
  90453. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  90454. */
  90455. static PerspectiveFovWebVRToRef(fov: {
  90456. upDegrees: number;
  90457. downDegrees: number;
  90458. leftDegrees: number;
  90459. rightDegrees: number;
  90460. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  90461. /**
  90462. * Computes a complete transformation matrix
  90463. * @param viewport defines the viewport to use
  90464. * @param world defines the world matrix
  90465. * @param view defines the view matrix
  90466. * @param projection defines the projection matrix
  90467. * @param zmin defines the near clip plane
  90468. * @param zmax defines the far clip plane
  90469. * @returns the transformation matrix
  90470. */
  90471. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  90472. /**
  90473. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  90474. * @param matrix defines the matrix to use
  90475. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  90476. */
  90477. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  90478. /**
  90479. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  90480. * @param matrix defines the matrix to use
  90481. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  90482. */
  90483. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  90484. /**
  90485. * Compute the transpose of a given matrix
  90486. * @param matrix defines the matrix to transpose
  90487. * @returns the new matrix
  90488. */
  90489. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  90490. /**
  90491. * Compute the transpose of a matrix and store it in a target matrix
  90492. * @param matrix defines the matrix to transpose
  90493. * @param result defines the target matrix
  90494. */
  90495. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  90496. /**
  90497. * Computes a reflection matrix from a plane
  90498. * @param plane defines the reflection plane
  90499. * @returns a new matrix
  90500. */
  90501. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  90502. /**
  90503. * Computes a reflection matrix from a plane
  90504. * @param plane defines the reflection plane
  90505. * @param result defines the target matrix
  90506. */
  90507. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  90508. /**
  90509. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  90510. * @param xaxis defines the value of the 1st axis
  90511. * @param yaxis defines the value of the 2nd axis
  90512. * @param zaxis defines the value of the 3rd axis
  90513. * @param result defines the target matrix
  90514. */
  90515. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  90516. /**
  90517. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  90518. * @param quat defines the quaternion to use
  90519. * @param result defines the target matrix
  90520. */
  90521. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  90522. }
  90523. /**
  90524. * @hidden
  90525. */
  90526. export class TmpVectors {
  90527. static Vector2: Vector2[];
  90528. static Vector3: Vector3[];
  90529. static Vector4: Vector4[];
  90530. static Quaternion: Quaternion[];
  90531. static Matrix: Matrix[];
  90532. }
  90533. }
  90534. declare module BABYLON {
  90535. /**
  90536. * Defines potential orientation for back face culling
  90537. */
  90538. export enum Orientation {
  90539. /**
  90540. * Clockwise
  90541. */
  90542. CW = 0,
  90543. /** Counter clockwise */
  90544. CCW = 1
  90545. }
  90546. /** Class used to represent a Bezier curve */
  90547. export class BezierCurve {
  90548. /**
  90549. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  90550. * @param t defines the time
  90551. * @param x1 defines the left coordinate on X axis
  90552. * @param y1 defines the left coordinate on Y axis
  90553. * @param x2 defines the right coordinate on X axis
  90554. * @param y2 defines the right coordinate on Y axis
  90555. * @returns the interpolated value
  90556. */
  90557. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  90558. }
  90559. /**
  90560. * Defines angle representation
  90561. */
  90562. export class Angle {
  90563. private _radians;
  90564. /**
  90565. * Creates an Angle object of "radians" radians (float).
  90566. * @param radians the angle in radians
  90567. */
  90568. constructor(radians: number);
  90569. /**
  90570. * Get value in degrees
  90571. * @returns the Angle value in degrees (float)
  90572. */
  90573. degrees(): number;
  90574. /**
  90575. * Get value in radians
  90576. * @returns the Angle value in radians (float)
  90577. */
  90578. radians(): number;
  90579. /**
  90580. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  90581. * @param a defines first point as the origin
  90582. * @param b defines point
  90583. * @returns a new Angle
  90584. */
  90585. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  90586. /**
  90587. * Gets a new Angle object from the given float in radians
  90588. * @param radians defines the angle value in radians
  90589. * @returns a new Angle
  90590. */
  90591. static FromRadians(radians: number): Angle;
  90592. /**
  90593. * Gets a new Angle object from the given float in degrees
  90594. * @param degrees defines the angle value in degrees
  90595. * @returns a new Angle
  90596. */
  90597. static FromDegrees(degrees: number): Angle;
  90598. }
  90599. /**
  90600. * This represents an arc in a 2d space.
  90601. */
  90602. export class Arc2 {
  90603. /** Defines the start point of the arc */
  90604. startPoint: Vector2;
  90605. /** Defines the mid point of the arc */
  90606. midPoint: Vector2;
  90607. /** Defines the end point of the arc */
  90608. endPoint: Vector2;
  90609. /**
  90610. * Defines the center point of the arc.
  90611. */
  90612. centerPoint: Vector2;
  90613. /**
  90614. * Defines the radius of the arc.
  90615. */
  90616. radius: number;
  90617. /**
  90618. * Defines the angle of the arc (from mid point to end point).
  90619. */
  90620. angle: Angle;
  90621. /**
  90622. * Defines the start angle of the arc (from start point to middle point).
  90623. */
  90624. startAngle: Angle;
  90625. /**
  90626. * Defines the orientation of the arc (clock wise/counter clock wise).
  90627. */
  90628. orientation: Orientation;
  90629. /**
  90630. * Creates an Arc object from the three given points : start, middle and end.
  90631. * @param startPoint Defines the start point of the arc
  90632. * @param midPoint Defines the midlle point of the arc
  90633. * @param endPoint Defines the end point of the arc
  90634. */
  90635. constructor(
  90636. /** Defines the start point of the arc */
  90637. startPoint: Vector2,
  90638. /** Defines the mid point of the arc */
  90639. midPoint: Vector2,
  90640. /** Defines the end point of the arc */
  90641. endPoint: Vector2);
  90642. }
  90643. /**
  90644. * Represents a 2D path made up of multiple 2D points
  90645. */
  90646. export class Path2 {
  90647. private _points;
  90648. private _length;
  90649. /**
  90650. * If the path start and end point are the same
  90651. */
  90652. closed: boolean;
  90653. /**
  90654. * Creates a Path2 object from the starting 2D coordinates x and y.
  90655. * @param x the starting points x value
  90656. * @param y the starting points y value
  90657. */
  90658. constructor(x: number, y: number);
  90659. /**
  90660. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  90661. * @param x the added points x value
  90662. * @param y the added points y value
  90663. * @returns the updated Path2.
  90664. */
  90665. addLineTo(x: number, y: number): Path2;
  90666. /**
  90667. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  90668. * @param midX middle point x value
  90669. * @param midY middle point y value
  90670. * @param endX end point x value
  90671. * @param endY end point y value
  90672. * @param numberOfSegments (default: 36)
  90673. * @returns the updated Path2.
  90674. */
  90675. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  90676. /**
  90677. * Closes the Path2.
  90678. * @returns the Path2.
  90679. */
  90680. close(): Path2;
  90681. /**
  90682. * Gets the sum of the distance between each sequential point in the path
  90683. * @returns the Path2 total length (float).
  90684. */
  90685. length(): number;
  90686. /**
  90687. * Gets the points which construct the path
  90688. * @returns the Path2 internal array of points.
  90689. */
  90690. getPoints(): Vector2[];
  90691. /**
  90692. * Retreives the point at the distance aways from the starting point
  90693. * @param normalizedLengthPosition the length along the path to retreive the point from
  90694. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  90695. */
  90696. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  90697. /**
  90698. * Creates a new path starting from an x and y position
  90699. * @param x starting x value
  90700. * @param y starting y value
  90701. * @returns a new Path2 starting at the coordinates (x, y).
  90702. */
  90703. static StartingAt(x: number, y: number): Path2;
  90704. }
  90705. /**
  90706. * Represents a 3D path made up of multiple 3D points
  90707. */
  90708. export class Path3D {
  90709. /**
  90710. * an array of Vector3, the curve axis of the Path3D
  90711. */
  90712. path: Vector3[];
  90713. private _curve;
  90714. private _distances;
  90715. private _tangents;
  90716. private _normals;
  90717. private _binormals;
  90718. private _raw;
  90719. private _alignTangentsWithPath;
  90720. private readonly _pointAtData;
  90721. /**
  90722. * new Path3D(path, normal, raw)
  90723. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  90724. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  90725. * @param path an array of Vector3, the curve axis of the Path3D
  90726. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  90727. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  90728. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  90729. */
  90730. constructor(
  90731. /**
  90732. * an array of Vector3, the curve axis of the Path3D
  90733. */
  90734. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  90735. /**
  90736. * Returns the Path3D array of successive Vector3 designing its curve.
  90737. * @returns the Path3D array of successive Vector3 designing its curve.
  90738. */
  90739. getCurve(): Vector3[];
  90740. /**
  90741. * Returns the Path3D array of successive Vector3 designing its curve.
  90742. * @returns the Path3D array of successive Vector3 designing its curve.
  90743. */
  90744. getPoints(): Vector3[];
  90745. /**
  90746. * @returns the computed length (float) of the path.
  90747. */
  90748. length(): number;
  90749. /**
  90750. * Returns an array populated with tangent vectors on each Path3D curve point.
  90751. * @returns an array populated with tangent vectors on each Path3D curve point.
  90752. */
  90753. getTangents(): Vector3[];
  90754. /**
  90755. * Returns an array populated with normal vectors on each Path3D curve point.
  90756. * @returns an array populated with normal vectors on each Path3D curve point.
  90757. */
  90758. getNormals(): Vector3[];
  90759. /**
  90760. * Returns an array populated with binormal vectors on each Path3D curve point.
  90761. * @returns an array populated with binormal vectors on each Path3D curve point.
  90762. */
  90763. getBinormals(): Vector3[];
  90764. /**
  90765. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  90766. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  90767. */
  90768. getDistances(): number[];
  90769. /**
  90770. * Returns an interpolated point along this path
  90771. * @param position the position of the point along this path, from 0.0 to 1.0
  90772. * @returns a new Vector3 as the point
  90773. */
  90774. getPointAt(position: number): Vector3;
  90775. /**
  90776. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90777. * @param position the position of the point along this path, from 0.0 to 1.0
  90778. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  90779. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  90780. */
  90781. getTangentAt(position: number, interpolated?: boolean): Vector3;
  90782. /**
  90783. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90784. * @param position the position of the point along this path, from 0.0 to 1.0
  90785. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  90786. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  90787. */
  90788. getNormalAt(position: number, interpolated?: boolean): Vector3;
  90789. /**
  90790. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  90791. * @param position the position of the point along this path, from 0.0 to 1.0
  90792. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  90793. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  90794. */
  90795. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  90796. /**
  90797. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  90798. * @param position the position of the point along this path, from 0.0 to 1.0
  90799. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  90800. */
  90801. getDistanceAt(position: number): number;
  90802. /**
  90803. * Returns the array index of the previous point of an interpolated point along this path
  90804. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90805. * @returns the array index
  90806. */
  90807. getPreviousPointIndexAt(position: number): number;
  90808. /**
  90809. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  90810. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90811. * @returns the sub position
  90812. */
  90813. getSubPositionAt(position: number): number;
  90814. /**
  90815. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  90816. * @param target the vector of which to get the closest position to
  90817. * @returns the position of the closest virtual point on this path to the target vector
  90818. */
  90819. getClosestPositionTo(target: Vector3): number;
  90820. /**
  90821. * Returns a sub path (slice) of this path
  90822. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  90823. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  90824. * @returns a sub path (slice) of this path
  90825. */
  90826. slice(start?: number, end?: number): Path3D;
  90827. /**
  90828. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  90829. * @param path path which all values are copied into the curves points
  90830. * @param firstNormal which should be projected onto the curve
  90831. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  90832. * @returns the same object updated.
  90833. */
  90834. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  90835. private _compute;
  90836. private _getFirstNonNullVector;
  90837. private _getLastNonNullVector;
  90838. private _normalVector;
  90839. /**
  90840. * Updates the point at data for an interpolated point along this curve
  90841. * @param position the position of the point along this curve, from 0.0 to 1.0
  90842. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  90843. * @returns the (updated) point at data
  90844. */
  90845. private _updatePointAtData;
  90846. /**
  90847. * Updates the point at data from the specified parameters
  90848. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  90849. * @param point the interpolated point
  90850. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  90851. */
  90852. private _setPointAtData;
  90853. /**
  90854. * Updates the point at interpolation matrix for the tangents, normals and binormals
  90855. */
  90856. private _updateInterpolationMatrix;
  90857. }
  90858. /**
  90859. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90860. * A Curve3 is designed from a series of successive Vector3.
  90861. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  90862. */
  90863. export class Curve3 {
  90864. private _points;
  90865. private _length;
  90866. /**
  90867. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  90868. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  90869. * @param v1 (Vector3) the control point
  90870. * @param v2 (Vector3) the end point of the Quadratic Bezier
  90871. * @param nbPoints (integer) the wanted number of points in the curve
  90872. * @returns the created Curve3
  90873. */
  90874. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90875. /**
  90876. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  90877. * @param v0 (Vector3) the origin point of the Cubic Bezier
  90878. * @param v1 (Vector3) the first control point
  90879. * @param v2 (Vector3) the second control point
  90880. * @param v3 (Vector3) the end point of the Cubic Bezier
  90881. * @param nbPoints (integer) the wanted number of points in the curve
  90882. * @returns the created Curve3
  90883. */
  90884. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90885. /**
  90886. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  90887. * @param p1 (Vector3) the origin point of the Hermite Spline
  90888. * @param t1 (Vector3) the tangent vector at the origin point
  90889. * @param p2 (Vector3) the end point of the Hermite Spline
  90890. * @param t2 (Vector3) the tangent vector at the end point
  90891. * @param nbPoints (integer) the wanted number of points in the curve
  90892. * @returns the created Curve3
  90893. */
  90894. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90895. /**
  90896. * Returns a Curve3 object along a CatmullRom Spline curve :
  90897. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  90898. * @param nbPoints (integer) the wanted number of points between each curve control points
  90899. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  90900. * @returns the created Curve3
  90901. */
  90902. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  90903. /**
  90904. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90905. * A Curve3 is designed from a series of successive Vector3.
  90906. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  90907. * @param points points which make up the curve
  90908. */
  90909. constructor(points: Vector3[]);
  90910. /**
  90911. * @returns the Curve3 stored array of successive Vector3
  90912. */
  90913. getPoints(): Vector3[];
  90914. /**
  90915. * @returns the computed length (float) of the curve.
  90916. */
  90917. length(): number;
  90918. /**
  90919. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  90920. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  90921. * curveA and curveB keep unchanged.
  90922. * @param curve the curve to continue from this curve
  90923. * @returns the newly constructed curve
  90924. */
  90925. continue(curve: DeepImmutable<Curve3>): Curve3;
  90926. private _computeLength;
  90927. }
  90928. }
  90929. declare module BABYLON {
  90930. /**
  90931. * This represents the main contract an easing function should follow.
  90932. * Easing functions are used throughout the animation system.
  90933. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90934. */
  90935. export interface IEasingFunction {
  90936. /**
  90937. * Given an input gradient between 0 and 1, this returns the corrseponding value
  90938. * of the easing function.
  90939. * The link below provides some of the most common examples of easing functions.
  90940. * @see https://easings.net/
  90941. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90942. * @returns the corresponding value on the curve defined by the easing function
  90943. */
  90944. ease(gradient: number): number;
  90945. }
  90946. /**
  90947. * Base class used for every default easing function.
  90948. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90949. */
  90950. export class EasingFunction implements IEasingFunction {
  90951. /**
  90952. * Interpolation follows the mathematical formula associated with the easing function.
  90953. */
  90954. static readonly EASINGMODE_EASEIN: number;
  90955. /**
  90956. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  90957. */
  90958. static readonly EASINGMODE_EASEOUT: number;
  90959. /**
  90960. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  90961. */
  90962. static readonly EASINGMODE_EASEINOUT: number;
  90963. private _easingMode;
  90964. /**
  90965. * Sets the easing mode of the current function.
  90966. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  90967. */
  90968. setEasingMode(easingMode: number): void;
  90969. /**
  90970. * Gets the current easing mode.
  90971. * @returns the easing mode
  90972. */
  90973. getEasingMode(): number;
  90974. /**
  90975. * @hidden
  90976. */
  90977. easeInCore(gradient: number): number;
  90978. /**
  90979. * Given an input gradient between 0 and 1, this returns the corresponding value
  90980. * of the easing function.
  90981. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90982. * @returns the corresponding value on the curve defined by the easing function
  90983. */
  90984. ease(gradient: number): number;
  90985. }
  90986. /**
  90987. * Easing function with a circle shape (see link below).
  90988. * @see https://easings.net/#easeInCirc
  90989. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90990. */
  90991. export class CircleEase extends EasingFunction implements IEasingFunction {
  90992. /** @hidden */
  90993. easeInCore(gradient: number): number;
  90994. }
  90995. /**
  90996. * Easing function with a ease back shape (see link below).
  90997. * @see https://easings.net/#easeInBack
  90998. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90999. */
  91000. export class BackEase extends EasingFunction implements IEasingFunction {
  91001. /** Defines the amplitude of the function */
  91002. amplitude: number;
  91003. /**
  91004. * Instantiates a back ease easing
  91005. * @see https://easings.net/#easeInBack
  91006. * @param amplitude Defines the amplitude of the function
  91007. */
  91008. constructor(
  91009. /** Defines the amplitude of the function */
  91010. amplitude?: number);
  91011. /** @hidden */
  91012. easeInCore(gradient: number): number;
  91013. }
  91014. /**
  91015. * Easing function with a bouncing shape (see link below).
  91016. * @see https://easings.net/#easeInBounce
  91017. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91018. */
  91019. export class BounceEase extends EasingFunction implements IEasingFunction {
  91020. /** Defines the number of bounces */
  91021. bounces: number;
  91022. /** Defines the amplitude of the bounce */
  91023. bounciness: number;
  91024. /**
  91025. * Instantiates a bounce easing
  91026. * @see https://easings.net/#easeInBounce
  91027. * @param bounces Defines the number of bounces
  91028. * @param bounciness Defines the amplitude of the bounce
  91029. */
  91030. constructor(
  91031. /** Defines the number of bounces */
  91032. bounces?: number,
  91033. /** Defines the amplitude of the bounce */
  91034. bounciness?: number);
  91035. /** @hidden */
  91036. easeInCore(gradient: number): number;
  91037. }
  91038. /**
  91039. * Easing function with a power of 3 shape (see link below).
  91040. * @see https://easings.net/#easeInCubic
  91041. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91042. */
  91043. export class CubicEase extends EasingFunction implements IEasingFunction {
  91044. /** @hidden */
  91045. easeInCore(gradient: number): number;
  91046. }
  91047. /**
  91048. * Easing function with an elastic shape (see link below).
  91049. * @see https://easings.net/#easeInElastic
  91050. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91051. */
  91052. export class ElasticEase extends EasingFunction implements IEasingFunction {
  91053. /** Defines the number of oscillations*/
  91054. oscillations: number;
  91055. /** Defines the amplitude of the oscillations*/
  91056. springiness: number;
  91057. /**
  91058. * Instantiates an elastic easing function
  91059. * @see https://easings.net/#easeInElastic
  91060. * @param oscillations Defines the number of oscillations
  91061. * @param springiness Defines the amplitude of the oscillations
  91062. */
  91063. constructor(
  91064. /** Defines the number of oscillations*/
  91065. oscillations?: number,
  91066. /** Defines the amplitude of the oscillations*/
  91067. springiness?: number);
  91068. /** @hidden */
  91069. easeInCore(gradient: number): number;
  91070. }
  91071. /**
  91072. * Easing function with an exponential shape (see link below).
  91073. * @see https://easings.net/#easeInExpo
  91074. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91075. */
  91076. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  91077. /** Defines the exponent of the function */
  91078. exponent: number;
  91079. /**
  91080. * Instantiates an exponential easing function
  91081. * @see https://easings.net/#easeInExpo
  91082. * @param exponent Defines the exponent of the function
  91083. */
  91084. constructor(
  91085. /** Defines the exponent of the function */
  91086. exponent?: number);
  91087. /** @hidden */
  91088. easeInCore(gradient: number): number;
  91089. }
  91090. /**
  91091. * Easing function with a power shape (see link below).
  91092. * @see https://easings.net/#easeInQuad
  91093. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91094. */
  91095. export class PowerEase extends EasingFunction implements IEasingFunction {
  91096. /** Defines the power of the function */
  91097. power: number;
  91098. /**
  91099. * Instantiates an power base easing function
  91100. * @see https://easings.net/#easeInQuad
  91101. * @param power Defines the power of the function
  91102. */
  91103. constructor(
  91104. /** Defines the power of the function */
  91105. power?: number);
  91106. /** @hidden */
  91107. easeInCore(gradient: number): number;
  91108. }
  91109. /**
  91110. * Easing function with a power of 2 shape (see link below).
  91111. * @see https://easings.net/#easeInQuad
  91112. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91113. */
  91114. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  91115. /** @hidden */
  91116. easeInCore(gradient: number): number;
  91117. }
  91118. /**
  91119. * Easing function with a power of 4 shape (see link below).
  91120. * @see https://easings.net/#easeInQuart
  91121. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91122. */
  91123. export class QuarticEase extends EasingFunction implements IEasingFunction {
  91124. /** @hidden */
  91125. easeInCore(gradient: number): number;
  91126. }
  91127. /**
  91128. * Easing function with a power of 5 shape (see link below).
  91129. * @see https://easings.net/#easeInQuint
  91130. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91131. */
  91132. export class QuinticEase extends EasingFunction implements IEasingFunction {
  91133. /** @hidden */
  91134. easeInCore(gradient: number): number;
  91135. }
  91136. /**
  91137. * Easing function with a sin shape (see link below).
  91138. * @see https://easings.net/#easeInSine
  91139. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91140. */
  91141. export class SineEase extends EasingFunction implements IEasingFunction {
  91142. /** @hidden */
  91143. easeInCore(gradient: number): number;
  91144. }
  91145. /**
  91146. * Easing function with a bezier shape (see link below).
  91147. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  91148. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91149. */
  91150. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  91151. /** Defines the x component of the start tangent in the bezier curve */
  91152. x1: number;
  91153. /** Defines the y component of the start tangent in the bezier curve */
  91154. y1: number;
  91155. /** Defines the x component of the end tangent in the bezier curve */
  91156. x2: number;
  91157. /** Defines the y component of the end tangent in the bezier curve */
  91158. y2: number;
  91159. /**
  91160. * Instantiates a bezier function
  91161. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  91162. * @param x1 Defines the x component of the start tangent in the bezier curve
  91163. * @param y1 Defines the y component of the start tangent in the bezier curve
  91164. * @param x2 Defines the x component of the end tangent in the bezier curve
  91165. * @param y2 Defines the y component of the end tangent in the bezier curve
  91166. */
  91167. constructor(
  91168. /** Defines the x component of the start tangent in the bezier curve */
  91169. x1?: number,
  91170. /** Defines the y component of the start tangent in the bezier curve */
  91171. y1?: number,
  91172. /** Defines the x component of the end tangent in the bezier curve */
  91173. x2?: number,
  91174. /** Defines the y component of the end tangent in the bezier curve */
  91175. y2?: number);
  91176. /** @hidden */
  91177. easeInCore(gradient: number): number;
  91178. }
  91179. }
  91180. declare module BABYLON {
  91181. /**
  91182. * Class used to hold a RGB color
  91183. */
  91184. export class Color3 {
  91185. /**
  91186. * Defines the red component (between 0 and 1, default is 0)
  91187. */
  91188. r: number;
  91189. /**
  91190. * Defines the green component (between 0 and 1, default is 0)
  91191. */
  91192. g: number;
  91193. /**
  91194. * Defines the blue component (between 0 and 1, default is 0)
  91195. */
  91196. b: number;
  91197. /**
  91198. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  91199. * @param r defines the red component (between 0 and 1, default is 0)
  91200. * @param g defines the green component (between 0 and 1, default is 0)
  91201. * @param b defines the blue component (between 0 and 1, default is 0)
  91202. */
  91203. constructor(
  91204. /**
  91205. * Defines the red component (between 0 and 1, default is 0)
  91206. */
  91207. r?: number,
  91208. /**
  91209. * Defines the green component (between 0 and 1, default is 0)
  91210. */
  91211. g?: number,
  91212. /**
  91213. * Defines the blue component (between 0 and 1, default is 0)
  91214. */
  91215. b?: number);
  91216. /**
  91217. * Creates a string with the Color3 current values
  91218. * @returns the string representation of the Color3 object
  91219. */
  91220. toString(): string;
  91221. /**
  91222. * Returns the string "Color3"
  91223. * @returns "Color3"
  91224. */
  91225. getClassName(): string;
  91226. /**
  91227. * Compute the Color3 hash code
  91228. * @returns an unique number that can be used to hash Color3 objects
  91229. */
  91230. getHashCode(): number;
  91231. /**
  91232. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  91233. * @param array defines the array where to store the r,g,b components
  91234. * @param index defines an optional index in the target array to define where to start storing values
  91235. * @returns the current Color3 object
  91236. */
  91237. toArray(array: FloatArray, index?: number): Color3;
  91238. /**
  91239. * Update the current color with values stored in an array from the starting index of the given array
  91240. * @param array defines the source array
  91241. * @param offset defines an offset in the source array
  91242. * @returns the current Color3 object
  91243. */
  91244. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  91245. /**
  91246. * Returns a new Color4 object from the current Color3 and the given alpha
  91247. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  91248. * @returns a new Color4 object
  91249. */
  91250. toColor4(alpha?: number): Color4;
  91251. /**
  91252. * Returns a new array populated with 3 numeric elements : red, green and blue values
  91253. * @returns the new array
  91254. */
  91255. asArray(): number[];
  91256. /**
  91257. * Returns the luminance value
  91258. * @returns a float value
  91259. */
  91260. toLuminance(): number;
  91261. /**
  91262. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  91263. * @param otherColor defines the second operand
  91264. * @returns the new Color3 object
  91265. */
  91266. multiply(otherColor: DeepImmutable<Color3>): Color3;
  91267. /**
  91268. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  91269. * @param otherColor defines the second operand
  91270. * @param result defines the Color3 object where to store the result
  91271. * @returns the current Color3
  91272. */
  91273. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91274. /**
  91275. * Determines equality between Color3 objects
  91276. * @param otherColor defines the second operand
  91277. * @returns true if the rgb values are equal to the given ones
  91278. */
  91279. equals(otherColor: DeepImmutable<Color3>): boolean;
  91280. /**
  91281. * Determines equality between the current Color3 object and a set of r,b,g values
  91282. * @param r defines the red component to check
  91283. * @param g defines the green component to check
  91284. * @param b defines the blue component to check
  91285. * @returns true if the rgb values are equal to the given ones
  91286. */
  91287. equalsFloats(r: number, g: number, b: number): boolean;
  91288. /**
  91289. * Multiplies in place each rgb value by scale
  91290. * @param scale defines the scaling factor
  91291. * @returns the updated Color3
  91292. */
  91293. scale(scale: number): Color3;
  91294. /**
  91295. * Multiplies the rgb values by scale and stores the result into "result"
  91296. * @param scale defines the scaling factor
  91297. * @param result defines the Color3 object where to store the result
  91298. * @returns the unmodified current Color3
  91299. */
  91300. scaleToRef(scale: number, result: Color3): Color3;
  91301. /**
  91302. * Scale the current Color3 values by a factor and add the result to a given Color3
  91303. * @param scale defines the scale factor
  91304. * @param result defines color to store the result into
  91305. * @returns the unmodified current Color3
  91306. */
  91307. scaleAndAddToRef(scale: number, result: Color3): Color3;
  91308. /**
  91309. * Clamps the rgb values by the min and max values and stores the result into "result"
  91310. * @param min defines minimum clamping value (default is 0)
  91311. * @param max defines maximum clamping value (default is 1)
  91312. * @param result defines color to store the result into
  91313. * @returns the original Color3
  91314. */
  91315. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  91316. /**
  91317. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  91318. * @param otherColor defines the second operand
  91319. * @returns the new Color3
  91320. */
  91321. add(otherColor: DeepImmutable<Color3>): Color3;
  91322. /**
  91323. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  91324. * @param otherColor defines the second operand
  91325. * @param result defines Color3 object to store the result into
  91326. * @returns the unmodified current Color3
  91327. */
  91328. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91329. /**
  91330. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  91331. * @param otherColor defines the second operand
  91332. * @returns the new Color3
  91333. */
  91334. subtract(otherColor: DeepImmutable<Color3>): Color3;
  91335. /**
  91336. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  91337. * @param otherColor defines the second operand
  91338. * @param result defines Color3 object to store the result into
  91339. * @returns the unmodified current Color3
  91340. */
  91341. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91342. /**
  91343. * Copy the current object
  91344. * @returns a new Color3 copied the current one
  91345. */
  91346. clone(): Color3;
  91347. /**
  91348. * Copies the rgb values from the source in the current Color3
  91349. * @param source defines the source Color3 object
  91350. * @returns the updated Color3 object
  91351. */
  91352. copyFrom(source: DeepImmutable<Color3>): Color3;
  91353. /**
  91354. * Updates the Color3 rgb values from the given floats
  91355. * @param r defines the red component to read from
  91356. * @param g defines the green component to read from
  91357. * @param b defines the blue component to read from
  91358. * @returns the current Color3 object
  91359. */
  91360. copyFromFloats(r: number, g: number, b: number): Color3;
  91361. /**
  91362. * Updates the Color3 rgb values from the given floats
  91363. * @param r defines the red component to read from
  91364. * @param g defines the green component to read from
  91365. * @param b defines the blue component to read from
  91366. * @returns the current Color3 object
  91367. */
  91368. set(r: number, g: number, b: number): Color3;
  91369. /**
  91370. * Compute the Color3 hexadecimal code as a string
  91371. * @returns a string containing the hexadecimal representation of the Color3 object
  91372. */
  91373. toHexString(): string;
  91374. /**
  91375. * Computes a new Color3 converted from the current one to linear space
  91376. * @returns a new Color3 object
  91377. */
  91378. toLinearSpace(): Color3;
  91379. /**
  91380. * Converts current color in rgb space to HSV values
  91381. * @returns a new color3 representing the HSV values
  91382. */
  91383. toHSV(): Color3;
  91384. /**
  91385. * Converts current color in rgb space to HSV values
  91386. * @param result defines the Color3 where to store the HSV values
  91387. */
  91388. toHSVToRef(result: Color3): void;
  91389. /**
  91390. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  91391. * @param convertedColor defines the Color3 object where to store the linear space version
  91392. * @returns the unmodified Color3
  91393. */
  91394. toLinearSpaceToRef(convertedColor: Color3): Color3;
  91395. /**
  91396. * Computes a new Color3 converted from the current one to gamma space
  91397. * @returns a new Color3 object
  91398. */
  91399. toGammaSpace(): Color3;
  91400. /**
  91401. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  91402. * @param convertedColor defines the Color3 object where to store the gamma space version
  91403. * @returns the unmodified Color3
  91404. */
  91405. toGammaSpaceToRef(convertedColor: Color3): Color3;
  91406. private static _BlackReadOnly;
  91407. /**
  91408. * Convert Hue, saturation and value to a Color3 (RGB)
  91409. * @param hue defines the hue
  91410. * @param saturation defines the saturation
  91411. * @param value defines the value
  91412. * @param result defines the Color3 where to store the RGB values
  91413. */
  91414. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  91415. /**
  91416. * Creates a new Color3 from the string containing valid hexadecimal values
  91417. * @param hex defines a string containing valid hexadecimal values
  91418. * @returns a new Color3 object
  91419. */
  91420. static FromHexString(hex: string): Color3;
  91421. /**
  91422. * Creates a new Color3 from the starting index of the given array
  91423. * @param array defines the source array
  91424. * @param offset defines an offset in the source array
  91425. * @returns a new Color3 object
  91426. */
  91427. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  91428. /**
  91429. * Creates a new Color3 from the starting index element of the given array
  91430. * @param array defines the source array to read from
  91431. * @param offset defines the offset in the source array
  91432. * @param result defines the target Color3 object
  91433. */
  91434. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  91435. /**
  91436. * Creates a new Color3 from integer values (< 256)
  91437. * @param r defines the red component to read from (value between 0 and 255)
  91438. * @param g defines the green component to read from (value between 0 and 255)
  91439. * @param b defines the blue component to read from (value between 0 and 255)
  91440. * @returns a new Color3 object
  91441. */
  91442. static FromInts(r: number, g: number, b: number): Color3;
  91443. /**
  91444. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  91445. * @param start defines the start Color3 value
  91446. * @param end defines the end Color3 value
  91447. * @param amount defines the gradient value between start and end
  91448. * @returns a new Color3 object
  91449. */
  91450. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  91451. /**
  91452. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  91453. * @param left defines the start value
  91454. * @param right defines the end value
  91455. * @param amount defines the gradient factor
  91456. * @param result defines the Color3 object where to store the result
  91457. */
  91458. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  91459. /**
  91460. * Returns a Color3 value containing a red color
  91461. * @returns a new Color3 object
  91462. */
  91463. static Red(): Color3;
  91464. /**
  91465. * Returns a Color3 value containing a green color
  91466. * @returns a new Color3 object
  91467. */
  91468. static Green(): Color3;
  91469. /**
  91470. * Returns a Color3 value containing a blue color
  91471. * @returns a new Color3 object
  91472. */
  91473. static Blue(): Color3;
  91474. /**
  91475. * Returns a Color3 value containing a black color
  91476. * @returns a new Color3 object
  91477. */
  91478. static Black(): Color3;
  91479. /**
  91480. * Gets a Color3 value containing a black color that must not be updated
  91481. */
  91482. static get BlackReadOnly(): DeepImmutable<Color3>;
  91483. /**
  91484. * Returns a Color3 value containing a white color
  91485. * @returns a new Color3 object
  91486. */
  91487. static White(): Color3;
  91488. /**
  91489. * Returns a Color3 value containing a purple color
  91490. * @returns a new Color3 object
  91491. */
  91492. static Purple(): Color3;
  91493. /**
  91494. * Returns a Color3 value containing a magenta color
  91495. * @returns a new Color3 object
  91496. */
  91497. static Magenta(): Color3;
  91498. /**
  91499. * Returns a Color3 value containing a yellow color
  91500. * @returns a new Color3 object
  91501. */
  91502. static Yellow(): Color3;
  91503. /**
  91504. * Returns a Color3 value containing a gray color
  91505. * @returns a new Color3 object
  91506. */
  91507. static Gray(): Color3;
  91508. /**
  91509. * Returns a Color3 value containing a teal color
  91510. * @returns a new Color3 object
  91511. */
  91512. static Teal(): Color3;
  91513. /**
  91514. * Returns a Color3 value containing a random color
  91515. * @returns a new Color3 object
  91516. */
  91517. static Random(): Color3;
  91518. }
  91519. /**
  91520. * Class used to hold a RBGA color
  91521. */
  91522. export class Color4 {
  91523. /**
  91524. * Defines the red component (between 0 and 1, default is 0)
  91525. */
  91526. r: number;
  91527. /**
  91528. * Defines the green component (between 0 and 1, default is 0)
  91529. */
  91530. g: number;
  91531. /**
  91532. * Defines the blue component (between 0 and 1, default is 0)
  91533. */
  91534. b: number;
  91535. /**
  91536. * Defines the alpha component (between 0 and 1, default is 1)
  91537. */
  91538. a: number;
  91539. /**
  91540. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  91541. * @param r defines the red component (between 0 and 1, default is 0)
  91542. * @param g defines the green component (between 0 and 1, default is 0)
  91543. * @param b defines the blue component (between 0 and 1, default is 0)
  91544. * @param a defines the alpha component (between 0 and 1, default is 1)
  91545. */
  91546. constructor(
  91547. /**
  91548. * Defines the red component (between 0 and 1, default is 0)
  91549. */
  91550. r?: number,
  91551. /**
  91552. * Defines the green component (between 0 and 1, default is 0)
  91553. */
  91554. g?: number,
  91555. /**
  91556. * Defines the blue component (between 0 and 1, default is 0)
  91557. */
  91558. b?: number,
  91559. /**
  91560. * Defines the alpha component (between 0 and 1, default is 1)
  91561. */
  91562. a?: number);
  91563. /**
  91564. * Adds in place the given Color4 values to the current Color4 object
  91565. * @param right defines the second operand
  91566. * @returns the current updated Color4 object
  91567. */
  91568. addInPlace(right: DeepImmutable<Color4>): Color4;
  91569. /**
  91570. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  91571. * @returns the new array
  91572. */
  91573. asArray(): number[];
  91574. /**
  91575. * Stores from the starting index in the given array the Color4 successive values
  91576. * @param array defines the array where to store the r,g,b components
  91577. * @param index defines an optional index in the target array to define where to start storing values
  91578. * @returns the current Color4 object
  91579. */
  91580. toArray(array: number[], index?: number): Color4;
  91581. /**
  91582. * Update the current color with values stored in an array from the starting index of the given array
  91583. * @param array defines the source array
  91584. * @param offset defines an offset in the source array
  91585. * @returns the current Color4 object
  91586. */
  91587. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91588. /**
  91589. * Determines equality between Color4 objects
  91590. * @param otherColor defines the second operand
  91591. * @returns true if the rgba values are equal to the given ones
  91592. */
  91593. equals(otherColor: DeepImmutable<Color4>): boolean;
  91594. /**
  91595. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  91596. * @param right defines the second operand
  91597. * @returns a new Color4 object
  91598. */
  91599. add(right: DeepImmutable<Color4>): Color4;
  91600. /**
  91601. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  91602. * @param right defines the second operand
  91603. * @returns a new Color4 object
  91604. */
  91605. subtract(right: DeepImmutable<Color4>): Color4;
  91606. /**
  91607. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  91608. * @param right defines the second operand
  91609. * @param result defines the Color4 object where to store the result
  91610. * @returns the current Color4 object
  91611. */
  91612. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  91613. /**
  91614. * Creates a new Color4 with the current Color4 values multiplied by scale
  91615. * @param scale defines the scaling factor to apply
  91616. * @returns a new Color4 object
  91617. */
  91618. scale(scale: number): Color4;
  91619. /**
  91620. * Multiplies the current Color4 values by scale and stores the result in "result"
  91621. * @param scale defines the scaling factor to apply
  91622. * @param result defines the Color4 object where to store the result
  91623. * @returns the current unmodified Color4
  91624. */
  91625. scaleToRef(scale: number, result: Color4): Color4;
  91626. /**
  91627. * Scale the current Color4 values by a factor and add the result to a given Color4
  91628. * @param scale defines the scale factor
  91629. * @param result defines the Color4 object where to store the result
  91630. * @returns the unmodified current Color4
  91631. */
  91632. scaleAndAddToRef(scale: number, result: Color4): Color4;
  91633. /**
  91634. * Clamps the rgb values by the min and max values and stores the result into "result"
  91635. * @param min defines minimum clamping value (default is 0)
  91636. * @param max defines maximum clamping value (default is 1)
  91637. * @param result defines color to store the result into.
  91638. * @returns the cuurent Color4
  91639. */
  91640. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  91641. /**
  91642. * Multipy an Color4 value by another and return a new Color4 object
  91643. * @param color defines the Color4 value to multiply by
  91644. * @returns a new Color4 object
  91645. */
  91646. multiply(color: Color4): Color4;
  91647. /**
  91648. * Multipy a Color4 value by another and push the result in a reference value
  91649. * @param color defines the Color4 value to multiply by
  91650. * @param result defines the Color4 to fill the result in
  91651. * @returns the result Color4
  91652. */
  91653. multiplyToRef(color: Color4, result: Color4): Color4;
  91654. /**
  91655. * Creates a string with the Color4 current values
  91656. * @returns the string representation of the Color4 object
  91657. */
  91658. toString(): string;
  91659. /**
  91660. * Returns the string "Color4"
  91661. * @returns "Color4"
  91662. */
  91663. getClassName(): string;
  91664. /**
  91665. * Compute the Color4 hash code
  91666. * @returns an unique number that can be used to hash Color4 objects
  91667. */
  91668. getHashCode(): number;
  91669. /**
  91670. * Creates a new Color4 copied from the current one
  91671. * @returns a new Color4 object
  91672. */
  91673. clone(): Color4;
  91674. /**
  91675. * Copies the given Color4 values into the current one
  91676. * @param source defines the source Color4 object
  91677. * @returns the current updated Color4 object
  91678. */
  91679. copyFrom(source: Color4): Color4;
  91680. /**
  91681. * Copies the given float values into the current one
  91682. * @param r defines the red component to read from
  91683. * @param g defines the green component to read from
  91684. * @param b defines the blue component to read from
  91685. * @param a defines the alpha component to read from
  91686. * @returns the current updated Color4 object
  91687. */
  91688. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  91689. /**
  91690. * Copies the given float values into the current one
  91691. * @param r defines the red component to read from
  91692. * @param g defines the green component to read from
  91693. * @param b defines the blue component to read from
  91694. * @param a defines the alpha component to read from
  91695. * @returns the current updated Color4 object
  91696. */
  91697. set(r: number, g: number, b: number, a: number): Color4;
  91698. /**
  91699. * Compute the Color4 hexadecimal code as a string
  91700. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  91701. * @returns a string containing the hexadecimal representation of the Color4 object
  91702. */
  91703. toHexString(returnAsColor3?: boolean): string;
  91704. /**
  91705. * Computes a new Color4 converted from the current one to linear space
  91706. * @returns a new Color4 object
  91707. */
  91708. toLinearSpace(): Color4;
  91709. /**
  91710. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  91711. * @param convertedColor defines the Color4 object where to store the linear space version
  91712. * @returns the unmodified Color4
  91713. */
  91714. toLinearSpaceToRef(convertedColor: Color4): Color4;
  91715. /**
  91716. * Computes a new Color4 converted from the current one to gamma space
  91717. * @returns a new Color4 object
  91718. */
  91719. toGammaSpace(): Color4;
  91720. /**
  91721. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  91722. * @param convertedColor defines the Color4 object where to store the gamma space version
  91723. * @returns the unmodified Color4
  91724. */
  91725. toGammaSpaceToRef(convertedColor: Color4): Color4;
  91726. /**
  91727. * Creates a new Color4 from the string containing valid hexadecimal values
  91728. * @param hex defines a string containing valid hexadecimal values
  91729. * @returns a new Color4 object
  91730. */
  91731. static FromHexString(hex: string): Color4;
  91732. /**
  91733. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91734. * @param left defines the start value
  91735. * @param right defines the end value
  91736. * @param amount defines the gradient factor
  91737. * @returns a new Color4 object
  91738. */
  91739. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  91740. /**
  91741. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91742. * @param left defines the start value
  91743. * @param right defines the end value
  91744. * @param amount defines the gradient factor
  91745. * @param result defines the Color4 object where to store data
  91746. */
  91747. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  91748. /**
  91749. * Creates a new Color4 from a Color3 and an alpha value
  91750. * @param color3 defines the source Color3 to read from
  91751. * @param alpha defines the alpha component (1.0 by default)
  91752. * @returns a new Color4 object
  91753. */
  91754. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  91755. /**
  91756. * Creates a new Color4 from the starting index element of the given array
  91757. * @param array defines the source array to read from
  91758. * @param offset defines the offset in the source array
  91759. * @returns a new Color4 object
  91760. */
  91761. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91762. /**
  91763. * Creates a new Color4 from the starting index element of the given array
  91764. * @param array defines the source array to read from
  91765. * @param offset defines the offset in the source array
  91766. * @param result defines the target Color4 object
  91767. */
  91768. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  91769. /**
  91770. * Creates a new Color3 from integer values (< 256)
  91771. * @param r defines the red component to read from (value between 0 and 255)
  91772. * @param g defines the green component to read from (value between 0 and 255)
  91773. * @param b defines the blue component to read from (value between 0 and 255)
  91774. * @param a defines the alpha component to read from (value between 0 and 255)
  91775. * @returns a new Color3 object
  91776. */
  91777. static FromInts(r: number, g: number, b: number, a: number): Color4;
  91778. /**
  91779. * Check the content of a given array and convert it to an array containing RGBA data
  91780. * If the original array was already containing count * 4 values then it is returned directly
  91781. * @param colors defines the array to check
  91782. * @param count defines the number of RGBA data to expect
  91783. * @returns an array containing count * 4 values (RGBA)
  91784. */
  91785. static CheckColors4(colors: number[], count: number): number[];
  91786. }
  91787. /**
  91788. * @hidden
  91789. */
  91790. export class TmpColors {
  91791. static Color3: Color3[];
  91792. static Color4: Color4[];
  91793. }
  91794. }
  91795. declare module BABYLON {
  91796. /**
  91797. * Defines an interface which represents an animation key frame
  91798. */
  91799. export interface IAnimationKey {
  91800. /**
  91801. * Frame of the key frame
  91802. */
  91803. frame: number;
  91804. /**
  91805. * Value at the specifies key frame
  91806. */
  91807. value: any;
  91808. /**
  91809. * The input tangent for the cubic hermite spline
  91810. */
  91811. inTangent?: any;
  91812. /**
  91813. * The output tangent for the cubic hermite spline
  91814. */
  91815. outTangent?: any;
  91816. /**
  91817. * The animation interpolation type
  91818. */
  91819. interpolation?: AnimationKeyInterpolation;
  91820. }
  91821. /**
  91822. * Enum for the animation key frame interpolation type
  91823. */
  91824. export enum AnimationKeyInterpolation {
  91825. /**
  91826. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  91827. */
  91828. STEP = 1
  91829. }
  91830. }
  91831. declare module BABYLON {
  91832. /**
  91833. * Represents the range of an animation
  91834. */
  91835. export class AnimationRange {
  91836. /**The name of the animation range**/
  91837. name: string;
  91838. /**The starting frame of the animation */
  91839. from: number;
  91840. /**The ending frame of the animation*/
  91841. to: number;
  91842. /**
  91843. * Initializes the range of an animation
  91844. * @param name The name of the animation range
  91845. * @param from The starting frame of the animation
  91846. * @param to The ending frame of the animation
  91847. */
  91848. constructor(
  91849. /**The name of the animation range**/
  91850. name: string,
  91851. /**The starting frame of the animation */
  91852. from: number,
  91853. /**The ending frame of the animation*/
  91854. to: number);
  91855. /**
  91856. * Makes a copy of the animation range
  91857. * @returns A copy of the animation range
  91858. */
  91859. clone(): AnimationRange;
  91860. }
  91861. }
  91862. declare module BABYLON {
  91863. /**
  91864. * Composed of a frame, and an action function
  91865. */
  91866. export class AnimationEvent {
  91867. /** The frame for which the event is triggered **/
  91868. frame: number;
  91869. /** The event to perform when triggered **/
  91870. action: (currentFrame: number) => void;
  91871. /** Specifies if the event should be triggered only once**/
  91872. onlyOnce?: boolean | undefined;
  91873. /**
  91874. * Specifies if the animation event is done
  91875. */
  91876. isDone: boolean;
  91877. /**
  91878. * Initializes the animation event
  91879. * @param frame The frame for which the event is triggered
  91880. * @param action The event to perform when triggered
  91881. * @param onlyOnce Specifies if the event should be triggered only once
  91882. */
  91883. constructor(
  91884. /** The frame for which the event is triggered **/
  91885. frame: number,
  91886. /** The event to perform when triggered **/
  91887. action: (currentFrame: number) => void,
  91888. /** Specifies if the event should be triggered only once**/
  91889. onlyOnce?: boolean | undefined);
  91890. /** @hidden */
  91891. _clone(): AnimationEvent;
  91892. }
  91893. }
  91894. declare module BABYLON {
  91895. /**
  91896. * Interface used to define a behavior
  91897. */
  91898. export interface Behavior<T> {
  91899. /** gets or sets behavior's name */
  91900. name: string;
  91901. /**
  91902. * Function called when the behavior needs to be initialized (after attaching it to a target)
  91903. */
  91904. init(): void;
  91905. /**
  91906. * Called when the behavior is attached to a target
  91907. * @param target defines the target where the behavior is attached to
  91908. */
  91909. attach(target: T): void;
  91910. /**
  91911. * Called when the behavior is detached from its target
  91912. */
  91913. detach(): void;
  91914. }
  91915. /**
  91916. * Interface implemented by classes supporting behaviors
  91917. */
  91918. export interface IBehaviorAware<T> {
  91919. /**
  91920. * Attach a behavior
  91921. * @param behavior defines the behavior to attach
  91922. * @returns the current host
  91923. */
  91924. addBehavior(behavior: Behavior<T>): T;
  91925. /**
  91926. * Remove a behavior from the current object
  91927. * @param behavior defines the behavior to detach
  91928. * @returns the current host
  91929. */
  91930. removeBehavior(behavior: Behavior<T>): T;
  91931. /**
  91932. * Gets a behavior using its name to search
  91933. * @param name defines the name to search
  91934. * @returns the behavior or null if not found
  91935. */
  91936. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  91937. }
  91938. }
  91939. declare module BABYLON {
  91940. /**
  91941. * Class used to provide helpers for slicing
  91942. */
  91943. export class SliceTools {
  91944. /**
  91945. * Provides a slice function that will work even on IE
  91946. * @param data defines the array to slice
  91947. * @param start defines the start of the data (optional)
  91948. * @param end defines the end of the data (optional)
  91949. * @returns the new sliced array
  91950. */
  91951. static Slice<T>(data: T, start?: number, end?: number): T;
  91952. /**
  91953. * Provides a slice function that will work even on IE
  91954. * The difference between this and Slice is that this will force-convert to array
  91955. * @param data defines the array to slice
  91956. * @param start defines the start of the data (optional)
  91957. * @param end defines the end of the data (optional)
  91958. * @returns the new sliced array
  91959. */
  91960. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  91961. }
  91962. }
  91963. declare module BABYLON {
  91964. /**
  91965. * Class used to store data that will be store in GPU memory
  91966. */
  91967. export class Buffer {
  91968. private _engine;
  91969. private _buffer;
  91970. /** @hidden */
  91971. _data: Nullable<DataArray>;
  91972. private _updatable;
  91973. private _instanced;
  91974. private _divisor;
  91975. private _isAlreadyOwned;
  91976. /**
  91977. * Gets the byte stride.
  91978. */
  91979. readonly byteStride: number;
  91980. /**
  91981. * Constructor
  91982. * @param engine the engine
  91983. * @param data the data to use for this buffer
  91984. * @param updatable whether the data is updatable
  91985. * @param stride the stride (optional)
  91986. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  91987. * @param instanced whether the buffer is instanced (optional)
  91988. * @param useBytes set to true if the stride in in bytes (optional)
  91989. * @param divisor sets an optional divisor for instances (1 by default)
  91990. */
  91991. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  91992. /**
  91993. * Create a new VertexBuffer based on the current buffer
  91994. * @param kind defines the vertex buffer kind (position, normal, etc.)
  91995. * @param offset defines offset in the buffer (0 by default)
  91996. * @param size defines the size in floats of attributes (position is 3 for instance)
  91997. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  91998. * @param instanced defines if the vertex buffer contains indexed data
  91999. * @param useBytes defines if the offset and stride are in bytes *
  92000. * @param divisor sets an optional divisor for instances (1 by default)
  92001. * @returns the new vertex buffer
  92002. */
  92003. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  92004. /**
  92005. * Gets a boolean indicating if the Buffer is updatable?
  92006. * @returns true if the buffer is updatable
  92007. */
  92008. isUpdatable(): boolean;
  92009. /**
  92010. * Gets current buffer's data
  92011. * @returns a DataArray or null
  92012. */
  92013. getData(): Nullable<DataArray>;
  92014. /**
  92015. * Gets underlying native buffer
  92016. * @returns underlying native buffer
  92017. */
  92018. getBuffer(): Nullable<DataBuffer>;
  92019. /**
  92020. * Gets the stride in float32 units (i.e. byte stride / 4).
  92021. * May not be an integer if the byte stride is not divisible by 4.
  92022. * @returns the stride in float32 units
  92023. * @deprecated Please use byteStride instead.
  92024. */
  92025. getStrideSize(): number;
  92026. /**
  92027. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  92028. * @param data defines the data to store
  92029. */
  92030. create(data?: Nullable<DataArray>): void;
  92031. /** @hidden */
  92032. _rebuild(): void;
  92033. /**
  92034. * Update current buffer data
  92035. * @param data defines the data to store
  92036. */
  92037. update(data: DataArray): void;
  92038. /**
  92039. * Updates the data directly.
  92040. * @param data the new data
  92041. * @param offset the new offset
  92042. * @param vertexCount the vertex count (optional)
  92043. * @param useBytes set to true if the offset is in bytes
  92044. */
  92045. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  92046. /** @hidden */
  92047. _increaseReferences(): void;
  92048. /**
  92049. * Release all resources
  92050. */
  92051. dispose(): void;
  92052. }
  92053. /**
  92054. * Specialized buffer used to store vertex data
  92055. */
  92056. export class VertexBuffer {
  92057. private static _Counter;
  92058. /** @hidden */
  92059. _buffer: Buffer;
  92060. private _kind;
  92061. private _size;
  92062. private _ownsBuffer;
  92063. private _instanced;
  92064. private _instanceDivisor;
  92065. /**
  92066. * The byte type.
  92067. */
  92068. static readonly BYTE: number;
  92069. /**
  92070. * The unsigned byte type.
  92071. */
  92072. static readonly UNSIGNED_BYTE: number;
  92073. /**
  92074. * The short type.
  92075. */
  92076. static readonly SHORT: number;
  92077. /**
  92078. * The unsigned short type.
  92079. */
  92080. static readonly UNSIGNED_SHORT: number;
  92081. /**
  92082. * The integer type.
  92083. */
  92084. static readonly INT: number;
  92085. /**
  92086. * The unsigned integer type.
  92087. */
  92088. static readonly UNSIGNED_INT: number;
  92089. /**
  92090. * The float type.
  92091. */
  92092. static readonly FLOAT: number;
  92093. /**
  92094. * Gets or sets the instance divisor when in instanced mode
  92095. */
  92096. get instanceDivisor(): number;
  92097. set instanceDivisor(value: number);
  92098. /**
  92099. * Gets the byte stride.
  92100. */
  92101. readonly byteStride: number;
  92102. /**
  92103. * Gets the byte offset.
  92104. */
  92105. readonly byteOffset: number;
  92106. /**
  92107. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  92108. */
  92109. readonly normalized: boolean;
  92110. /**
  92111. * Gets the data type of each component in the array.
  92112. */
  92113. readonly type: number;
  92114. /**
  92115. * Gets the unique id of this vertex buffer
  92116. */
  92117. readonly uniqueId: number;
  92118. /**
  92119. * Constructor
  92120. * @param engine the engine
  92121. * @param data the data to use for this vertex buffer
  92122. * @param kind the vertex buffer kind
  92123. * @param updatable whether the data is updatable
  92124. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  92125. * @param stride the stride (optional)
  92126. * @param instanced whether the buffer is instanced (optional)
  92127. * @param offset the offset of the data (optional)
  92128. * @param size the number of components (optional)
  92129. * @param type the type of the component (optional)
  92130. * @param normalized whether the data contains normalized data (optional)
  92131. * @param useBytes set to true if stride and offset are in bytes (optional)
  92132. * @param divisor defines the instance divisor to use (1 by default)
  92133. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  92134. */
  92135. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  92136. /** @hidden */
  92137. _rebuild(): void;
  92138. /**
  92139. * Returns the kind of the VertexBuffer (string)
  92140. * @returns a string
  92141. */
  92142. getKind(): string;
  92143. /**
  92144. * Gets a boolean indicating if the VertexBuffer is updatable?
  92145. * @returns true if the buffer is updatable
  92146. */
  92147. isUpdatable(): boolean;
  92148. /**
  92149. * Gets current buffer's data
  92150. * @returns a DataArray or null
  92151. */
  92152. getData(): Nullable<DataArray>;
  92153. /**
  92154. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  92155. * @param totalVertices number of vertices in the buffer to take into account
  92156. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92157. * @returns a float array containing vertex data
  92158. */
  92159. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  92160. /**
  92161. * Gets underlying native buffer
  92162. * @returns underlying native buffer
  92163. */
  92164. getBuffer(): Nullable<DataBuffer>;
  92165. /**
  92166. * Gets the stride in float32 units (i.e. byte stride / 4).
  92167. * May not be an integer if the byte stride is not divisible by 4.
  92168. * @returns the stride in float32 units
  92169. * @deprecated Please use byteStride instead.
  92170. */
  92171. getStrideSize(): number;
  92172. /**
  92173. * Returns the offset as a multiple of the type byte length.
  92174. * @returns the offset in bytes
  92175. * @deprecated Please use byteOffset instead.
  92176. */
  92177. getOffset(): number;
  92178. /**
  92179. * Returns the number of components per vertex attribute (integer)
  92180. * @returns the size in float
  92181. */
  92182. getSize(): number;
  92183. /**
  92184. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  92185. * @returns true if this buffer is instanced
  92186. */
  92187. getIsInstanced(): boolean;
  92188. /**
  92189. * Returns the instancing divisor, zero for non-instanced (integer).
  92190. * @returns a number
  92191. */
  92192. getInstanceDivisor(): number;
  92193. /**
  92194. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  92195. * @param data defines the data to store
  92196. */
  92197. create(data?: DataArray): void;
  92198. /**
  92199. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  92200. * This function will create a new buffer if the current one is not updatable
  92201. * @param data defines the data to store
  92202. */
  92203. update(data: DataArray): void;
  92204. /**
  92205. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  92206. * Returns the directly updated WebGLBuffer.
  92207. * @param data the new data
  92208. * @param offset the new offset
  92209. * @param useBytes set to true if the offset is in bytes
  92210. */
  92211. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  92212. /**
  92213. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  92214. */
  92215. dispose(): void;
  92216. /**
  92217. * Enumerates each value of this vertex buffer as numbers.
  92218. * @param count the number of values to enumerate
  92219. * @param callback the callback function called for each value
  92220. */
  92221. forEach(count: number, callback: (value: number, index: number) => void): void;
  92222. /**
  92223. * Positions
  92224. */
  92225. static readonly PositionKind: string;
  92226. /**
  92227. * Normals
  92228. */
  92229. static readonly NormalKind: string;
  92230. /**
  92231. * Tangents
  92232. */
  92233. static readonly TangentKind: string;
  92234. /**
  92235. * Texture coordinates
  92236. */
  92237. static readonly UVKind: string;
  92238. /**
  92239. * Texture coordinates 2
  92240. */
  92241. static readonly UV2Kind: string;
  92242. /**
  92243. * Texture coordinates 3
  92244. */
  92245. static readonly UV3Kind: string;
  92246. /**
  92247. * Texture coordinates 4
  92248. */
  92249. static readonly UV4Kind: string;
  92250. /**
  92251. * Texture coordinates 5
  92252. */
  92253. static readonly UV5Kind: string;
  92254. /**
  92255. * Texture coordinates 6
  92256. */
  92257. static readonly UV6Kind: string;
  92258. /**
  92259. * Colors
  92260. */
  92261. static readonly ColorKind: string;
  92262. /**
  92263. * Matrix indices (for bones)
  92264. */
  92265. static readonly MatricesIndicesKind: string;
  92266. /**
  92267. * Matrix weights (for bones)
  92268. */
  92269. static readonly MatricesWeightsKind: string;
  92270. /**
  92271. * Additional matrix indices (for bones)
  92272. */
  92273. static readonly MatricesIndicesExtraKind: string;
  92274. /**
  92275. * Additional matrix weights (for bones)
  92276. */
  92277. static readonly MatricesWeightsExtraKind: string;
  92278. /**
  92279. * Deduces the stride given a kind.
  92280. * @param kind The kind string to deduce
  92281. * @returns The deduced stride
  92282. */
  92283. static DeduceStride(kind: string): number;
  92284. /**
  92285. * Gets the byte length of the given type.
  92286. * @param type the type
  92287. * @returns the number of bytes
  92288. */
  92289. static GetTypeByteLength(type: number): number;
  92290. /**
  92291. * Enumerates each value of the given parameters as numbers.
  92292. * @param data the data to enumerate
  92293. * @param byteOffset the byte offset of the data
  92294. * @param byteStride the byte stride of the data
  92295. * @param componentCount the number of components per element
  92296. * @param componentType the type of the component
  92297. * @param count the number of values to enumerate
  92298. * @param normalized whether the data is normalized
  92299. * @param callback the callback function called for each value
  92300. */
  92301. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  92302. private static _GetFloatValue;
  92303. }
  92304. }
  92305. declare module BABYLON {
  92306. /**
  92307. * @hidden
  92308. */
  92309. export class IntersectionInfo {
  92310. bu: Nullable<number>;
  92311. bv: Nullable<number>;
  92312. distance: number;
  92313. faceId: number;
  92314. subMeshId: number;
  92315. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  92316. }
  92317. }
  92318. declare module BABYLON {
  92319. /**
  92320. * Class used to store bounding sphere information
  92321. */
  92322. export class BoundingSphere {
  92323. /**
  92324. * Gets the center of the bounding sphere in local space
  92325. */
  92326. readonly center: Vector3;
  92327. /**
  92328. * Radius of the bounding sphere in local space
  92329. */
  92330. radius: number;
  92331. /**
  92332. * Gets the center of the bounding sphere in world space
  92333. */
  92334. readonly centerWorld: Vector3;
  92335. /**
  92336. * Radius of the bounding sphere in world space
  92337. */
  92338. radiusWorld: number;
  92339. /**
  92340. * Gets the minimum vector in local space
  92341. */
  92342. readonly minimum: Vector3;
  92343. /**
  92344. * Gets the maximum vector in local space
  92345. */
  92346. readonly maximum: Vector3;
  92347. private _worldMatrix;
  92348. private static readonly TmpVector3;
  92349. /**
  92350. * Creates a new bounding sphere
  92351. * @param min defines the minimum vector (in local space)
  92352. * @param max defines the maximum vector (in local space)
  92353. * @param worldMatrix defines the new world matrix
  92354. */
  92355. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92356. /**
  92357. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  92358. * @param min defines the new minimum vector (in local space)
  92359. * @param max defines the new maximum vector (in local space)
  92360. * @param worldMatrix defines the new world matrix
  92361. */
  92362. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92363. /**
  92364. * Scale the current bounding sphere by applying a scale factor
  92365. * @param factor defines the scale factor to apply
  92366. * @returns the current bounding box
  92367. */
  92368. scale(factor: number): BoundingSphere;
  92369. /**
  92370. * Gets the world matrix of the bounding box
  92371. * @returns a matrix
  92372. */
  92373. getWorldMatrix(): DeepImmutable<Matrix>;
  92374. /** @hidden */
  92375. _update(worldMatrix: DeepImmutable<Matrix>): void;
  92376. /**
  92377. * Tests if the bounding sphere is intersecting the frustum planes
  92378. * @param frustumPlanes defines the frustum planes to test
  92379. * @returns true if there is an intersection
  92380. */
  92381. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92382. /**
  92383. * Tests if the bounding sphere center is in between the frustum planes.
  92384. * Used for optimistic fast inclusion.
  92385. * @param frustumPlanes defines the frustum planes to test
  92386. * @returns true if the sphere center is in between the frustum planes
  92387. */
  92388. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92389. /**
  92390. * Tests if a point is inside the bounding sphere
  92391. * @param point defines the point to test
  92392. * @returns true if the point is inside the bounding sphere
  92393. */
  92394. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92395. /**
  92396. * Checks if two sphere intersct
  92397. * @param sphere0 sphere 0
  92398. * @param sphere1 sphere 1
  92399. * @returns true if the speres intersect
  92400. */
  92401. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  92402. }
  92403. }
  92404. declare module BABYLON {
  92405. /**
  92406. * Class used to store bounding box information
  92407. */
  92408. export class BoundingBox implements ICullable {
  92409. /**
  92410. * Gets the 8 vectors representing the bounding box in local space
  92411. */
  92412. readonly vectors: Vector3[];
  92413. /**
  92414. * Gets the center of the bounding box in local space
  92415. */
  92416. readonly center: Vector3;
  92417. /**
  92418. * Gets the center of the bounding box in world space
  92419. */
  92420. readonly centerWorld: Vector3;
  92421. /**
  92422. * Gets the extend size in local space
  92423. */
  92424. readonly extendSize: Vector3;
  92425. /**
  92426. * Gets the extend size in world space
  92427. */
  92428. readonly extendSizeWorld: Vector3;
  92429. /**
  92430. * Gets the OBB (object bounding box) directions
  92431. */
  92432. readonly directions: Vector3[];
  92433. /**
  92434. * Gets the 8 vectors representing the bounding box in world space
  92435. */
  92436. readonly vectorsWorld: Vector3[];
  92437. /**
  92438. * Gets the minimum vector in world space
  92439. */
  92440. readonly minimumWorld: Vector3;
  92441. /**
  92442. * Gets the maximum vector in world space
  92443. */
  92444. readonly maximumWorld: Vector3;
  92445. /**
  92446. * Gets the minimum vector in local space
  92447. */
  92448. readonly minimum: Vector3;
  92449. /**
  92450. * Gets the maximum vector in local space
  92451. */
  92452. readonly maximum: Vector3;
  92453. private _worldMatrix;
  92454. private static readonly TmpVector3;
  92455. /**
  92456. * @hidden
  92457. */
  92458. _tag: number;
  92459. /**
  92460. * Creates a new bounding box
  92461. * @param min defines the minimum vector (in local space)
  92462. * @param max defines the maximum vector (in local space)
  92463. * @param worldMatrix defines the new world matrix
  92464. */
  92465. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92466. /**
  92467. * Recreates the entire bounding box from scratch as if we call the constructor in place
  92468. * @param min defines the new minimum vector (in local space)
  92469. * @param max defines the new maximum vector (in local space)
  92470. * @param worldMatrix defines the new world matrix
  92471. */
  92472. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92473. /**
  92474. * Scale the current bounding box by applying a scale factor
  92475. * @param factor defines the scale factor to apply
  92476. * @returns the current bounding box
  92477. */
  92478. scale(factor: number): BoundingBox;
  92479. /**
  92480. * Gets the world matrix of the bounding box
  92481. * @returns a matrix
  92482. */
  92483. getWorldMatrix(): DeepImmutable<Matrix>;
  92484. /** @hidden */
  92485. _update(world: DeepImmutable<Matrix>): void;
  92486. /**
  92487. * Tests if the bounding box is intersecting the frustum planes
  92488. * @param frustumPlanes defines the frustum planes to test
  92489. * @returns true if there is an intersection
  92490. */
  92491. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92492. /**
  92493. * Tests if the bounding box is entirely inside the frustum planes
  92494. * @param frustumPlanes defines the frustum planes to test
  92495. * @returns true if there is an inclusion
  92496. */
  92497. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92498. /**
  92499. * Tests if a point is inside the bounding box
  92500. * @param point defines the point to test
  92501. * @returns true if the point is inside the bounding box
  92502. */
  92503. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92504. /**
  92505. * Tests if the bounding box intersects with a bounding sphere
  92506. * @param sphere defines the sphere to test
  92507. * @returns true if there is an intersection
  92508. */
  92509. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  92510. /**
  92511. * Tests if the bounding box intersects with a box defined by a min and max vectors
  92512. * @param min defines the min vector to use
  92513. * @param max defines the max vector to use
  92514. * @returns true if there is an intersection
  92515. */
  92516. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  92517. /**
  92518. * Tests if two bounding boxes are intersections
  92519. * @param box0 defines the first box to test
  92520. * @param box1 defines the second box to test
  92521. * @returns true if there is an intersection
  92522. */
  92523. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  92524. /**
  92525. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  92526. * @param minPoint defines the minimum vector of the bounding box
  92527. * @param maxPoint defines the maximum vector of the bounding box
  92528. * @param sphereCenter defines the sphere center
  92529. * @param sphereRadius defines the sphere radius
  92530. * @returns true if there is an intersection
  92531. */
  92532. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  92533. /**
  92534. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  92535. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  92536. * @param frustumPlanes defines the frustum planes to test
  92537. * @return true if there is an inclusion
  92538. */
  92539. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92540. /**
  92541. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  92542. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  92543. * @param frustumPlanes defines the frustum planes to test
  92544. * @return true if there is an intersection
  92545. */
  92546. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92547. }
  92548. }
  92549. declare module BABYLON {
  92550. /** @hidden */
  92551. export class Collider {
  92552. /** Define if a collision was found */
  92553. collisionFound: boolean;
  92554. /**
  92555. * Define last intersection point in local space
  92556. */
  92557. intersectionPoint: Vector3;
  92558. /**
  92559. * Define last collided mesh
  92560. */
  92561. collidedMesh: Nullable<AbstractMesh>;
  92562. private _collisionPoint;
  92563. private _planeIntersectionPoint;
  92564. private _tempVector;
  92565. private _tempVector2;
  92566. private _tempVector3;
  92567. private _tempVector4;
  92568. private _edge;
  92569. private _baseToVertex;
  92570. private _destinationPoint;
  92571. private _slidePlaneNormal;
  92572. private _displacementVector;
  92573. /** @hidden */
  92574. _radius: Vector3;
  92575. /** @hidden */
  92576. _retry: number;
  92577. private _velocity;
  92578. private _basePoint;
  92579. private _epsilon;
  92580. /** @hidden */
  92581. _velocityWorldLength: number;
  92582. /** @hidden */
  92583. _basePointWorld: Vector3;
  92584. private _velocityWorld;
  92585. private _normalizedVelocity;
  92586. /** @hidden */
  92587. _initialVelocity: Vector3;
  92588. /** @hidden */
  92589. _initialPosition: Vector3;
  92590. private _nearestDistance;
  92591. private _collisionMask;
  92592. get collisionMask(): number;
  92593. set collisionMask(mask: number);
  92594. /**
  92595. * Gets the plane normal used to compute the sliding response (in local space)
  92596. */
  92597. get slidePlaneNormal(): Vector3;
  92598. /** @hidden */
  92599. _initialize(source: Vector3, dir: Vector3, e: number): void;
  92600. /** @hidden */
  92601. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  92602. /** @hidden */
  92603. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  92604. /** @hidden */
  92605. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92606. /** @hidden */
  92607. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92608. /** @hidden */
  92609. _getResponse(pos: Vector3, vel: Vector3): void;
  92610. }
  92611. }
  92612. declare module BABYLON {
  92613. /**
  92614. * Interface for cullable objects
  92615. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  92616. */
  92617. export interface ICullable {
  92618. /**
  92619. * Checks if the object or part of the object is in the frustum
  92620. * @param frustumPlanes Camera near/planes
  92621. * @returns true if the object is in frustum otherwise false
  92622. */
  92623. isInFrustum(frustumPlanes: Plane[]): boolean;
  92624. /**
  92625. * Checks if a cullable object (mesh...) is in the camera frustum
  92626. * Unlike isInFrustum this cheks the full bounding box
  92627. * @param frustumPlanes Camera near/planes
  92628. * @returns true if the object is in frustum otherwise false
  92629. */
  92630. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92631. }
  92632. /**
  92633. * Info for a bounding data of a mesh
  92634. */
  92635. export class BoundingInfo implements ICullable {
  92636. /**
  92637. * Bounding box for the mesh
  92638. */
  92639. readonly boundingBox: BoundingBox;
  92640. /**
  92641. * Bounding sphere for the mesh
  92642. */
  92643. readonly boundingSphere: BoundingSphere;
  92644. private _isLocked;
  92645. private static readonly TmpVector3;
  92646. /**
  92647. * Constructs bounding info
  92648. * @param minimum min vector of the bounding box/sphere
  92649. * @param maximum max vector of the bounding box/sphere
  92650. * @param worldMatrix defines the new world matrix
  92651. */
  92652. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92653. /**
  92654. * Recreates the entire bounding info from scratch as if we call the constructor in place
  92655. * @param min defines the new minimum vector (in local space)
  92656. * @param max defines the new maximum vector (in local space)
  92657. * @param worldMatrix defines the new world matrix
  92658. */
  92659. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92660. /**
  92661. * min vector of the bounding box/sphere
  92662. */
  92663. get minimum(): Vector3;
  92664. /**
  92665. * max vector of the bounding box/sphere
  92666. */
  92667. get maximum(): Vector3;
  92668. /**
  92669. * If the info is locked and won't be updated to avoid perf overhead
  92670. */
  92671. get isLocked(): boolean;
  92672. set isLocked(value: boolean);
  92673. /**
  92674. * Updates the bounding sphere and box
  92675. * @param world world matrix to be used to update
  92676. */
  92677. update(world: DeepImmutable<Matrix>): void;
  92678. /**
  92679. * Recreate the bounding info to be centered around a specific point given a specific extend.
  92680. * @param center New center of the bounding info
  92681. * @param extend New extend of the bounding info
  92682. * @returns the current bounding info
  92683. */
  92684. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  92685. /**
  92686. * Grows the bounding info to include the given point.
  92687. * @param point The point that will be included in the current bounding info
  92688. * @returns the current bounding info
  92689. */
  92690. encapsulate(point: Vector3): BoundingInfo;
  92691. /**
  92692. * Grows the bounding info to encapsulate the given bounding info.
  92693. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  92694. * @returns the current bounding info
  92695. */
  92696. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  92697. /**
  92698. * Scale the current bounding info by applying a scale factor
  92699. * @param factor defines the scale factor to apply
  92700. * @returns the current bounding info
  92701. */
  92702. scale(factor: number): BoundingInfo;
  92703. /**
  92704. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  92705. * @param frustumPlanes defines the frustum to test
  92706. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  92707. * @returns true if the bounding info is in the frustum planes
  92708. */
  92709. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  92710. /**
  92711. * Gets the world distance between the min and max points of the bounding box
  92712. */
  92713. get diagonalLength(): number;
  92714. /**
  92715. * Checks if a cullable object (mesh...) is in the camera frustum
  92716. * Unlike isInFrustum this cheks the full bounding box
  92717. * @param frustumPlanes Camera near/planes
  92718. * @returns true if the object is in frustum otherwise false
  92719. */
  92720. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92721. /** @hidden */
  92722. _checkCollision(collider: Collider): boolean;
  92723. /**
  92724. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  92725. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92726. * @param point the point to check intersection with
  92727. * @returns if the point intersects
  92728. */
  92729. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92730. /**
  92731. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  92732. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92733. * @param boundingInfo the bounding info to check intersection with
  92734. * @param precise if the intersection should be done using OBB
  92735. * @returns if the bounding info intersects
  92736. */
  92737. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  92738. }
  92739. }
  92740. declare module BABYLON {
  92741. /**
  92742. * Extracts minimum and maximum values from a list of indexed positions
  92743. * @param positions defines the positions to use
  92744. * @param indices defines the indices to the positions
  92745. * @param indexStart defines the start index
  92746. * @param indexCount defines the end index
  92747. * @param bias defines bias value to add to the result
  92748. * @return minimum and maximum values
  92749. */
  92750. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  92751. minimum: Vector3;
  92752. maximum: Vector3;
  92753. };
  92754. /**
  92755. * Extracts minimum and maximum values from a list of positions
  92756. * @param positions defines the positions to use
  92757. * @param start defines the start index in the positions array
  92758. * @param count defines the number of positions to handle
  92759. * @param bias defines bias value to add to the result
  92760. * @param stride defines the stride size to use (distance between two positions in the positions array)
  92761. * @return minimum and maximum values
  92762. */
  92763. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  92764. minimum: Vector3;
  92765. maximum: Vector3;
  92766. };
  92767. }
  92768. declare module BABYLON {
  92769. /**
  92770. * Class used to manipulate GUIDs
  92771. */
  92772. export class GUID {
  92773. /**
  92774. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92775. * Be aware Math.random() could cause collisions, but:
  92776. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  92777. * @returns a pseudo random id
  92778. */
  92779. static RandomId(): string;
  92780. }
  92781. }
  92782. declare module BABYLON {
  92783. /**
  92784. * Base class of all the textures in babylon.
  92785. * It groups all the common properties the materials, post process, lights... might need
  92786. * in order to make a correct use of the texture.
  92787. */
  92788. export class BaseTexture extends ThinTexture implements IAnimatable {
  92789. /**
  92790. * Default anisotropic filtering level for the application.
  92791. * It is set to 4 as a good tradeoff between perf and quality.
  92792. */
  92793. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92794. /**
  92795. * Gets or sets the unique id of the texture
  92796. */
  92797. uniqueId: number;
  92798. /**
  92799. * Define the name of the texture.
  92800. */
  92801. name: string;
  92802. /**
  92803. * Gets or sets an object used to store user defined information.
  92804. */
  92805. metadata: any;
  92806. /**
  92807. * For internal use only. Please do not use.
  92808. */
  92809. reservedDataStore: any;
  92810. private _hasAlpha;
  92811. /**
  92812. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92813. */
  92814. set hasAlpha(value: boolean);
  92815. get hasAlpha(): boolean;
  92816. /**
  92817. * Defines if the alpha value should be determined via the rgb values.
  92818. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92819. */
  92820. getAlphaFromRGB: boolean;
  92821. /**
  92822. * Intensity or strength of the texture.
  92823. * It is commonly used by materials to fine tune the intensity of the texture
  92824. */
  92825. level: number;
  92826. /**
  92827. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92828. * This is part of the texture as textures usually maps to one uv set.
  92829. */
  92830. coordinatesIndex: number;
  92831. protected _coordinatesMode: number;
  92832. /**
  92833. * How a texture is mapped.
  92834. *
  92835. * | Value | Type | Description |
  92836. * | ----- | ----------------------------------- | ----------- |
  92837. * | 0 | EXPLICIT_MODE | |
  92838. * | 1 | SPHERICAL_MODE | |
  92839. * | 2 | PLANAR_MODE | |
  92840. * | 3 | CUBIC_MODE | |
  92841. * | 4 | PROJECTION_MODE | |
  92842. * | 5 | SKYBOX_MODE | |
  92843. * | 6 | INVCUBIC_MODE | |
  92844. * | 7 | EQUIRECTANGULAR_MODE | |
  92845. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92846. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92847. */
  92848. set coordinatesMode(value: number);
  92849. get coordinatesMode(): number;
  92850. /**
  92851. * | Value | Type | Description |
  92852. * | ----- | ------------------ | ----------- |
  92853. * | 0 | CLAMP_ADDRESSMODE | |
  92854. * | 1 | WRAP_ADDRESSMODE | |
  92855. * | 2 | MIRROR_ADDRESSMODE | |
  92856. */
  92857. get wrapU(): number;
  92858. set wrapU(value: number);
  92859. /**
  92860. * | Value | Type | Description |
  92861. * | ----- | ------------------ | ----------- |
  92862. * | 0 | CLAMP_ADDRESSMODE | |
  92863. * | 1 | WRAP_ADDRESSMODE | |
  92864. * | 2 | MIRROR_ADDRESSMODE | |
  92865. */
  92866. get wrapV(): number;
  92867. set wrapV(value: number);
  92868. /**
  92869. * | Value | Type | Description |
  92870. * | ----- | ------------------ | ----------- |
  92871. * | 0 | CLAMP_ADDRESSMODE | |
  92872. * | 1 | WRAP_ADDRESSMODE | |
  92873. * | 2 | MIRROR_ADDRESSMODE | |
  92874. */
  92875. wrapR: number;
  92876. /**
  92877. * With compliant hardware and browser (supporting anisotropic filtering)
  92878. * this defines the level of anisotropic filtering in the texture.
  92879. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92880. */
  92881. anisotropicFilteringLevel: number;
  92882. private _isCube;
  92883. /**
  92884. * Define if the texture is a cube texture or if false a 2d texture.
  92885. */
  92886. get isCube(): boolean;
  92887. set isCube(value: boolean);
  92888. /**
  92889. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92890. */
  92891. get is3D(): boolean;
  92892. set is3D(value: boolean);
  92893. /**
  92894. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  92895. */
  92896. get is2DArray(): boolean;
  92897. set is2DArray(value: boolean);
  92898. private _gammaSpace;
  92899. /**
  92900. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92901. * HDR texture are usually stored in linear space.
  92902. * This only impacts the PBR and Background materials
  92903. */
  92904. get gammaSpace(): boolean;
  92905. set gammaSpace(gamma: boolean);
  92906. /**
  92907. * Gets or sets whether or not the texture contains RGBD data.
  92908. */
  92909. get isRGBD(): boolean;
  92910. set isRGBD(value: boolean);
  92911. /**
  92912. * Is Z inverted in the texture (useful in a cube texture).
  92913. */
  92914. invertZ: boolean;
  92915. /**
  92916. * Are mip maps generated for this texture or not.
  92917. */
  92918. get noMipmap(): boolean;
  92919. /**
  92920. * @hidden
  92921. */
  92922. lodLevelInAlpha: boolean;
  92923. /**
  92924. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92925. */
  92926. get lodGenerationOffset(): number;
  92927. set lodGenerationOffset(value: number);
  92928. /**
  92929. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92930. */
  92931. get lodGenerationScale(): number;
  92932. set lodGenerationScale(value: number);
  92933. /**
  92934. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92935. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92936. * average roughness values.
  92937. */
  92938. get linearSpecularLOD(): boolean;
  92939. set linearSpecularLOD(value: boolean);
  92940. /**
  92941. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92942. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92943. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92944. */
  92945. get irradianceTexture(): Nullable<BaseTexture>;
  92946. set irradianceTexture(value: Nullable<BaseTexture>);
  92947. /**
  92948. * Define if the texture is a render target.
  92949. */
  92950. isRenderTarget: boolean;
  92951. /**
  92952. * Define the unique id of the texture in the scene.
  92953. */
  92954. get uid(): string;
  92955. /** @hidden */
  92956. _prefiltered: boolean;
  92957. /**
  92958. * Return a string representation of the texture.
  92959. * @returns the texture as a string
  92960. */
  92961. toString(): string;
  92962. /**
  92963. * Get the class name of the texture.
  92964. * @returns "BaseTexture"
  92965. */
  92966. getClassName(): string;
  92967. /**
  92968. * Define the list of animation attached to the texture.
  92969. */
  92970. animations: Animation[];
  92971. /**
  92972. * An event triggered when the texture is disposed.
  92973. */
  92974. onDisposeObservable: Observable<BaseTexture>;
  92975. private _onDisposeObserver;
  92976. /**
  92977. * Callback triggered when the texture has been disposed.
  92978. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92979. */
  92980. set onDispose(callback: () => void);
  92981. protected _scene: Nullable<Scene>;
  92982. /** @hidden */
  92983. _texture: Nullable<InternalTexture>;
  92984. private _uid;
  92985. /**
  92986. * Define if the texture is preventinga material to render or not.
  92987. * If not and the texture is not ready, the engine will use a default black texture instead.
  92988. */
  92989. get isBlocking(): boolean;
  92990. /**
  92991. * Instantiates a new BaseTexture.
  92992. * Base class of all the textures in babylon.
  92993. * It groups all the common properties the materials, post process, lights... might need
  92994. * in order to make a correct use of the texture.
  92995. * @param sceneOrEngine Define the scene or engine the texture blongs to
  92996. */
  92997. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  92998. /**
  92999. * Get the scene the texture belongs to.
  93000. * @returns the scene or null if undefined
  93001. */
  93002. getScene(): Nullable<Scene>;
  93003. /** @hidden */
  93004. protected _getEngine(): Nullable<ThinEngine>;
  93005. /**
  93006. * Checks if the texture has the same transform matrix than another texture
  93007. * @param texture texture to check against
  93008. * @returns true if the transforms are the same, else false
  93009. */
  93010. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  93011. /**
  93012. * Get the texture transform matrix used to offset tile the texture for istance.
  93013. * @returns the transformation matrix
  93014. */
  93015. getTextureMatrix(): Matrix;
  93016. /**
  93017. * Get the texture reflection matrix used to rotate/transform the reflection.
  93018. * @returns the reflection matrix
  93019. */
  93020. getReflectionTextureMatrix(): Matrix;
  93021. /**
  93022. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93023. * @returns true if ready or not blocking
  93024. */
  93025. isReadyOrNotBlocking(): boolean;
  93026. /**
  93027. * Scales the texture if is `canRescale()`
  93028. * @param ratio the resize factor we want to use to rescale
  93029. */
  93030. scale(ratio: number): void;
  93031. /**
  93032. * Get if the texture can rescale.
  93033. */
  93034. get canRescale(): boolean;
  93035. /** @hidden */
  93036. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93037. /** @hidden */
  93038. _rebuild(): void;
  93039. /**
  93040. * Clones the texture.
  93041. * @returns the cloned texture
  93042. */
  93043. clone(): Nullable<BaseTexture>;
  93044. /**
  93045. * Get the texture underlying type (INT, FLOAT...)
  93046. */
  93047. get textureType(): number;
  93048. /**
  93049. * Get the texture underlying format (RGB, RGBA...)
  93050. */
  93051. get textureFormat(): number;
  93052. /**
  93053. * Indicates that textures need to be re-calculated for all materials
  93054. */
  93055. protected _markAllSubMeshesAsTexturesDirty(): void;
  93056. /**
  93057. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93058. * This will returns an RGBA array buffer containing either in values (0-255) or
  93059. * float values (0-1) depending of the underlying buffer type.
  93060. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93061. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93062. * @param buffer defines a user defined buffer to fill with data (can be null)
  93063. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  93064. * @returns The Array buffer promise containing the pixels data.
  93065. */
  93066. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  93067. /** @hidden */
  93068. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  93069. /** @hidden */
  93070. get _lodTextureHigh(): Nullable<BaseTexture>;
  93071. /** @hidden */
  93072. get _lodTextureMid(): Nullable<BaseTexture>;
  93073. /** @hidden */
  93074. get _lodTextureLow(): Nullable<BaseTexture>;
  93075. /**
  93076. * Dispose the texture and release its associated resources.
  93077. */
  93078. dispose(): void;
  93079. /**
  93080. * Serialize the texture into a JSON representation that can be parsed later on.
  93081. * @returns the JSON representation of the texture
  93082. */
  93083. serialize(): any;
  93084. /**
  93085. * Helper function to be called back once a list of texture contains only ready textures.
  93086. * @param textures Define the list of textures to wait for
  93087. * @param callback Define the callback triggered once the entire list will be ready
  93088. */
  93089. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93090. private static _isScene;
  93091. }
  93092. }
  93093. declare module BABYLON {
  93094. /** @hidden */
  93095. export class WebGLDataBuffer extends DataBuffer {
  93096. private _buffer;
  93097. constructor(resource: WebGLBuffer);
  93098. get underlyingResource(): any;
  93099. }
  93100. }
  93101. declare module BABYLON {
  93102. /** @hidden */
  93103. export class WebGLPipelineContext implements IPipelineContext {
  93104. private _valueCache;
  93105. private _uniforms;
  93106. engine: ThinEngine;
  93107. program: Nullable<WebGLProgram>;
  93108. context?: WebGLRenderingContext;
  93109. vertexShader?: WebGLShader;
  93110. fragmentShader?: WebGLShader;
  93111. isParallelCompiled: boolean;
  93112. onCompiled?: () => void;
  93113. transformFeedback?: WebGLTransformFeedback | null;
  93114. vertexCompilationError: Nullable<string>;
  93115. fragmentCompilationError: Nullable<string>;
  93116. programLinkError: Nullable<string>;
  93117. programValidationError: Nullable<string>;
  93118. get isAsync(): boolean;
  93119. get isReady(): boolean;
  93120. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93121. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  93122. [key: string]: number;
  93123. }, uniformsNames: string[], uniforms: {
  93124. [key: string]: Nullable<WebGLUniformLocation>;
  93125. }, samplerList: string[], samplers: {
  93126. [key: string]: number;
  93127. }, attributesNames: string[], attributes: number[]): void;
  93128. /**
  93129. * Release all associated resources.
  93130. **/
  93131. dispose(): void;
  93132. /** @hidden */
  93133. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93134. /** @hidden */
  93135. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93136. /** @hidden */
  93137. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93138. /** @hidden */
  93139. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93140. /**
  93141. * Sets an interger value on a uniform variable.
  93142. * @param uniformName Name of the variable.
  93143. * @param value Value to be set.
  93144. */
  93145. setInt(uniformName: string, value: number): void;
  93146. /**
  93147. * Sets a int2 on a uniform variable.
  93148. * @param uniformName Name of the variable.
  93149. * @param x First int in int2.
  93150. * @param y Second int in int2.
  93151. */
  93152. setInt2(uniformName: string, x: number, y: number): void;
  93153. /**
  93154. * Sets a int3 on a uniform variable.
  93155. * @param uniformName Name of the variable.
  93156. * @param x First int in int3.
  93157. * @param y Second int in int3.
  93158. * @param y Third int in int3.
  93159. */
  93160. setInt3(uniformName: string, x: number, y: number, z: number): void;
  93161. /**
  93162. * Sets a int4 on a uniform variable.
  93163. * @param uniformName Name of the variable.
  93164. * @param x First int in int4.
  93165. * @param y Second int in int4.
  93166. * @param y Third int in int4.
  93167. * @param w Fourth int in int4.
  93168. */
  93169. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  93170. /**
  93171. * Sets an int array on a uniform variable.
  93172. * @param uniformName Name of the variable.
  93173. * @param array array to be set.
  93174. */
  93175. setIntArray(uniformName: string, array: Int32Array): void;
  93176. /**
  93177. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  93178. * @param uniformName Name of the variable.
  93179. * @param array array to be set.
  93180. */
  93181. setIntArray2(uniformName: string, array: Int32Array): void;
  93182. /**
  93183. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  93184. * @param uniformName Name of the variable.
  93185. * @param array array to be set.
  93186. */
  93187. setIntArray3(uniformName: string, array: Int32Array): void;
  93188. /**
  93189. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  93190. * @param uniformName Name of the variable.
  93191. * @param array array to be set.
  93192. */
  93193. setIntArray4(uniformName: string, array: Int32Array): void;
  93194. /**
  93195. * Sets an array on a uniform variable.
  93196. * @param uniformName Name of the variable.
  93197. * @param array array to be set.
  93198. */
  93199. setArray(uniformName: string, array: number[]): void;
  93200. /**
  93201. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  93202. * @param uniformName Name of the variable.
  93203. * @param array array to be set.
  93204. */
  93205. setArray2(uniformName: string, array: number[]): void;
  93206. /**
  93207. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  93208. * @param uniformName Name of the variable.
  93209. * @param array array to be set.
  93210. * @returns this effect.
  93211. */
  93212. setArray3(uniformName: string, array: number[]): void;
  93213. /**
  93214. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  93215. * @param uniformName Name of the variable.
  93216. * @param array array to be set.
  93217. */
  93218. setArray4(uniformName: string, array: number[]): void;
  93219. /**
  93220. * Sets matrices on a uniform variable.
  93221. * @param uniformName Name of the variable.
  93222. * @param matrices matrices to be set.
  93223. */
  93224. setMatrices(uniformName: string, matrices: Float32Array): void;
  93225. /**
  93226. * Sets matrix on a uniform variable.
  93227. * @param uniformName Name of the variable.
  93228. * @param matrix matrix to be set.
  93229. */
  93230. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  93231. /**
  93232. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  93233. * @param uniformName Name of the variable.
  93234. * @param matrix matrix to be set.
  93235. */
  93236. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  93237. /**
  93238. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93239. * @param uniformName Name of the variable.
  93240. * @param matrix matrix to be set.
  93241. */
  93242. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  93243. /**
  93244. * Sets a float on a uniform variable.
  93245. * @param uniformName Name of the variable.
  93246. * @param value value to be set.
  93247. * @returns this effect.
  93248. */
  93249. setFloat(uniformName: string, value: number): void;
  93250. /**
  93251. * Sets a Vector2 on a uniform variable.
  93252. * @param uniformName Name of the variable.
  93253. * @param vector2 vector2 to be set.
  93254. */
  93255. setVector2(uniformName: string, vector2: IVector2Like): void;
  93256. /**
  93257. * Sets a float2 on a uniform variable.
  93258. * @param uniformName Name of the variable.
  93259. * @param x First float in float2.
  93260. * @param y Second float in float2.
  93261. */
  93262. setFloat2(uniformName: string, x: number, y: number): void;
  93263. /**
  93264. * Sets a Vector3 on a uniform variable.
  93265. * @param uniformName Name of the variable.
  93266. * @param vector3 Value to be set.
  93267. */
  93268. setVector3(uniformName: string, vector3: IVector3Like): void;
  93269. /**
  93270. * Sets a float3 on a uniform variable.
  93271. * @param uniformName Name of the variable.
  93272. * @param x First float in float3.
  93273. * @param y Second float in float3.
  93274. * @param z Third float in float3.
  93275. */
  93276. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  93277. /**
  93278. * Sets a Vector4 on a uniform variable.
  93279. * @param uniformName Name of the variable.
  93280. * @param vector4 Value to be set.
  93281. */
  93282. setVector4(uniformName: string, vector4: IVector4Like): void;
  93283. /**
  93284. * Sets a float4 on a uniform variable.
  93285. * @param uniformName Name of the variable.
  93286. * @param x First float in float4.
  93287. * @param y Second float in float4.
  93288. * @param z Third float in float4.
  93289. * @param w Fourth float in float4.
  93290. * @returns this effect.
  93291. */
  93292. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  93293. /**
  93294. * Sets a Color3 on a uniform variable.
  93295. * @param uniformName Name of the variable.
  93296. * @param color3 Value to be set.
  93297. */
  93298. setColor3(uniformName: string, color3: IColor3Like): void;
  93299. /**
  93300. * Sets a Color4 on a uniform variable.
  93301. * @param uniformName Name of the variable.
  93302. * @param color3 Value to be set.
  93303. * @param alpha Alpha value to be set.
  93304. */
  93305. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  93306. /**
  93307. * Sets a Color4 on a uniform variable
  93308. * @param uniformName defines the name of the variable
  93309. * @param color4 defines the value to be set
  93310. */
  93311. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  93312. _getVertexShaderCode(): string | null;
  93313. _getFragmentShaderCode(): string | null;
  93314. }
  93315. }
  93316. declare module BABYLON {
  93317. interface ThinEngine {
  93318. /**
  93319. * Create an uniform buffer
  93320. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93321. * @param elements defines the content of the uniform buffer
  93322. * @returns the webGL uniform buffer
  93323. */
  93324. createUniformBuffer(elements: FloatArray): DataBuffer;
  93325. /**
  93326. * Create a dynamic uniform buffer
  93327. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93328. * @param elements defines the content of the uniform buffer
  93329. * @returns the webGL uniform buffer
  93330. */
  93331. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  93332. /**
  93333. * Update an existing uniform buffer
  93334. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93335. * @param uniformBuffer defines the target uniform buffer
  93336. * @param elements defines the content to update
  93337. * @param offset defines the offset in the uniform buffer where update should start
  93338. * @param count defines the size of the data to update
  93339. */
  93340. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  93341. /**
  93342. * Bind an uniform buffer to the current webGL context
  93343. * @param buffer defines the buffer to bind
  93344. */
  93345. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  93346. /**
  93347. * Bind a buffer to the current webGL context at a given location
  93348. * @param buffer defines the buffer to bind
  93349. * @param location defines the index where to bind the buffer
  93350. * @param name Name of the uniform variable to bind
  93351. */
  93352. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  93353. /**
  93354. * Bind a specific block at a given index in a specific shader program
  93355. * @param pipelineContext defines the pipeline context to use
  93356. * @param blockName defines the block name
  93357. * @param index defines the index where to bind the block
  93358. */
  93359. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  93360. }
  93361. }
  93362. declare module BABYLON {
  93363. /**
  93364. * Uniform buffer objects.
  93365. *
  93366. * Handles blocks of uniform on the GPU.
  93367. *
  93368. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93369. *
  93370. * For more information, please refer to :
  93371. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93372. */
  93373. export class UniformBuffer {
  93374. /** @hidden */
  93375. static _updatedUbosInFrame: {
  93376. [name: string]: number;
  93377. };
  93378. private _engine;
  93379. private _buffer;
  93380. private _buffers;
  93381. private _bufferIndex;
  93382. private _createBufferOnWrite;
  93383. private _data;
  93384. private _bufferData;
  93385. private _dynamic?;
  93386. private _uniformLocations;
  93387. private _uniformSizes;
  93388. private _uniformArraySizes;
  93389. private _uniformLocationPointer;
  93390. private _needSync;
  93391. private _noUBO;
  93392. private _currentEffect;
  93393. private _currentEffectName;
  93394. private _name;
  93395. private _currentFrameId;
  93396. /** @hidden */
  93397. _alreadyBound: boolean;
  93398. private static _MAX_UNIFORM_SIZE;
  93399. private static _tempBuffer;
  93400. private static _tempBufferInt32View;
  93401. /**
  93402. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93403. * This is dynamic to allow compat with webgl 1 and 2.
  93404. * You will need to pass the name of the uniform as well as the value.
  93405. */
  93406. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93407. /**
  93408. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93409. * This is dynamic to allow compat with webgl 1 and 2.
  93410. * You will need to pass the name of the uniform as well as the value.
  93411. */
  93412. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93413. /**
  93414. * Lambda to Update a single float in a uniform buffer.
  93415. * This is dynamic to allow compat with webgl 1 and 2.
  93416. * You will need to pass the name of the uniform as well as the value.
  93417. */
  93418. updateFloat: (name: string, x: number) => void;
  93419. /**
  93420. * Lambda to Update a vec2 of float in a uniform buffer.
  93421. * This is dynamic to allow compat with webgl 1 and 2.
  93422. * You will need to pass the name of the uniform as well as the value.
  93423. */
  93424. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93425. /**
  93426. * Lambda to Update a vec3 of float in a uniform buffer.
  93427. * This is dynamic to allow compat with webgl 1 and 2.
  93428. * You will need to pass the name of the uniform as well as the value.
  93429. */
  93430. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93431. /**
  93432. * Lambda to Update a vec4 of float in a uniform buffer.
  93433. * This is dynamic to allow compat with webgl 1 and 2.
  93434. * You will need to pass the name of the uniform as well as the value.
  93435. */
  93436. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93437. /**
  93438. * Lambda to Update an array of float in a uniform buffer.
  93439. * This is dynamic to allow compat with webgl 1 and 2.
  93440. * You will need to pass the name of the uniform as well as the value.
  93441. */
  93442. updateFloatArray: (name: string, array: Float32Array) => void;
  93443. /**
  93444. * Lambda to Update an array of number in a uniform buffer.
  93445. * This is dynamic to allow compat with webgl 1 and 2.
  93446. * You will need to pass the name of the uniform as well as the value.
  93447. */
  93448. updateArray: (name: string, array: number[]) => void;
  93449. /**
  93450. * Lambda to Update an array of number in a uniform buffer.
  93451. * This is dynamic to allow compat with webgl 1 and 2.
  93452. * You will need to pass the name of the uniform as well as the value.
  93453. */
  93454. updateIntArray: (name: string, array: Int32Array) => void;
  93455. /**
  93456. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93457. * This is dynamic to allow compat with webgl 1 and 2.
  93458. * You will need to pass the name of the uniform as well as the value.
  93459. */
  93460. updateMatrix: (name: string, mat: IMatrixLike) => void;
  93461. /**
  93462. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  93463. * This is dynamic to allow compat with webgl 1 and 2.
  93464. * You will need to pass the name of the uniform as well as the value.
  93465. */
  93466. updateMatrices: (name: string, mat: Float32Array) => void;
  93467. /**
  93468. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93469. * This is dynamic to allow compat with webgl 1 and 2.
  93470. * You will need to pass the name of the uniform as well as the value.
  93471. */
  93472. updateVector3: (name: string, vector: Vector3) => void;
  93473. /**
  93474. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93475. * This is dynamic to allow compat with webgl 1 and 2.
  93476. * You will need to pass the name of the uniform as well as the value.
  93477. */
  93478. updateVector4: (name: string, vector: Vector4) => void;
  93479. /**
  93480. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93481. * This is dynamic to allow compat with webgl 1 and 2.
  93482. * You will need to pass the name of the uniform as well as the value.
  93483. */
  93484. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93485. /**
  93486. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93487. * This is dynamic to allow compat with webgl 1 and 2.
  93488. * You will need to pass the name of the uniform as well as the value.
  93489. */
  93490. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93491. /**
  93492. * Lambda to Update a int a uniform buffer.
  93493. * This is dynamic to allow compat with webgl 1 and 2.
  93494. * You will need to pass the name of the uniform as well as the value.
  93495. */
  93496. updateInt: (name: string, x: number, suffix?: string) => void;
  93497. /**
  93498. * Lambda to Update a vec2 of int in a uniform buffer.
  93499. * This is dynamic to allow compat with webgl 1 and 2.
  93500. * You will need to pass the name of the uniform as well as the value.
  93501. */
  93502. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  93503. /**
  93504. * Lambda to Update a vec3 of int in a uniform buffer.
  93505. * This is dynamic to allow compat with webgl 1 and 2.
  93506. * You will need to pass the name of the uniform as well as the value.
  93507. */
  93508. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93509. /**
  93510. * Lambda to Update a vec4 of int in a uniform buffer.
  93511. * This is dynamic to allow compat with webgl 1 and 2.
  93512. * You will need to pass the name of the uniform as well as the value.
  93513. */
  93514. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93515. /**
  93516. * Instantiates a new Uniform buffer objects.
  93517. *
  93518. * Handles blocks of uniform on the GPU.
  93519. *
  93520. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93521. *
  93522. * For more information, please refer to :
  93523. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93524. * @param engine Define the engine the buffer is associated with
  93525. * @param data Define the data contained in the buffer
  93526. * @param dynamic Define if the buffer is updatable
  93527. * @param name to assign to the buffer (debugging purpose)
  93528. */
  93529. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  93530. /**
  93531. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93532. * or just falling back on setUniformXXX calls.
  93533. */
  93534. get useUbo(): boolean;
  93535. /**
  93536. * Indicates if the WebGL underlying uniform buffer is in sync
  93537. * with the javascript cache data.
  93538. */
  93539. get isSync(): boolean;
  93540. /**
  93541. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93542. * Also, a dynamic UniformBuffer will disable cache verification and always
  93543. * update the underlying WebGL uniform buffer to the GPU.
  93544. * @returns if Dynamic, otherwise false
  93545. */
  93546. isDynamic(): boolean;
  93547. /**
  93548. * The data cache on JS side.
  93549. * @returns the underlying data as a float array
  93550. */
  93551. getData(): Float32Array;
  93552. /**
  93553. * The underlying WebGL Uniform buffer.
  93554. * @returns the webgl buffer
  93555. */
  93556. getBuffer(): Nullable<DataBuffer>;
  93557. /**
  93558. * std140 layout specifies how to align data within an UBO structure.
  93559. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93560. * for specs.
  93561. */
  93562. private _fillAlignment;
  93563. /**
  93564. * Adds an uniform in the buffer.
  93565. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93566. * for the layout to be correct !
  93567. * @param name Name of the uniform, as used in the uniform block in the shader.
  93568. * @param size Data size, or data directly.
  93569. * @param arraySize The number of elements in the array, 0 if not an array.
  93570. */
  93571. addUniform(name: string, size: number | number[], arraySize?: number): void;
  93572. /**
  93573. * Adds a Matrix 4x4 to the uniform buffer.
  93574. * @param name Name of the uniform, as used in the uniform block in the shader.
  93575. * @param mat A 4x4 matrix.
  93576. */
  93577. addMatrix(name: string, mat: Matrix): void;
  93578. /**
  93579. * Adds a vec2 to the uniform buffer.
  93580. * @param name Name of the uniform, as used in the uniform block in the shader.
  93581. * @param x Define the x component value of the vec2
  93582. * @param y Define the y component value of the vec2
  93583. */
  93584. addFloat2(name: string, x: number, y: number): void;
  93585. /**
  93586. * Adds a vec3 to the uniform buffer.
  93587. * @param name Name of the uniform, as used in the uniform block in the shader.
  93588. * @param x Define the x component value of the vec3
  93589. * @param y Define the y component value of the vec3
  93590. * @param z Define the z component value of the vec3
  93591. */
  93592. addFloat3(name: string, x: number, y: number, z: number): void;
  93593. /**
  93594. * Adds a vec3 to the uniform buffer.
  93595. * @param name Name of the uniform, as used in the uniform block in the shader.
  93596. * @param color Define the vec3 from a Color
  93597. */
  93598. addColor3(name: string, color: Color3): void;
  93599. /**
  93600. * Adds a vec4 to the uniform buffer.
  93601. * @param name Name of the uniform, as used in the uniform block in the shader.
  93602. * @param color Define the rgb components from a Color
  93603. * @param alpha Define the a component of the vec4
  93604. */
  93605. addColor4(name: string, color: Color3, alpha: number): void;
  93606. /**
  93607. * Adds a vec3 to the uniform buffer.
  93608. * @param name Name of the uniform, as used in the uniform block in the shader.
  93609. * @param vector Define the vec3 components from a Vector
  93610. */
  93611. addVector3(name: string, vector: Vector3): void;
  93612. /**
  93613. * Adds a Matrix 3x3 to the uniform buffer.
  93614. * @param name Name of the uniform, as used in the uniform block in the shader.
  93615. */
  93616. addMatrix3x3(name: string): void;
  93617. /**
  93618. * Adds a Matrix 2x2 to the uniform buffer.
  93619. * @param name Name of the uniform, as used in the uniform block in the shader.
  93620. */
  93621. addMatrix2x2(name: string): void;
  93622. /**
  93623. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93624. */
  93625. create(): void;
  93626. /** @hidden */
  93627. _rebuild(): void;
  93628. /** @hidden */
  93629. get _numBuffers(): number;
  93630. /** @hidden */
  93631. get _indexBuffer(): number;
  93632. /** Gets the name of this buffer */
  93633. get name(): string;
  93634. /**
  93635. * Updates the WebGL Uniform Buffer on the GPU.
  93636. * If the `dynamic` flag is set to true, no cache comparison is done.
  93637. * Otherwise, the buffer will be updated only if the cache differs.
  93638. */
  93639. update(): void;
  93640. private _createNewBuffer;
  93641. private _checkNewFrame;
  93642. /**
  93643. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93644. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93645. * @param data Define the flattened data
  93646. * @param size Define the size of the data.
  93647. */
  93648. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93649. /**
  93650. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93651. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93652. * @param data Define the flattened data
  93653. * @param size Define the size of the data.
  93654. */
  93655. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  93656. private _valueCache;
  93657. private _cacheMatrix;
  93658. private _updateMatrix3x3ForUniform;
  93659. private _updateMatrix3x3ForEffect;
  93660. private _updateMatrix2x2ForEffect;
  93661. private _updateMatrix2x2ForUniform;
  93662. private _updateFloatForEffect;
  93663. private _updateFloatForUniform;
  93664. private _updateFloat2ForEffect;
  93665. private _updateFloat2ForUniform;
  93666. private _updateFloat3ForEffect;
  93667. private _updateFloat3ForUniform;
  93668. private _updateFloat4ForEffect;
  93669. private _updateFloat4ForUniform;
  93670. private _updateFloatArrayForEffect;
  93671. private _updateFloatArrayForUniform;
  93672. private _updateArrayForEffect;
  93673. private _updateArrayForUniform;
  93674. private _updateIntArrayForEffect;
  93675. private _updateIntArrayForUniform;
  93676. private _updateMatrixForEffect;
  93677. private _updateMatrixForUniform;
  93678. private _updateMatricesForEffect;
  93679. private _updateMatricesForUniform;
  93680. private _updateVector3ForEffect;
  93681. private _updateVector3ForUniform;
  93682. private _updateVector4ForEffect;
  93683. private _updateVector4ForUniform;
  93684. private _updateColor3ForEffect;
  93685. private _updateColor3ForUniform;
  93686. private _updateColor4ForEffect;
  93687. private _updateColor4ForUniform;
  93688. private _updateIntForEffect;
  93689. private _updateIntForUniform;
  93690. private _updateInt2ForEffect;
  93691. private _updateInt2ForUniform;
  93692. private _updateInt3ForEffect;
  93693. private _updateInt3ForUniform;
  93694. private _updateInt4ForEffect;
  93695. private _updateInt4ForUniform;
  93696. /**
  93697. * Sets a sampler uniform on the effect.
  93698. * @param name Define the name of the sampler.
  93699. * @param texture Define the texture to set in the sampler
  93700. */
  93701. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93702. /**
  93703. * Directly updates the value of the uniform in the cache AND on the GPU.
  93704. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93705. * @param data Define the flattened data
  93706. */
  93707. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93708. /**
  93709. * Binds this uniform buffer to an effect.
  93710. * @param effect Define the effect to bind the buffer to
  93711. * @param name Name of the uniform block in the shader.
  93712. */
  93713. bindToEffect(effect: Effect, name: string): void;
  93714. /**
  93715. * Disposes the uniform buffer.
  93716. */
  93717. dispose(): void;
  93718. }
  93719. }
  93720. declare module BABYLON {
  93721. /**
  93722. * Manages the defines for the Material
  93723. */
  93724. export class MaterialDefines {
  93725. /** @hidden */
  93726. protected _keys: string[];
  93727. private _isDirty;
  93728. /** @hidden */
  93729. _renderId: number;
  93730. /** @hidden */
  93731. _areLightsDirty: boolean;
  93732. /** @hidden */
  93733. _areLightsDisposed: boolean;
  93734. /** @hidden */
  93735. _areAttributesDirty: boolean;
  93736. /** @hidden */
  93737. _areTexturesDirty: boolean;
  93738. /** @hidden */
  93739. _areFresnelDirty: boolean;
  93740. /** @hidden */
  93741. _areMiscDirty: boolean;
  93742. /** @hidden */
  93743. _arePrePassDirty: boolean;
  93744. /** @hidden */
  93745. _areImageProcessingDirty: boolean;
  93746. /** @hidden */
  93747. _normals: boolean;
  93748. /** @hidden */
  93749. _uvs: boolean;
  93750. /** @hidden */
  93751. _needNormals: boolean;
  93752. /** @hidden */
  93753. _needUVs: boolean;
  93754. [id: string]: any;
  93755. /**
  93756. * Specifies if the material needs to be re-calculated
  93757. */
  93758. get isDirty(): boolean;
  93759. /**
  93760. * Marks the material to indicate that it has been re-calculated
  93761. */
  93762. markAsProcessed(): void;
  93763. /**
  93764. * Marks the material to indicate that it needs to be re-calculated
  93765. */
  93766. markAsUnprocessed(): void;
  93767. /**
  93768. * Marks the material to indicate all of its defines need to be re-calculated
  93769. */
  93770. markAllAsDirty(): void;
  93771. /**
  93772. * Marks the material to indicate that image processing needs to be re-calculated
  93773. */
  93774. markAsImageProcessingDirty(): void;
  93775. /**
  93776. * Marks the material to indicate the lights need to be re-calculated
  93777. * @param disposed Defines whether the light is dirty due to dispose or not
  93778. */
  93779. markAsLightDirty(disposed?: boolean): void;
  93780. /**
  93781. * Marks the attribute state as changed
  93782. */
  93783. markAsAttributesDirty(): void;
  93784. /**
  93785. * Marks the texture state as changed
  93786. */
  93787. markAsTexturesDirty(): void;
  93788. /**
  93789. * Marks the fresnel state as changed
  93790. */
  93791. markAsFresnelDirty(): void;
  93792. /**
  93793. * Marks the misc state as changed
  93794. */
  93795. markAsMiscDirty(): void;
  93796. /**
  93797. * Marks the prepass state as changed
  93798. */
  93799. markAsPrePassDirty(): void;
  93800. /**
  93801. * Rebuilds the material defines
  93802. */
  93803. rebuild(): void;
  93804. /**
  93805. * Specifies if two material defines are equal
  93806. * @param other - A material define instance to compare to
  93807. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  93808. */
  93809. isEqual(other: MaterialDefines): boolean;
  93810. /**
  93811. * Clones this instance's defines to another instance
  93812. * @param other - material defines to clone values to
  93813. */
  93814. cloneTo(other: MaterialDefines): void;
  93815. /**
  93816. * Resets the material define values
  93817. */
  93818. reset(): void;
  93819. /**
  93820. * Converts the material define values to a string
  93821. * @returns - String of material define information
  93822. */
  93823. toString(): string;
  93824. }
  93825. }
  93826. declare module BABYLON {
  93827. /**
  93828. * Enum that determines the text-wrapping mode to use.
  93829. */
  93830. export enum InspectableType {
  93831. /**
  93832. * Checkbox for booleans
  93833. */
  93834. Checkbox = 0,
  93835. /**
  93836. * Sliders for numbers
  93837. */
  93838. Slider = 1,
  93839. /**
  93840. * Vector3
  93841. */
  93842. Vector3 = 2,
  93843. /**
  93844. * Quaternions
  93845. */
  93846. Quaternion = 3,
  93847. /**
  93848. * Color3
  93849. */
  93850. Color3 = 4,
  93851. /**
  93852. * String
  93853. */
  93854. String = 5
  93855. }
  93856. /**
  93857. * Interface used to define custom inspectable properties.
  93858. * This interface is used by the inspector to display custom property grids
  93859. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93860. */
  93861. export interface IInspectable {
  93862. /**
  93863. * Gets the label to display
  93864. */
  93865. label: string;
  93866. /**
  93867. * Gets the name of the property to edit
  93868. */
  93869. propertyName: string;
  93870. /**
  93871. * Gets the type of the editor to use
  93872. */
  93873. type: InspectableType;
  93874. /**
  93875. * Gets the minimum value of the property when using in "slider" mode
  93876. */
  93877. min?: number;
  93878. /**
  93879. * Gets the maximum value of the property when using in "slider" mode
  93880. */
  93881. max?: number;
  93882. /**
  93883. * Gets the setp to use when using in "slider" mode
  93884. */
  93885. step?: number;
  93886. }
  93887. }
  93888. declare module BABYLON {
  93889. /**
  93890. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  93891. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  93892. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  93893. */
  93894. export abstract class Light extends Node {
  93895. /**
  93896. * Falloff Default: light is falling off following the material specification:
  93897. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  93898. */
  93899. static readonly FALLOFF_DEFAULT: number;
  93900. /**
  93901. * Falloff Physical: light is falling off following the inverse squared distance law.
  93902. */
  93903. static readonly FALLOFF_PHYSICAL: number;
  93904. /**
  93905. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  93906. * to enhance interoperability with other engines.
  93907. */
  93908. static readonly FALLOFF_GLTF: number;
  93909. /**
  93910. * Falloff Standard: light is falling off like in the standard material
  93911. * to enhance interoperability with other materials.
  93912. */
  93913. static readonly FALLOFF_STANDARD: number;
  93914. /**
  93915. * If every light affecting the material is in this lightmapMode,
  93916. * material.lightmapTexture adds or multiplies
  93917. * (depends on material.useLightmapAsShadowmap)
  93918. * after every other light calculations.
  93919. */
  93920. static readonly LIGHTMAP_DEFAULT: number;
  93921. /**
  93922. * material.lightmapTexture as only diffuse lighting from this light
  93923. * adds only specular lighting from this light
  93924. * adds dynamic shadows
  93925. */
  93926. static readonly LIGHTMAP_SPECULAR: number;
  93927. /**
  93928. * material.lightmapTexture as only lighting
  93929. * no light calculation from this light
  93930. * only adds dynamic shadows from this light
  93931. */
  93932. static readonly LIGHTMAP_SHADOWSONLY: number;
  93933. /**
  93934. * Each light type uses the default quantity according to its type:
  93935. * point/spot lights use luminous intensity
  93936. * directional lights use illuminance
  93937. */
  93938. static readonly INTENSITYMODE_AUTOMATIC: number;
  93939. /**
  93940. * lumen (lm)
  93941. */
  93942. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  93943. /**
  93944. * candela (lm/sr)
  93945. */
  93946. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  93947. /**
  93948. * lux (lm/m^2)
  93949. */
  93950. static readonly INTENSITYMODE_ILLUMINANCE: number;
  93951. /**
  93952. * nit (cd/m^2)
  93953. */
  93954. static readonly INTENSITYMODE_LUMINANCE: number;
  93955. /**
  93956. * Light type const id of the point light.
  93957. */
  93958. static readonly LIGHTTYPEID_POINTLIGHT: number;
  93959. /**
  93960. * Light type const id of the directional light.
  93961. */
  93962. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  93963. /**
  93964. * Light type const id of the spot light.
  93965. */
  93966. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  93967. /**
  93968. * Light type const id of the hemispheric light.
  93969. */
  93970. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  93971. /**
  93972. * Diffuse gives the basic color to an object.
  93973. */
  93974. diffuse: Color3;
  93975. /**
  93976. * Specular produces a highlight color on an object.
  93977. * Note: This is note affecting PBR materials.
  93978. */
  93979. specular: Color3;
  93980. /**
  93981. * Defines the falloff type for this light. This lets overrriding how punctual light are
  93982. * falling off base on range or angle.
  93983. * This can be set to any values in Light.FALLOFF_x.
  93984. *
  93985. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  93986. * other types of materials.
  93987. */
  93988. falloffType: number;
  93989. /**
  93990. * Strength of the light.
  93991. * Note: By default it is define in the framework own unit.
  93992. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  93993. */
  93994. intensity: number;
  93995. private _range;
  93996. protected _inverseSquaredRange: number;
  93997. /**
  93998. * Defines how far from the source the light is impacting in scene units.
  93999. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94000. */
  94001. get range(): number;
  94002. /**
  94003. * Defines how far from the source the light is impacting in scene units.
  94004. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94005. */
  94006. set range(value: number);
  94007. /**
  94008. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  94009. * of light.
  94010. */
  94011. private _photometricScale;
  94012. private _intensityMode;
  94013. /**
  94014. * Gets the photometric scale used to interpret the intensity.
  94015. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94016. */
  94017. get intensityMode(): number;
  94018. /**
  94019. * Sets the photometric scale used to interpret the intensity.
  94020. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94021. */
  94022. set intensityMode(value: number);
  94023. private _radius;
  94024. /**
  94025. * Gets the light radius used by PBR Materials to simulate soft area lights.
  94026. */
  94027. get radius(): number;
  94028. /**
  94029. * sets the light radius used by PBR Materials to simulate soft area lights.
  94030. */
  94031. set radius(value: number);
  94032. private _renderPriority;
  94033. /**
  94034. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  94035. * exceeding the number allowed of the materials.
  94036. */
  94037. renderPriority: number;
  94038. private _shadowEnabled;
  94039. /**
  94040. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94041. * the current shadow generator.
  94042. */
  94043. get shadowEnabled(): boolean;
  94044. /**
  94045. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94046. * the current shadow generator.
  94047. */
  94048. set shadowEnabled(value: boolean);
  94049. private _includedOnlyMeshes;
  94050. /**
  94051. * Gets the only meshes impacted by this light.
  94052. */
  94053. get includedOnlyMeshes(): AbstractMesh[];
  94054. /**
  94055. * Sets the only meshes impacted by this light.
  94056. */
  94057. set includedOnlyMeshes(value: AbstractMesh[]);
  94058. private _excludedMeshes;
  94059. /**
  94060. * Gets the meshes not impacted by this light.
  94061. */
  94062. get excludedMeshes(): AbstractMesh[];
  94063. /**
  94064. * Sets the meshes not impacted by this light.
  94065. */
  94066. set excludedMeshes(value: AbstractMesh[]);
  94067. private _excludeWithLayerMask;
  94068. /**
  94069. * Gets the layer id use to find what meshes are not impacted by the light.
  94070. * Inactive if 0
  94071. */
  94072. get excludeWithLayerMask(): number;
  94073. /**
  94074. * Sets the layer id use to find what meshes are not impacted by the light.
  94075. * Inactive if 0
  94076. */
  94077. set excludeWithLayerMask(value: number);
  94078. private _includeOnlyWithLayerMask;
  94079. /**
  94080. * Gets the layer id use to find what meshes are impacted by the light.
  94081. * Inactive if 0
  94082. */
  94083. get includeOnlyWithLayerMask(): number;
  94084. /**
  94085. * Sets the layer id use to find what meshes are impacted by the light.
  94086. * Inactive if 0
  94087. */
  94088. set includeOnlyWithLayerMask(value: number);
  94089. private _lightmapMode;
  94090. /**
  94091. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94092. */
  94093. get lightmapMode(): number;
  94094. /**
  94095. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94096. */
  94097. set lightmapMode(value: number);
  94098. /**
  94099. * Shadow generator associted to the light.
  94100. * @hidden Internal use only.
  94101. */
  94102. _shadowGenerator: Nullable<IShadowGenerator>;
  94103. /**
  94104. * @hidden Internal use only.
  94105. */
  94106. _excludedMeshesIds: string[];
  94107. /**
  94108. * @hidden Internal use only.
  94109. */
  94110. _includedOnlyMeshesIds: string[];
  94111. /**
  94112. * The current light unifom buffer.
  94113. * @hidden Internal use only.
  94114. */
  94115. _uniformBuffer: UniformBuffer;
  94116. /** @hidden */
  94117. _renderId: number;
  94118. /**
  94119. * Creates a Light object in the scene.
  94120. * Documentation : https://doc.babylonjs.com/babylon101/lights
  94121. * @param name The firendly name of the light
  94122. * @param scene The scene the light belongs too
  94123. */
  94124. constructor(name: string, scene: Scene);
  94125. protected abstract _buildUniformLayout(): void;
  94126. /**
  94127. * Sets the passed Effect "effect" with the Light information.
  94128. * @param effect The effect to update
  94129. * @param lightIndex The index of the light in the effect to update
  94130. * @returns The light
  94131. */
  94132. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  94133. /**
  94134. * Sets the passed Effect "effect" with the Light textures.
  94135. * @param effect The effect to update
  94136. * @param lightIndex The index of the light in the effect to update
  94137. * @returns The light
  94138. */
  94139. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  94140. /**
  94141. * Binds the lights information from the scene to the effect for the given mesh.
  94142. * @param lightIndex Light index
  94143. * @param scene The scene where the light belongs to
  94144. * @param effect The effect we are binding the data to
  94145. * @param useSpecular Defines if specular is supported
  94146. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  94147. */
  94148. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  94149. /**
  94150. * Sets the passed Effect "effect" with the Light information.
  94151. * @param effect The effect to update
  94152. * @param lightDataUniformName The uniform used to store light data (position or direction)
  94153. * @returns The light
  94154. */
  94155. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  94156. /**
  94157. * Returns the string "Light".
  94158. * @returns the class name
  94159. */
  94160. getClassName(): string;
  94161. /** @hidden */
  94162. readonly _isLight: boolean;
  94163. /**
  94164. * Converts the light information to a readable string for debug purpose.
  94165. * @param fullDetails Supports for multiple levels of logging within scene loading
  94166. * @returns the human readable light info
  94167. */
  94168. toString(fullDetails?: boolean): string;
  94169. /** @hidden */
  94170. protected _syncParentEnabledState(): void;
  94171. /**
  94172. * Set the enabled state of this node.
  94173. * @param value - the new enabled state
  94174. */
  94175. setEnabled(value: boolean): void;
  94176. /**
  94177. * Returns the Light associated shadow generator if any.
  94178. * @return the associated shadow generator.
  94179. */
  94180. getShadowGenerator(): Nullable<IShadowGenerator>;
  94181. /**
  94182. * Returns a Vector3, the absolute light position in the World.
  94183. * @returns the world space position of the light
  94184. */
  94185. getAbsolutePosition(): Vector3;
  94186. /**
  94187. * Specifies if the light will affect the passed mesh.
  94188. * @param mesh The mesh to test against the light
  94189. * @return true the mesh is affected otherwise, false.
  94190. */
  94191. canAffectMesh(mesh: AbstractMesh): boolean;
  94192. /**
  94193. * Sort function to order lights for rendering.
  94194. * @param a First Light object to compare to second.
  94195. * @param b Second Light object to compare first.
  94196. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  94197. */
  94198. static CompareLightsPriority(a: Light, b: Light): number;
  94199. /**
  94200. * Releases resources associated with this node.
  94201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94203. */
  94204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94205. /**
  94206. * Returns the light type ID (integer).
  94207. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  94208. */
  94209. getTypeID(): number;
  94210. /**
  94211. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  94212. * @returns the scaled intensity in intensity mode unit
  94213. */
  94214. getScaledIntensity(): number;
  94215. /**
  94216. * Returns a new Light object, named "name", from the current one.
  94217. * @param name The name of the cloned light
  94218. * @param newParent The parent of this light, if it has one
  94219. * @returns the new created light
  94220. */
  94221. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  94222. /**
  94223. * Serializes the current light into a Serialization object.
  94224. * @returns the serialized object.
  94225. */
  94226. serialize(): any;
  94227. /**
  94228. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  94229. * This new light is named "name" and added to the passed scene.
  94230. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  94231. * @param name The friendly name of the light
  94232. * @param scene The scene the new light will belong to
  94233. * @returns the constructor function
  94234. */
  94235. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  94236. /**
  94237. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  94238. * @param parsedLight The JSON representation of the light
  94239. * @param scene The scene to create the parsed light in
  94240. * @returns the created light after parsing
  94241. */
  94242. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  94243. private _hookArrayForExcluded;
  94244. private _hookArrayForIncludedOnly;
  94245. private _resyncMeshes;
  94246. /**
  94247. * Forces the meshes to update their light related information in their rendering used effects
  94248. * @hidden Internal Use Only
  94249. */
  94250. _markMeshesAsLightDirty(): void;
  94251. /**
  94252. * Recomputes the cached photometric scale if needed.
  94253. */
  94254. private _computePhotometricScale;
  94255. /**
  94256. * Returns the Photometric Scale according to the light type and intensity mode.
  94257. */
  94258. private _getPhotometricScale;
  94259. /**
  94260. * Reorder the light in the scene according to their defined priority.
  94261. * @hidden Internal Use Only
  94262. */
  94263. _reorderLightsInScene(): void;
  94264. /**
  94265. * Prepares the list of defines specific to the light type.
  94266. * @param defines the list of defines
  94267. * @param lightIndex defines the index of the light for the effect
  94268. */
  94269. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  94270. }
  94271. }
  94272. declare module BABYLON {
  94273. /** Defines supported spaces */
  94274. export enum Space {
  94275. /** Local (object) space */
  94276. LOCAL = 0,
  94277. /** World space */
  94278. WORLD = 1,
  94279. /** Bone space */
  94280. BONE = 2
  94281. }
  94282. /** Defines the 3 main axes */
  94283. export class Axis {
  94284. /** X axis */
  94285. static X: Vector3;
  94286. /** Y axis */
  94287. static Y: Vector3;
  94288. /** Z axis */
  94289. static Z: Vector3;
  94290. }
  94291. /**
  94292. * Defines cartesian components.
  94293. */
  94294. export enum Coordinate {
  94295. /** X axis */
  94296. X = 0,
  94297. /** Y axis */
  94298. Y = 1,
  94299. /** Z axis */
  94300. Z = 2
  94301. }
  94302. }
  94303. declare module BABYLON {
  94304. /**
  94305. * Interface describing all the common properties and methods a shadow light needs to implement.
  94306. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  94307. * as well as binding the different shadow properties to the effects.
  94308. */
  94309. export interface IShadowLight extends Light {
  94310. /**
  94311. * The light id in the scene (used in scene.findLighById for instance)
  94312. */
  94313. id: string;
  94314. /**
  94315. * The position the shdow will be casted from.
  94316. */
  94317. position: Vector3;
  94318. /**
  94319. * In 2d mode (needCube being false), the direction used to cast the shadow.
  94320. */
  94321. direction: Vector3;
  94322. /**
  94323. * The transformed position. Position of the light in world space taking parenting in account.
  94324. */
  94325. transformedPosition: Vector3;
  94326. /**
  94327. * The transformed direction. Direction of the light in world space taking parenting in account.
  94328. */
  94329. transformedDirection: Vector3;
  94330. /**
  94331. * The friendly name of the light in the scene.
  94332. */
  94333. name: string;
  94334. /**
  94335. * Defines the shadow projection clipping minimum z value.
  94336. */
  94337. shadowMinZ: number;
  94338. /**
  94339. * Defines the shadow projection clipping maximum z value.
  94340. */
  94341. shadowMaxZ: number;
  94342. /**
  94343. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  94344. * @returns true if the information has been computed, false if it does not need to (no parenting)
  94345. */
  94346. computeTransformedInformation(): boolean;
  94347. /**
  94348. * Gets the scene the light belongs to.
  94349. * @returns The scene
  94350. */
  94351. getScene(): Scene;
  94352. /**
  94353. * Callback defining a custom Projection Matrix Builder.
  94354. * This can be used to override the default projection matrix computation.
  94355. */
  94356. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  94357. /**
  94358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  94359. * @param matrix The materix to updated with the projection information
  94360. * @param viewMatrix The transform matrix of the light
  94361. * @param renderList The list of mesh to render in the map
  94362. * @returns The current light
  94363. */
  94364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  94365. /**
  94366. * Gets the current depth scale used in ESM.
  94367. * @returns The scale
  94368. */
  94369. getDepthScale(): number;
  94370. /**
  94371. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  94372. * @returns true if a cube texture needs to be use
  94373. */
  94374. needCube(): boolean;
  94375. /**
  94376. * Detects if the projection matrix requires to be recomputed this frame.
  94377. * @returns true if it requires to be recomputed otherwise, false.
  94378. */
  94379. needProjectionMatrixCompute(): boolean;
  94380. /**
  94381. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  94382. */
  94383. forceProjectionMatrixCompute(): void;
  94384. /**
  94385. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  94386. * @param faceIndex The index of the face we are computed the direction to generate shadow
  94387. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  94388. */
  94389. getShadowDirection(faceIndex?: number): Vector3;
  94390. /**
  94391. * Gets the minZ used for shadow according to both the scene and the light.
  94392. * @param activeCamera The camera we are returning the min for
  94393. * @returns the depth min z
  94394. */
  94395. getDepthMinZ(activeCamera: Camera): number;
  94396. /**
  94397. * Gets the maxZ used for shadow according to both the scene and the light.
  94398. * @param activeCamera The camera we are returning the max for
  94399. * @returns the depth max z
  94400. */
  94401. getDepthMaxZ(activeCamera: Camera): number;
  94402. }
  94403. /**
  94404. * Base implementation IShadowLight
  94405. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  94406. */
  94407. export abstract class ShadowLight extends Light implements IShadowLight {
  94408. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  94409. protected _position: Vector3;
  94410. protected _setPosition(value: Vector3): void;
  94411. /**
  94412. * Sets the position the shadow will be casted from. Also use as the light position for both
  94413. * point and spot lights.
  94414. */
  94415. get position(): Vector3;
  94416. /**
  94417. * Sets the position the shadow will be casted from. Also use as the light position for both
  94418. * point and spot lights.
  94419. */
  94420. set position(value: Vector3);
  94421. protected _direction: Vector3;
  94422. protected _setDirection(value: Vector3): void;
  94423. /**
  94424. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  94425. * Also use as the light direction on spot and directional lights.
  94426. */
  94427. get direction(): Vector3;
  94428. /**
  94429. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  94430. * Also use as the light direction on spot and directional lights.
  94431. */
  94432. set direction(value: Vector3);
  94433. protected _shadowMinZ: number;
  94434. /**
  94435. * Gets the shadow projection clipping minimum z value.
  94436. */
  94437. get shadowMinZ(): number;
  94438. /**
  94439. * Sets the shadow projection clipping minimum z value.
  94440. */
  94441. set shadowMinZ(value: number);
  94442. protected _shadowMaxZ: number;
  94443. /**
  94444. * Sets the shadow projection clipping maximum z value.
  94445. */
  94446. get shadowMaxZ(): number;
  94447. /**
  94448. * Gets the shadow projection clipping maximum z value.
  94449. */
  94450. set shadowMaxZ(value: number);
  94451. /**
  94452. * Callback defining a custom Projection Matrix Builder.
  94453. * This can be used to override the default projection matrix computation.
  94454. */
  94455. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  94456. /**
  94457. * The transformed position. Position of the light in world space taking parenting in account.
  94458. */
  94459. transformedPosition: Vector3;
  94460. /**
  94461. * The transformed direction. Direction of the light in world space taking parenting in account.
  94462. */
  94463. transformedDirection: Vector3;
  94464. private _needProjectionMatrixCompute;
  94465. /**
  94466. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  94467. * @returns true if the information has been computed, false if it does not need to (no parenting)
  94468. */
  94469. computeTransformedInformation(): boolean;
  94470. /**
  94471. * Return the depth scale used for the shadow map.
  94472. * @returns the depth scale.
  94473. */
  94474. getDepthScale(): number;
  94475. /**
  94476. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  94477. * @param faceIndex The index of the face we are computed the direction to generate shadow
  94478. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  94479. */
  94480. getShadowDirection(faceIndex?: number): Vector3;
  94481. /**
  94482. * Returns the ShadowLight absolute position in the World.
  94483. * @returns the position vector in world space
  94484. */
  94485. getAbsolutePosition(): Vector3;
  94486. /**
  94487. * Sets the ShadowLight direction toward the passed target.
  94488. * @param target The point to target in local space
  94489. * @returns the updated ShadowLight direction
  94490. */
  94491. setDirectionToTarget(target: Vector3): Vector3;
  94492. /**
  94493. * Returns the light rotation in euler definition.
  94494. * @returns the x y z rotation in local space.
  94495. */
  94496. getRotation(): Vector3;
  94497. /**
  94498. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  94499. * @returns true if a cube texture needs to be use
  94500. */
  94501. needCube(): boolean;
  94502. /**
  94503. * Detects if the projection matrix requires to be recomputed this frame.
  94504. * @returns true if it requires to be recomputed otherwise, false.
  94505. */
  94506. needProjectionMatrixCompute(): boolean;
  94507. /**
  94508. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  94509. */
  94510. forceProjectionMatrixCompute(): void;
  94511. /** @hidden */
  94512. _initCache(): void;
  94513. /** @hidden */
  94514. _isSynchronized(): boolean;
  94515. /**
  94516. * Computes the world matrix of the node
  94517. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94518. * @returns the world matrix
  94519. */
  94520. computeWorldMatrix(force?: boolean): Matrix;
  94521. /**
  94522. * Gets the minZ used for shadow according to both the scene and the light.
  94523. * @param activeCamera The camera we are returning the min for
  94524. * @returns the depth min z
  94525. */
  94526. getDepthMinZ(activeCamera: Camera): number;
  94527. /**
  94528. * Gets the maxZ used for shadow according to both the scene and the light.
  94529. * @param activeCamera The camera we are returning the max for
  94530. * @returns the depth max z
  94531. */
  94532. getDepthMaxZ(activeCamera: Camera): number;
  94533. /**
  94534. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  94535. * @param matrix The materix to updated with the projection information
  94536. * @param viewMatrix The transform matrix of the light
  94537. * @param renderList The list of mesh to render in the map
  94538. * @returns The current light
  94539. */
  94540. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  94541. }
  94542. }
  94543. declare module BABYLON {
  94544. /**
  94545. * Configuration needed for prepass-capable materials
  94546. */
  94547. export class PrePassConfiguration {
  94548. /**
  94549. * Previous world matrices of meshes carrying this material
  94550. * Used for computing velocity
  94551. */
  94552. previousWorldMatrices: {
  94553. [index: number]: Matrix;
  94554. };
  94555. /**
  94556. * Previous view project matrix
  94557. * Used for computing velocity
  94558. */
  94559. previousViewProjection: Matrix;
  94560. /**
  94561. * Previous bones of meshes carrying this material
  94562. * Used for computing velocity
  94563. */
  94564. previousBones: {
  94565. [index: number]: Float32Array;
  94566. };
  94567. /**
  94568. * Add the required uniforms to the current list.
  94569. * @param uniforms defines the current uniform list.
  94570. */
  94571. static AddUniforms(uniforms: string[]): void;
  94572. /**
  94573. * Add the required samplers to the current list.
  94574. * @param samplers defines the current sampler list.
  94575. */
  94576. static AddSamplers(samplers: string[]): void;
  94577. /**
  94578. * Binds the material data.
  94579. * @param effect defines the effect to update
  94580. * @param scene defines the scene the material belongs to.
  94581. * @param mesh The mesh
  94582. * @param world World matrix of this mesh
  94583. * @param isFrozen Is the material frozen
  94584. */
  94585. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  94586. }
  94587. }
  94588. declare module BABYLON {
  94589. /**
  94590. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  94591. * This is the base of the follow, arc rotate cameras and Free camera
  94592. * @see https://doc.babylonjs.com/features/cameras
  94593. */
  94594. export class TargetCamera extends Camera {
  94595. private static _RigCamTransformMatrix;
  94596. private static _TargetTransformMatrix;
  94597. private static _TargetFocalPoint;
  94598. private _tmpUpVector;
  94599. private _tmpTargetVector;
  94600. /**
  94601. * Define the current direction the camera is moving to
  94602. */
  94603. cameraDirection: Vector3;
  94604. /**
  94605. * Define the current rotation the camera is rotating to
  94606. */
  94607. cameraRotation: Vector2;
  94608. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  94609. ignoreParentScaling: boolean;
  94610. /**
  94611. * When set, the up vector of the camera will be updated by the rotation of the camera
  94612. */
  94613. updateUpVectorFromRotation: boolean;
  94614. private _tmpQuaternion;
  94615. /**
  94616. * Define the current rotation of the camera
  94617. */
  94618. rotation: Vector3;
  94619. /**
  94620. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  94621. */
  94622. rotationQuaternion: Quaternion;
  94623. /**
  94624. * Define the current speed of the camera
  94625. */
  94626. speed: number;
  94627. /**
  94628. * Add constraint to the camera to prevent it to move freely in all directions and
  94629. * around all axis.
  94630. */
  94631. noRotationConstraint: boolean;
  94632. /**
  94633. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  94634. * panning
  94635. */
  94636. invertRotation: boolean;
  94637. /**
  94638. * Speed multiplier for inverse camera panning
  94639. */
  94640. inverseRotationSpeed: number;
  94641. /**
  94642. * Define the current target of the camera as an object or a position.
  94643. */
  94644. lockedTarget: any;
  94645. /** @hidden */
  94646. _currentTarget: Vector3;
  94647. /** @hidden */
  94648. _initialFocalDistance: number;
  94649. /** @hidden */
  94650. _viewMatrix: Matrix;
  94651. /** @hidden */
  94652. _camMatrix: Matrix;
  94653. /** @hidden */
  94654. _cameraTransformMatrix: Matrix;
  94655. /** @hidden */
  94656. _cameraRotationMatrix: Matrix;
  94657. /** @hidden */
  94658. _referencePoint: Vector3;
  94659. /** @hidden */
  94660. _transformedReferencePoint: Vector3;
  94661. /** @hidden */
  94662. _reset: () => void;
  94663. private _defaultUp;
  94664. /**
  94665. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  94666. * This is the base of the follow, arc rotate cameras and Free camera
  94667. * @see https://doc.babylonjs.com/features/cameras
  94668. * @param name Defines the name of the camera in the scene
  94669. * @param position Defines the start position of the camera in the scene
  94670. * @param scene Defines the scene the camera belongs to
  94671. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94672. */
  94673. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94674. /**
  94675. * Gets the position in front of the camera at a given distance.
  94676. * @param distance The distance from the camera we want the position to be
  94677. * @returns the position
  94678. */
  94679. getFrontPosition(distance: number): Vector3;
  94680. /** @hidden */
  94681. _getLockedTargetPosition(): Nullable<Vector3>;
  94682. private _storedPosition;
  94683. private _storedRotation;
  94684. private _storedRotationQuaternion;
  94685. /**
  94686. * Store current camera state of the camera (fov, position, rotation, etc..)
  94687. * @returns the camera
  94688. */
  94689. storeState(): Camera;
  94690. /**
  94691. * Restored camera state. You must call storeState() first
  94692. * @returns whether it was successful or not
  94693. * @hidden
  94694. */
  94695. _restoreStateValues(): boolean;
  94696. /** @hidden */
  94697. _initCache(): void;
  94698. /** @hidden */
  94699. _updateCache(ignoreParentClass?: boolean): void;
  94700. /** @hidden */
  94701. _isSynchronizedViewMatrix(): boolean;
  94702. /** @hidden */
  94703. _computeLocalCameraSpeed(): number;
  94704. /**
  94705. * Defines the target the camera should look at.
  94706. * @param target Defines the new target as a Vector or a mesh
  94707. */
  94708. setTarget(target: Vector3): void;
  94709. /**
  94710. * Defines the target point of the camera.
  94711. * The camera looks towards it form the radius distance.
  94712. */
  94713. get target(): Vector3;
  94714. set target(value: Vector3);
  94715. /**
  94716. * Return the current target position of the camera. This value is expressed in local space.
  94717. * @returns the target position
  94718. */
  94719. getTarget(): Vector3;
  94720. /** @hidden */
  94721. _decideIfNeedsToMove(): boolean;
  94722. /** @hidden */
  94723. _updatePosition(): void;
  94724. /** @hidden */
  94725. _checkInputs(): void;
  94726. protected _updateCameraRotationMatrix(): void;
  94727. /**
  94728. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  94729. * @returns the current camera
  94730. */
  94731. private _rotateUpVectorWithCameraRotationMatrix;
  94732. private _cachedRotationZ;
  94733. private _cachedQuaternionRotationZ;
  94734. /** @hidden */
  94735. _getViewMatrix(): Matrix;
  94736. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  94737. /**
  94738. * @hidden
  94739. */
  94740. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94741. /**
  94742. * @hidden
  94743. */
  94744. _updateRigCameras(): void;
  94745. private _getRigCamPositionAndTarget;
  94746. /**
  94747. * Gets the current object class name.
  94748. * @return the class name
  94749. */
  94750. getClassName(): string;
  94751. }
  94752. }
  94753. declare module BABYLON {
  94754. /**
  94755. * @ignore
  94756. * This is a list of all the different input types that are available in the application.
  94757. * Fo instance: ArcRotateCameraGamepadInput...
  94758. */
  94759. export var CameraInputTypes: {};
  94760. /**
  94761. * This is the contract to implement in order to create a new input class.
  94762. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  94763. */
  94764. export interface ICameraInput<TCamera extends Camera> {
  94765. /**
  94766. * Defines the camera the input is attached to.
  94767. */
  94768. camera: Nullable<TCamera>;
  94769. /**
  94770. * Gets the class name of the current intput.
  94771. * @returns the class name
  94772. */
  94773. getClassName(): string;
  94774. /**
  94775. * Get the friendly name associated with the input class.
  94776. * @returns the input friendly name
  94777. */
  94778. getSimpleName(): string;
  94779. /**
  94780. * Attach the input controls to a specific dom element to get the input from.
  94781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94782. */
  94783. attachControl(noPreventDefault?: boolean): void;
  94784. /**
  94785. * Detach the current controls from the specified dom element.
  94786. */
  94787. detachControl(): void;
  94788. /**
  94789. * Update the current camera state depending on the inputs that have been used this frame.
  94790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94791. */
  94792. checkInputs?: () => void;
  94793. }
  94794. /**
  94795. * Represents a map of input types to input instance or input index to input instance.
  94796. */
  94797. export interface CameraInputsMap<TCamera extends Camera> {
  94798. /**
  94799. * Accessor to the input by input type.
  94800. */
  94801. [name: string]: ICameraInput<TCamera>;
  94802. /**
  94803. * Accessor to the input by input index.
  94804. */
  94805. [idx: number]: ICameraInput<TCamera>;
  94806. }
  94807. /**
  94808. * This represents the input manager used within a camera.
  94809. * It helps dealing with all the different kind of input attached to a camera.
  94810. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94811. */
  94812. export class CameraInputsManager<TCamera extends Camera> {
  94813. /**
  94814. * Defines the list of inputs attahed to the camera.
  94815. */
  94816. attached: CameraInputsMap<TCamera>;
  94817. /**
  94818. * Defines the dom element the camera is collecting inputs from.
  94819. * This is null if the controls have not been attached.
  94820. */
  94821. attachedToElement: boolean;
  94822. /**
  94823. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94824. */
  94825. noPreventDefault: boolean;
  94826. /**
  94827. * Defined the camera the input manager belongs to.
  94828. */
  94829. camera: TCamera;
  94830. /**
  94831. * Update the current camera state depending on the inputs that have been used this frame.
  94832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94833. */
  94834. checkInputs: () => void;
  94835. /**
  94836. * Instantiate a new Camera Input Manager.
  94837. * @param camera Defines the camera the input manager blongs to
  94838. */
  94839. constructor(camera: TCamera);
  94840. /**
  94841. * Add an input method to a camera
  94842. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94843. * @param input camera input method
  94844. */
  94845. add(input: ICameraInput<TCamera>): void;
  94846. /**
  94847. * Remove a specific input method from a camera
  94848. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  94849. * @param inputToRemove camera input method
  94850. */
  94851. remove(inputToRemove: ICameraInput<TCamera>): void;
  94852. /**
  94853. * Remove a specific input type from a camera
  94854. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  94855. * @param inputType the type of the input to remove
  94856. */
  94857. removeByType(inputType: string): void;
  94858. private _addCheckInputs;
  94859. /**
  94860. * Attach the input controls to the currently attached dom element to listen the events from.
  94861. * @param input Defines the input to attach
  94862. */
  94863. attachInput(input: ICameraInput<TCamera>): void;
  94864. /**
  94865. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  94866. * @param element Defines the dom element to collect the events from
  94867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94868. */
  94869. attachElement(noPreventDefault?: boolean): void;
  94870. /**
  94871. * Detach the current manager inputs controls from a specific dom element.
  94872. * @param element Defines the dom element to collect the events from
  94873. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  94874. */
  94875. detachElement(disconnect?: boolean): void;
  94876. /**
  94877. * Rebuild the dynamic inputCheck function from the current list of
  94878. * defined inputs in the manager.
  94879. */
  94880. rebuildInputCheck(): void;
  94881. /**
  94882. * Remove all attached input methods from a camera
  94883. */
  94884. clear(): void;
  94885. /**
  94886. * Serialize the current input manager attached to a camera.
  94887. * This ensures than once parsed,
  94888. * the input associated to the camera will be identical to the current ones
  94889. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  94890. */
  94891. serialize(serializedCamera: any): void;
  94892. /**
  94893. * Parses an input manager serialized JSON to restore the previous list of inputs
  94894. * and states associated to a camera.
  94895. * @param parsedCamera Defines the JSON to parse
  94896. */
  94897. parse(parsedCamera: any): void;
  94898. }
  94899. }
  94900. declare module BABYLON {
  94901. /**
  94902. * Gather the list of keyboard event types as constants.
  94903. */
  94904. export class KeyboardEventTypes {
  94905. /**
  94906. * The keydown event is fired when a key becomes active (pressed).
  94907. */
  94908. static readonly KEYDOWN: number;
  94909. /**
  94910. * The keyup event is fired when a key has been released.
  94911. */
  94912. static readonly KEYUP: number;
  94913. }
  94914. /**
  94915. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94916. */
  94917. export class KeyboardInfo {
  94918. /**
  94919. * Defines the type of event (KeyboardEventTypes)
  94920. */
  94921. type: number;
  94922. /**
  94923. * Defines the related dom event
  94924. */
  94925. event: KeyboardEvent;
  94926. /**
  94927. * Instantiates a new keyboard info.
  94928. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94929. * @param type Defines the type of event (KeyboardEventTypes)
  94930. * @param event Defines the related dom event
  94931. */
  94932. constructor(
  94933. /**
  94934. * Defines the type of event (KeyboardEventTypes)
  94935. */
  94936. type: number,
  94937. /**
  94938. * Defines the related dom event
  94939. */
  94940. event: KeyboardEvent);
  94941. }
  94942. /**
  94943. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94944. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  94945. */
  94946. export class KeyboardInfoPre extends KeyboardInfo {
  94947. /**
  94948. * Defines the type of event (KeyboardEventTypes)
  94949. */
  94950. type: number;
  94951. /**
  94952. * Defines the related dom event
  94953. */
  94954. event: KeyboardEvent;
  94955. /**
  94956. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  94957. */
  94958. skipOnPointerObservable: boolean;
  94959. /**
  94960. * Instantiates a new keyboard pre info.
  94961. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94962. * @param type Defines the type of event (KeyboardEventTypes)
  94963. * @param event Defines the related dom event
  94964. */
  94965. constructor(
  94966. /**
  94967. * Defines the type of event (KeyboardEventTypes)
  94968. */
  94969. type: number,
  94970. /**
  94971. * Defines the related dom event
  94972. */
  94973. event: KeyboardEvent);
  94974. }
  94975. }
  94976. declare module BABYLON {
  94977. /**
  94978. * Manage the keyboard inputs to control the movement of a free camera.
  94979. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94980. */
  94981. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  94982. /**
  94983. * Defines the camera the input is attached to.
  94984. */
  94985. camera: FreeCamera;
  94986. /**
  94987. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94988. */
  94989. keysUp: number[];
  94990. /**
  94991. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94992. */
  94993. keysUpward: number[];
  94994. /**
  94995. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94996. */
  94997. keysDown: number[];
  94998. /**
  94999. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95000. */
  95001. keysDownward: number[];
  95002. /**
  95003. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95004. */
  95005. keysLeft: number[];
  95006. /**
  95007. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95008. */
  95009. keysRight: number[];
  95010. private _keys;
  95011. private _onCanvasBlurObserver;
  95012. private _onKeyboardObserver;
  95013. private _engine;
  95014. private _scene;
  95015. /**
  95016. * Attach the input controls to a specific dom element to get the input from.
  95017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95018. */
  95019. attachControl(noPreventDefault?: boolean): void;
  95020. /**
  95021. * Detach the current controls from the specified dom element.
  95022. */
  95023. detachControl(): void;
  95024. /**
  95025. * Update the current camera state depending on the inputs that have been used this frame.
  95026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95027. */
  95028. checkInputs(): void;
  95029. /**
  95030. * Gets the class name of the current intput.
  95031. * @returns the class name
  95032. */
  95033. getClassName(): string;
  95034. /** @hidden */
  95035. _onLostFocus(): void;
  95036. /**
  95037. * Get the friendly name associated with the input class.
  95038. * @returns the input friendly name
  95039. */
  95040. getSimpleName(): string;
  95041. }
  95042. }
  95043. declare module BABYLON {
  95044. /**
  95045. * Interface used to define Action
  95046. */
  95047. export interface IAction {
  95048. /**
  95049. * Trigger for the action
  95050. */
  95051. trigger: number;
  95052. /** Options of the trigger */
  95053. triggerOptions: any;
  95054. /**
  95055. * Gets the trigger parameters
  95056. * @returns the trigger parameters
  95057. */
  95058. getTriggerParameter(): any;
  95059. /**
  95060. * Internal only - executes current action event
  95061. * @hidden
  95062. */
  95063. _executeCurrent(evt?: ActionEvent): void;
  95064. /**
  95065. * Serialize placeholder for child classes
  95066. * @param parent of child
  95067. * @returns the serialized object
  95068. */
  95069. serialize(parent: any): any;
  95070. /**
  95071. * Internal only
  95072. * @hidden
  95073. */
  95074. _prepare(): void;
  95075. /**
  95076. * Internal only - manager for action
  95077. * @hidden
  95078. */
  95079. _actionManager: Nullable<AbstractActionManager>;
  95080. /**
  95081. * Adds action to chain of actions, may be a DoNothingAction
  95082. * @param action defines the next action to execute
  95083. * @returns The action passed in
  95084. * @see https://www.babylonjs-playground.com/#1T30HR#0
  95085. */
  95086. then(action: IAction): IAction;
  95087. }
  95088. /**
  95089. * The action to be carried out following a trigger
  95090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  95091. */
  95092. export class Action implements IAction {
  95093. /** the trigger, with or without parameters, for the action */
  95094. triggerOptions: any;
  95095. /**
  95096. * Trigger for the action
  95097. */
  95098. trigger: number;
  95099. /**
  95100. * Internal only - manager for action
  95101. * @hidden
  95102. */
  95103. _actionManager: ActionManager;
  95104. private _nextActiveAction;
  95105. private _child;
  95106. private _condition?;
  95107. private _triggerParameter;
  95108. /**
  95109. * An event triggered prior to action being executed.
  95110. */
  95111. onBeforeExecuteObservable: Observable<Action>;
  95112. /**
  95113. * Creates a new Action
  95114. * @param triggerOptions the trigger, with or without parameters, for the action
  95115. * @param condition an optional determinant of action
  95116. */
  95117. constructor(
  95118. /** the trigger, with or without parameters, for the action */
  95119. triggerOptions: any, condition?: Condition);
  95120. /**
  95121. * Internal only
  95122. * @hidden
  95123. */
  95124. _prepare(): void;
  95125. /**
  95126. * Gets the trigger parameter
  95127. * @returns the trigger parameter
  95128. */
  95129. getTriggerParameter(): any;
  95130. /**
  95131. * Sets the trigger parameter
  95132. * @param value defines the new trigger parameter
  95133. */
  95134. setTriggerParameter(value: any): void;
  95135. /**
  95136. * Internal only - executes current action event
  95137. * @hidden
  95138. */
  95139. _executeCurrent(evt?: ActionEvent): void;
  95140. /**
  95141. * Execute placeholder for child classes
  95142. * @param evt optional action event
  95143. */
  95144. execute(evt?: ActionEvent): void;
  95145. /**
  95146. * Skips to next active action
  95147. */
  95148. skipToNextActiveAction(): void;
  95149. /**
  95150. * Adds action to chain of actions, may be a DoNothingAction
  95151. * @param action defines the next action to execute
  95152. * @returns The action passed in
  95153. * @see https://www.babylonjs-playground.com/#1T30HR#0
  95154. */
  95155. then(action: Action): Action;
  95156. /**
  95157. * Internal only
  95158. * @hidden
  95159. */
  95160. _getProperty(propertyPath: string): string;
  95161. /**
  95162. * Internal only
  95163. * @hidden
  95164. */
  95165. _getEffectiveTarget(target: any, propertyPath: string): any;
  95166. /**
  95167. * Serialize placeholder for child classes
  95168. * @param parent of child
  95169. * @returns the serialized object
  95170. */
  95171. serialize(parent: any): any;
  95172. /**
  95173. * Internal only called by serialize
  95174. * @hidden
  95175. */
  95176. protected _serialize(serializedAction: any, parent?: any): any;
  95177. /**
  95178. * Internal only
  95179. * @hidden
  95180. */
  95181. static _SerializeValueAsString: (value: any) => string;
  95182. /**
  95183. * Internal only
  95184. * @hidden
  95185. */
  95186. static _GetTargetProperty: (target: Scene | Node) => {
  95187. name: string;
  95188. targetType: string;
  95189. value: string;
  95190. };
  95191. }
  95192. }
  95193. declare module BABYLON {
  95194. /**
  95195. * A Condition applied to an Action
  95196. */
  95197. export class Condition {
  95198. /**
  95199. * Internal only - manager for action
  95200. * @hidden
  95201. */
  95202. _actionManager: ActionManager;
  95203. /**
  95204. * Internal only
  95205. * @hidden
  95206. */
  95207. _evaluationId: number;
  95208. /**
  95209. * Internal only
  95210. * @hidden
  95211. */
  95212. _currentResult: boolean;
  95213. /**
  95214. * Creates a new Condition
  95215. * @param actionManager the manager of the action the condition is applied to
  95216. */
  95217. constructor(actionManager: ActionManager);
  95218. /**
  95219. * Check if the current condition is valid
  95220. * @returns a boolean
  95221. */
  95222. isValid(): boolean;
  95223. /**
  95224. * Internal only
  95225. * @hidden
  95226. */
  95227. _getProperty(propertyPath: string): string;
  95228. /**
  95229. * Internal only
  95230. * @hidden
  95231. */
  95232. _getEffectiveTarget(target: any, propertyPath: string): any;
  95233. /**
  95234. * Serialize placeholder for child classes
  95235. * @returns the serialized object
  95236. */
  95237. serialize(): any;
  95238. /**
  95239. * Internal only
  95240. * @hidden
  95241. */
  95242. protected _serialize(serializedCondition: any): any;
  95243. }
  95244. /**
  95245. * Defines specific conditional operators as extensions of Condition
  95246. */
  95247. export class ValueCondition extends Condition {
  95248. /** path to specify the property of the target the conditional operator uses */
  95249. propertyPath: string;
  95250. /** the value compared by the conditional operator against the current value of the property */
  95251. value: any;
  95252. /** the conditional operator, default ValueCondition.IsEqual */
  95253. operator: number;
  95254. /**
  95255. * Internal only
  95256. * @hidden
  95257. */
  95258. private static _IsEqual;
  95259. /**
  95260. * Internal only
  95261. * @hidden
  95262. */
  95263. private static _IsDifferent;
  95264. /**
  95265. * Internal only
  95266. * @hidden
  95267. */
  95268. private static _IsGreater;
  95269. /**
  95270. * Internal only
  95271. * @hidden
  95272. */
  95273. private static _IsLesser;
  95274. /**
  95275. * returns the number for IsEqual
  95276. */
  95277. static get IsEqual(): number;
  95278. /**
  95279. * Returns the number for IsDifferent
  95280. */
  95281. static get IsDifferent(): number;
  95282. /**
  95283. * Returns the number for IsGreater
  95284. */
  95285. static get IsGreater(): number;
  95286. /**
  95287. * Returns the number for IsLesser
  95288. */
  95289. static get IsLesser(): number;
  95290. /**
  95291. * Internal only The action manager for the condition
  95292. * @hidden
  95293. */
  95294. _actionManager: ActionManager;
  95295. /**
  95296. * Internal only
  95297. * @hidden
  95298. */
  95299. private _target;
  95300. /**
  95301. * Internal only
  95302. * @hidden
  95303. */
  95304. private _effectiveTarget;
  95305. /**
  95306. * Internal only
  95307. * @hidden
  95308. */
  95309. private _property;
  95310. /**
  95311. * Creates a new ValueCondition
  95312. * @param actionManager manager for the action the condition applies to
  95313. * @param target for the action
  95314. * @param propertyPath path to specify the property of the target the conditional operator uses
  95315. * @param value the value compared by the conditional operator against the current value of the property
  95316. * @param operator the conditional operator, default ValueCondition.IsEqual
  95317. */
  95318. constructor(actionManager: ActionManager, target: any,
  95319. /** path to specify the property of the target the conditional operator uses */
  95320. propertyPath: string,
  95321. /** the value compared by the conditional operator against the current value of the property */
  95322. value: any,
  95323. /** the conditional operator, default ValueCondition.IsEqual */
  95324. operator?: number);
  95325. /**
  95326. * Compares the given value with the property value for the specified conditional operator
  95327. * @returns the result of the comparison
  95328. */
  95329. isValid(): boolean;
  95330. /**
  95331. * Serialize the ValueCondition into a JSON compatible object
  95332. * @returns serialization object
  95333. */
  95334. serialize(): any;
  95335. /**
  95336. * Gets the name of the conditional operator for the ValueCondition
  95337. * @param operator the conditional operator
  95338. * @returns the name
  95339. */
  95340. static GetOperatorName(operator: number): string;
  95341. }
  95342. /**
  95343. * Defines a predicate condition as an extension of Condition
  95344. */
  95345. export class PredicateCondition extends Condition {
  95346. /** defines the predicate function used to validate the condition */
  95347. predicate: () => boolean;
  95348. /**
  95349. * Internal only - manager for action
  95350. * @hidden
  95351. */
  95352. _actionManager: ActionManager;
  95353. /**
  95354. * Creates a new PredicateCondition
  95355. * @param actionManager manager for the action the condition applies to
  95356. * @param predicate defines the predicate function used to validate the condition
  95357. */
  95358. constructor(actionManager: ActionManager,
  95359. /** defines the predicate function used to validate the condition */
  95360. predicate: () => boolean);
  95361. /**
  95362. * @returns the validity of the predicate condition
  95363. */
  95364. isValid(): boolean;
  95365. }
  95366. /**
  95367. * Defines a state condition as an extension of Condition
  95368. */
  95369. export class StateCondition extends Condition {
  95370. /** Value to compare with target state */
  95371. value: string;
  95372. /**
  95373. * Internal only - manager for action
  95374. * @hidden
  95375. */
  95376. _actionManager: ActionManager;
  95377. /**
  95378. * Internal only
  95379. * @hidden
  95380. */
  95381. private _target;
  95382. /**
  95383. * Creates a new StateCondition
  95384. * @param actionManager manager for the action the condition applies to
  95385. * @param target of the condition
  95386. * @param value to compare with target state
  95387. */
  95388. constructor(actionManager: ActionManager, target: any,
  95389. /** Value to compare with target state */
  95390. value: string);
  95391. /**
  95392. * Gets a boolean indicating if the current condition is met
  95393. * @returns the validity of the state
  95394. */
  95395. isValid(): boolean;
  95396. /**
  95397. * Serialize the StateCondition into a JSON compatible object
  95398. * @returns serialization object
  95399. */
  95400. serialize(): any;
  95401. }
  95402. }
  95403. declare module BABYLON {
  95404. /**
  95405. * This defines an action responsible to toggle a boolean once triggered.
  95406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95407. */
  95408. export class SwitchBooleanAction extends Action {
  95409. /**
  95410. * The path to the boolean property in the target object
  95411. */
  95412. propertyPath: string;
  95413. private _target;
  95414. private _effectiveTarget;
  95415. private _property;
  95416. /**
  95417. * Instantiate the action
  95418. * @param triggerOptions defines the trigger options
  95419. * @param target defines the object containing the boolean
  95420. * @param propertyPath defines the path to the boolean property in the target object
  95421. * @param condition defines the trigger related conditions
  95422. */
  95423. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  95424. /** @hidden */
  95425. _prepare(): void;
  95426. /**
  95427. * Execute the action toggle the boolean value.
  95428. */
  95429. execute(): void;
  95430. /**
  95431. * Serializes the actions and its related information.
  95432. * @param parent defines the object to serialize in
  95433. * @returns the serialized object
  95434. */
  95435. serialize(parent: any): any;
  95436. }
  95437. /**
  95438. * This defines an action responsible to set a the state field of the target
  95439. * to a desired value once triggered.
  95440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95441. */
  95442. export class SetStateAction extends Action {
  95443. /**
  95444. * The value to store in the state field.
  95445. */
  95446. value: string;
  95447. private _target;
  95448. /**
  95449. * Instantiate the action
  95450. * @param triggerOptions defines the trigger options
  95451. * @param target defines the object containing the state property
  95452. * @param value defines the value to store in the state field
  95453. * @param condition defines the trigger related conditions
  95454. */
  95455. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  95456. /**
  95457. * Execute the action and store the value on the target state property.
  95458. */
  95459. execute(): void;
  95460. /**
  95461. * Serializes the actions and its related information.
  95462. * @param parent defines the object to serialize in
  95463. * @returns the serialized object
  95464. */
  95465. serialize(parent: any): any;
  95466. }
  95467. /**
  95468. * This defines an action responsible to set a property of the target
  95469. * to a desired value once triggered.
  95470. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95471. */
  95472. export class SetValueAction extends Action {
  95473. /**
  95474. * The path of the property to set in the target.
  95475. */
  95476. propertyPath: string;
  95477. /**
  95478. * The value to set in the property
  95479. */
  95480. value: any;
  95481. private _target;
  95482. private _effectiveTarget;
  95483. private _property;
  95484. /**
  95485. * Instantiate the action
  95486. * @param triggerOptions defines the trigger options
  95487. * @param target defines the object containing the property
  95488. * @param propertyPath defines the path of the property to set in the target
  95489. * @param value defines the value to set in the property
  95490. * @param condition defines the trigger related conditions
  95491. */
  95492. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  95493. /** @hidden */
  95494. _prepare(): void;
  95495. /**
  95496. * Execute the action and set the targetted property to the desired value.
  95497. */
  95498. execute(): void;
  95499. /**
  95500. * Serializes the actions and its related information.
  95501. * @param parent defines the object to serialize in
  95502. * @returns the serialized object
  95503. */
  95504. serialize(parent: any): any;
  95505. }
  95506. /**
  95507. * This defines an action responsible to increment the target value
  95508. * to a desired value once triggered.
  95509. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95510. */
  95511. export class IncrementValueAction extends Action {
  95512. /**
  95513. * The path of the property to increment in the target.
  95514. */
  95515. propertyPath: string;
  95516. /**
  95517. * The value we should increment the property by.
  95518. */
  95519. value: any;
  95520. private _target;
  95521. private _effectiveTarget;
  95522. private _property;
  95523. /**
  95524. * Instantiate the action
  95525. * @param triggerOptions defines the trigger options
  95526. * @param target defines the object containing the property
  95527. * @param propertyPath defines the path of the property to increment in the target
  95528. * @param value defines the value value we should increment the property by
  95529. * @param condition defines the trigger related conditions
  95530. */
  95531. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  95532. /** @hidden */
  95533. _prepare(): void;
  95534. /**
  95535. * Execute the action and increment the target of the value amount.
  95536. */
  95537. execute(): void;
  95538. /**
  95539. * Serializes the actions and its related information.
  95540. * @param parent defines the object to serialize in
  95541. * @returns the serialized object
  95542. */
  95543. serialize(parent: any): any;
  95544. }
  95545. /**
  95546. * This defines an action responsible to start an animation once triggered.
  95547. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95548. */
  95549. export class PlayAnimationAction extends Action {
  95550. /**
  95551. * Where the animation should start (animation frame)
  95552. */
  95553. from: number;
  95554. /**
  95555. * Where the animation should stop (animation frame)
  95556. */
  95557. to: number;
  95558. /**
  95559. * Define if the animation should loop or stop after the first play.
  95560. */
  95561. loop?: boolean;
  95562. private _target;
  95563. /**
  95564. * Instantiate the action
  95565. * @param triggerOptions defines the trigger options
  95566. * @param target defines the target animation or animation name
  95567. * @param from defines from where the animation should start (animation frame)
  95568. * @param end defines where the animation should stop (animation frame)
  95569. * @param loop defines if the animation should loop or stop after the first play
  95570. * @param condition defines the trigger related conditions
  95571. */
  95572. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  95573. /** @hidden */
  95574. _prepare(): void;
  95575. /**
  95576. * Execute the action and play the animation.
  95577. */
  95578. execute(): void;
  95579. /**
  95580. * Serializes the actions and its related information.
  95581. * @param parent defines the object to serialize in
  95582. * @returns the serialized object
  95583. */
  95584. serialize(parent: any): any;
  95585. }
  95586. /**
  95587. * This defines an action responsible to stop an animation once triggered.
  95588. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95589. */
  95590. export class StopAnimationAction extends Action {
  95591. private _target;
  95592. /**
  95593. * Instantiate the action
  95594. * @param triggerOptions defines the trigger options
  95595. * @param target defines the target animation or animation name
  95596. * @param condition defines the trigger related conditions
  95597. */
  95598. constructor(triggerOptions: any, target: any, condition?: Condition);
  95599. /** @hidden */
  95600. _prepare(): void;
  95601. /**
  95602. * Execute the action and stop the animation.
  95603. */
  95604. execute(): void;
  95605. /**
  95606. * Serializes the actions and its related information.
  95607. * @param parent defines the object to serialize in
  95608. * @returns the serialized object
  95609. */
  95610. serialize(parent: any): any;
  95611. }
  95612. /**
  95613. * This defines an action responsible that does nothing once triggered.
  95614. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95615. */
  95616. export class DoNothingAction extends Action {
  95617. /**
  95618. * Instantiate the action
  95619. * @param triggerOptions defines the trigger options
  95620. * @param condition defines the trigger related conditions
  95621. */
  95622. constructor(triggerOptions?: any, condition?: Condition);
  95623. /**
  95624. * Execute the action and do nothing.
  95625. */
  95626. execute(): void;
  95627. /**
  95628. * Serializes the actions and its related information.
  95629. * @param parent defines the object to serialize in
  95630. * @returns the serialized object
  95631. */
  95632. serialize(parent: any): any;
  95633. }
  95634. /**
  95635. * This defines an action responsible to trigger several actions once triggered.
  95636. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95637. */
  95638. export class CombineAction extends Action {
  95639. /**
  95640. * The list of aggregated animations to run.
  95641. */
  95642. children: Action[];
  95643. /**
  95644. * Instantiate the action
  95645. * @param triggerOptions defines the trigger options
  95646. * @param children defines the list of aggregated animations to run
  95647. * @param condition defines the trigger related conditions
  95648. */
  95649. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  95650. /** @hidden */
  95651. _prepare(): void;
  95652. /**
  95653. * Execute the action and executes all the aggregated actions.
  95654. */
  95655. execute(evt: ActionEvent): void;
  95656. /**
  95657. * Serializes the actions and its related information.
  95658. * @param parent defines the object to serialize in
  95659. * @returns the serialized object
  95660. */
  95661. serialize(parent: any): any;
  95662. }
  95663. /**
  95664. * This defines an action responsible to run code (external event) once triggered.
  95665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95666. */
  95667. export class ExecuteCodeAction extends Action {
  95668. /**
  95669. * The callback function to run.
  95670. */
  95671. func: (evt: ActionEvent) => void;
  95672. /**
  95673. * Instantiate the action
  95674. * @param triggerOptions defines the trigger options
  95675. * @param func defines the callback function to run
  95676. * @param condition defines the trigger related conditions
  95677. */
  95678. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  95679. /**
  95680. * Execute the action and run the attached code.
  95681. */
  95682. execute(evt: ActionEvent): void;
  95683. }
  95684. /**
  95685. * This defines an action responsible to set the parent property of the target once triggered.
  95686. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95687. */
  95688. export class SetParentAction extends Action {
  95689. private _parent;
  95690. private _target;
  95691. /**
  95692. * Instantiate the action
  95693. * @param triggerOptions defines the trigger options
  95694. * @param target defines the target containing the parent property
  95695. * @param parent defines from where the animation should start (animation frame)
  95696. * @param condition defines the trigger related conditions
  95697. */
  95698. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  95699. /** @hidden */
  95700. _prepare(): void;
  95701. /**
  95702. * Execute the action and set the parent property.
  95703. */
  95704. execute(): void;
  95705. /**
  95706. * Serializes the actions and its related information.
  95707. * @param parent defines the object to serialize in
  95708. * @returns the serialized object
  95709. */
  95710. serialize(parent: any): any;
  95711. }
  95712. }
  95713. declare module BABYLON {
  95714. /**
  95715. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  95716. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  95717. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95718. */
  95719. export class ActionManager extends AbstractActionManager {
  95720. /**
  95721. * Nothing
  95722. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95723. */
  95724. static readonly NothingTrigger: number;
  95725. /**
  95726. * On pick
  95727. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95728. */
  95729. static readonly OnPickTrigger: number;
  95730. /**
  95731. * On left pick
  95732. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95733. */
  95734. static readonly OnLeftPickTrigger: number;
  95735. /**
  95736. * On right pick
  95737. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95738. */
  95739. static readonly OnRightPickTrigger: number;
  95740. /**
  95741. * On center pick
  95742. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95743. */
  95744. static readonly OnCenterPickTrigger: number;
  95745. /**
  95746. * On pick down
  95747. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95748. */
  95749. static readonly OnPickDownTrigger: number;
  95750. /**
  95751. * On double pick
  95752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95753. */
  95754. static readonly OnDoublePickTrigger: number;
  95755. /**
  95756. * On pick up
  95757. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95758. */
  95759. static readonly OnPickUpTrigger: number;
  95760. /**
  95761. * On pick out.
  95762. * This trigger will only be raised if you also declared a OnPickDown
  95763. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95764. */
  95765. static readonly OnPickOutTrigger: number;
  95766. /**
  95767. * On long press
  95768. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95769. */
  95770. static readonly OnLongPressTrigger: number;
  95771. /**
  95772. * On pointer over
  95773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95774. */
  95775. static readonly OnPointerOverTrigger: number;
  95776. /**
  95777. * On pointer out
  95778. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95779. */
  95780. static readonly OnPointerOutTrigger: number;
  95781. /**
  95782. * On every frame
  95783. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95784. */
  95785. static readonly OnEveryFrameTrigger: number;
  95786. /**
  95787. * On intersection enter
  95788. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95789. */
  95790. static readonly OnIntersectionEnterTrigger: number;
  95791. /**
  95792. * On intersection exit
  95793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95794. */
  95795. static readonly OnIntersectionExitTrigger: number;
  95796. /**
  95797. * On key down
  95798. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95799. */
  95800. static readonly OnKeyDownTrigger: number;
  95801. /**
  95802. * On key up
  95803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95804. */
  95805. static readonly OnKeyUpTrigger: number;
  95806. private _scene;
  95807. /**
  95808. * Creates a new action manager
  95809. * @param scene defines the hosting scene
  95810. */
  95811. constructor(scene: Scene);
  95812. /**
  95813. * Releases all associated resources
  95814. */
  95815. dispose(): void;
  95816. /**
  95817. * Gets hosting scene
  95818. * @returns the hosting scene
  95819. */
  95820. getScene(): Scene;
  95821. /**
  95822. * Does this action manager handles actions of any of the given triggers
  95823. * @param triggers defines the triggers to be tested
  95824. * @return a boolean indicating whether one (or more) of the triggers is handled
  95825. */
  95826. hasSpecificTriggers(triggers: number[]): boolean;
  95827. /**
  95828. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95829. * speed.
  95830. * @param triggerA defines the trigger to be tested
  95831. * @param triggerB defines the trigger to be tested
  95832. * @return a boolean indicating whether one (or more) of the triggers is handled
  95833. */
  95834. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95835. /**
  95836. * Does this action manager handles actions of a given trigger
  95837. * @param trigger defines the trigger to be tested
  95838. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95839. * @return whether the trigger is handled
  95840. */
  95841. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95842. /**
  95843. * Does this action manager has pointer triggers
  95844. */
  95845. get hasPointerTriggers(): boolean;
  95846. /**
  95847. * Does this action manager has pick triggers
  95848. */
  95849. get hasPickTriggers(): boolean;
  95850. /**
  95851. * Registers an action to this action manager
  95852. * @param action defines the action to be registered
  95853. * @return the action amended (prepared) after registration
  95854. */
  95855. registerAction(action: IAction): Nullable<IAction>;
  95856. /**
  95857. * Unregisters an action to this action manager
  95858. * @param action defines the action to be unregistered
  95859. * @return a boolean indicating whether the action has been unregistered
  95860. */
  95861. unregisterAction(action: IAction): Boolean;
  95862. /**
  95863. * Process a specific trigger
  95864. * @param trigger defines the trigger to process
  95865. * @param evt defines the event details to be processed
  95866. */
  95867. processTrigger(trigger: number, evt?: IActionEvent): void;
  95868. /** @hidden */
  95869. _getEffectiveTarget(target: any, propertyPath: string): any;
  95870. /** @hidden */
  95871. _getProperty(propertyPath: string): string;
  95872. /**
  95873. * Serialize this manager to a JSON object
  95874. * @param name defines the property name to store this manager
  95875. * @returns a JSON representation of this manager
  95876. */
  95877. serialize(name: string): any;
  95878. /**
  95879. * Creates a new ActionManager from a JSON data
  95880. * @param parsedActions defines the JSON data to read from
  95881. * @param object defines the hosting mesh
  95882. * @param scene defines the hosting scene
  95883. */
  95884. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  95885. /**
  95886. * Get a trigger name by index
  95887. * @param trigger defines the trigger index
  95888. * @returns a trigger name
  95889. */
  95890. static GetTriggerName(trigger: number): string;
  95891. }
  95892. }
  95893. declare module BABYLON {
  95894. /**
  95895. * Class representing a ray with position and direction
  95896. */
  95897. export class Ray {
  95898. /** origin point */
  95899. origin: Vector3;
  95900. /** direction */
  95901. direction: Vector3;
  95902. /** length of the ray */
  95903. length: number;
  95904. private static readonly _TmpVector3;
  95905. private _tmpRay;
  95906. /**
  95907. * Creates a new ray
  95908. * @param origin origin point
  95909. * @param direction direction
  95910. * @param length length of the ray
  95911. */
  95912. constructor(
  95913. /** origin point */
  95914. origin: Vector3,
  95915. /** direction */
  95916. direction: Vector3,
  95917. /** length of the ray */
  95918. length?: number);
  95919. /**
  95920. * Checks if the ray intersects a box
  95921. * This does not account for the ray lenght by design to improve perfs.
  95922. * @param minimum bound of the box
  95923. * @param maximum bound of the box
  95924. * @param intersectionTreshold extra extend to be added to the box in all direction
  95925. * @returns if the box was hit
  95926. */
  95927. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  95928. /**
  95929. * Checks if the ray intersects a box
  95930. * This does not account for the ray lenght by design to improve perfs.
  95931. * @param box the bounding box to check
  95932. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  95933. * @returns if the box was hit
  95934. */
  95935. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  95936. /**
  95937. * If the ray hits a sphere
  95938. * @param sphere the bounding sphere to check
  95939. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  95940. * @returns true if it hits the sphere
  95941. */
  95942. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  95943. /**
  95944. * If the ray hits a triange
  95945. * @param vertex0 triangle vertex
  95946. * @param vertex1 triangle vertex
  95947. * @param vertex2 triangle vertex
  95948. * @returns intersection information if hit
  95949. */
  95950. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  95951. /**
  95952. * Checks if ray intersects a plane
  95953. * @param plane the plane to check
  95954. * @returns the distance away it was hit
  95955. */
  95956. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  95957. /**
  95958. * Calculate the intercept of a ray on a given axis
  95959. * @param axis to check 'x' | 'y' | 'z'
  95960. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  95961. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  95962. */
  95963. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  95964. /**
  95965. * Checks if ray intersects a mesh
  95966. * @param mesh the mesh to check
  95967. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95968. * @returns picking info of the intersecton
  95969. */
  95970. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  95971. /**
  95972. * Checks if ray intersects a mesh
  95973. * @param meshes the meshes to check
  95974. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95975. * @param results array to store result in
  95976. * @returns Array of picking infos
  95977. */
  95978. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  95979. private _comparePickingInfo;
  95980. private static smallnum;
  95981. private static rayl;
  95982. /**
  95983. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  95984. * @param sega the first point of the segment to test the intersection against
  95985. * @param segb the second point of the segment to test the intersection against
  95986. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  95987. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  95988. */
  95989. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  95990. /**
  95991. * Update the ray from viewport position
  95992. * @param x position
  95993. * @param y y position
  95994. * @param viewportWidth viewport width
  95995. * @param viewportHeight viewport height
  95996. * @param world world matrix
  95997. * @param view view matrix
  95998. * @param projection projection matrix
  95999. * @returns this ray updated
  96000. */
  96001. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  96002. /**
  96003. * Creates a ray with origin and direction of 0,0,0
  96004. * @returns the new ray
  96005. */
  96006. static Zero(): Ray;
  96007. /**
  96008. * Creates a new ray from screen space and viewport
  96009. * @param x position
  96010. * @param y y position
  96011. * @param viewportWidth viewport width
  96012. * @param viewportHeight viewport height
  96013. * @param world world matrix
  96014. * @param view view matrix
  96015. * @param projection projection matrix
  96016. * @returns new ray
  96017. */
  96018. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  96019. /**
  96020. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  96021. * transformed to the given world matrix.
  96022. * @param origin The origin point
  96023. * @param end The end point
  96024. * @param world a matrix to transform the ray to. Default is the identity matrix.
  96025. * @returns the new ray
  96026. */
  96027. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  96028. /**
  96029. * Transforms a ray by a matrix
  96030. * @param ray ray to transform
  96031. * @param matrix matrix to apply
  96032. * @returns the resulting new ray
  96033. */
  96034. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  96035. /**
  96036. * Transforms a ray by a matrix
  96037. * @param ray ray to transform
  96038. * @param matrix matrix to apply
  96039. * @param result ray to store result in
  96040. */
  96041. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  96042. /**
  96043. * Unproject a ray from screen space to object space
  96044. * @param sourceX defines the screen space x coordinate to use
  96045. * @param sourceY defines the screen space y coordinate to use
  96046. * @param viewportWidth defines the current width of the viewport
  96047. * @param viewportHeight defines the current height of the viewport
  96048. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  96049. * @param view defines the view matrix to use
  96050. * @param projection defines the projection matrix to use
  96051. */
  96052. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  96053. }
  96054. /**
  96055. * Type used to define predicate used to select faces when a mesh intersection is detected
  96056. */
  96057. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  96058. interface Scene {
  96059. /** @hidden */
  96060. _tempPickingRay: Nullable<Ray>;
  96061. /** @hidden */
  96062. _cachedRayForTransform: Ray;
  96063. /** @hidden */
  96064. _pickWithRayInverseMatrix: Matrix;
  96065. /** @hidden */
  96066. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96067. /** @hidden */
  96068. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96069. /** @hidden */
  96070. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  96071. }
  96072. }
  96073. declare module BABYLON {
  96074. /**
  96075. * Groups all the scene component constants in one place to ease maintenance.
  96076. * @hidden
  96077. */
  96078. export class SceneComponentConstants {
  96079. static readonly NAME_EFFECTLAYER: string;
  96080. static readonly NAME_LAYER: string;
  96081. static readonly NAME_LENSFLARESYSTEM: string;
  96082. static readonly NAME_BOUNDINGBOXRENDERER: string;
  96083. static readonly NAME_PARTICLESYSTEM: string;
  96084. static readonly NAME_GAMEPAD: string;
  96085. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  96086. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  96087. static readonly NAME_PREPASSRENDERER: string;
  96088. static readonly NAME_DEPTHRENDERER: string;
  96089. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  96090. static readonly NAME_SPRITE: string;
  96091. static readonly NAME_SUBSURFACE: string;
  96092. static readonly NAME_OUTLINERENDERER: string;
  96093. static readonly NAME_PROCEDURALTEXTURE: string;
  96094. static readonly NAME_SHADOWGENERATOR: string;
  96095. static readonly NAME_OCTREE: string;
  96096. static readonly NAME_PHYSICSENGINE: string;
  96097. static readonly NAME_AUDIO: string;
  96098. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  96099. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  96100. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  96101. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  96102. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  96103. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  96104. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  96105. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  96106. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  96107. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  96108. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  96109. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  96110. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  96111. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  96112. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  96113. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  96114. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  96115. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  96116. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  96117. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  96118. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  96119. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  96120. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  96121. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  96122. static readonly STEP_AFTERRENDER_AUDIO: number;
  96123. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  96124. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  96125. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  96126. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  96127. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  96128. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  96129. static readonly STEP_POINTERMOVE_SPRITE: number;
  96130. static readonly STEP_POINTERDOWN_SPRITE: number;
  96131. static readonly STEP_POINTERUP_SPRITE: number;
  96132. }
  96133. /**
  96134. * This represents a scene component.
  96135. *
  96136. * This is used to decouple the dependency the scene is having on the different workloads like
  96137. * layers, post processes...
  96138. */
  96139. export interface ISceneComponent {
  96140. /**
  96141. * The name of the component. Each component must have a unique name.
  96142. */
  96143. name: string;
  96144. /**
  96145. * The scene the component belongs to.
  96146. */
  96147. scene: Scene;
  96148. /**
  96149. * Register the component to one instance of a scene.
  96150. */
  96151. register(): void;
  96152. /**
  96153. * Rebuilds the elements related to this component in case of
  96154. * context lost for instance.
  96155. */
  96156. rebuild(): void;
  96157. /**
  96158. * Disposes the component and the associated ressources.
  96159. */
  96160. dispose(): void;
  96161. }
  96162. /**
  96163. * This represents a SERIALIZABLE scene component.
  96164. *
  96165. * This extends Scene Component to add Serialization methods on top.
  96166. */
  96167. export interface ISceneSerializableComponent extends ISceneComponent {
  96168. /**
  96169. * Adds all the elements from the container to the scene
  96170. * @param container the container holding the elements
  96171. */
  96172. addFromContainer(container: AbstractScene): void;
  96173. /**
  96174. * Removes all the elements in the container from the scene
  96175. * @param container contains the elements to remove
  96176. * @param dispose if the removed element should be disposed (default: false)
  96177. */
  96178. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  96179. /**
  96180. * Serializes the component data to the specified json object
  96181. * @param serializationObject The object to serialize to
  96182. */
  96183. serialize(serializationObject: any): void;
  96184. }
  96185. /**
  96186. * Strong typing of a Mesh related stage step action
  96187. */
  96188. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  96189. /**
  96190. * Strong typing of a Evaluate Sub Mesh related stage step action
  96191. */
  96192. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  96193. /**
  96194. * Strong typing of a pre active Mesh related stage step action
  96195. */
  96196. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  96197. /**
  96198. * Strong typing of a Camera related stage step action
  96199. */
  96200. export type CameraStageAction = (camera: Camera) => void;
  96201. /**
  96202. * Strong typing of a Camera Frame buffer related stage step action
  96203. */
  96204. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  96205. /**
  96206. * Strong typing of a Render Target related stage step action
  96207. */
  96208. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  96209. /**
  96210. * Strong typing of a RenderingGroup related stage step action
  96211. */
  96212. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  96213. /**
  96214. * Strong typing of a Mesh Render related stage step action
  96215. */
  96216. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  96217. /**
  96218. * Strong typing of a simple stage step action
  96219. */
  96220. export type SimpleStageAction = () => void;
  96221. /**
  96222. * Strong typing of a render target action.
  96223. */
  96224. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  96225. /**
  96226. * Strong typing of a pointer move action.
  96227. */
  96228. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  96229. /**
  96230. * Strong typing of a pointer up/down action.
  96231. */
  96232. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  96233. /**
  96234. * Representation of a stage in the scene (Basically a list of ordered steps)
  96235. * @hidden
  96236. */
  96237. export class Stage<T extends Function> extends Array<{
  96238. index: number;
  96239. component: ISceneComponent;
  96240. action: T;
  96241. }> {
  96242. /**
  96243. * Hide ctor from the rest of the world.
  96244. * @param items The items to add.
  96245. */
  96246. private constructor();
  96247. /**
  96248. * Creates a new Stage.
  96249. * @returns A new instance of a Stage
  96250. */
  96251. static Create<T extends Function>(): Stage<T>;
  96252. /**
  96253. * Registers a step in an ordered way in the targeted stage.
  96254. * @param index Defines the position to register the step in
  96255. * @param component Defines the component attached to the step
  96256. * @param action Defines the action to launch during the step
  96257. */
  96258. registerStep(index: number, component: ISceneComponent, action: T): void;
  96259. /**
  96260. * Clears all the steps from the stage.
  96261. */
  96262. clear(): void;
  96263. }
  96264. }
  96265. declare module BABYLON {
  96266. interface Scene {
  96267. /** @hidden */
  96268. _pointerOverSprite: Nullable<Sprite>;
  96269. /** @hidden */
  96270. _pickedDownSprite: Nullable<Sprite>;
  96271. /** @hidden */
  96272. _tempSpritePickingRay: Nullable<Ray>;
  96273. /**
  96274. * All of the sprite managers added to this scene
  96275. * @see https://doc.babylonjs.com/babylon101/sprites
  96276. */
  96277. spriteManagers: Array<ISpriteManager>;
  96278. /**
  96279. * An event triggered when sprites rendering is about to start
  96280. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  96281. */
  96282. onBeforeSpritesRenderingObservable: Observable<Scene>;
  96283. /**
  96284. * An event triggered when sprites rendering is done
  96285. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  96286. */
  96287. onAfterSpritesRenderingObservable: Observable<Scene>;
  96288. /** @hidden */
  96289. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96290. /** Launch a ray to try to pick a sprite in the scene
  96291. * @param x position on screen
  96292. * @param y position on screen
  96293. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  96294. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96295. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96296. * @returns a PickingInfo
  96297. */
  96298. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96299. /** Use the given ray to pick a sprite in the scene
  96300. * @param ray The ray (in world space) to use to pick meshes
  96301. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  96302. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96303. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  96304. * @returns a PickingInfo
  96305. */
  96306. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96307. /** @hidden */
  96308. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96309. /** Launch a ray to try to pick sprites in the scene
  96310. * @param x position on screen
  96311. * @param y position on screen
  96312. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  96313. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96314. * @returns a PickingInfo array
  96315. */
  96316. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96317. /** Use the given ray to pick sprites in the scene
  96318. * @param ray The ray (in world space) to use to pick meshes
  96319. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  96320. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  96321. * @returns a PickingInfo array
  96322. */
  96323. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96324. /**
  96325. * Force the sprite under the pointer
  96326. * @param sprite defines the sprite to use
  96327. */
  96328. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  96329. /**
  96330. * Gets the sprite under the pointer
  96331. * @returns a Sprite or null if no sprite is under the pointer
  96332. */
  96333. getPointerOverSprite(): Nullable<Sprite>;
  96334. }
  96335. /**
  96336. * Defines the sprite scene component responsible to manage sprites
  96337. * in a given scene.
  96338. */
  96339. export class SpriteSceneComponent implements ISceneComponent {
  96340. /**
  96341. * The component name helpfull to identify the component in the list of scene components.
  96342. */
  96343. readonly name: string;
  96344. /**
  96345. * The scene the component belongs to.
  96346. */
  96347. scene: Scene;
  96348. /** @hidden */
  96349. private _spritePredicate;
  96350. /**
  96351. * Creates a new instance of the component for the given scene
  96352. * @param scene Defines the scene to register the component in
  96353. */
  96354. constructor(scene: Scene);
  96355. /**
  96356. * Registers the component in a given scene
  96357. */
  96358. register(): void;
  96359. /**
  96360. * Rebuilds the elements related to this component in case of
  96361. * context lost for instance.
  96362. */
  96363. rebuild(): void;
  96364. /**
  96365. * Disposes the component and the associated ressources.
  96366. */
  96367. dispose(): void;
  96368. private _pickSpriteButKeepRay;
  96369. private _pointerMove;
  96370. private _pointerDown;
  96371. private _pointerUp;
  96372. }
  96373. }
  96374. declare module BABYLON {
  96375. /**
  96376. * Class used to provide helper for timing
  96377. */
  96378. export class TimingTools {
  96379. /**
  96380. * Polyfill for setImmediate
  96381. * @param action defines the action to execute after the current execution block
  96382. */
  96383. static SetImmediate(action: () => void): void;
  96384. }
  96385. }
  96386. declare module BABYLON {
  96387. /**
  96388. * Class used to enable instatition of objects by class name
  96389. */
  96390. export class InstantiationTools {
  96391. /**
  96392. * Use this object to register external classes like custom textures or material
  96393. * to allow the laoders to instantiate them
  96394. */
  96395. static RegisteredExternalClasses: {
  96396. [key: string]: Object;
  96397. };
  96398. /**
  96399. * Tries to instantiate a new object from a given class name
  96400. * @param className defines the class name to instantiate
  96401. * @returns the new object or null if the system was not able to do the instantiation
  96402. */
  96403. static Instantiate(className: string): any;
  96404. }
  96405. }
  96406. declare module BABYLON {
  96407. /**
  96408. * Class used to host copy specific utilities
  96409. */
  96410. export class CopyTools {
  96411. /**
  96412. * Transform some pixel data to a base64 string
  96413. * @param pixels defines the pixel data to transform to base64
  96414. * @param size defines the width and height of the (texture) data
  96415. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  96416. * @returns The base64 encoded string or null
  96417. */
  96418. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  96419. /**
  96420. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  96421. * @param texture defines the texture to read pixels from
  96422. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96423. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96424. * @returns The base64 encoded string or null
  96425. */
  96426. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  96427. /**
  96428. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  96429. * @param texture defines the texture to read pixels from
  96430. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96431. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96432. * @returns The base64 encoded string or null wrapped in a promise
  96433. */
  96434. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  96435. }
  96436. }
  96437. declare module BABYLON {
  96438. /**
  96439. * Define options used to create a depth texture
  96440. */
  96441. export class DepthTextureCreationOptions {
  96442. /** Specifies whether or not a stencil should be allocated in the texture */
  96443. generateStencil?: boolean;
  96444. /** Specifies whether or not bilinear filtering is enable on the texture */
  96445. bilinearFiltering?: boolean;
  96446. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  96447. comparisonFunction?: number;
  96448. /** Specifies if the created texture is a cube texture */
  96449. isCube?: boolean;
  96450. /** Specifies the sample count of the depth/stencil texture texture */
  96451. samples?: number;
  96452. }
  96453. }
  96454. declare module BABYLON {
  96455. interface ThinEngine {
  96456. /**
  96457. * Creates a depth stencil cube texture.
  96458. * This is only available in WebGL 2.
  96459. * @param size The size of face edge in the cube texture.
  96460. * @param options The options defining the cube texture.
  96461. * @returns The cube texture
  96462. */
  96463. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  96464. /**
  96465. * Creates a cube texture
  96466. * @param rootUrl defines the url where the files to load is located
  96467. * @param scene defines the current scene
  96468. * @param files defines the list of files to load (1 per face)
  96469. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96470. * @param onLoad defines an optional callback raised when the texture is loaded
  96471. * @param onError defines an optional callback raised if there is an issue to load the texture
  96472. * @param format defines the format of the data
  96473. * @param forcedExtension defines the extension to use to pick the right loader
  96474. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  96475. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96476. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96477. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  96478. * @param loaderOptions options to be passed to the loader
  96479. * @returns the cube texture as an InternalTexture
  96480. */
  96481. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  96482. /**
  96483. * Creates a cube texture
  96484. * @param rootUrl defines the url where the files to load is located
  96485. * @param scene defines the current scene
  96486. * @param files defines the list of files to load (1 per face)
  96487. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96488. * @param onLoad defines an optional callback raised when the texture is loaded
  96489. * @param onError defines an optional callback raised if there is an issue to load the texture
  96490. * @param format defines the format of the data
  96491. * @param forcedExtension defines the extension to use to pick the right loader
  96492. * @returns the cube texture as an InternalTexture
  96493. */
  96494. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  96495. /**
  96496. * Creates a cube texture
  96497. * @param rootUrl defines the url where the files to load is located
  96498. * @param scene defines the current scene
  96499. * @param files defines the list of files to load (1 per face)
  96500. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96501. * @param onLoad defines an optional callback raised when the texture is loaded
  96502. * @param onError defines an optional callback raised if there is an issue to load the texture
  96503. * @param format defines the format of the data
  96504. * @param forcedExtension defines the extension to use to pick the right loader
  96505. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  96506. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96507. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96508. * @returns the cube texture as an InternalTexture
  96509. */
  96510. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  96511. /** @hidden */
  96512. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  96513. /** @hidden */
  96514. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  96515. /** @hidden */
  96516. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  96517. /** @hidden */
  96518. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  96519. /** @hidden */
  96520. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  96521. /**
  96522. * @hidden
  96523. */
  96524. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  96525. }
  96526. }
  96527. declare module BABYLON {
  96528. /**
  96529. * Class for creating a cube texture
  96530. */
  96531. export class CubeTexture extends BaseTexture {
  96532. private _delayedOnLoad;
  96533. /**
  96534. * Observable triggered once the texture has been loaded.
  96535. */
  96536. onLoadObservable: Observable<CubeTexture>;
  96537. /**
  96538. * The url of the texture
  96539. */
  96540. url: string;
  96541. /**
  96542. * Gets or sets the center of the bounding box associated with the cube texture.
  96543. * It must define where the camera used to render the texture was set
  96544. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  96545. */
  96546. boundingBoxPosition: Vector3;
  96547. private _boundingBoxSize;
  96548. /**
  96549. * Gets or sets the size of the bounding box associated with the cube texture
  96550. * When defined, the cubemap will switch to local mode
  96551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96552. * @example https://www.babylonjs-playground.com/#RNASML
  96553. */
  96554. set boundingBoxSize(value: Vector3);
  96555. /**
  96556. * Returns the bounding box size
  96557. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  96558. */
  96559. get boundingBoxSize(): Vector3;
  96560. protected _rotationY: number;
  96561. /**
  96562. * Sets texture matrix rotation angle around Y axis in radians.
  96563. */
  96564. set rotationY(value: number);
  96565. /**
  96566. * Gets texture matrix rotation angle around Y axis radians.
  96567. */
  96568. get rotationY(): number;
  96569. /**
  96570. * Are mip maps generated for this texture or not.
  96571. */
  96572. get noMipmap(): boolean;
  96573. private _noMipmap;
  96574. private _files;
  96575. protected _forcedExtension: Nullable<string>;
  96576. private _extensions;
  96577. private _textureMatrix;
  96578. private _format;
  96579. private _createPolynomials;
  96580. private _loaderOptions;
  96581. /**
  96582. * Creates a cube texture from an array of image urls
  96583. * @param files defines an array of image urls
  96584. * @param scene defines the hosting scene
  96585. * @param noMipmap specifies if mip maps are not used
  96586. * @returns a cube texture
  96587. */
  96588. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  96589. /**
  96590. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  96591. * @param url defines the url of the prefiltered texture
  96592. * @param scene defines the scene the texture is attached to
  96593. * @param forcedExtension defines the extension of the file if different from the url
  96594. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  96595. * @return the prefiltered texture
  96596. */
  96597. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  96598. /**
  96599. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  96600. * as prefiltered data.
  96601. * @param rootUrl defines the url of the texture or the root name of the six images
  96602. * @param null defines the scene or engine the texture is attached to
  96603. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  96604. * @param noMipmap defines if mipmaps should be created or not
  96605. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  96606. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  96607. * @param onError defines a callback triggered in case of error during load
  96608. * @param format defines the internal format to use for the texture once loaded
  96609. * @param prefiltered defines whether or not the texture is created from prefiltered data
  96610. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  96611. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  96612. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96613. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96614. * @param loaderOptions options to be passed to the loader
  96615. * @return the cube texture
  96616. */
  96617. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  96618. /**
  96619. * Get the current class name of the texture useful for serialization or dynamic coding.
  96620. * @returns "CubeTexture"
  96621. */
  96622. getClassName(): string;
  96623. /**
  96624. * Update the url (and optional buffer) of this texture if url was null during construction.
  96625. * @param url the url of the texture
  96626. * @param forcedExtension defines the extension to use
  96627. * @param onLoad callback called when the texture is loaded (defaults to null)
  96628. * @param prefiltered Defines whether the updated texture is prefiltered or not
  96629. */
  96630. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  96631. /**
  96632. * Delays loading of the cube texture
  96633. * @param forcedExtension defines the extension to use
  96634. */
  96635. delayLoad(forcedExtension?: string): void;
  96636. /**
  96637. * Returns the reflection texture matrix
  96638. * @returns the reflection texture matrix
  96639. */
  96640. getReflectionTextureMatrix(): Matrix;
  96641. /**
  96642. * Sets the reflection texture matrix
  96643. * @param value Reflection texture matrix
  96644. */
  96645. setReflectionTextureMatrix(value: Matrix): void;
  96646. /**
  96647. * Parses text to create a cube texture
  96648. * @param parsedTexture define the serialized text to read from
  96649. * @param scene defines the hosting scene
  96650. * @param rootUrl defines the root url of the cube texture
  96651. * @returns a cube texture
  96652. */
  96653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  96654. /**
  96655. * Makes a clone, or deep copy, of the cube texture
  96656. * @returns a new cube texture
  96657. */
  96658. clone(): CubeTexture;
  96659. }
  96660. }
  96661. declare module BABYLON {
  96662. /**
  96663. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96664. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96665. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  96666. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96667. */
  96668. export class ColorCurves {
  96669. private _dirty;
  96670. private _tempColor;
  96671. private _globalCurve;
  96672. private _highlightsCurve;
  96673. private _midtonesCurve;
  96674. private _shadowsCurve;
  96675. private _positiveCurve;
  96676. private _negativeCurve;
  96677. private _globalHue;
  96678. private _globalDensity;
  96679. private _globalSaturation;
  96680. private _globalExposure;
  96681. /**
  96682. * Gets the global Hue value.
  96683. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96684. */
  96685. get globalHue(): number;
  96686. /**
  96687. * Sets the global Hue value.
  96688. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96689. */
  96690. set globalHue(value: number);
  96691. /**
  96692. * Gets the global Density value.
  96693. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96694. * Values less than zero provide a filter of opposite hue.
  96695. */
  96696. get globalDensity(): number;
  96697. /**
  96698. * Sets the global Density value.
  96699. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96700. * Values less than zero provide a filter of opposite hue.
  96701. */
  96702. set globalDensity(value: number);
  96703. /**
  96704. * Gets the global Saturation value.
  96705. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96706. */
  96707. get globalSaturation(): number;
  96708. /**
  96709. * Sets the global Saturation value.
  96710. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96711. */
  96712. set globalSaturation(value: number);
  96713. /**
  96714. * Gets the global Exposure value.
  96715. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96716. */
  96717. get globalExposure(): number;
  96718. /**
  96719. * Sets the global Exposure value.
  96720. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96721. */
  96722. set globalExposure(value: number);
  96723. private _highlightsHue;
  96724. private _highlightsDensity;
  96725. private _highlightsSaturation;
  96726. private _highlightsExposure;
  96727. /**
  96728. * Gets the highlights Hue value.
  96729. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96730. */
  96731. get highlightsHue(): number;
  96732. /**
  96733. * Sets the highlights Hue value.
  96734. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96735. */
  96736. set highlightsHue(value: number);
  96737. /**
  96738. * Gets the highlights Density value.
  96739. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96740. * Values less than zero provide a filter of opposite hue.
  96741. */
  96742. get highlightsDensity(): number;
  96743. /**
  96744. * Sets the highlights Density value.
  96745. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96746. * Values less than zero provide a filter of opposite hue.
  96747. */
  96748. set highlightsDensity(value: number);
  96749. /**
  96750. * Gets the highlights Saturation value.
  96751. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96752. */
  96753. get highlightsSaturation(): number;
  96754. /**
  96755. * Sets the highlights Saturation value.
  96756. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96757. */
  96758. set highlightsSaturation(value: number);
  96759. /**
  96760. * Gets the highlights Exposure value.
  96761. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96762. */
  96763. get highlightsExposure(): number;
  96764. /**
  96765. * Sets the highlights Exposure value.
  96766. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96767. */
  96768. set highlightsExposure(value: number);
  96769. private _midtonesHue;
  96770. private _midtonesDensity;
  96771. private _midtonesSaturation;
  96772. private _midtonesExposure;
  96773. /**
  96774. * Gets the midtones Hue value.
  96775. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96776. */
  96777. get midtonesHue(): number;
  96778. /**
  96779. * Sets the midtones Hue value.
  96780. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96781. */
  96782. set midtonesHue(value: number);
  96783. /**
  96784. * Gets the midtones Density value.
  96785. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96786. * Values less than zero provide a filter of opposite hue.
  96787. */
  96788. get midtonesDensity(): number;
  96789. /**
  96790. * Sets the midtones Density value.
  96791. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96792. * Values less than zero provide a filter of opposite hue.
  96793. */
  96794. set midtonesDensity(value: number);
  96795. /**
  96796. * Gets the midtones Saturation value.
  96797. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96798. */
  96799. get midtonesSaturation(): number;
  96800. /**
  96801. * Sets the midtones Saturation value.
  96802. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96803. */
  96804. set midtonesSaturation(value: number);
  96805. /**
  96806. * Gets the midtones Exposure value.
  96807. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96808. */
  96809. get midtonesExposure(): number;
  96810. /**
  96811. * Sets the midtones Exposure value.
  96812. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96813. */
  96814. set midtonesExposure(value: number);
  96815. private _shadowsHue;
  96816. private _shadowsDensity;
  96817. private _shadowsSaturation;
  96818. private _shadowsExposure;
  96819. /**
  96820. * Gets the shadows Hue value.
  96821. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96822. */
  96823. get shadowsHue(): number;
  96824. /**
  96825. * Sets the shadows Hue value.
  96826. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  96827. */
  96828. set shadowsHue(value: number);
  96829. /**
  96830. * Gets the shadows Density value.
  96831. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96832. * Values less than zero provide a filter of opposite hue.
  96833. */
  96834. get shadowsDensity(): number;
  96835. /**
  96836. * Sets the shadows Density value.
  96837. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  96838. * Values less than zero provide a filter of opposite hue.
  96839. */
  96840. set shadowsDensity(value: number);
  96841. /**
  96842. * Gets the shadows Saturation value.
  96843. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96844. */
  96845. get shadowsSaturation(): number;
  96846. /**
  96847. * Sets the shadows Saturation value.
  96848. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  96849. */
  96850. set shadowsSaturation(value: number);
  96851. /**
  96852. * Gets the shadows Exposure value.
  96853. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96854. */
  96855. get shadowsExposure(): number;
  96856. /**
  96857. * Sets the shadows Exposure value.
  96858. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  96859. */
  96860. set shadowsExposure(value: number);
  96861. /**
  96862. * Returns the class name
  96863. * @returns The class name
  96864. */
  96865. getClassName(): string;
  96866. /**
  96867. * Binds the color curves to the shader.
  96868. * @param colorCurves The color curve to bind
  96869. * @param effect The effect to bind to
  96870. * @param positiveUniform The positive uniform shader parameter
  96871. * @param neutralUniform The neutral uniform shader parameter
  96872. * @param negativeUniform The negative uniform shader parameter
  96873. */
  96874. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  96875. /**
  96876. * Prepare the list of uniforms associated with the ColorCurves effects.
  96877. * @param uniformsList The list of uniforms used in the effect
  96878. */
  96879. static PrepareUniforms(uniformsList: string[]): void;
  96880. /**
  96881. * Returns color grading data based on a hue, density, saturation and exposure value.
  96882. * @param filterHue The hue of the color filter.
  96883. * @param filterDensity The density of the color filter.
  96884. * @param saturation The saturation.
  96885. * @param exposure The exposure.
  96886. * @param result The result data container.
  96887. */
  96888. private getColorGradingDataToRef;
  96889. /**
  96890. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  96891. * @param value The input slider value in range [-100,100].
  96892. * @returns Adjusted value.
  96893. */
  96894. private static applyColorGradingSliderNonlinear;
  96895. /**
  96896. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  96897. * @param hue The hue (H) input.
  96898. * @param saturation The saturation (S) input.
  96899. * @param brightness The brightness (B) input.
  96900. * @result An RGBA color represented as Vector4.
  96901. */
  96902. private static fromHSBToRef;
  96903. /**
  96904. * Returns a value clamped between min and max
  96905. * @param value The value to clamp
  96906. * @param min The minimum of value
  96907. * @param max The maximum of value
  96908. * @returns The clamped value.
  96909. */
  96910. private static clamp;
  96911. /**
  96912. * Clones the current color curve instance.
  96913. * @return The cloned curves
  96914. */
  96915. clone(): ColorCurves;
  96916. /**
  96917. * Serializes the current color curve instance to a json representation.
  96918. * @return a JSON representation
  96919. */
  96920. serialize(): any;
  96921. /**
  96922. * Parses the color curve from a json representation.
  96923. * @param source the JSON source to parse
  96924. * @return The parsed curves
  96925. */
  96926. static Parse(source: any): ColorCurves;
  96927. }
  96928. }
  96929. declare module BABYLON {
  96930. /**
  96931. * Interface to follow in your material defines to integrate easily the
  96932. * Image proccessing functions.
  96933. * @hidden
  96934. */
  96935. export interface IImageProcessingConfigurationDefines {
  96936. IMAGEPROCESSING: boolean;
  96937. VIGNETTE: boolean;
  96938. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96939. VIGNETTEBLENDMODEOPAQUE: boolean;
  96940. TONEMAPPING: boolean;
  96941. TONEMAPPING_ACES: boolean;
  96942. CONTRAST: boolean;
  96943. EXPOSURE: boolean;
  96944. COLORCURVES: boolean;
  96945. COLORGRADING: boolean;
  96946. COLORGRADING3D: boolean;
  96947. SAMPLER3DGREENDEPTH: boolean;
  96948. SAMPLER3DBGRMAP: boolean;
  96949. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96950. }
  96951. /**
  96952. * @hidden
  96953. */
  96954. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96955. IMAGEPROCESSING: boolean;
  96956. VIGNETTE: boolean;
  96957. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96958. VIGNETTEBLENDMODEOPAQUE: boolean;
  96959. TONEMAPPING: boolean;
  96960. TONEMAPPING_ACES: boolean;
  96961. CONTRAST: boolean;
  96962. COLORCURVES: boolean;
  96963. COLORGRADING: boolean;
  96964. COLORGRADING3D: boolean;
  96965. SAMPLER3DGREENDEPTH: boolean;
  96966. SAMPLER3DBGRMAP: boolean;
  96967. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96968. EXPOSURE: boolean;
  96969. constructor();
  96970. }
  96971. /**
  96972. * This groups together the common properties used for image processing either in direct forward pass
  96973. * or through post processing effect depending on the use of the image processing pipeline in your scene
  96974. * or not.
  96975. */
  96976. export class ImageProcessingConfiguration {
  96977. /**
  96978. * Default tone mapping applied in BabylonJS.
  96979. */
  96980. static readonly TONEMAPPING_STANDARD: number;
  96981. /**
  96982. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  96983. * to other engines rendering to increase portability.
  96984. */
  96985. static readonly TONEMAPPING_ACES: number;
  96986. /**
  96987. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  96988. */
  96989. colorCurves: Nullable<ColorCurves>;
  96990. private _colorCurvesEnabled;
  96991. /**
  96992. * Gets wether the color curves effect is enabled.
  96993. */
  96994. get colorCurvesEnabled(): boolean;
  96995. /**
  96996. * Sets wether the color curves effect is enabled.
  96997. */
  96998. set colorCurvesEnabled(value: boolean);
  96999. private _colorGradingTexture;
  97000. /**
  97001. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  97002. */
  97003. get colorGradingTexture(): Nullable<BaseTexture>;
  97004. /**
  97005. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  97006. */
  97007. set colorGradingTexture(value: Nullable<BaseTexture>);
  97008. private _colorGradingEnabled;
  97009. /**
  97010. * Gets wether the color grading effect is enabled.
  97011. */
  97012. get colorGradingEnabled(): boolean;
  97013. /**
  97014. * Sets wether the color grading effect is enabled.
  97015. */
  97016. set colorGradingEnabled(value: boolean);
  97017. private _colorGradingWithGreenDepth;
  97018. /**
  97019. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  97020. */
  97021. get colorGradingWithGreenDepth(): boolean;
  97022. /**
  97023. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  97024. */
  97025. set colorGradingWithGreenDepth(value: boolean);
  97026. private _colorGradingBGR;
  97027. /**
  97028. * Gets wether the color grading texture contains BGR values.
  97029. */
  97030. get colorGradingBGR(): boolean;
  97031. /**
  97032. * Sets wether the color grading texture contains BGR values.
  97033. */
  97034. set colorGradingBGR(value: boolean);
  97035. /** @hidden */
  97036. _exposure: number;
  97037. /**
  97038. * Gets the Exposure used in the effect.
  97039. */
  97040. get exposure(): number;
  97041. /**
  97042. * Sets the Exposure used in the effect.
  97043. */
  97044. set exposure(value: number);
  97045. private _toneMappingEnabled;
  97046. /**
  97047. * Gets wether the tone mapping effect is enabled.
  97048. */
  97049. get toneMappingEnabled(): boolean;
  97050. /**
  97051. * Sets wether the tone mapping effect is enabled.
  97052. */
  97053. set toneMappingEnabled(value: boolean);
  97054. private _toneMappingType;
  97055. /**
  97056. * Gets the type of tone mapping effect.
  97057. */
  97058. get toneMappingType(): number;
  97059. /**
  97060. * Sets the type of tone mapping effect used in BabylonJS.
  97061. */
  97062. set toneMappingType(value: number);
  97063. protected _contrast: number;
  97064. /**
  97065. * Gets the contrast used in the effect.
  97066. */
  97067. get contrast(): number;
  97068. /**
  97069. * Sets the contrast used in the effect.
  97070. */
  97071. set contrast(value: number);
  97072. /**
  97073. * Vignette stretch size.
  97074. */
  97075. vignetteStretch: number;
  97076. /**
  97077. * Vignette centre X Offset.
  97078. */
  97079. vignetteCentreX: number;
  97080. /**
  97081. * Vignette centre Y Offset.
  97082. */
  97083. vignetteCentreY: number;
  97084. /**
  97085. * Vignette weight or intensity of the vignette effect.
  97086. */
  97087. vignetteWeight: number;
  97088. /**
  97089. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97090. * if vignetteEnabled is set to true.
  97091. */
  97092. vignetteColor: Color4;
  97093. /**
  97094. * Camera field of view used by the Vignette effect.
  97095. */
  97096. vignetteCameraFov: number;
  97097. private _vignetteBlendMode;
  97098. /**
  97099. * Gets the vignette blend mode allowing different kind of effect.
  97100. */
  97101. get vignetteBlendMode(): number;
  97102. /**
  97103. * Sets the vignette blend mode allowing different kind of effect.
  97104. */
  97105. set vignetteBlendMode(value: number);
  97106. private _vignetteEnabled;
  97107. /**
  97108. * Gets wether the vignette effect is enabled.
  97109. */
  97110. get vignetteEnabled(): boolean;
  97111. /**
  97112. * Sets wether the vignette effect is enabled.
  97113. */
  97114. set vignetteEnabled(value: boolean);
  97115. private _applyByPostProcess;
  97116. /**
  97117. * Gets wether the image processing is applied through a post process or not.
  97118. */
  97119. get applyByPostProcess(): boolean;
  97120. /**
  97121. * Sets wether the image processing is applied through a post process or not.
  97122. */
  97123. set applyByPostProcess(value: boolean);
  97124. private _isEnabled;
  97125. /**
  97126. * Gets wether the image processing is enabled or not.
  97127. */
  97128. get isEnabled(): boolean;
  97129. /**
  97130. * Sets wether the image processing is enabled or not.
  97131. */
  97132. set isEnabled(value: boolean);
  97133. /**
  97134. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  97135. */
  97136. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  97137. /**
  97138. * Method called each time the image processing information changes requires to recompile the effect.
  97139. */
  97140. protected _updateParameters(): void;
  97141. /**
  97142. * Gets the current class name.
  97143. * @return "ImageProcessingConfiguration"
  97144. */
  97145. getClassName(): string;
  97146. /**
  97147. * Prepare the list of uniforms associated with the Image Processing effects.
  97148. * @param uniforms The list of uniforms used in the effect
  97149. * @param defines the list of defines currently in use
  97150. */
  97151. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  97152. /**
  97153. * Prepare the list of samplers associated with the Image Processing effects.
  97154. * @param samplersList The list of uniforms used in the effect
  97155. * @param defines the list of defines currently in use
  97156. */
  97157. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  97158. /**
  97159. * Prepare the list of defines associated to the shader.
  97160. * @param defines the list of defines to complete
  97161. * @param forPostProcess Define if we are currently in post process mode or not
  97162. */
  97163. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  97164. /**
  97165. * Returns true if all the image processing information are ready.
  97166. * @returns True if ready, otherwise, false
  97167. */
  97168. isReady(): boolean;
  97169. /**
  97170. * Binds the image processing to the shader.
  97171. * @param effect The effect to bind to
  97172. * @param overrideAspectRatio Override the aspect ratio of the effect
  97173. */
  97174. bind(effect: Effect, overrideAspectRatio?: number): void;
  97175. /**
  97176. * Clones the current image processing instance.
  97177. * @return The cloned image processing
  97178. */
  97179. clone(): ImageProcessingConfiguration;
  97180. /**
  97181. * Serializes the current image processing instance to a json representation.
  97182. * @return a JSON representation
  97183. */
  97184. serialize(): any;
  97185. /**
  97186. * Parses the image processing from a json representation.
  97187. * @param source the JSON source to parse
  97188. * @return The parsed image processing
  97189. */
  97190. static Parse(source: any): ImageProcessingConfiguration;
  97191. private static _VIGNETTEMODE_MULTIPLY;
  97192. private static _VIGNETTEMODE_OPAQUE;
  97193. /**
  97194. * Used to apply the vignette as a mix with the pixel color.
  97195. */
  97196. static get VIGNETTEMODE_MULTIPLY(): number;
  97197. /**
  97198. * Used to apply the vignette as a replacement of the pixel color.
  97199. */
  97200. static get VIGNETTEMODE_OPAQUE(): number;
  97201. }
  97202. }
  97203. declare module BABYLON {
  97204. /** @hidden */
  97205. export var postprocessVertexShader: {
  97206. name: string;
  97207. shader: string;
  97208. };
  97209. }
  97210. declare module BABYLON {
  97211. /**
  97212. * Type used to define a render target texture size (either with a number or with a rect width and height)
  97213. */
  97214. export type RenderTargetTextureSize = number | {
  97215. width: number;
  97216. height: number;
  97217. layers?: number;
  97218. };
  97219. interface ThinEngine {
  97220. /**
  97221. * Creates a new render target texture
  97222. * @param size defines the size of the texture
  97223. * @param options defines the options used to create the texture
  97224. * @returns a new render target texture stored in an InternalTexture
  97225. */
  97226. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97227. /**
  97228. * Creates a depth stencil texture.
  97229. * This is only available in WebGL 2 or with the depth texture extension available.
  97230. * @param size The size of face edge in the texture.
  97231. * @param options The options defining the texture.
  97232. * @returns The texture
  97233. */
  97234. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  97235. /** @hidden */
  97236. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  97237. }
  97238. }
  97239. declare module BABYLON {
  97240. /**
  97241. * Defines the kind of connection point for node based material
  97242. */
  97243. export enum NodeMaterialBlockConnectionPointTypes {
  97244. /** Float */
  97245. Float = 1,
  97246. /** Int */
  97247. Int = 2,
  97248. /** Vector2 */
  97249. Vector2 = 4,
  97250. /** Vector3 */
  97251. Vector3 = 8,
  97252. /** Vector4 */
  97253. Vector4 = 16,
  97254. /** Color3 */
  97255. Color3 = 32,
  97256. /** Color4 */
  97257. Color4 = 64,
  97258. /** Matrix */
  97259. Matrix = 128,
  97260. /** Custom object */
  97261. Object = 256,
  97262. /** Detect type based on connection */
  97263. AutoDetect = 1024,
  97264. /** Output type that will be defined by input type */
  97265. BasedOnInput = 2048
  97266. }
  97267. }
  97268. declare module BABYLON {
  97269. /**
  97270. * Enum used to define the target of a block
  97271. */
  97272. export enum NodeMaterialBlockTargets {
  97273. /** Vertex shader */
  97274. Vertex = 1,
  97275. /** Fragment shader */
  97276. Fragment = 2,
  97277. /** Neutral */
  97278. Neutral = 4,
  97279. /** Vertex and Fragment */
  97280. VertexAndFragment = 3
  97281. }
  97282. }
  97283. declare module BABYLON {
  97284. /**
  97285. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  97286. */
  97287. export enum NodeMaterialBlockConnectionPointMode {
  97288. /** Value is an uniform */
  97289. Uniform = 0,
  97290. /** Value is a mesh attribute */
  97291. Attribute = 1,
  97292. /** Value is a varying between vertex and fragment shaders */
  97293. Varying = 2,
  97294. /** Mode is undefined */
  97295. Undefined = 3
  97296. }
  97297. }
  97298. declare module BABYLON {
  97299. /**
  97300. * Enum used to define system values e.g. values automatically provided by the system
  97301. */
  97302. export enum NodeMaterialSystemValues {
  97303. /** World */
  97304. World = 1,
  97305. /** View */
  97306. View = 2,
  97307. /** Projection */
  97308. Projection = 3,
  97309. /** ViewProjection */
  97310. ViewProjection = 4,
  97311. /** WorldView */
  97312. WorldView = 5,
  97313. /** WorldViewProjection */
  97314. WorldViewProjection = 6,
  97315. /** CameraPosition */
  97316. CameraPosition = 7,
  97317. /** Fog Color */
  97318. FogColor = 8,
  97319. /** Delta time */
  97320. DeltaTime = 9
  97321. }
  97322. }
  97323. declare module BABYLON {
  97324. /**
  97325. * Represents a camera frustum
  97326. */
  97327. export class Frustum {
  97328. /**
  97329. * Gets the planes representing the frustum
  97330. * @param transform matrix to be applied to the returned planes
  97331. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  97332. */
  97333. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  97334. /**
  97335. * Gets the near frustum plane transformed by the transform matrix
  97336. * @param transform transformation matrix to be applied to the resulting frustum plane
  97337. * @param frustumPlane the resuling frustum plane
  97338. */
  97339. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97340. /**
  97341. * Gets the far frustum plane transformed by the transform matrix
  97342. * @param transform transformation matrix to be applied to the resulting frustum plane
  97343. * @param frustumPlane the resuling frustum plane
  97344. */
  97345. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97346. /**
  97347. * Gets the left frustum plane transformed by the transform matrix
  97348. * @param transform transformation matrix to be applied to the resulting frustum plane
  97349. * @param frustumPlane the resuling frustum plane
  97350. */
  97351. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97352. /**
  97353. * Gets the right frustum plane transformed by the transform matrix
  97354. * @param transform transformation matrix to be applied to the resulting frustum plane
  97355. * @param frustumPlane the resuling frustum plane
  97356. */
  97357. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97358. /**
  97359. * Gets the top frustum plane transformed by the transform matrix
  97360. * @param transform transformation matrix to be applied to the resulting frustum plane
  97361. * @param frustumPlane the resuling frustum plane
  97362. */
  97363. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97364. /**
  97365. * Gets the bottom frustum plane transformed by the transform matrix
  97366. * @param transform transformation matrix to be applied to the resulting frustum plane
  97367. * @param frustumPlane the resuling frustum plane
  97368. */
  97369. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97370. /**
  97371. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  97372. * @param transform transformation matrix to be applied to the resulting frustum planes
  97373. * @param frustumPlanes the resuling frustum planes
  97374. */
  97375. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  97376. }
  97377. }
  97378. declare module BABYLON {
  97379. /**
  97380. * Contains position and normal vectors for a vertex
  97381. */
  97382. export class PositionNormalVertex {
  97383. /** the position of the vertex (defaut: 0,0,0) */
  97384. position: Vector3;
  97385. /** the normal of the vertex (defaut: 0,1,0) */
  97386. normal: Vector3;
  97387. /**
  97388. * Creates a PositionNormalVertex
  97389. * @param position the position of the vertex (defaut: 0,0,0)
  97390. * @param normal the normal of the vertex (defaut: 0,1,0)
  97391. */
  97392. constructor(
  97393. /** the position of the vertex (defaut: 0,0,0) */
  97394. position?: Vector3,
  97395. /** the normal of the vertex (defaut: 0,1,0) */
  97396. normal?: Vector3);
  97397. /**
  97398. * Clones the PositionNormalVertex
  97399. * @returns the cloned PositionNormalVertex
  97400. */
  97401. clone(): PositionNormalVertex;
  97402. }
  97403. /**
  97404. * Contains position, normal and uv vectors for a vertex
  97405. */
  97406. export class PositionNormalTextureVertex {
  97407. /** the position of the vertex (defaut: 0,0,0) */
  97408. position: Vector3;
  97409. /** the normal of the vertex (defaut: 0,1,0) */
  97410. normal: Vector3;
  97411. /** the uv of the vertex (default: 0,0) */
  97412. uv: Vector2;
  97413. /**
  97414. * Creates a PositionNormalTextureVertex
  97415. * @param position the position of the vertex (defaut: 0,0,0)
  97416. * @param normal the normal of the vertex (defaut: 0,1,0)
  97417. * @param uv the uv of the vertex (default: 0,0)
  97418. */
  97419. constructor(
  97420. /** the position of the vertex (defaut: 0,0,0) */
  97421. position?: Vector3,
  97422. /** the normal of the vertex (defaut: 0,1,0) */
  97423. normal?: Vector3,
  97424. /** the uv of the vertex (default: 0,0) */
  97425. uv?: Vector2);
  97426. /**
  97427. * Clones the PositionNormalTextureVertex
  97428. * @returns the cloned PositionNormalTextureVertex
  97429. */
  97430. clone(): PositionNormalTextureVertex;
  97431. }
  97432. }
  97433. declare module BABYLON {
  97434. /**
  97435. * Enum defining the type of animations supported by InputBlock
  97436. */
  97437. export enum AnimatedInputBlockTypes {
  97438. /** No animation */
  97439. None = 0,
  97440. /** Time based animation. Will only work for floats */
  97441. Time = 1
  97442. }
  97443. }
  97444. declare module BABYLON {
  97445. /**
  97446. * Block used to expose an input value
  97447. */
  97448. export class InputBlock extends NodeMaterialBlock {
  97449. private _mode;
  97450. private _associatedVariableName;
  97451. private _storedValue;
  97452. private _valueCallback;
  97453. private _type;
  97454. private _animationType;
  97455. /** Gets or set a value used to limit the range of float values */
  97456. min: number;
  97457. /** Gets or set a value used to limit the range of float values */
  97458. max: number;
  97459. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97460. isBoolean: boolean;
  97461. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97462. matrixMode: number;
  97463. /** @hidden */
  97464. _systemValue: Nullable<NodeMaterialSystemValues>;
  97465. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97466. isConstant: boolean;
  97467. /** Gets or sets the group to use to display this block in the Inspector */
  97468. groupInInspector: string;
  97469. /** Gets an observable raised when the value is changed */
  97470. onValueChangedObservable: Observable<InputBlock>;
  97471. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  97472. convertToGammaSpace: boolean;
  97473. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  97474. convertToLinearSpace: boolean;
  97475. /**
  97476. * Gets or sets the connection point type (default is float)
  97477. */
  97478. get type(): NodeMaterialBlockConnectionPointTypes;
  97479. /**
  97480. * Creates a new InputBlock
  97481. * @param name defines the block name
  97482. * @param target defines the target of that block (Vertex by default)
  97483. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97484. */
  97485. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97486. /**
  97487. * Validates if a name is a reserve word.
  97488. * @param newName the new name to be given to the node.
  97489. * @returns false if the name is a reserve word, else true.
  97490. */
  97491. validateBlockName(newName: string): boolean;
  97492. /**
  97493. * Gets the output component
  97494. */
  97495. get output(): NodeMaterialConnectionPoint;
  97496. /**
  97497. * Set the source of this connection point to a vertex attribute
  97498. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97499. * @returns the current connection point
  97500. */
  97501. setAsAttribute(attributeName?: string): InputBlock;
  97502. /**
  97503. * Set the source of this connection point to a system value
  97504. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97505. * @returns the current connection point
  97506. */
  97507. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97508. /**
  97509. * Gets or sets the value of that point.
  97510. * Please note that this value will be ignored if valueCallback is defined
  97511. */
  97512. get value(): any;
  97513. set value(value: any);
  97514. /**
  97515. * Gets or sets a callback used to get the value of that point.
  97516. * Please note that setting this value will force the connection point to ignore the value property
  97517. */
  97518. get valueCallback(): () => any;
  97519. set valueCallback(value: () => any);
  97520. /**
  97521. * Gets or sets the associated variable name in the shader
  97522. */
  97523. get associatedVariableName(): string;
  97524. set associatedVariableName(value: string);
  97525. /** Gets or sets the type of animation applied to the input */
  97526. get animationType(): AnimatedInputBlockTypes;
  97527. set animationType(value: AnimatedInputBlockTypes);
  97528. /**
  97529. * Gets a boolean indicating that this connection point not defined yet
  97530. */
  97531. get isUndefined(): boolean;
  97532. /**
  97533. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97534. * In this case the connection point name must be the name of the uniform to use.
  97535. * Can only be set on inputs
  97536. */
  97537. get isUniform(): boolean;
  97538. set isUniform(value: boolean);
  97539. /**
  97540. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97541. * In this case the connection point name must be the name of the attribute to use
  97542. * Can only be set on inputs
  97543. */
  97544. get isAttribute(): boolean;
  97545. set isAttribute(value: boolean);
  97546. /**
  97547. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97548. * Can only be set on exit points
  97549. */
  97550. get isVarying(): boolean;
  97551. set isVarying(value: boolean);
  97552. /**
  97553. * Gets a boolean indicating that the current connection point is a system value
  97554. */
  97555. get isSystemValue(): boolean;
  97556. /**
  97557. * Gets or sets the current well known value or null if not defined as a system value
  97558. */
  97559. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97560. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97561. /**
  97562. * Gets the current class name
  97563. * @returns the class name
  97564. */
  97565. getClassName(): string;
  97566. /**
  97567. * Animate the input if animationType !== None
  97568. * @param scene defines the rendering scene
  97569. */
  97570. animate(scene: Scene): void;
  97571. private _emitDefine;
  97572. initialize(state: NodeMaterialBuildState): void;
  97573. /**
  97574. * Set the input block to its default value (based on its type)
  97575. */
  97576. setDefaultValue(): void;
  97577. private _emitConstant;
  97578. /** @hidden */
  97579. get _noContextSwitch(): boolean;
  97580. private _emit;
  97581. /** @hidden */
  97582. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97583. /** @hidden */
  97584. _transmit(effect: Effect, scene: Scene): void;
  97585. protected _buildBlock(state: NodeMaterialBuildState): void;
  97586. protected _dumpPropertiesCode(): string;
  97587. dispose(): void;
  97588. serialize(): any;
  97589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97590. }
  97591. }
  97592. declare module BABYLON {
  97593. /**
  97594. * Enum used to define the compatibility state between two connection points
  97595. */
  97596. export enum NodeMaterialConnectionPointCompatibilityStates {
  97597. /** Points are compatibles */
  97598. Compatible = 0,
  97599. /** Points are incompatible because of their types */
  97600. TypeIncompatible = 1,
  97601. /** Points are incompatible because of their targets (vertex vs fragment) */
  97602. TargetIncompatible = 2
  97603. }
  97604. /**
  97605. * Defines the direction of a connection point
  97606. */
  97607. export enum NodeMaterialConnectionPointDirection {
  97608. /** Input */
  97609. Input = 0,
  97610. /** Output */
  97611. Output = 1
  97612. }
  97613. /**
  97614. * Defines a connection point for a block
  97615. */
  97616. export class NodeMaterialConnectionPoint {
  97617. /**
  97618. * Checks if two types are equivalent
  97619. * @param type1 type 1 to check
  97620. * @param type2 type 2 to check
  97621. * @returns true if both types are equivalent, else false
  97622. */
  97623. static AreEquivalentTypes(type1: number, type2: number): boolean;
  97624. /** @hidden */
  97625. _ownerBlock: NodeMaterialBlock;
  97626. /** @hidden */
  97627. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97628. private _endpoints;
  97629. private _associatedVariableName;
  97630. private _direction;
  97631. /** @hidden */
  97632. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97633. /** @hidden */
  97634. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97635. /** @hidden */
  97636. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  97637. private _type;
  97638. /** @hidden */
  97639. _enforceAssociatedVariableName: boolean;
  97640. /** Gets the direction of the point */
  97641. get direction(): NodeMaterialConnectionPointDirection;
  97642. /** Indicates that this connection point needs dual validation before being connected to another point */
  97643. needDualDirectionValidation: boolean;
  97644. /**
  97645. * Gets or sets the additional types supported by this connection point
  97646. */
  97647. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97648. /**
  97649. * Gets or sets the additional types excluded by this connection point
  97650. */
  97651. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97652. /**
  97653. * Observable triggered when this point is connected
  97654. */
  97655. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97656. /**
  97657. * Gets or sets the associated variable name in the shader
  97658. */
  97659. get associatedVariableName(): string;
  97660. set associatedVariableName(value: string);
  97661. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97662. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97663. /**
  97664. * Gets or sets the connection point type (default is float)
  97665. */
  97666. get type(): NodeMaterialBlockConnectionPointTypes;
  97667. set type(value: NodeMaterialBlockConnectionPointTypes);
  97668. /**
  97669. * Gets or sets the connection point name
  97670. */
  97671. name: string;
  97672. /**
  97673. * Gets or sets the connection point name
  97674. */
  97675. displayName: string;
  97676. /**
  97677. * Gets or sets a boolean indicating that this connection point can be omitted
  97678. */
  97679. isOptional: boolean;
  97680. /**
  97681. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  97682. */
  97683. isExposedOnFrame: boolean;
  97684. /**
  97685. * Gets or sets number indicating the position that the port is exposed to on a frame
  97686. */
  97687. exposedPortPosition: number;
  97688. /**
  97689. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97690. */
  97691. define: string;
  97692. /** @hidden */
  97693. _prioritizeVertex: boolean;
  97694. private _target;
  97695. /** Gets or sets the target of that connection point */
  97696. get target(): NodeMaterialBlockTargets;
  97697. set target(value: NodeMaterialBlockTargets);
  97698. /**
  97699. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97700. */
  97701. get isConnected(): boolean;
  97702. /**
  97703. * Gets a boolean indicating that the current point is connected to an input block
  97704. */
  97705. get isConnectedToInputBlock(): boolean;
  97706. /**
  97707. * Gets a the connected input block (if any)
  97708. */
  97709. get connectInputBlock(): Nullable<InputBlock>;
  97710. /** Get the other side of the connection (if any) */
  97711. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97712. /** Get the block that owns this connection point */
  97713. get ownerBlock(): NodeMaterialBlock;
  97714. /** Get the block connected on the other side of this connection (if any) */
  97715. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97716. /** Get the block connected on the endpoints of this connection (if any) */
  97717. get connectedBlocks(): Array<NodeMaterialBlock>;
  97718. /** Gets the list of connected endpoints */
  97719. get endpoints(): NodeMaterialConnectionPoint[];
  97720. /** Gets a boolean indicating if that output point is connected to at least one input */
  97721. get hasEndpoints(): boolean;
  97722. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97723. get isConnectedInVertexShader(): boolean;
  97724. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97725. get isConnectedInFragmentShader(): boolean;
  97726. /**
  97727. * Creates a block suitable to be used as an input for this input point.
  97728. * If null is returned, a block based on the point type will be created.
  97729. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  97730. */
  97731. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97732. /**
  97733. * Creates a new connection point
  97734. * @param name defines the connection point name
  97735. * @param ownerBlock defines the block hosting this connection point
  97736. * @param direction defines the direction of the connection point
  97737. */
  97738. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97739. /**
  97740. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97741. * @returns the class name
  97742. */
  97743. getClassName(): string;
  97744. /**
  97745. * Gets a boolean indicating if the current point can be connected to another point
  97746. * @param connectionPoint defines the other connection point
  97747. * @returns a boolean
  97748. */
  97749. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97750. /**
  97751. * Gets a number indicating if the current point can be connected to another point
  97752. * @param connectionPoint defines the other connection point
  97753. * @returns a number defining the compatibility state
  97754. */
  97755. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97756. /**
  97757. * Connect this point to another connection point
  97758. * @param connectionPoint defines the other connection point
  97759. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97760. * @returns the current connection point
  97761. */
  97762. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97763. /**
  97764. * Disconnect this point from one of his endpoint
  97765. * @param endpoint defines the other connection point
  97766. * @returns the current connection point
  97767. */
  97768. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97769. /**
  97770. * Serializes this point in a JSON representation
  97771. * @param isInput defines if the connection point is an input (default is true)
  97772. * @returns the serialized point object
  97773. */
  97774. serialize(isInput?: boolean): any;
  97775. /**
  97776. * Release resources
  97777. */
  97778. dispose(): void;
  97779. }
  97780. }
  97781. declare module BABYLON {
  97782. /**
  97783. * Enum used to define the material modes
  97784. */
  97785. export enum NodeMaterialModes {
  97786. /** Regular material */
  97787. Material = 0,
  97788. /** For post process */
  97789. PostProcess = 1,
  97790. /** For particle system */
  97791. Particle = 2,
  97792. /** For procedural texture */
  97793. ProceduralTexture = 3
  97794. }
  97795. }
  97796. declare module BABYLON {
  97797. /** @hidden */
  97798. export var helperFunctions: {
  97799. name: string;
  97800. shader: string;
  97801. };
  97802. }
  97803. declare module BABYLON {
  97804. /**
  97805. * Block used to read a texture from a sampler
  97806. */
  97807. export class TextureBlock extends NodeMaterialBlock {
  97808. private _defineName;
  97809. private _linearDefineName;
  97810. private _gammaDefineName;
  97811. private _tempTextureRead;
  97812. private _samplerName;
  97813. private _transformedUVName;
  97814. private _textureTransformName;
  97815. private _textureInfoName;
  97816. private _mainUVName;
  97817. private _mainUVDefineName;
  97818. private _fragmentOnly;
  97819. /**
  97820. * Gets or sets the texture associated with the node
  97821. */
  97822. texture: Nullable<Texture>;
  97823. /**
  97824. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97825. */
  97826. convertToGammaSpace: boolean;
  97827. /**
  97828. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97829. */
  97830. convertToLinearSpace: boolean;
  97831. /**
  97832. * Create a new TextureBlock
  97833. * @param name defines the block name
  97834. */
  97835. constructor(name: string, fragmentOnly?: boolean);
  97836. /**
  97837. * Gets the current class name
  97838. * @returns the class name
  97839. */
  97840. getClassName(): string;
  97841. /**
  97842. * Gets the uv input component
  97843. */
  97844. get uv(): NodeMaterialConnectionPoint;
  97845. /**
  97846. * Gets the rgba output component
  97847. */
  97848. get rgba(): NodeMaterialConnectionPoint;
  97849. /**
  97850. * Gets the rgb output component
  97851. */
  97852. get rgb(): NodeMaterialConnectionPoint;
  97853. /**
  97854. * Gets the r output component
  97855. */
  97856. get r(): NodeMaterialConnectionPoint;
  97857. /**
  97858. * Gets the g output component
  97859. */
  97860. get g(): NodeMaterialConnectionPoint;
  97861. /**
  97862. * Gets the b output component
  97863. */
  97864. get b(): NodeMaterialConnectionPoint;
  97865. /**
  97866. * Gets the a output component
  97867. */
  97868. get a(): NodeMaterialConnectionPoint;
  97869. get target(): NodeMaterialBlockTargets;
  97870. autoConfigure(material: NodeMaterial): void;
  97871. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97873. isReady(): boolean;
  97874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97875. private get _isMixed();
  97876. private _injectVertexCode;
  97877. private _writeTextureRead;
  97878. private _writeOutput;
  97879. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97880. protected _dumpPropertiesCode(): string;
  97881. serialize(): any;
  97882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97883. dispose(): void;
  97884. }
  97885. }
  97886. declare module BABYLON {
  97887. /** @hidden */
  97888. export var reflectionFunction: {
  97889. name: string;
  97890. shader: string;
  97891. };
  97892. }
  97893. declare module BABYLON {
  97894. /**
  97895. * Base block used to read a reflection texture from a sampler
  97896. */
  97897. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97898. /** @hidden */
  97899. _define3DName: string;
  97900. /** @hidden */
  97901. _defineCubicName: string;
  97902. /** @hidden */
  97903. _defineExplicitName: string;
  97904. /** @hidden */
  97905. _defineProjectionName: string;
  97906. /** @hidden */
  97907. _defineLocalCubicName: string;
  97908. /** @hidden */
  97909. _defineSphericalName: string;
  97910. /** @hidden */
  97911. _definePlanarName: string;
  97912. /** @hidden */
  97913. _defineEquirectangularName: string;
  97914. /** @hidden */
  97915. _defineMirroredEquirectangularFixedName: string;
  97916. /** @hidden */
  97917. _defineEquirectangularFixedName: string;
  97918. /** @hidden */
  97919. _defineSkyboxName: string;
  97920. /** @hidden */
  97921. _defineOppositeZ: string;
  97922. /** @hidden */
  97923. _cubeSamplerName: string;
  97924. /** @hidden */
  97925. _2DSamplerName: string;
  97926. protected _positionUVWName: string;
  97927. protected _directionWName: string;
  97928. protected _reflectionVectorName: string;
  97929. /** @hidden */
  97930. _reflectionCoordsName: string;
  97931. /** @hidden */
  97932. _reflectionMatrixName: string;
  97933. protected _reflectionColorName: string;
  97934. /**
  97935. * Gets or sets the texture associated with the node
  97936. */
  97937. texture: Nullable<BaseTexture>;
  97938. /**
  97939. * Create a new ReflectionTextureBaseBlock
  97940. * @param name defines the block name
  97941. */
  97942. constructor(name: string);
  97943. /**
  97944. * Gets the current class name
  97945. * @returns the class name
  97946. */
  97947. getClassName(): string;
  97948. /**
  97949. * Gets the world position input component
  97950. */
  97951. abstract get position(): NodeMaterialConnectionPoint;
  97952. /**
  97953. * Gets the world position input component
  97954. */
  97955. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97956. /**
  97957. * Gets the world normal input component
  97958. */
  97959. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97960. /**
  97961. * Gets the world input component
  97962. */
  97963. abstract get world(): NodeMaterialConnectionPoint;
  97964. /**
  97965. * Gets the camera (or eye) position component
  97966. */
  97967. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97968. /**
  97969. * Gets the view input component
  97970. */
  97971. abstract get view(): NodeMaterialConnectionPoint;
  97972. protected _getTexture(): Nullable<BaseTexture>;
  97973. autoConfigure(material: NodeMaterial): void;
  97974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97975. isReady(): boolean;
  97976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97977. /**
  97978. * Gets the code to inject in the vertex shader
  97979. * @param state current state of the node material building
  97980. * @returns the shader code
  97981. */
  97982. handleVertexSide(state: NodeMaterialBuildState): string;
  97983. /**
  97984. * Handles the inits for the fragment code path
  97985. * @param state node material build state
  97986. */
  97987. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97988. /**
  97989. * Generates the reflection coords code for the fragment code path
  97990. * @param worldNormalVarName name of the world normal variable
  97991. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97992. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97993. * @returns the shader code
  97994. */
  97995. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97996. /**
  97997. * Generates the reflection color code for the fragment code path
  97998. * @param lodVarName name of the lod variable
  97999. * @param swizzleLookupTexture swizzle to use for the final color variable
  98000. * @returns the shader code
  98001. */
  98002. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98003. /**
  98004. * Generates the code corresponding to the connected output points
  98005. * @param state node material build state
  98006. * @param varName name of the variable to output
  98007. * @returns the shader code
  98008. */
  98009. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98010. protected _buildBlock(state: NodeMaterialBuildState): this;
  98011. protected _dumpPropertiesCode(): string;
  98012. serialize(): any;
  98013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98014. dispose(): void;
  98015. }
  98016. }
  98017. declare module BABYLON {
  98018. /**
  98019. * Defines a connection point to be used for points with a custom object type
  98020. */
  98021. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98022. private _blockType;
  98023. private _blockName;
  98024. private _nameForCheking?;
  98025. /**
  98026. * Creates a new connection point
  98027. * @param name defines the connection point name
  98028. * @param ownerBlock defines the block hosting this connection point
  98029. * @param direction defines the direction of the connection point
  98030. */
  98031. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98032. /**
  98033. * Gets a number indicating if the current point can be connected to another point
  98034. * @param connectionPoint defines the other connection point
  98035. * @returns a number defining the compatibility state
  98036. */
  98037. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98038. /**
  98039. * Creates a block suitable to be used as an input for this input point.
  98040. * If null is returned, a block based on the point type will be created.
  98041. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  98042. */
  98043. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98044. }
  98045. }
  98046. declare module BABYLON {
  98047. /**
  98048. * Enum defining the type of properties that can be edited in the property pages in the NME
  98049. */
  98050. export enum PropertyTypeForEdition {
  98051. /** property is a boolean */
  98052. Boolean = 0,
  98053. /** property is a float */
  98054. Float = 1,
  98055. /** property is a Vector2 */
  98056. Vector2 = 2,
  98057. /** property is a list of values */
  98058. List = 3
  98059. }
  98060. /**
  98061. * Interface that defines an option in a variable of type list
  98062. */
  98063. export interface IEditablePropertyListOption {
  98064. /** label of the option */
  98065. "label": string;
  98066. /** value of the option */
  98067. "value": number;
  98068. }
  98069. /**
  98070. * Interface that defines the options available for an editable property
  98071. */
  98072. export interface IEditablePropertyOption {
  98073. /** min value */
  98074. "min"?: number;
  98075. /** max value */
  98076. "max"?: number;
  98077. /** notifiers: indicates which actions to take when the property is changed */
  98078. "notifiers"?: {
  98079. /** the material should be rebuilt */
  98080. "rebuild"?: boolean;
  98081. /** the preview should be updated */
  98082. "update"?: boolean;
  98083. };
  98084. /** list of the options for a variable of type list */
  98085. "options"?: IEditablePropertyListOption[];
  98086. }
  98087. /**
  98088. * Interface that describes an editable property
  98089. */
  98090. export interface IPropertyDescriptionForEdition {
  98091. /** name of the property */
  98092. "propertyName": string;
  98093. /** display name of the property */
  98094. "displayName": string;
  98095. /** type of the property */
  98096. "type": PropertyTypeForEdition;
  98097. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98098. "groupName": string;
  98099. /** options for the property */
  98100. "options": IEditablePropertyOption;
  98101. }
  98102. /**
  98103. * Decorator that flags a property in a node material block as being editable
  98104. */
  98105. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98106. }
  98107. declare module BABYLON {
  98108. /**
  98109. * Block used to implement the refraction part of the sub surface module of the PBR material
  98110. */
  98111. export class RefractionBlock extends NodeMaterialBlock {
  98112. /** @hidden */
  98113. _define3DName: string;
  98114. /** @hidden */
  98115. _refractionMatrixName: string;
  98116. /** @hidden */
  98117. _defineLODRefractionAlpha: string;
  98118. /** @hidden */
  98119. _defineLinearSpecularRefraction: string;
  98120. /** @hidden */
  98121. _defineOppositeZ: string;
  98122. /** @hidden */
  98123. _cubeSamplerName: string;
  98124. /** @hidden */
  98125. _2DSamplerName: string;
  98126. /** @hidden */
  98127. _vRefractionMicrosurfaceInfosName: string;
  98128. /** @hidden */
  98129. _vRefractionInfosName: string;
  98130. /** @hidden */
  98131. _vRefractionFilteringInfoName: string;
  98132. private _scene;
  98133. /**
  98134. * The properties below are set by the main PBR block prior to calling methods of this class.
  98135. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  98136. * It's less burden on the user side in the editor part.
  98137. */
  98138. /** @hidden */
  98139. viewConnectionPoint: NodeMaterialConnectionPoint;
  98140. /** @hidden */
  98141. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  98142. /**
  98143. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98144. * Materials half opaque for instance using refraction could benefit from this control.
  98145. */
  98146. linkRefractionWithTransparency: boolean;
  98147. /**
  98148. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98149. */
  98150. invertRefractionY: boolean;
  98151. /**
  98152. * Gets or sets the texture associated with the node
  98153. */
  98154. texture: Nullable<BaseTexture>;
  98155. /**
  98156. * Create a new RefractionBlock
  98157. * @param name defines the block name
  98158. */
  98159. constructor(name: string);
  98160. /**
  98161. * Gets the current class name
  98162. * @returns the class name
  98163. */
  98164. getClassName(): string;
  98165. /**
  98166. * Gets the intensity input component
  98167. */
  98168. get intensity(): NodeMaterialConnectionPoint;
  98169. /**
  98170. * Gets the tint at distance input component
  98171. */
  98172. get tintAtDistance(): NodeMaterialConnectionPoint;
  98173. /**
  98174. * Gets the view input component
  98175. */
  98176. get view(): NodeMaterialConnectionPoint;
  98177. /**
  98178. * Gets the refraction object output component
  98179. */
  98180. get refraction(): NodeMaterialConnectionPoint;
  98181. /**
  98182. * Returns true if the block has a texture
  98183. */
  98184. get hasTexture(): boolean;
  98185. protected _getTexture(): Nullable<BaseTexture>;
  98186. autoConfigure(material: NodeMaterial): void;
  98187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98188. isReady(): boolean;
  98189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98190. /**
  98191. * Gets the main code of the block (fragment side)
  98192. * @param state current state of the node material building
  98193. * @returns the shader code
  98194. */
  98195. getCode(state: NodeMaterialBuildState): string;
  98196. protected _buildBlock(state: NodeMaterialBuildState): this;
  98197. protected _dumpPropertiesCode(): string;
  98198. serialize(): any;
  98199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98200. dispose(): void;
  98201. }
  98202. }
  98203. declare module BABYLON {
  98204. /**
  98205. * Base block used as input for post process
  98206. */
  98207. export class CurrentScreenBlock extends NodeMaterialBlock {
  98208. private _samplerName;
  98209. private _linearDefineName;
  98210. private _gammaDefineName;
  98211. private _mainUVName;
  98212. private _tempTextureRead;
  98213. /**
  98214. * Gets or sets the texture associated with the node
  98215. */
  98216. texture: Nullable<BaseTexture>;
  98217. /**
  98218. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98219. */
  98220. convertToGammaSpace: boolean;
  98221. /**
  98222. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98223. */
  98224. convertToLinearSpace: boolean;
  98225. /**
  98226. * Create a new CurrentScreenBlock
  98227. * @param name defines the block name
  98228. */
  98229. constructor(name: string);
  98230. /**
  98231. * Gets the current class name
  98232. * @returns the class name
  98233. */
  98234. getClassName(): string;
  98235. /**
  98236. * Gets the uv input component
  98237. */
  98238. get uv(): NodeMaterialConnectionPoint;
  98239. /**
  98240. * Gets the rgba output component
  98241. */
  98242. get rgba(): NodeMaterialConnectionPoint;
  98243. /**
  98244. * Gets the rgb output component
  98245. */
  98246. get rgb(): NodeMaterialConnectionPoint;
  98247. /**
  98248. * Gets the r output component
  98249. */
  98250. get r(): NodeMaterialConnectionPoint;
  98251. /**
  98252. * Gets the g output component
  98253. */
  98254. get g(): NodeMaterialConnectionPoint;
  98255. /**
  98256. * Gets the b output component
  98257. */
  98258. get b(): NodeMaterialConnectionPoint;
  98259. /**
  98260. * Gets the a output component
  98261. */
  98262. get a(): NodeMaterialConnectionPoint;
  98263. /**
  98264. * Initialize the block and prepare the context for build
  98265. * @param state defines the state that will be used for the build
  98266. */
  98267. initialize(state: NodeMaterialBuildState): void;
  98268. get target(): NodeMaterialBlockTargets;
  98269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98270. isReady(): boolean;
  98271. private _injectVertexCode;
  98272. private _writeTextureRead;
  98273. private _writeOutput;
  98274. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98275. serialize(): any;
  98276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98277. dispose(): void;
  98278. }
  98279. }
  98280. declare module BABYLON {
  98281. /**
  98282. * Base block used for the particle texture
  98283. */
  98284. export class ParticleTextureBlock extends NodeMaterialBlock {
  98285. private _samplerName;
  98286. private _linearDefineName;
  98287. private _gammaDefineName;
  98288. private _tempTextureRead;
  98289. /**
  98290. * Gets or sets the texture associated with the node
  98291. */
  98292. texture: Nullable<BaseTexture>;
  98293. /**
  98294. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98295. */
  98296. convertToGammaSpace: boolean;
  98297. /**
  98298. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98299. */
  98300. convertToLinearSpace: boolean;
  98301. /**
  98302. * Create a new ParticleTextureBlock
  98303. * @param name defines the block name
  98304. */
  98305. constructor(name: string);
  98306. /**
  98307. * Gets the current class name
  98308. * @returns the class name
  98309. */
  98310. getClassName(): string;
  98311. /**
  98312. * Gets the uv input component
  98313. */
  98314. get uv(): NodeMaterialConnectionPoint;
  98315. /**
  98316. * Gets the rgba output component
  98317. */
  98318. get rgba(): NodeMaterialConnectionPoint;
  98319. /**
  98320. * Gets the rgb output component
  98321. */
  98322. get rgb(): NodeMaterialConnectionPoint;
  98323. /**
  98324. * Gets the r output component
  98325. */
  98326. get r(): NodeMaterialConnectionPoint;
  98327. /**
  98328. * Gets the g output component
  98329. */
  98330. get g(): NodeMaterialConnectionPoint;
  98331. /**
  98332. * Gets the b output component
  98333. */
  98334. get b(): NodeMaterialConnectionPoint;
  98335. /**
  98336. * Gets the a output component
  98337. */
  98338. get a(): NodeMaterialConnectionPoint;
  98339. /**
  98340. * Initialize the block and prepare the context for build
  98341. * @param state defines the state that will be used for the build
  98342. */
  98343. initialize(state: NodeMaterialBuildState): void;
  98344. autoConfigure(material: NodeMaterial): void;
  98345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98346. isReady(): boolean;
  98347. private _writeOutput;
  98348. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98349. serialize(): any;
  98350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98351. dispose(): void;
  98352. }
  98353. }
  98354. declare module BABYLON {
  98355. /**
  98356. * Class used to store shared data between 2 NodeMaterialBuildState
  98357. */
  98358. export class NodeMaterialBuildStateSharedData {
  98359. /**
  98360. * Gets the list of emitted varyings
  98361. */
  98362. temps: string[];
  98363. /**
  98364. * Gets the list of emitted varyings
  98365. */
  98366. varyings: string[];
  98367. /**
  98368. * Gets the varying declaration string
  98369. */
  98370. varyingDeclaration: string;
  98371. /**
  98372. * Input blocks
  98373. */
  98374. inputBlocks: InputBlock[];
  98375. /**
  98376. * Input blocks
  98377. */
  98378. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98379. /**
  98380. * Bindable blocks (Blocks that need to set data to the effect)
  98381. */
  98382. bindableBlocks: NodeMaterialBlock[];
  98383. /**
  98384. * List of blocks that can provide a compilation fallback
  98385. */
  98386. blocksWithFallbacks: NodeMaterialBlock[];
  98387. /**
  98388. * List of blocks that can provide a define update
  98389. */
  98390. blocksWithDefines: NodeMaterialBlock[];
  98391. /**
  98392. * List of blocks that can provide a repeatable content
  98393. */
  98394. repeatableContentBlocks: NodeMaterialBlock[];
  98395. /**
  98396. * List of blocks that can provide a dynamic list of uniforms
  98397. */
  98398. dynamicUniformBlocks: NodeMaterialBlock[];
  98399. /**
  98400. * List of blocks that can block the isReady function for the material
  98401. */
  98402. blockingBlocks: NodeMaterialBlock[];
  98403. /**
  98404. * Gets the list of animated inputs
  98405. */
  98406. animatedInputs: InputBlock[];
  98407. /**
  98408. * Build Id used to avoid multiple recompilations
  98409. */
  98410. buildId: number;
  98411. /** List of emitted variables */
  98412. variableNames: {
  98413. [key: string]: number;
  98414. };
  98415. /** List of emitted defines */
  98416. defineNames: {
  98417. [key: string]: number;
  98418. };
  98419. /** Should emit comments? */
  98420. emitComments: boolean;
  98421. /** Emit build activity */
  98422. verbose: boolean;
  98423. /** Gets or sets the hosting scene */
  98424. scene: Scene;
  98425. /**
  98426. * Gets the compilation hints emitted at compilation time
  98427. */
  98428. hints: {
  98429. needWorldViewMatrix: boolean;
  98430. needWorldViewProjectionMatrix: boolean;
  98431. needAlphaBlending: boolean;
  98432. needAlphaTesting: boolean;
  98433. };
  98434. /**
  98435. * List of compilation checks
  98436. */
  98437. checks: {
  98438. emitVertex: boolean;
  98439. emitFragment: boolean;
  98440. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98441. };
  98442. /**
  98443. * Is vertex program allowed to be empty?
  98444. */
  98445. allowEmptyVertexProgram: boolean;
  98446. /** Creates a new shared data */
  98447. constructor();
  98448. /**
  98449. * Emits console errors and exceptions if there is a failing check
  98450. */
  98451. emitErrors(): void;
  98452. }
  98453. }
  98454. declare module BABYLON {
  98455. /**
  98456. * Class used to store node based material build state
  98457. */
  98458. export class NodeMaterialBuildState {
  98459. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98460. supportUniformBuffers: boolean;
  98461. /**
  98462. * Gets the list of emitted attributes
  98463. */
  98464. attributes: string[];
  98465. /**
  98466. * Gets the list of emitted uniforms
  98467. */
  98468. uniforms: string[];
  98469. /**
  98470. * Gets the list of emitted constants
  98471. */
  98472. constants: string[];
  98473. /**
  98474. * Gets the list of emitted samplers
  98475. */
  98476. samplers: string[];
  98477. /**
  98478. * Gets the list of emitted functions
  98479. */
  98480. functions: {
  98481. [key: string]: string;
  98482. };
  98483. /**
  98484. * Gets the list of emitted extensions
  98485. */
  98486. extensions: {
  98487. [key: string]: string;
  98488. };
  98489. /**
  98490. * Gets the target of the compilation state
  98491. */
  98492. target: NodeMaterialBlockTargets;
  98493. /**
  98494. * Gets the list of emitted counters
  98495. */
  98496. counters: {
  98497. [key: string]: number;
  98498. };
  98499. /**
  98500. * Shared data between multiple NodeMaterialBuildState instances
  98501. */
  98502. sharedData: NodeMaterialBuildStateSharedData;
  98503. /** @hidden */
  98504. _vertexState: NodeMaterialBuildState;
  98505. /** @hidden */
  98506. _attributeDeclaration: string;
  98507. /** @hidden */
  98508. _uniformDeclaration: string;
  98509. /** @hidden */
  98510. _constantDeclaration: string;
  98511. /** @hidden */
  98512. _samplerDeclaration: string;
  98513. /** @hidden */
  98514. _varyingTransfer: string;
  98515. /** @hidden */
  98516. _injectAtEnd: string;
  98517. private _repeatableContentAnchorIndex;
  98518. /** @hidden */
  98519. _builtCompilationString: string;
  98520. /**
  98521. * Gets the emitted compilation strings
  98522. */
  98523. compilationString: string;
  98524. /**
  98525. * Finalize the compilation strings
  98526. * @param state defines the current compilation state
  98527. */
  98528. finalize(state: NodeMaterialBuildState): void;
  98529. /** @hidden */
  98530. get _repeatableContentAnchor(): string;
  98531. /** @hidden */
  98532. _getFreeVariableName(prefix: string): string;
  98533. /** @hidden */
  98534. _getFreeDefineName(prefix: string): string;
  98535. /** @hidden */
  98536. _excludeVariableName(name: string): void;
  98537. /** @hidden */
  98538. _emit2DSampler(name: string): void;
  98539. /** @hidden */
  98540. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98541. /** @hidden */
  98542. _emitExtension(name: string, extension: string, define?: string): void;
  98543. /** @hidden */
  98544. _emitFunction(name: string, code: string, comments: string): void;
  98545. /** @hidden */
  98546. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98547. replaceStrings?: {
  98548. search: RegExp;
  98549. replace: string;
  98550. }[];
  98551. repeatKey?: string;
  98552. }): string;
  98553. /** @hidden */
  98554. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98555. repeatKey?: string;
  98556. removeAttributes?: boolean;
  98557. removeUniforms?: boolean;
  98558. removeVaryings?: boolean;
  98559. removeIfDef?: boolean;
  98560. replaceStrings?: {
  98561. search: RegExp;
  98562. replace: string;
  98563. }[];
  98564. }, storeKey?: string): void;
  98565. /** @hidden */
  98566. _registerTempVariable(name: string): boolean;
  98567. /** @hidden */
  98568. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98569. /** @hidden */
  98570. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98571. /** @hidden */
  98572. _emitFloat(value: number): string;
  98573. }
  98574. }
  98575. declare module BABYLON {
  98576. /**
  98577. * Helper class used to generate session unique ID
  98578. */
  98579. export class UniqueIdGenerator {
  98580. private static _UniqueIdCounter;
  98581. /**
  98582. * Gets an unique (relatively to the current scene) Id
  98583. */
  98584. static get UniqueId(): number;
  98585. }
  98586. }
  98587. declare module BABYLON {
  98588. /**
  98589. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  98590. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  98591. */
  98592. export class EffectFallbacks implements IEffectFallbacks {
  98593. private _defines;
  98594. private _currentRank;
  98595. private _maxRank;
  98596. private _mesh;
  98597. /**
  98598. * Removes the fallback from the bound mesh.
  98599. */
  98600. unBindMesh(): void;
  98601. /**
  98602. * Adds a fallback on the specified property.
  98603. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  98604. * @param define The name of the define in the shader
  98605. */
  98606. addFallback(rank: number, define: string): void;
  98607. /**
  98608. * Sets the mesh to use CPU skinning when needing to fallback.
  98609. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  98610. * @param mesh The mesh to use the fallbacks.
  98611. */
  98612. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  98613. /**
  98614. * Checks to see if more fallbacks are still availible.
  98615. */
  98616. get hasMoreFallbacks(): boolean;
  98617. /**
  98618. * Removes the defines that should be removed when falling back.
  98619. * @param currentDefines defines the current define statements for the shader.
  98620. * @param effect defines the current effect we try to compile
  98621. * @returns The resulting defines with defines of the current rank removed.
  98622. */
  98623. reduce(currentDefines: string, effect: Effect): string;
  98624. }
  98625. }
  98626. declare module BABYLON {
  98627. /**
  98628. * Defines a block that can be used inside a node based material
  98629. */
  98630. export class NodeMaterialBlock {
  98631. private _buildId;
  98632. private _buildTarget;
  98633. private _target;
  98634. private _isFinalMerger;
  98635. private _isInput;
  98636. private _name;
  98637. protected _isUnique: boolean;
  98638. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98639. inputsAreExclusive: boolean;
  98640. /** @hidden */
  98641. _codeVariableName: string;
  98642. /** @hidden */
  98643. _inputs: NodeMaterialConnectionPoint[];
  98644. /** @hidden */
  98645. _outputs: NodeMaterialConnectionPoint[];
  98646. /** @hidden */
  98647. _preparationId: number;
  98648. /** @hidden */
  98649. readonly _originalTargetIsNeutral: boolean;
  98650. /**
  98651. * Gets the name of the block
  98652. */
  98653. get name(): string;
  98654. /**
  98655. * Sets the name of the block. Will check if the name is valid.
  98656. */
  98657. set name(newName: string);
  98658. /**
  98659. * Gets or sets the unique id of the node
  98660. */
  98661. uniqueId: number;
  98662. /**
  98663. * Gets or sets the comments associated with this block
  98664. */
  98665. comments: string;
  98666. /**
  98667. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98668. */
  98669. get isUnique(): boolean;
  98670. /**
  98671. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98672. */
  98673. get isFinalMerger(): boolean;
  98674. /**
  98675. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98676. */
  98677. get isInput(): boolean;
  98678. /**
  98679. * Gets or sets the build Id
  98680. */
  98681. get buildId(): number;
  98682. set buildId(value: number);
  98683. /**
  98684. * Gets or sets the target of the block
  98685. */
  98686. get target(): NodeMaterialBlockTargets;
  98687. set target(value: NodeMaterialBlockTargets);
  98688. /**
  98689. * Gets the list of input points
  98690. */
  98691. get inputs(): NodeMaterialConnectionPoint[];
  98692. /** Gets the list of output points */
  98693. get outputs(): NodeMaterialConnectionPoint[];
  98694. /**
  98695. * Find an input by its name
  98696. * @param name defines the name of the input to look for
  98697. * @returns the input or null if not found
  98698. */
  98699. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98700. /**
  98701. * Find an output by its name
  98702. * @param name defines the name of the outputto look for
  98703. * @returns the output or null if not found
  98704. */
  98705. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98706. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98707. visibleInInspector: boolean;
  98708. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  98709. visibleOnFrame: boolean;
  98710. /**
  98711. * Creates a new NodeMaterialBlock
  98712. * @param name defines the block name
  98713. * @param target defines the target of that block (Vertex by default)
  98714. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98715. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98716. */
  98717. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98718. /**
  98719. * Initialize the block and prepare the context for build
  98720. * @param state defines the state that will be used for the build
  98721. */
  98722. initialize(state: NodeMaterialBuildState): void;
  98723. /**
  98724. * Bind data to effect. Will only be called for blocks with isBindable === true
  98725. * @param effect defines the effect to bind data to
  98726. * @param nodeMaterial defines the hosting NodeMaterial
  98727. * @param mesh defines the mesh that will be rendered
  98728. * @param subMesh defines the submesh that will be rendered
  98729. */
  98730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98731. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98732. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98733. protected _writeFloat(value: number): string;
  98734. /**
  98735. * Gets the current class name e.g. "NodeMaterialBlock"
  98736. * @returns the class name
  98737. */
  98738. getClassName(): string;
  98739. /**
  98740. * Register a new input. Must be called inside a block constructor
  98741. * @param name defines the connection point name
  98742. * @param type defines the connection point type
  98743. * @param isOptional defines a boolean indicating that this input can be omitted
  98744. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98745. * @param point an already created connection point. If not provided, create a new one
  98746. * @returns the current block
  98747. */
  98748. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98749. /**
  98750. * Register a new output. Must be called inside a block constructor
  98751. * @param name defines the connection point name
  98752. * @param type defines the connection point type
  98753. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98754. * @param point an already created connection point. If not provided, create a new one
  98755. * @returns the current block
  98756. */
  98757. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98758. /**
  98759. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98760. * @param forOutput defines an optional connection point to check compatibility with
  98761. * @returns the first available input or null
  98762. */
  98763. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98764. /**
  98765. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98766. * @param forBlock defines an optional block to check compatibility with
  98767. * @returns the first available input or null
  98768. */
  98769. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98770. /**
  98771. * Gets the sibling of the given output
  98772. * @param current defines the current output
  98773. * @returns the next output in the list or null
  98774. */
  98775. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98776. /**
  98777. * Connect current block with another block
  98778. * @param other defines the block to connect with
  98779. * @param options define the various options to help pick the right connections
  98780. * @returns the current block
  98781. */
  98782. connectTo(other: NodeMaterialBlock, options?: {
  98783. input?: string;
  98784. output?: string;
  98785. outputSwizzle?: string;
  98786. }): this | undefined;
  98787. protected _buildBlock(state: NodeMaterialBuildState): void;
  98788. /**
  98789. * Add uniforms, samplers and uniform buffers at compilation time
  98790. * @param state defines the state to update
  98791. * @param nodeMaterial defines the node material requesting the update
  98792. * @param defines defines the material defines to update
  98793. * @param uniformBuffers defines the list of uniform buffer names
  98794. */
  98795. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98796. /**
  98797. * Add potential fallbacks if shader compilation fails
  98798. * @param mesh defines the mesh to be rendered
  98799. * @param fallbacks defines the current prioritized list of fallbacks
  98800. */
  98801. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98802. /**
  98803. * Initialize defines for shader compilation
  98804. * @param mesh defines the mesh to be rendered
  98805. * @param nodeMaterial defines the node material requesting the update
  98806. * @param defines defines the material defines to update
  98807. * @param useInstances specifies that instances should be used
  98808. */
  98809. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98810. /**
  98811. * Update defines for shader compilation
  98812. * @param mesh defines the mesh to be rendered
  98813. * @param nodeMaterial defines the node material requesting the update
  98814. * @param defines defines the material defines to update
  98815. * @param useInstances specifies that instances should be used
  98816. * @param subMesh defines which submesh to render
  98817. */
  98818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98819. /**
  98820. * Lets the block try to connect some inputs automatically
  98821. * @param material defines the hosting NodeMaterial
  98822. */
  98823. autoConfigure(material: NodeMaterial): void;
  98824. /**
  98825. * Function called when a block is declared as repeatable content generator
  98826. * @param vertexShaderState defines the current compilation state for the vertex shader
  98827. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98828. * @param mesh defines the mesh to be rendered
  98829. * @param defines defines the material defines to update
  98830. */
  98831. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98832. /**
  98833. * Checks if the block is ready
  98834. * @param mesh defines the mesh to be rendered
  98835. * @param nodeMaterial defines the node material requesting the update
  98836. * @param defines defines the material defines to update
  98837. * @param useInstances specifies that instances should be used
  98838. * @returns true if the block is ready
  98839. */
  98840. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98841. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  98842. private _processBuild;
  98843. /**
  98844. * Validates the new name for the block node.
  98845. * @param newName the new name to be given to the node.
  98846. * @returns false if the name is a reserve word, else true.
  98847. */
  98848. validateBlockName(newName: string): boolean;
  98849. /**
  98850. * Compile the current node and generate the shader code
  98851. * @param state defines the current compilation state (uniforms, samplers, current string)
  98852. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98853. * @returns true if already built
  98854. */
  98855. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98856. protected _inputRename(name: string): string;
  98857. protected _outputRename(name: string): string;
  98858. protected _dumpPropertiesCode(): string;
  98859. /** @hidden */
  98860. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98861. /** @hidden */
  98862. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98863. /**
  98864. * Clone the current block to a new identical block
  98865. * @param scene defines the hosting scene
  98866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98867. * @returns a copy of the current block
  98868. */
  98869. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98870. /**
  98871. * Serializes this block in a JSON representation
  98872. * @returns the serialized block object
  98873. */
  98874. serialize(): any;
  98875. /** @hidden */
  98876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98877. private _deserializePortDisplayNamesAndExposedOnFrame;
  98878. /**
  98879. * Release resources
  98880. */
  98881. dispose(): void;
  98882. }
  98883. }
  98884. declare module BABYLON {
  98885. /**
  98886. * Base class of materials working in push mode in babylon JS
  98887. * @hidden
  98888. */
  98889. export class PushMaterial extends Material {
  98890. protected _activeEffect: Effect;
  98891. protected _normalMatrix: Matrix;
  98892. constructor(name: string, scene: Scene);
  98893. getEffect(): Effect;
  98894. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98895. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98896. /**
  98897. * Binds the given world matrix to the active effect
  98898. *
  98899. * @param world the matrix to bind
  98900. */
  98901. bindOnlyWorldMatrix(world: Matrix): void;
  98902. /**
  98903. * Binds the given normal matrix to the active effect
  98904. *
  98905. * @param normalMatrix the matrix to bind
  98906. */
  98907. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98908. bind(world: Matrix, mesh?: Mesh): void;
  98909. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98910. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98911. }
  98912. }
  98913. declare module BABYLON {
  98914. /**
  98915. * Root class for all node material optimizers
  98916. */
  98917. export class NodeMaterialOptimizer {
  98918. /**
  98919. * Function used to optimize a NodeMaterial graph
  98920. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98921. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98922. */
  98923. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98924. }
  98925. }
  98926. declare module BABYLON {
  98927. /**
  98928. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98929. */
  98930. export class TransformBlock extends NodeMaterialBlock {
  98931. /**
  98932. * Defines the value to use to complement W value to transform it to a Vector4
  98933. */
  98934. complementW: number;
  98935. /**
  98936. * Defines the value to use to complement z value to transform it to a Vector4
  98937. */
  98938. complementZ: number;
  98939. /**
  98940. * Creates a new TransformBlock
  98941. * @param name defines the block name
  98942. */
  98943. constructor(name: string);
  98944. /**
  98945. * Gets the current class name
  98946. * @returns the class name
  98947. */
  98948. getClassName(): string;
  98949. /**
  98950. * Gets the vector input
  98951. */
  98952. get vector(): NodeMaterialConnectionPoint;
  98953. /**
  98954. * Gets the output component
  98955. */
  98956. get output(): NodeMaterialConnectionPoint;
  98957. /**
  98958. * Gets the xyz output component
  98959. */
  98960. get xyz(): NodeMaterialConnectionPoint;
  98961. /**
  98962. * Gets the matrix transform input
  98963. */
  98964. get transform(): NodeMaterialConnectionPoint;
  98965. protected _buildBlock(state: NodeMaterialBuildState): this;
  98966. /**
  98967. * Update defines for shader compilation
  98968. * @param mesh defines the mesh to be rendered
  98969. * @param nodeMaterial defines the node material requesting the update
  98970. * @param defines defines the material defines to update
  98971. * @param useInstances specifies that instances should be used
  98972. * @param subMesh defines which submesh to render
  98973. */
  98974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98975. serialize(): any;
  98976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98977. protected _dumpPropertiesCode(): string;
  98978. }
  98979. }
  98980. declare module BABYLON {
  98981. /**
  98982. * Block used to output the vertex position
  98983. */
  98984. export class VertexOutputBlock extends NodeMaterialBlock {
  98985. /**
  98986. * Creates a new VertexOutputBlock
  98987. * @param name defines the block name
  98988. */
  98989. constructor(name: string);
  98990. /**
  98991. * Gets the current class name
  98992. * @returns the class name
  98993. */
  98994. getClassName(): string;
  98995. /**
  98996. * Gets the vector input component
  98997. */
  98998. get vector(): NodeMaterialConnectionPoint;
  98999. protected _buildBlock(state: NodeMaterialBuildState): this;
  99000. }
  99001. }
  99002. declare module BABYLON {
  99003. /**
  99004. * Block used to output the final color
  99005. */
  99006. export class FragmentOutputBlock extends NodeMaterialBlock {
  99007. /**
  99008. * Create a new FragmentOutputBlock
  99009. * @param name defines the block name
  99010. */
  99011. constructor(name: string);
  99012. /**
  99013. * Gets the current class name
  99014. * @returns the class name
  99015. */
  99016. getClassName(): string;
  99017. /**
  99018. * Gets the rgba input component
  99019. */
  99020. get rgba(): NodeMaterialConnectionPoint;
  99021. /**
  99022. * Gets the rgb input component
  99023. */
  99024. get rgb(): NodeMaterialConnectionPoint;
  99025. /**
  99026. * Gets the a input component
  99027. */
  99028. get a(): NodeMaterialConnectionPoint;
  99029. protected _buildBlock(state: NodeMaterialBuildState): this;
  99030. }
  99031. }
  99032. declare module BABYLON {
  99033. /**
  99034. * Block used for the particle ramp gradient section
  99035. */
  99036. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99037. /**
  99038. * Create a new ParticleRampGradientBlock
  99039. * @param name defines the block name
  99040. */
  99041. constructor(name: string);
  99042. /**
  99043. * Gets the current class name
  99044. * @returns the class name
  99045. */
  99046. getClassName(): string;
  99047. /**
  99048. * Gets the color input component
  99049. */
  99050. get color(): NodeMaterialConnectionPoint;
  99051. /**
  99052. * Gets the rampColor output component
  99053. */
  99054. get rampColor(): NodeMaterialConnectionPoint;
  99055. /**
  99056. * Initialize the block and prepare the context for build
  99057. * @param state defines the state that will be used for the build
  99058. */
  99059. initialize(state: NodeMaterialBuildState): void;
  99060. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99061. }
  99062. }
  99063. declare module BABYLON {
  99064. /**
  99065. * Block used for the particle blend multiply section
  99066. */
  99067. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99068. /**
  99069. * Create a new ParticleBlendMultiplyBlock
  99070. * @param name defines the block name
  99071. */
  99072. constructor(name: string);
  99073. /**
  99074. * Gets the current class name
  99075. * @returns the class name
  99076. */
  99077. getClassName(): string;
  99078. /**
  99079. * Gets the color input component
  99080. */
  99081. get color(): NodeMaterialConnectionPoint;
  99082. /**
  99083. * Gets the alphaTexture input component
  99084. */
  99085. get alphaTexture(): NodeMaterialConnectionPoint;
  99086. /**
  99087. * Gets the alphaColor input component
  99088. */
  99089. get alphaColor(): NodeMaterialConnectionPoint;
  99090. /**
  99091. * Gets the blendColor output component
  99092. */
  99093. get blendColor(): NodeMaterialConnectionPoint;
  99094. /**
  99095. * Initialize the block and prepare the context for build
  99096. * @param state defines the state that will be used for the build
  99097. */
  99098. initialize(state: NodeMaterialBuildState): void;
  99099. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99100. }
  99101. }
  99102. declare module BABYLON {
  99103. /**
  99104. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99105. */
  99106. export class VectorMergerBlock extends NodeMaterialBlock {
  99107. /**
  99108. * Create a new VectorMergerBlock
  99109. * @param name defines the block name
  99110. */
  99111. constructor(name: string);
  99112. /**
  99113. * Gets the current class name
  99114. * @returns the class name
  99115. */
  99116. getClassName(): string;
  99117. /**
  99118. * Gets the xyz component (input)
  99119. */
  99120. get xyzIn(): NodeMaterialConnectionPoint;
  99121. /**
  99122. * Gets the xy component (input)
  99123. */
  99124. get xyIn(): NodeMaterialConnectionPoint;
  99125. /**
  99126. * Gets the x component (input)
  99127. */
  99128. get x(): NodeMaterialConnectionPoint;
  99129. /**
  99130. * Gets the y component (input)
  99131. */
  99132. get y(): NodeMaterialConnectionPoint;
  99133. /**
  99134. * Gets the z component (input)
  99135. */
  99136. get z(): NodeMaterialConnectionPoint;
  99137. /**
  99138. * Gets the w component (input)
  99139. */
  99140. get w(): NodeMaterialConnectionPoint;
  99141. /**
  99142. * Gets the xyzw component (output)
  99143. */
  99144. get xyzw(): NodeMaterialConnectionPoint;
  99145. /**
  99146. * Gets the xyz component (output)
  99147. */
  99148. get xyzOut(): NodeMaterialConnectionPoint;
  99149. /**
  99150. * Gets the xy component (output)
  99151. */
  99152. get xyOut(): NodeMaterialConnectionPoint;
  99153. /**
  99154. * Gets the xy component (output)
  99155. * @deprecated Please use xyOut instead.
  99156. */
  99157. get xy(): NodeMaterialConnectionPoint;
  99158. /**
  99159. * Gets the xyz component (output)
  99160. * @deprecated Please use xyzOut instead.
  99161. */
  99162. get xyz(): NodeMaterialConnectionPoint;
  99163. protected _buildBlock(state: NodeMaterialBuildState): this;
  99164. }
  99165. }
  99166. declare module BABYLON {
  99167. /**
  99168. * Block used to remap a float from a range to a new one
  99169. */
  99170. export class RemapBlock extends NodeMaterialBlock {
  99171. /**
  99172. * Gets or sets the source range
  99173. */
  99174. sourceRange: Vector2;
  99175. /**
  99176. * Gets or sets the target range
  99177. */
  99178. targetRange: Vector2;
  99179. /**
  99180. * Creates a new RemapBlock
  99181. * @param name defines the block name
  99182. */
  99183. constructor(name: string);
  99184. /**
  99185. * Gets the current class name
  99186. * @returns the class name
  99187. */
  99188. getClassName(): string;
  99189. /**
  99190. * Gets the input component
  99191. */
  99192. get input(): NodeMaterialConnectionPoint;
  99193. /**
  99194. * Gets the source min input component
  99195. */
  99196. get sourceMin(): NodeMaterialConnectionPoint;
  99197. /**
  99198. * Gets the source max input component
  99199. */
  99200. get sourceMax(): NodeMaterialConnectionPoint;
  99201. /**
  99202. * Gets the target min input component
  99203. */
  99204. get targetMin(): NodeMaterialConnectionPoint;
  99205. /**
  99206. * Gets the target max input component
  99207. */
  99208. get targetMax(): NodeMaterialConnectionPoint;
  99209. /**
  99210. * Gets the output component
  99211. */
  99212. get output(): NodeMaterialConnectionPoint;
  99213. protected _buildBlock(state: NodeMaterialBuildState): this;
  99214. protected _dumpPropertiesCode(): string;
  99215. serialize(): any;
  99216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99217. }
  99218. }
  99219. declare module BABYLON {
  99220. /**
  99221. * Block used to multiply 2 values
  99222. */
  99223. export class MultiplyBlock extends NodeMaterialBlock {
  99224. /**
  99225. * Creates a new MultiplyBlock
  99226. * @param name defines the block name
  99227. */
  99228. constructor(name: string);
  99229. /**
  99230. * Gets the current class name
  99231. * @returns the class name
  99232. */
  99233. getClassName(): string;
  99234. /**
  99235. * Gets the left operand input component
  99236. */
  99237. get left(): NodeMaterialConnectionPoint;
  99238. /**
  99239. * Gets the right operand input component
  99240. */
  99241. get right(): NodeMaterialConnectionPoint;
  99242. /**
  99243. * Gets the output component
  99244. */
  99245. get output(): NodeMaterialConnectionPoint;
  99246. protected _buildBlock(state: NodeMaterialBuildState): this;
  99247. }
  99248. }
  99249. declare module BABYLON {
  99250. /** Interface used by value gradients (color, factor, ...) */
  99251. export interface IValueGradient {
  99252. /**
  99253. * Gets or sets the gradient value (between 0 and 1)
  99254. */
  99255. gradient: number;
  99256. }
  99257. /** Class used to store color4 gradient */
  99258. export class ColorGradient implements IValueGradient {
  99259. /**
  99260. * Gets or sets the gradient value (between 0 and 1)
  99261. */
  99262. gradient: number;
  99263. /**
  99264. * Gets or sets first associated color
  99265. */
  99266. color1: Color4;
  99267. /**
  99268. * Gets or sets second associated color
  99269. */
  99270. color2?: Color4 | undefined;
  99271. /**
  99272. * Creates a new color4 gradient
  99273. * @param gradient gets or sets the gradient value (between 0 and 1)
  99274. * @param color1 gets or sets first associated color
  99275. * @param color2 gets or sets first second color
  99276. */
  99277. constructor(
  99278. /**
  99279. * Gets or sets the gradient value (between 0 and 1)
  99280. */
  99281. gradient: number,
  99282. /**
  99283. * Gets or sets first associated color
  99284. */
  99285. color1: Color4,
  99286. /**
  99287. * Gets or sets second associated color
  99288. */
  99289. color2?: Color4 | undefined);
  99290. /**
  99291. * Will get a color picked randomly between color1 and color2.
  99292. * If color2 is undefined then color1 will be used
  99293. * @param result defines the target Color4 to store the result in
  99294. */
  99295. getColorToRef(result: Color4): void;
  99296. }
  99297. /** Class used to store color 3 gradient */
  99298. export class Color3Gradient implements IValueGradient {
  99299. /**
  99300. * Gets or sets the gradient value (between 0 and 1)
  99301. */
  99302. gradient: number;
  99303. /**
  99304. * Gets or sets the associated color
  99305. */
  99306. color: Color3;
  99307. /**
  99308. * Creates a new color3 gradient
  99309. * @param gradient gets or sets the gradient value (between 0 and 1)
  99310. * @param color gets or sets associated color
  99311. */
  99312. constructor(
  99313. /**
  99314. * Gets or sets the gradient value (between 0 and 1)
  99315. */
  99316. gradient: number,
  99317. /**
  99318. * Gets or sets the associated color
  99319. */
  99320. color: Color3);
  99321. }
  99322. /** Class used to store factor gradient */
  99323. export class FactorGradient implements IValueGradient {
  99324. /**
  99325. * Gets or sets the gradient value (between 0 and 1)
  99326. */
  99327. gradient: number;
  99328. /**
  99329. * Gets or sets first associated factor
  99330. */
  99331. factor1: number;
  99332. /**
  99333. * Gets or sets second associated factor
  99334. */
  99335. factor2?: number | undefined;
  99336. /**
  99337. * Creates a new factor gradient
  99338. * @param gradient gets or sets the gradient value (between 0 and 1)
  99339. * @param factor1 gets or sets first associated factor
  99340. * @param factor2 gets or sets second associated factor
  99341. */
  99342. constructor(
  99343. /**
  99344. * Gets or sets the gradient value (between 0 and 1)
  99345. */
  99346. gradient: number,
  99347. /**
  99348. * Gets or sets first associated factor
  99349. */
  99350. factor1: number,
  99351. /**
  99352. * Gets or sets second associated factor
  99353. */
  99354. factor2?: number | undefined);
  99355. /**
  99356. * Will get a number picked randomly between factor1 and factor2.
  99357. * If factor2 is undefined then factor1 will be used
  99358. * @returns the picked number
  99359. */
  99360. getFactor(): number;
  99361. }
  99362. /**
  99363. * Helper used to simplify some generic gradient tasks
  99364. */
  99365. export class GradientHelper {
  99366. /**
  99367. * Gets the current gradient from an array of IValueGradient
  99368. * @param ratio defines the current ratio to get
  99369. * @param gradients defines the array of IValueGradient
  99370. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99371. */
  99372. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  99373. }
  99374. }
  99375. declare module BABYLON {
  99376. interface ThinEngine {
  99377. /**
  99378. * Creates a raw texture
  99379. * @param data defines the data to store in the texture
  99380. * @param width defines the width of the texture
  99381. * @param height defines the height of the texture
  99382. * @param format defines the format of the data
  99383. * @param generateMipMaps defines if the engine should generate the mip levels
  99384. * @param invertY defines if data must be stored with Y axis inverted
  99385. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  99386. * @param compression defines the compression used (null by default)
  99387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99388. * @returns the raw texture inside an InternalTexture
  99389. */
  99390. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  99391. /**
  99392. * Update a raw texture
  99393. * @param texture defines the texture to update
  99394. * @param data defines the data to store in the texture
  99395. * @param format defines the format of the data
  99396. * @param invertY defines if data must be stored with Y axis inverted
  99397. */
  99398. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99399. /**
  99400. * Update a raw texture
  99401. * @param texture defines the texture to update
  99402. * @param data defines the data to store in the texture
  99403. * @param format defines the format of the data
  99404. * @param invertY defines if data must be stored with Y axis inverted
  99405. * @param compression defines the compression used (null by default)
  99406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99407. */
  99408. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  99409. /**
  99410. * Creates a new raw cube texture
  99411. * @param data defines the array of data to use to create each face
  99412. * @param size defines the size of the textures
  99413. * @param format defines the format of the data
  99414. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99415. * @param generateMipMaps defines if the engine should generate the mip levels
  99416. * @param invertY defines if data must be stored with Y axis inverted
  99417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99418. * @param compression defines the compression used (null by default)
  99419. * @returns the cube texture as an InternalTexture
  99420. */
  99421. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  99422. /**
  99423. * Update a raw cube texture
  99424. * @param texture defines the texture to udpdate
  99425. * @param data defines the data to store
  99426. * @param format defines the data format
  99427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99428. * @param invertY defines if data must be stored with Y axis inverted
  99429. */
  99430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  99431. /**
  99432. * Update a raw cube texture
  99433. * @param texture defines the texture to udpdate
  99434. * @param data defines the data to store
  99435. * @param format defines the data format
  99436. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99437. * @param invertY defines if data must be stored with Y axis inverted
  99438. * @param compression defines the compression used (null by default)
  99439. */
  99440. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  99441. /**
  99442. * Update a raw cube texture
  99443. * @param texture defines the texture to udpdate
  99444. * @param data defines the data to store
  99445. * @param format defines the data format
  99446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99447. * @param invertY defines if data must be stored with Y axis inverted
  99448. * @param compression defines the compression used (null by default)
  99449. * @param level defines which level of the texture to update
  99450. */
  99451. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  99452. /**
  99453. * Creates a new raw cube texture from a specified url
  99454. * @param url defines the url where the data is located
  99455. * @param scene defines the current scene
  99456. * @param size defines the size of the textures
  99457. * @param format defines the format of the data
  99458. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99459. * @param noMipmap defines if the engine should avoid generating the mip levels
  99460. * @param callback defines a callback used to extract texture data from loaded data
  99461. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  99462. * @param onLoad defines a callback called when texture is loaded
  99463. * @param onError defines a callback called if there is an error
  99464. * @returns the cube texture as an InternalTexture
  99465. */
  99466. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  99467. /**
  99468. * Creates a new raw cube texture from a specified url
  99469. * @param url defines the url where the data is located
  99470. * @param scene defines the current scene
  99471. * @param size defines the size of the textures
  99472. * @param format defines the format of the data
  99473. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99474. * @param noMipmap defines if the engine should avoid generating the mip levels
  99475. * @param callback defines a callback used to extract texture data from loaded data
  99476. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  99477. * @param onLoad defines a callback called when texture is loaded
  99478. * @param onError defines a callback called if there is an error
  99479. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99480. * @param invertY defines if data must be stored with Y axis inverted
  99481. * @returns the cube texture as an InternalTexture
  99482. */
  99483. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  99484. /**
  99485. * Creates a new raw 3D texture
  99486. * @param data defines the data used to create the texture
  99487. * @param width defines the width of the texture
  99488. * @param height defines the height of the texture
  99489. * @param depth defines the depth of the texture
  99490. * @param format defines the format of the texture
  99491. * @param generateMipMaps defines if the engine must generate mip levels
  99492. * @param invertY defines if data must be stored with Y axis inverted
  99493. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99494. * @param compression defines the compressed used (can be null)
  99495. * @param textureType defines the compressed used (can be null)
  99496. * @returns a new raw 3D texture (stored in an InternalTexture)
  99497. */
  99498. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  99499. /**
  99500. * Update a raw 3D texture
  99501. * @param texture defines the texture to update
  99502. * @param data defines the data to store
  99503. * @param format defines the data format
  99504. * @param invertY defines if data must be stored with Y axis inverted
  99505. */
  99506. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99507. /**
  99508. * Update a raw 3D texture
  99509. * @param texture defines the texture to update
  99510. * @param data defines the data to store
  99511. * @param format defines the data format
  99512. * @param invertY defines if data must be stored with Y axis inverted
  99513. * @param compression defines the used compression (can be null)
  99514. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  99515. */
  99516. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  99517. /**
  99518. * Creates a new raw 2D array texture
  99519. * @param data defines the data used to create the texture
  99520. * @param width defines the width of the texture
  99521. * @param height defines the height of the texture
  99522. * @param depth defines the number of layers of the texture
  99523. * @param format defines the format of the texture
  99524. * @param generateMipMaps defines if the engine must generate mip levels
  99525. * @param invertY defines if data must be stored with Y axis inverted
  99526. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99527. * @param compression defines the compressed used (can be null)
  99528. * @param textureType defines the compressed used (can be null)
  99529. * @returns a new raw 2D array texture (stored in an InternalTexture)
  99530. */
  99531. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  99532. /**
  99533. * Update a raw 2D array texture
  99534. * @param texture defines the texture to update
  99535. * @param data defines the data to store
  99536. * @param format defines the data format
  99537. * @param invertY defines if data must be stored with Y axis inverted
  99538. */
  99539. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99540. /**
  99541. * Update a raw 2D array texture
  99542. * @param texture defines the texture to update
  99543. * @param data defines the data to store
  99544. * @param format defines the data format
  99545. * @param invertY defines if data must be stored with Y axis inverted
  99546. * @param compression defines the used compression (can be null)
  99547. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  99548. */
  99549. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  99550. }
  99551. }
  99552. declare module BABYLON {
  99553. /**
  99554. * Raw texture can help creating a texture directly from an array of data.
  99555. * This can be super useful if you either get the data from an uncompressed source or
  99556. * if you wish to create your texture pixel by pixel.
  99557. */
  99558. export class RawTexture extends Texture {
  99559. /**
  99560. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  99561. */
  99562. format: number;
  99563. /**
  99564. * Instantiates a new RawTexture.
  99565. * Raw texture can help creating a texture directly from an array of data.
  99566. * This can be super useful if you either get the data from an uncompressed source or
  99567. * if you wish to create your texture pixel by pixel.
  99568. * @param data define the array of data to use to create the texture
  99569. * @param width define the width of the texture
  99570. * @param height define the height of the texture
  99571. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  99572. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99573. * @param generateMipMaps define whether mip maps should be generated or not
  99574. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99575. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99576. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99577. */
  99578. constructor(data: ArrayBufferView, width: number, height: number,
  99579. /**
  99580. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  99581. */
  99582. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  99583. /**
  99584. * Updates the texture underlying data.
  99585. * @param data Define the new data of the texture
  99586. */
  99587. update(data: ArrayBufferView): void;
  99588. /**
  99589. * Creates a luminance texture from some data.
  99590. * @param data Define the texture data
  99591. * @param width Define the width of the texture
  99592. * @param height Define the height of the texture
  99593. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99597. * @returns the luminance texture
  99598. */
  99599. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99600. /**
  99601. * Creates a luminance alpha texture from some data.
  99602. * @param data Define the texture data
  99603. * @param width Define the width of the texture
  99604. * @param height Define the height of the texture
  99605. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99606. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99609. * @returns the luminance alpha texture
  99610. */
  99611. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99612. /**
  99613. * Creates an alpha texture from some data.
  99614. * @param data Define the texture data
  99615. * @param width Define the width of the texture
  99616. * @param height Define the height of the texture
  99617. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99618. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99619. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99620. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99621. * @returns the alpha texture
  99622. */
  99623. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99624. /**
  99625. * Creates a RGB texture from some data.
  99626. * @param data Define the texture data
  99627. * @param width Define the width of the texture
  99628. * @param height Define the height of the texture
  99629. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99630. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99631. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99632. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99633. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99634. * @returns the RGB alpha texture
  99635. */
  99636. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99637. /**
  99638. * Creates a RGBA texture from some data.
  99639. * @param data Define the texture data
  99640. * @param width Define the width of the texture
  99641. * @param height Define the height of the texture
  99642. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99647. * @returns the RGBA texture
  99648. */
  99649. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99650. /**
  99651. * Creates a R texture from some data.
  99652. * @param data Define the texture data
  99653. * @param width Define the width of the texture
  99654. * @param height Define the height of the texture
  99655. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99656. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99657. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99658. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99659. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99660. * @returns the R texture
  99661. */
  99662. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99663. }
  99664. }
  99665. declare module BABYLON {
  99666. interface ThinEngine {
  99667. /**
  99668. * Update a dynamic index buffer
  99669. * @param indexBuffer defines the target index buffer
  99670. * @param indices defines the data to update
  99671. * @param offset defines the offset in the target index buffer where update should start
  99672. */
  99673. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99674. /**
  99675. * Updates a dynamic vertex buffer.
  99676. * @param vertexBuffer the vertex buffer to update
  99677. * @param data the data used to update the vertex buffer
  99678. * @param byteOffset the byte offset of the data
  99679. * @param byteLength the byte length of the data
  99680. */
  99681. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99682. }
  99683. }
  99684. declare module BABYLON {
  99685. interface AbstractScene {
  99686. /**
  99687. * The list of procedural textures added to the scene
  99688. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99689. */
  99690. proceduralTextures: Array<ProceduralTexture>;
  99691. }
  99692. /**
  99693. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  99694. * in a given scene.
  99695. */
  99696. export class ProceduralTextureSceneComponent implements ISceneComponent {
  99697. /**
  99698. * The component name helpfull to identify the component in the list of scene components.
  99699. */
  99700. readonly name: string;
  99701. /**
  99702. * The scene the component belongs to.
  99703. */
  99704. scene: Scene;
  99705. /**
  99706. * Creates a new instance of the component for the given scene
  99707. * @param scene Defines the scene to register the component in
  99708. */
  99709. constructor(scene: Scene);
  99710. /**
  99711. * Registers the component in a given scene
  99712. */
  99713. register(): void;
  99714. /**
  99715. * Rebuilds the elements related to this component in case of
  99716. * context lost for instance.
  99717. */
  99718. rebuild(): void;
  99719. /**
  99720. * Disposes the component and the associated ressources.
  99721. */
  99722. dispose(): void;
  99723. private _beforeClear;
  99724. }
  99725. }
  99726. declare module BABYLON {
  99727. interface ThinEngine {
  99728. /**
  99729. * Creates a new render target cube texture
  99730. * @param size defines the size of the texture
  99731. * @param options defines the options used to create the texture
  99732. * @returns a new render target cube texture stored in an InternalTexture
  99733. */
  99734. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  99735. }
  99736. }
  99737. declare module BABYLON {
  99738. /** @hidden */
  99739. export var proceduralVertexShader: {
  99740. name: string;
  99741. shader: string;
  99742. };
  99743. }
  99744. declare module BABYLON {
  99745. /**
  99746. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  99747. * This is the base class of any Procedural texture and contains most of the shareable code.
  99748. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99749. */
  99750. export class ProceduralTexture extends Texture {
  99751. /**
  99752. * Define if the texture is enabled or not (disabled texture will not render)
  99753. */
  99754. isEnabled: boolean;
  99755. /**
  99756. * Define if the texture must be cleared before rendering (default is true)
  99757. */
  99758. autoClear: boolean;
  99759. /**
  99760. * Callback called when the texture is generated
  99761. */
  99762. onGenerated: () => void;
  99763. /**
  99764. * Event raised when the texture is generated
  99765. */
  99766. onGeneratedObservable: Observable<ProceduralTexture>;
  99767. /**
  99768. * Event raised before the texture is generated
  99769. */
  99770. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  99771. /**
  99772. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  99773. */
  99774. nodeMaterialSource: Nullable<NodeMaterial>;
  99775. /** @hidden */
  99776. _generateMipMaps: boolean;
  99777. /** @hidden **/
  99778. _effect: Effect;
  99779. /** @hidden */
  99780. _textures: {
  99781. [key: string]: Texture;
  99782. };
  99783. /** @hidden */
  99784. protected _fallbackTexture: Nullable<Texture>;
  99785. private _size;
  99786. private _textureType;
  99787. private _currentRefreshId;
  99788. private _frameId;
  99789. private _refreshRate;
  99790. private _vertexBuffers;
  99791. private _indexBuffer;
  99792. private _uniforms;
  99793. private _samplers;
  99794. private _fragment;
  99795. private _floats;
  99796. private _ints;
  99797. private _floatsArrays;
  99798. private _colors3;
  99799. private _colors4;
  99800. private _vectors2;
  99801. private _vectors3;
  99802. private _matrices;
  99803. private _fallbackTextureUsed;
  99804. private _fullEngine;
  99805. private _cachedDefines;
  99806. private _contentUpdateId;
  99807. private _contentData;
  99808. /**
  99809. * Instantiates a new procedural texture.
  99810. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  99811. * This is the base class of any Procedural texture and contains most of the shareable code.
  99812. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99813. * @param name Define the name of the texture
  99814. * @param size Define the size of the texture to create
  99815. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  99816. * @param scene Define the scene the texture belongs to
  99817. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  99818. * @param generateMipMaps Define if the texture should creates mip maps or not
  99819. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  99820. * @param textureType The FBO internal texture type
  99821. */
  99822. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  99823. /**
  99824. * The effect that is created when initializing the post process.
  99825. * @returns The created effect corresponding the the postprocess.
  99826. */
  99827. getEffect(): Effect;
  99828. /**
  99829. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  99830. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  99831. */
  99832. getContent(): Nullable<Promise<ArrayBufferView>>;
  99833. private _createIndexBuffer;
  99834. /** @hidden */
  99835. _rebuild(): void;
  99836. /**
  99837. * Resets the texture in order to recreate its associated resources.
  99838. * This can be called in case of context loss
  99839. */
  99840. reset(): void;
  99841. protected _getDefines(): string;
  99842. /**
  99843. * Is the texture ready to be used ? (rendered at least once)
  99844. * @returns true if ready, otherwise, false.
  99845. */
  99846. isReady(): boolean;
  99847. /**
  99848. * Resets the refresh counter of the texture and start bak from scratch.
  99849. * Could be useful to regenerate the texture if it is setup to render only once.
  99850. */
  99851. resetRefreshCounter(): void;
  99852. /**
  99853. * Set the fragment shader to use in order to render the texture.
  99854. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  99855. */
  99856. setFragment(fragment: any): void;
  99857. /**
  99858. * Define the refresh rate of the texture or the rendering frequency.
  99859. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  99860. */
  99861. get refreshRate(): number;
  99862. set refreshRate(value: number);
  99863. /** @hidden */
  99864. _shouldRender(): boolean;
  99865. /**
  99866. * Get the size the texture is rendering at.
  99867. * @returns the size (on cube texture it is always squared)
  99868. */
  99869. getRenderSize(): RenderTargetTextureSize;
  99870. /**
  99871. * Resize the texture to new value.
  99872. * @param size Define the new size the texture should have
  99873. * @param generateMipMaps Define whether the new texture should create mip maps
  99874. */
  99875. resize(size: number, generateMipMaps: boolean): void;
  99876. private _checkUniform;
  99877. /**
  99878. * Set a texture in the shader program used to render.
  99879. * @param name Define the name of the uniform samplers as defined in the shader
  99880. * @param texture Define the texture to bind to this sampler
  99881. * @return the texture itself allowing "fluent" like uniform updates
  99882. */
  99883. setTexture(name: string, texture: Texture): ProceduralTexture;
  99884. /**
  99885. * Set a float in the shader.
  99886. * @param name Define the name of the uniform as defined in the shader
  99887. * @param value Define the value to give to the uniform
  99888. * @return the texture itself allowing "fluent" like uniform updates
  99889. */
  99890. setFloat(name: string, value: number): ProceduralTexture;
  99891. /**
  99892. * Set a int in the shader.
  99893. * @param name Define the name of the uniform as defined in the shader
  99894. * @param value Define the value to give to the uniform
  99895. * @return the texture itself allowing "fluent" like uniform updates
  99896. */
  99897. setInt(name: string, value: number): ProceduralTexture;
  99898. /**
  99899. * Set an array of floats in the shader.
  99900. * @param name Define the name of the uniform as defined in the shader
  99901. * @param value Define the value to give to the uniform
  99902. * @return the texture itself allowing "fluent" like uniform updates
  99903. */
  99904. setFloats(name: string, value: number[]): ProceduralTexture;
  99905. /**
  99906. * Set a vec3 in the shader from a Color3.
  99907. * @param name Define the name of the uniform as defined in the shader
  99908. * @param value Define the value to give to the uniform
  99909. * @return the texture itself allowing "fluent" like uniform updates
  99910. */
  99911. setColor3(name: string, value: Color3): ProceduralTexture;
  99912. /**
  99913. * Set a vec4 in the shader from a Color4.
  99914. * @param name Define the name of the uniform as defined in the shader
  99915. * @param value Define the value to give to the uniform
  99916. * @return the texture itself allowing "fluent" like uniform updates
  99917. */
  99918. setColor4(name: string, value: Color4): ProceduralTexture;
  99919. /**
  99920. * Set a vec2 in the shader from a Vector2.
  99921. * @param name Define the name of the uniform as defined in the shader
  99922. * @param value Define the value to give to the uniform
  99923. * @return the texture itself allowing "fluent" like uniform updates
  99924. */
  99925. setVector2(name: string, value: Vector2): ProceduralTexture;
  99926. /**
  99927. * Set a vec3 in the shader from a Vector3.
  99928. * @param name Define the name of the uniform as defined in the shader
  99929. * @param value Define the value to give to the uniform
  99930. * @return the texture itself allowing "fluent" like uniform updates
  99931. */
  99932. setVector3(name: string, value: Vector3): ProceduralTexture;
  99933. /**
  99934. * Set a mat4 in the shader from a MAtrix.
  99935. * @param name Define the name of the uniform as defined in the shader
  99936. * @param value Define the value to give to the uniform
  99937. * @return the texture itself allowing "fluent" like uniform updates
  99938. */
  99939. setMatrix(name: string, value: Matrix): ProceduralTexture;
  99940. /**
  99941. * Render the texture to its associated render target.
  99942. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  99943. */
  99944. render(useCameraPostProcess?: boolean): void;
  99945. /**
  99946. * Clone the texture.
  99947. * @returns the cloned texture
  99948. */
  99949. clone(): ProceduralTexture;
  99950. /**
  99951. * Dispose the texture and release its asoociated resources.
  99952. */
  99953. dispose(): void;
  99954. }
  99955. }
  99956. declare module BABYLON {
  99957. /**
  99958. * This represents the base class for particle system in Babylon.
  99959. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  99960. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  99961. * @example https://doc.babylonjs.com/babylon101/particles
  99962. */
  99963. export class BaseParticleSystem {
  99964. /**
  99965. * Source color is added to the destination color without alpha affecting the result
  99966. */
  99967. static BLENDMODE_ONEONE: number;
  99968. /**
  99969. * Blend current color and particle color using particle’s alpha
  99970. */
  99971. static BLENDMODE_STANDARD: number;
  99972. /**
  99973. * Add current color and particle color multiplied by particle’s alpha
  99974. */
  99975. static BLENDMODE_ADD: number;
  99976. /**
  99977. * Multiply current color with particle color
  99978. */
  99979. static BLENDMODE_MULTIPLY: number;
  99980. /**
  99981. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  99982. */
  99983. static BLENDMODE_MULTIPLYADD: number;
  99984. /**
  99985. * List of animations used by the particle system.
  99986. */
  99987. animations: Animation[];
  99988. /**
  99989. * Gets or sets the unique id of the particle system
  99990. */
  99991. uniqueId: number;
  99992. /**
  99993. * The id of the Particle system.
  99994. */
  99995. id: string;
  99996. /**
  99997. * The friendly name of the Particle system.
  99998. */
  99999. name: string;
  100000. /**
  100001. * Snippet ID if the particle system was created from the snippet server
  100002. */
  100003. snippetId: string;
  100004. /**
  100005. * The rendering group used by the Particle system to chose when to render.
  100006. */
  100007. renderingGroupId: number;
  100008. /**
  100009. * The emitter represents the Mesh or position we are attaching the particle system to.
  100010. */
  100011. emitter: Nullable<AbstractMesh | Vector3>;
  100012. /**
  100013. * The maximum number of particles to emit per frame
  100014. */
  100015. emitRate: number;
  100016. /**
  100017. * If you want to launch only a few particles at once, that can be done, as well.
  100018. */
  100019. manualEmitCount: number;
  100020. /**
  100021. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  100022. */
  100023. updateSpeed: number;
  100024. /**
  100025. * The amount of time the particle system is running (depends of the overall update speed).
  100026. */
  100027. targetStopDuration: number;
  100028. /**
  100029. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  100030. */
  100031. disposeOnStop: boolean;
  100032. /**
  100033. * Minimum power of emitting particles.
  100034. */
  100035. minEmitPower: number;
  100036. /**
  100037. * Maximum power of emitting particles.
  100038. */
  100039. maxEmitPower: number;
  100040. /**
  100041. * Minimum life time of emitting particles.
  100042. */
  100043. minLifeTime: number;
  100044. /**
  100045. * Maximum life time of emitting particles.
  100046. */
  100047. maxLifeTime: number;
  100048. /**
  100049. * Minimum Size of emitting particles.
  100050. */
  100051. minSize: number;
  100052. /**
  100053. * Maximum Size of emitting particles.
  100054. */
  100055. maxSize: number;
  100056. /**
  100057. * Minimum scale of emitting particles on X axis.
  100058. */
  100059. minScaleX: number;
  100060. /**
  100061. * Maximum scale of emitting particles on X axis.
  100062. */
  100063. maxScaleX: number;
  100064. /**
  100065. * Minimum scale of emitting particles on Y axis.
  100066. */
  100067. minScaleY: number;
  100068. /**
  100069. * Maximum scale of emitting particles on Y axis.
  100070. */
  100071. maxScaleY: number;
  100072. /**
  100073. * Gets or sets the minimal initial rotation in radians.
  100074. */
  100075. minInitialRotation: number;
  100076. /**
  100077. * Gets or sets the maximal initial rotation in radians.
  100078. */
  100079. maxInitialRotation: number;
  100080. /**
  100081. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  100082. */
  100083. minAngularSpeed: number;
  100084. /**
  100085. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  100086. */
  100087. maxAngularSpeed: number;
  100088. /**
  100089. * The texture used to render each particle. (this can be a spritesheet)
  100090. */
  100091. particleTexture: Nullable<BaseTexture>;
  100092. /**
  100093. * The layer mask we are rendering the particles through.
  100094. */
  100095. layerMask: number;
  100096. /**
  100097. * This can help using your own shader to render the particle system.
  100098. * The according effect will be created
  100099. */
  100100. customShader: any;
  100101. /**
  100102. * By default particle system starts as soon as they are created. This prevents the
  100103. * automatic start to happen and let you decide when to start emitting particles.
  100104. */
  100105. preventAutoStart: boolean;
  100106. protected _rootUrl: string;
  100107. private _noiseTexture;
  100108. /**
  100109. * Gets or sets a texture used to add random noise to particle positions
  100110. */
  100111. get noiseTexture(): Nullable<ProceduralTexture>;
  100112. set noiseTexture(value: Nullable<ProceduralTexture>);
  100113. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  100114. noiseStrength: Vector3;
  100115. /**
  100116. * Callback triggered when the particle animation is ending.
  100117. */
  100118. onAnimationEnd: Nullable<() => void>;
  100119. /**
  100120. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  100121. */
  100122. blendMode: number;
  100123. /**
  100124. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  100125. * to override the particles.
  100126. */
  100127. forceDepthWrite: boolean;
  100128. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  100129. preWarmCycles: number;
  100130. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  100131. preWarmStepOffset: number;
  100132. /**
  100133. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  100134. */
  100135. spriteCellChangeSpeed: number;
  100136. /**
  100137. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  100138. */
  100139. startSpriteCellID: number;
  100140. /**
  100141. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  100142. */
  100143. endSpriteCellID: number;
  100144. /**
  100145. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  100146. */
  100147. spriteCellWidth: number;
  100148. /**
  100149. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  100150. */
  100151. spriteCellHeight: number;
  100152. /**
  100153. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  100154. */
  100155. spriteRandomStartCell: boolean;
  100156. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  100157. translationPivot: Vector2;
  100158. /** @hidden */
  100159. protected _isAnimationSheetEnabled: boolean;
  100160. /**
  100161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  100162. */
  100163. beginAnimationOnStart: boolean;
  100164. /**
  100165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  100166. */
  100167. beginAnimationFrom: number;
  100168. /**
  100169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  100170. */
  100171. beginAnimationTo: number;
  100172. /**
  100173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  100174. */
  100175. beginAnimationLoop: boolean;
  100176. /**
  100177. * Gets or sets a world offset applied to all particles
  100178. */
  100179. worldOffset: Vector3;
  100180. /**
  100181. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  100182. */
  100183. get isAnimationSheetEnabled(): boolean;
  100184. set isAnimationSheetEnabled(value: boolean);
  100185. /**
  100186. * Get hosting scene
  100187. * @returns the scene
  100188. */
  100189. getScene(): Nullable<Scene>;
  100190. /**
  100191. * You can use gravity if you want to give an orientation to your particles.
  100192. */
  100193. gravity: Vector3;
  100194. protected _colorGradients: Nullable<Array<ColorGradient>>;
  100195. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  100196. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  100197. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  100198. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  100199. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  100200. protected _dragGradients: Nullable<Array<FactorGradient>>;
  100201. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  100202. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  100203. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  100204. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  100205. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  100206. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  100207. /**
  100208. * Defines the delay in milliseconds before starting the system (0 by default)
  100209. */
  100210. startDelay: number;
  100211. /**
  100212. * Gets the current list of drag gradients.
  100213. * You must use addDragGradient and removeDragGradient to udpate this list
  100214. * @returns the list of drag gradients
  100215. */
  100216. getDragGradients(): Nullable<Array<FactorGradient>>;
  100217. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  100218. limitVelocityDamping: number;
  100219. /**
  100220. * Gets the current list of limit velocity gradients.
  100221. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  100222. * @returns the list of limit velocity gradients
  100223. */
  100224. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  100225. /**
  100226. * Gets the current list of color gradients.
  100227. * You must use addColorGradient and removeColorGradient to udpate this list
  100228. * @returns the list of color gradients
  100229. */
  100230. getColorGradients(): Nullable<Array<ColorGradient>>;
  100231. /**
  100232. * Gets the current list of size gradients.
  100233. * You must use addSizeGradient and removeSizeGradient to udpate this list
  100234. * @returns the list of size gradients
  100235. */
  100236. getSizeGradients(): Nullable<Array<FactorGradient>>;
  100237. /**
  100238. * Gets the current list of color remap gradients.
  100239. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  100240. * @returns the list of color remap gradients
  100241. */
  100242. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  100243. /**
  100244. * Gets the current list of alpha remap gradients.
  100245. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  100246. * @returns the list of alpha remap gradients
  100247. */
  100248. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  100249. /**
  100250. * Gets the current list of life time gradients.
  100251. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  100252. * @returns the list of life time gradients
  100253. */
  100254. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  100255. /**
  100256. * Gets the current list of angular speed gradients.
  100257. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  100258. * @returns the list of angular speed gradients
  100259. */
  100260. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  100261. /**
  100262. * Gets the current list of velocity gradients.
  100263. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  100264. * @returns the list of velocity gradients
  100265. */
  100266. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  100267. /**
  100268. * Gets the current list of start size gradients.
  100269. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  100270. * @returns the list of start size gradients
  100271. */
  100272. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  100273. /**
  100274. * Gets the current list of emit rate gradients.
  100275. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  100276. * @returns the list of emit rate gradients
  100277. */
  100278. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  100279. /**
  100280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100281. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100282. */
  100283. get direction1(): Vector3;
  100284. set direction1(value: Vector3);
  100285. /**
  100286. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100287. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100288. */
  100289. get direction2(): Vector3;
  100290. set direction2(value: Vector3);
  100291. /**
  100292. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  100293. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100294. */
  100295. get minEmitBox(): Vector3;
  100296. set minEmitBox(value: Vector3);
  100297. /**
  100298. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  100299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100300. */
  100301. get maxEmitBox(): Vector3;
  100302. set maxEmitBox(value: Vector3);
  100303. /**
  100304. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  100305. */
  100306. color1: Color4;
  100307. /**
  100308. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  100309. */
  100310. color2: Color4;
  100311. /**
  100312. * Color the particle will have at the end of its lifetime
  100313. */
  100314. colorDead: Color4;
  100315. /**
  100316. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  100317. */
  100318. textureMask: Color4;
  100319. /**
  100320. * The particle emitter type defines the emitter used by the particle system.
  100321. * It can be for example box, sphere, or cone...
  100322. */
  100323. particleEmitterType: IParticleEmitterType;
  100324. /** @hidden */
  100325. _isSubEmitter: boolean;
  100326. /**
  100327. * Gets or sets the billboard mode to use when isBillboardBased = true.
  100328. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  100329. */
  100330. billboardMode: number;
  100331. protected _isBillboardBased: boolean;
  100332. /**
  100333. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  100334. */
  100335. get isBillboardBased(): boolean;
  100336. set isBillboardBased(value: boolean);
  100337. /**
  100338. * The scene the particle system belongs to.
  100339. */
  100340. protected _scene: Nullable<Scene>;
  100341. /**
  100342. * The engine the particle system belongs to.
  100343. */
  100344. protected _engine: ThinEngine;
  100345. /**
  100346. * Local cache of defines for image processing.
  100347. */
  100348. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  100349. /**
  100350. * Default configuration related to image processing available in the standard Material.
  100351. */
  100352. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100353. /**
  100354. * Gets the image processing configuration used either in this material.
  100355. */
  100356. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  100357. /**
  100358. * Sets the Default image processing configuration used either in the this material.
  100359. *
  100360. * If sets to null, the scene one is in use.
  100361. */
  100362. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  100363. /**
  100364. * Attaches a new image processing configuration to the Standard Material.
  100365. * @param configuration
  100366. */
  100367. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100368. /** @hidden */
  100369. protected _reset(): void;
  100370. /** @hidden */
  100371. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  100372. /**
  100373. * Instantiates a particle system.
  100374. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  100375. * @param name The name of the particle system
  100376. */
  100377. constructor(name: string);
  100378. /**
  100379. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  100380. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  100381. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  100382. * @returns the emitter
  100383. */
  100384. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  100385. /**
  100386. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  100387. * @param radius The radius of the hemisphere to emit from
  100388. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  100389. * @returns the emitter
  100390. */
  100391. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  100392. /**
  100393. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  100394. * @param radius The radius of the sphere to emit from
  100395. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  100396. * @returns the emitter
  100397. */
  100398. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  100399. /**
  100400. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  100401. * @param radius The radius of the sphere to emit from
  100402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  100403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  100404. * @returns the emitter
  100405. */
  100406. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  100407. /**
  100408. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  100409. * @param radius The radius of the emission cylinder
  100410. * @param height The height of the emission cylinder
  100411. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  100412. * @param directionRandomizer How much to randomize the particle direction [0-1]
  100413. * @returns the emitter
  100414. */
  100415. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  100416. /**
  100417. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  100418. * @param radius The radius of the cylinder to emit from
  100419. * @param height The height of the emission cylinder
  100420. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  100422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  100423. * @returns the emitter
  100424. */
  100425. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  100426. /**
  100427. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  100428. * @param radius The radius of the cone to emit from
  100429. * @param angle The base angle of the cone
  100430. * @returns the emitter
  100431. */
  100432. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  100433. /**
  100434. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  100435. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  100436. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  100437. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  100438. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  100439. * @returns the emitter
  100440. */
  100441. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  100442. }
  100443. }
  100444. declare module BABYLON {
  100445. /**
  100446. * Type of sub emitter
  100447. */
  100448. export enum SubEmitterType {
  100449. /**
  100450. * Attached to the particle over it's lifetime
  100451. */
  100452. ATTACHED = 0,
  100453. /**
  100454. * Created when the particle dies
  100455. */
  100456. END = 1
  100457. }
  100458. /**
  100459. * Sub emitter class used to emit particles from an existing particle
  100460. */
  100461. export class SubEmitter {
  100462. /**
  100463. * the particle system to be used by the sub emitter
  100464. */
  100465. particleSystem: ParticleSystem;
  100466. /**
  100467. * Type of the submitter (Default: END)
  100468. */
  100469. type: SubEmitterType;
  100470. /**
  100471. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  100472. * Note: This only is supported when using an emitter of type Mesh
  100473. */
  100474. inheritDirection: boolean;
  100475. /**
  100476. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  100477. */
  100478. inheritedVelocityAmount: number;
  100479. /**
  100480. * Creates a sub emitter
  100481. * @param particleSystem the particle system to be used by the sub emitter
  100482. */
  100483. constructor(
  100484. /**
  100485. * the particle system to be used by the sub emitter
  100486. */
  100487. particleSystem: ParticleSystem);
  100488. /**
  100489. * Clones the sub emitter
  100490. * @returns the cloned sub emitter
  100491. */
  100492. clone(): SubEmitter;
  100493. /**
  100494. * Serialize current object to a JSON object
  100495. * @returns the serialized object
  100496. */
  100497. serialize(): any;
  100498. /** @hidden */
  100499. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  100500. /**
  100501. * Creates a new SubEmitter from a serialized JSON version
  100502. * @param serializationObject defines the JSON object to read from
  100503. * @param sceneOrEngine defines the hosting scene or the hosting engine
  100504. * @param rootUrl defines the rootUrl for data loading
  100505. * @returns a new SubEmitter
  100506. */
  100507. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  100508. /** Release associated resources */
  100509. dispose(): void;
  100510. }
  100511. }
  100512. declare module BABYLON {
  100513. /** @hidden */
  100514. export var clipPlaneFragmentDeclaration: {
  100515. name: string;
  100516. shader: string;
  100517. };
  100518. }
  100519. declare module BABYLON {
  100520. /** @hidden */
  100521. export var imageProcessingDeclaration: {
  100522. name: string;
  100523. shader: string;
  100524. };
  100525. }
  100526. declare module BABYLON {
  100527. /** @hidden */
  100528. export var imageProcessingFunctions: {
  100529. name: string;
  100530. shader: string;
  100531. };
  100532. }
  100533. declare module BABYLON {
  100534. /** @hidden */
  100535. export var clipPlaneFragment: {
  100536. name: string;
  100537. shader: string;
  100538. };
  100539. }
  100540. declare module BABYLON {
  100541. /** @hidden */
  100542. export var particlesPixelShader: {
  100543. name: string;
  100544. shader: string;
  100545. };
  100546. }
  100547. declare module BABYLON {
  100548. /** @hidden */
  100549. export var clipPlaneVertexDeclaration: {
  100550. name: string;
  100551. shader: string;
  100552. };
  100553. }
  100554. declare module BABYLON {
  100555. /** @hidden */
  100556. export var clipPlaneVertex: {
  100557. name: string;
  100558. shader: string;
  100559. };
  100560. }
  100561. declare module BABYLON {
  100562. /** @hidden */
  100563. export var particlesVertexShader: {
  100564. name: string;
  100565. shader: string;
  100566. };
  100567. }
  100568. declare module BABYLON {
  100569. /**
  100570. * Interface used to define entities containing multiple clip planes
  100571. */
  100572. export interface IClipPlanesHolder {
  100573. /**
  100574. * Gets or sets the active clipplane 1
  100575. */
  100576. clipPlane: Nullable<Plane>;
  100577. /**
  100578. * Gets or sets the active clipplane 2
  100579. */
  100580. clipPlane2: Nullable<Plane>;
  100581. /**
  100582. * Gets or sets the active clipplane 3
  100583. */
  100584. clipPlane3: Nullable<Plane>;
  100585. /**
  100586. * Gets or sets the active clipplane 4
  100587. */
  100588. clipPlane4: Nullable<Plane>;
  100589. /**
  100590. * Gets or sets the active clipplane 5
  100591. */
  100592. clipPlane5: Nullable<Plane>;
  100593. /**
  100594. * Gets or sets the active clipplane 6
  100595. */
  100596. clipPlane6: Nullable<Plane>;
  100597. }
  100598. }
  100599. declare module BABYLON {
  100600. /**
  100601. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  100602. *
  100603. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  100604. *
  100605. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100606. */
  100607. export class ThinMaterialHelper {
  100608. /**
  100609. * Binds the clip plane information from the holder to the effect.
  100610. * @param effect The effect we are binding the data to
  100611. * @param holder The entity containing the clip plane information
  100612. */
  100613. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  100614. }
  100615. }
  100616. declare module BABYLON {
  100617. interface ThinEngine {
  100618. /**
  100619. * Sets alpha constants used by some alpha blending modes
  100620. * @param r defines the red component
  100621. * @param g defines the green component
  100622. * @param b defines the blue component
  100623. * @param a defines the alpha component
  100624. */
  100625. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100626. /**
  100627. * Sets the current alpha mode
  100628. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100629. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100630. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100631. */
  100632. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100633. /**
  100634. * Gets the current alpha mode
  100635. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100636. * @returns the current alpha mode
  100637. */
  100638. getAlphaMode(): number;
  100639. /**
  100640. * Sets the current alpha equation
  100641. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100642. */
  100643. setAlphaEquation(equation: number): void;
  100644. /**
  100645. * Gets the current alpha equation.
  100646. * @returns the current alpha equation
  100647. */
  100648. getAlphaEquation(): number;
  100649. }
  100650. }
  100651. declare module BABYLON {
  100652. /**
  100653. * This represents a particle system in Babylon.
  100654. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  100655. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  100656. * @example https://doc.babylonjs.com/babylon101/particles
  100657. */
  100658. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  100659. /**
  100660. * Billboard mode will only apply to Y axis
  100661. */
  100662. static readonly BILLBOARDMODE_Y: number;
  100663. /**
  100664. * Billboard mode will apply to all axes
  100665. */
  100666. static readonly BILLBOARDMODE_ALL: number;
  100667. /**
  100668. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  100669. */
  100670. static readonly BILLBOARDMODE_STRETCHED: number;
  100671. /**
  100672. * This function can be defined to provide custom update for active particles.
  100673. * This function will be called instead of regular update (age, position, color, etc.).
  100674. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  100675. */
  100676. updateFunction: (particles: Particle[]) => void;
  100677. private _emitterWorldMatrix;
  100678. /**
  100679. * This function can be defined to specify initial direction for every new particle.
  100680. * It by default use the emitterType defined function
  100681. */
  100682. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100683. /**
  100684. * This function can be defined to specify initial position for every new particle.
  100685. * It by default use the emitterType defined function
  100686. */
  100687. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100688. /**
  100689. * @hidden
  100690. */
  100691. _inheritedVelocityOffset: Vector3;
  100692. /**
  100693. * An event triggered when the system is disposed
  100694. */
  100695. onDisposeObservable: Observable<IParticleSystem>;
  100696. /**
  100697. * An event triggered when the system is stopped
  100698. */
  100699. onStoppedObservable: Observable<IParticleSystem>;
  100700. private _onDisposeObserver;
  100701. /**
  100702. * Sets a callback that will be triggered when the system is disposed
  100703. */
  100704. set onDispose(callback: () => void);
  100705. private _particles;
  100706. private _epsilon;
  100707. private _capacity;
  100708. private _stockParticles;
  100709. private _newPartsExcess;
  100710. private _vertexData;
  100711. private _vertexBuffer;
  100712. private _vertexBuffers;
  100713. private _spriteBuffer;
  100714. private _indexBuffer;
  100715. private _effect;
  100716. private _customEffect;
  100717. private _cachedDefines;
  100718. private _scaledColorStep;
  100719. private _colorDiff;
  100720. private _scaledDirection;
  100721. private _scaledGravity;
  100722. private _currentRenderId;
  100723. private _alive;
  100724. private _useInstancing;
  100725. private _vertexArrayObject;
  100726. private _started;
  100727. private _stopped;
  100728. private _actualFrame;
  100729. private _scaledUpdateSpeed;
  100730. private _vertexBufferSize;
  100731. /** @hidden */
  100732. _currentEmitRateGradient: Nullable<FactorGradient>;
  100733. /** @hidden */
  100734. _currentEmitRate1: number;
  100735. /** @hidden */
  100736. _currentEmitRate2: number;
  100737. /** @hidden */
  100738. _currentStartSizeGradient: Nullable<FactorGradient>;
  100739. /** @hidden */
  100740. _currentStartSize1: number;
  100741. /** @hidden */
  100742. _currentStartSize2: number;
  100743. private readonly _rawTextureWidth;
  100744. private _rampGradientsTexture;
  100745. private _useRampGradients;
  100746. /** Gets or sets a matrix to use to compute projection */
  100747. defaultProjectionMatrix: Matrix;
  100748. /** Gets or sets a matrix to use to compute view */
  100749. defaultViewMatrix: Matrix;
  100750. /** Gets or sets a boolean indicating that ramp gradients must be used
  100751. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  100752. */
  100753. get useRampGradients(): boolean;
  100754. set useRampGradients(value: boolean);
  100755. /**
  100756. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  100757. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  100758. */
  100759. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  100760. private _subEmitters;
  100761. /**
  100762. * @hidden
  100763. * If the particle systems emitter should be disposed when the particle system is disposed
  100764. */
  100765. _disposeEmitterOnDispose: boolean;
  100766. /**
  100767. * The current active Sub-systems, this property is used by the root particle system only.
  100768. */
  100769. activeSubSystems: Array<ParticleSystem>;
  100770. /**
  100771. * Specifies if the particles are updated in emitter local space or world space
  100772. */
  100773. isLocal: boolean;
  100774. private _rootParticleSystem;
  100775. /**
  100776. * Gets the current list of active particles
  100777. */
  100778. get particles(): Particle[];
  100779. /**
  100780. * Gets the number of particles active at the same time.
  100781. * @returns The number of active particles.
  100782. */
  100783. getActiveCount(): number;
  100784. /**
  100785. * Returns the string "ParticleSystem"
  100786. * @returns a string containing the class name
  100787. */
  100788. getClassName(): string;
  100789. /**
  100790. * Gets a boolean indicating that the system is stopping
  100791. * @returns true if the system is currently stopping
  100792. */
  100793. isStopping(): boolean;
  100794. /**
  100795. * Gets the custom effect used to render the particles
  100796. * @param blendMode Blend mode for which the effect should be retrieved
  100797. * @returns The effect
  100798. */
  100799. getCustomEffect(blendMode?: number): Nullable<Effect>;
  100800. /**
  100801. * Sets the custom effect used to render the particles
  100802. * @param effect The effect to set
  100803. * @param blendMode Blend mode for which the effect should be set
  100804. */
  100805. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  100806. /** @hidden */
  100807. private _onBeforeDrawParticlesObservable;
  100808. /**
  100809. * Observable that will be called just before the particles are drawn
  100810. */
  100811. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  100812. /**
  100813. * Gets the name of the particle vertex shader
  100814. */
  100815. get vertexShaderName(): string;
  100816. /**
  100817. * Instantiates a particle system.
  100818. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  100819. * @param name The name of the particle system
  100820. * @param capacity The max number of particles alive at the same time
  100821. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  100822. * @param customEffect a custom effect used to change the way particles are rendered by default
  100823. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  100824. * @param epsilon Offset used to render the particles
  100825. */
  100826. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  100827. private _addFactorGradient;
  100828. private _removeFactorGradient;
  100829. /**
  100830. * Adds a new life time gradient
  100831. * @param gradient defines the gradient to use (between 0 and 1)
  100832. * @param factor defines the life time factor to affect to the specified gradient
  100833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100834. * @returns the current particle system
  100835. */
  100836. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100837. /**
  100838. * Remove a specific life time gradient
  100839. * @param gradient defines the gradient to remove
  100840. * @returns the current particle system
  100841. */
  100842. removeLifeTimeGradient(gradient: number): IParticleSystem;
  100843. /**
  100844. * Adds a new size gradient
  100845. * @param gradient defines the gradient to use (between 0 and 1)
  100846. * @param factor defines the size factor to affect to the specified gradient
  100847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100848. * @returns the current particle system
  100849. */
  100850. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100851. /**
  100852. * Remove a specific size gradient
  100853. * @param gradient defines the gradient to remove
  100854. * @returns the current particle system
  100855. */
  100856. removeSizeGradient(gradient: number): IParticleSystem;
  100857. /**
  100858. * Adds a new color remap gradient
  100859. * @param gradient defines the gradient to use (between 0 and 1)
  100860. * @param min defines the color remap minimal range
  100861. * @param max defines the color remap maximal range
  100862. * @returns the current particle system
  100863. */
  100864. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100865. /**
  100866. * Remove a specific color remap gradient
  100867. * @param gradient defines the gradient to remove
  100868. * @returns the current particle system
  100869. */
  100870. removeColorRemapGradient(gradient: number): IParticleSystem;
  100871. /**
  100872. * Adds a new alpha remap gradient
  100873. * @param gradient defines the gradient to use (between 0 and 1)
  100874. * @param min defines the alpha remap minimal range
  100875. * @param max defines the alpha remap maximal range
  100876. * @returns the current particle system
  100877. */
  100878. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100879. /**
  100880. * Remove a specific alpha remap gradient
  100881. * @param gradient defines the gradient to remove
  100882. * @returns the current particle system
  100883. */
  100884. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  100885. /**
  100886. * Adds a new angular speed gradient
  100887. * @param gradient defines the gradient to use (between 0 and 1)
  100888. * @param factor defines the angular speed to affect to the specified gradient
  100889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100890. * @returns the current particle system
  100891. */
  100892. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100893. /**
  100894. * Remove a specific angular speed gradient
  100895. * @param gradient defines the gradient to remove
  100896. * @returns the current particle system
  100897. */
  100898. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  100899. /**
  100900. * Adds a new velocity gradient
  100901. * @param gradient defines the gradient to use (between 0 and 1)
  100902. * @param factor defines the velocity to affect to the specified gradient
  100903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100904. * @returns the current particle system
  100905. */
  100906. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100907. /**
  100908. * Remove a specific velocity gradient
  100909. * @param gradient defines the gradient to remove
  100910. * @returns the current particle system
  100911. */
  100912. removeVelocityGradient(gradient: number): IParticleSystem;
  100913. /**
  100914. * Adds a new limit velocity gradient
  100915. * @param gradient defines the gradient to use (between 0 and 1)
  100916. * @param factor defines the limit velocity value to affect to the specified gradient
  100917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100918. * @returns the current particle system
  100919. */
  100920. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100921. /**
  100922. * Remove a specific limit velocity gradient
  100923. * @param gradient defines the gradient to remove
  100924. * @returns the current particle system
  100925. */
  100926. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  100927. /**
  100928. * Adds a new drag gradient
  100929. * @param gradient defines the gradient to use (between 0 and 1)
  100930. * @param factor defines the drag value to affect to the specified gradient
  100931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100932. * @returns the current particle system
  100933. */
  100934. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100935. /**
  100936. * Remove a specific drag gradient
  100937. * @param gradient defines the gradient to remove
  100938. * @returns the current particle system
  100939. */
  100940. removeDragGradient(gradient: number): IParticleSystem;
  100941. /**
  100942. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  100943. * @param gradient defines the gradient to use (between 0 and 1)
  100944. * @param factor defines the emit rate value to affect to the specified gradient
  100945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100946. * @returns the current particle system
  100947. */
  100948. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100949. /**
  100950. * Remove a specific emit rate gradient
  100951. * @param gradient defines the gradient to remove
  100952. * @returns the current particle system
  100953. */
  100954. removeEmitRateGradient(gradient: number): IParticleSystem;
  100955. /**
  100956. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  100957. * @param gradient defines the gradient to use (between 0 and 1)
  100958. * @param factor defines the start size value to affect to the specified gradient
  100959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100960. * @returns the current particle system
  100961. */
  100962. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100963. /**
  100964. * Remove a specific start size gradient
  100965. * @param gradient defines the gradient to remove
  100966. * @returns the current particle system
  100967. */
  100968. removeStartSizeGradient(gradient: number): IParticleSystem;
  100969. private _createRampGradientTexture;
  100970. /**
  100971. * Gets the current list of ramp gradients.
  100972. * You must use addRampGradient and removeRampGradient to udpate this list
  100973. * @returns the list of ramp gradients
  100974. */
  100975. getRampGradients(): Nullable<Array<Color3Gradient>>;
  100976. /** Force the system to rebuild all gradients that need to be resync */
  100977. forceRefreshGradients(): void;
  100978. private _syncRampGradientTexture;
  100979. /**
  100980. * Adds a new ramp gradient used to remap particle colors
  100981. * @param gradient defines the gradient to use (between 0 and 1)
  100982. * @param color defines the color to affect to the specified gradient
  100983. * @returns the current particle system
  100984. */
  100985. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  100986. /**
  100987. * Remove a specific ramp gradient
  100988. * @param gradient defines the gradient to remove
  100989. * @returns the current particle system
  100990. */
  100991. removeRampGradient(gradient: number): ParticleSystem;
  100992. /**
  100993. * Adds a new color gradient
  100994. * @param gradient defines the gradient to use (between 0 and 1)
  100995. * @param color1 defines the color to affect to the specified gradient
  100996. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  100997. * @returns this particle system
  100998. */
  100999. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  101000. /**
  101001. * Remove a specific color gradient
  101002. * @param gradient defines the gradient to remove
  101003. * @returns this particle system
  101004. */
  101005. removeColorGradient(gradient: number): IParticleSystem;
  101006. private _fetchR;
  101007. protected _reset(): void;
  101008. private _resetEffect;
  101009. private _createVertexBuffers;
  101010. private _createIndexBuffer;
  101011. /**
  101012. * Gets the maximum number of particles active at the same time.
  101013. * @returns The max number of active particles.
  101014. */
  101015. getCapacity(): number;
  101016. /**
  101017. * Gets whether there are still active particles in the system.
  101018. * @returns True if it is alive, otherwise false.
  101019. */
  101020. isAlive(): boolean;
  101021. /**
  101022. * Gets if the system has been started. (Note: this will still be true after stop is called)
  101023. * @returns True if it has been started, otherwise false.
  101024. */
  101025. isStarted(): boolean;
  101026. private _prepareSubEmitterInternalArray;
  101027. /**
  101028. * Starts the particle system and begins to emit
  101029. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  101030. */
  101031. start(delay?: number): void;
  101032. /**
  101033. * Stops the particle system.
  101034. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  101035. */
  101036. stop(stopSubEmitters?: boolean): void;
  101037. /**
  101038. * Remove all active particles
  101039. */
  101040. reset(): void;
  101041. /**
  101042. * @hidden (for internal use only)
  101043. */
  101044. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  101045. /**
  101046. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  101047. * Its lifetime will start back at 0.
  101048. */
  101049. recycleParticle: (particle: Particle) => void;
  101050. private _stopSubEmitters;
  101051. private _createParticle;
  101052. private _removeFromRoot;
  101053. private _emitFromParticle;
  101054. private _update;
  101055. /** @hidden */
  101056. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  101057. /** @hidden */
  101058. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  101059. /**
  101060. * Fill the defines array according to the current settings of the particle system
  101061. * @param defines Array to be updated
  101062. * @param blendMode blend mode to take into account when updating the array
  101063. */
  101064. fillDefines(defines: Array<string>, blendMode: number): void;
  101065. /**
  101066. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  101067. * @param uniforms Uniforms array to fill
  101068. * @param attributes Attributes array to fill
  101069. * @param samplers Samplers array to fill
  101070. */
  101071. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  101072. /** @hidden */
  101073. private _getEffect;
  101074. /**
  101075. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  101076. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  101077. */
  101078. animate(preWarmOnly?: boolean): void;
  101079. private _appendParticleVertices;
  101080. /**
  101081. * Rebuilds the particle system.
  101082. */
  101083. rebuild(): void;
  101084. /**
  101085. * Is this system ready to be used/rendered
  101086. * @return true if the system is ready
  101087. */
  101088. isReady(): boolean;
  101089. private _render;
  101090. /**
  101091. * Renders the particle system in its current state.
  101092. * @returns the current number of particles
  101093. */
  101094. render(): number;
  101095. /**
  101096. * Disposes the particle system and free the associated resources
  101097. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  101098. */
  101099. dispose(disposeTexture?: boolean): void;
  101100. /**
  101101. * Clones the particle system.
  101102. * @param name The name of the cloned object
  101103. * @param newEmitter The new emitter to use
  101104. * @returns the cloned particle system
  101105. */
  101106. clone(name: string, newEmitter: any): ParticleSystem;
  101107. /**
  101108. * Serializes the particle system to a JSON object
  101109. * @param serializeTexture defines if the texture must be serialized as well
  101110. * @returns the JSON object
  101111. */
  101112. serialize(serializeTexture?: boolean): any;
  101113. /** @hidden */
  101114. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  101115. /** @hidden */
  101116. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  101117. /**
  101118. * Parses a JSON object to create a particle system.
  101119. * @param parsedParticleSystem The JSON object to parse
  101120. * @param sceneOrEngine The scene or the engine to create the particle system in
  101121. * @param rootUrl The root url to use to load external dependencies like texture
  101122. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  101123. * @returns the Parsed particle system
  101124. */
  101125. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  101126. }
  101127. }
  101128. declare module BABYLON {
  101129. /**
  101130. * A particle represents one of the element emitted by a particle system.
  101131. * This is mainly define by its coordinates, direction, velocity and age.
  101132. */
  101133. export class Particle {
  101134. /**
  101135. * The particle system the particle belongs to.
  101136. */
  101137. particleSystem: ParticleSystem;
  101138. private static _Count;
  101139. /**
  101140. * Unique ID of the particle
  101141. */
  101142. id: number;
  101143. /**
  101144. * The world position of the particle in the scene.
  101145. */
  101146. position: Vector3;
  101147. /**
  101148. * The world direction of the particle in the scene.
  101149. */
  101150. direction: Vector3;
  101151. /**
  101152. * The color of the particle.
  101153. */
  101154. color: Color4;
  101155. /**
  101156. * The color change of the particle per step.
  101157. */
  101158. colorStep: Color4;
  101159. /**
  101160. * Defines how long will the life of the particle be.
  101161. */
  101162. lifeTime: number;
  101163. /**
  101164. * The current age of the particle.
  101165. */
  101166. age: number;
  101167. /**
  101168. * The current size of the particle.
  101169. */
  101170. size: number;
  101171. /**
  101172. * The current scale of the particle.
  101173. */
  101174. scale: Vector2;
  101175. /**
  101176. * The current angle of the particle.
  101177. */
  101178. angle: number;
  101179. /**
  101180. * Defines how fast is the angle changing.
  101181. */
  101182. angularSpeed: number;
  101183. /**
  101184. * Defines the cell index used by the particle to be rendered from a sprite.
  101185. */
  101186. cellIndex: number;
  101187. /**
  101188. * The information required to support color remapping
  101189. */
  101190. remapData: Vector4;
  101191. /** @hidden */
  101192. _randomCellOffset?: number;
  101193. /** @hidden */
  101194. _initialDirection: Nullable<Vector3>;
  101195. /** @hidden */
  101196. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  101197. /** @hidden */
  101198. _initialStartSpriteCellID: number;
  101199. /** @hidden */
  101200. _initialEndSpriteCellID: number;
  101201. /** @hidden */
  101202. _currentColorGradient: Nullable<ColorGradient>;
  101203. /** @hidden */
  101204. _currentColor1: Color4;
  101205. /** @hidden */
  101206. _currentColor2: Color4;
  101207. /** @hidden */
  101208. _currentSizeGradient: Nullable<FactorGradient>;
  101209. /** @hidden */
  101210. _currentSize1: number;
  101211. /** @hidden */
  101212. _currentSize2: number;
  101213. /** @hidden */
  101214. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  101215. /** @hidden */
  101216. _currentAngularSpeed1: number;
  101217. /** @hidden */
  101218. _currentAngularSpeed2: number;
  101219. /** @hidden */
  101220. _currentVelocityGradient: Nullable<FactorGradient>;
  101221. /** @hidden */
  101222. _currentVelocity1: number;
  101223. /** @hidden */
  101224. _currentVelocity2: number;
  101225. /** @hidden */
  101226. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  101227. /** @hidden */
  101228. _currentLimitVelocity1: number;
  101229. /** @hidden */
  101230. _currentLimitVelocity2: number;
  101231. /** @hidden */
  101232. _currentDragGradient: Nullable<FactorGradient>;
  101233. /** @hidden */
  101234. _currentDrag1: number;
  101235. /** @hidden */
  101236. _currentDrag2: number;
  101237. /** @hidden */
  101238. _randomNoiseCoordinates1: Vector3;
  101239. /** @hidden */
  101240. _randomNoiseCoordinates2: Vector3;
  101241. /** @hidden */
  101242. _localPosition?: Vector3;
  101243. /**
  101244. * Creates a new instance Particle
  101245. * @param particleSystem the particle system the particle belongs to
  101246. */
  101247. constructor(
  101248. /**
  101249. * The particle system the particle belongs to.
  101250. */
  101251. particleSystem: ParticleSystem);
  101252. private updateCellInfoFromSystem;
  101253. /**
  101254. * Defines how the sprite cell index is updated for the particle
  101255. */
  101256. updateCellIndex(): void;
  101257. /** @hidden */
  101258. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  101259. /** @hidden */
  101260. _inheritParticleInfoToSubEmitters(): void;
  101261. /** @hidden */
  101262. _reset(): void;
  101263. /**
  101264. * Copy the properties of particle to another one.
  101265. * @param other the particle to copy the information to.
  101266. */
  101267. copyTo(other: Particle): void;
  101268. }
  101269. }
  101270. declare module BABYLON {
  101271. /**
  101272. * Particle emitter represents a volume emitting particles.
  101273. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  101274. */
  101275. export interface IParticleEmitterType {
  101276. /**
  101277. * Called by the particle System when the direction is computed for the created particle.
  101278. * @param worldMatrix is the world matrix of the particle system
  101279. * @param directionToUpdate is the direction vector to update with the result
  101280. * @param particle is the particle we are computed the direction for
  101281. * @param isLocal defines if the direction should be set in local space
  101282. */
  101283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101284. /**
  101285. * Called by the particle System when the position is computed for the created particle.
  101286. * @param worldMatrix is the world matrix of the particle system
  101287. * @param positionToUpdate is the position vector to update with the result
  101288. * @param particle is the particle we are computed the position for
  101289. * @param isLocal defines if the position should be set in local space
  101290. */
  101291. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101292. /**
  101293. * Clones the current emitter and returns a copy of it
  101294. * @returns the new emitter
  101295. */
  101296. clone(): IParticleEmitterType;
  101297. /**
  101298. * Called by the GPUParticleSystem to setup the update shader
  101299. * @param effect defines the update shader
  101300. */
  101301. applyToShader(effect: Effect): void;
  101302. /**
  101303. * Returns a string to use to update the GPU particles update shader
  101304. * @returns the effect defines string
  101305. */
  101306. getEffectDefines(): string;
  101307. /**
  101308. * Returns a string representing the class name
  101309. * @returns a string containing the class name
  101310. */
  101311. getClassName(): string;
  101312. /**
  101313. * Serializes the particle system to a JSON object.
  101314. * @returns the JSON object
  101315. */
  101316. serialize(): any;
  101317. /**
  101318. * Parse properties from a JSON object
  101319. * @param serializationObject defines the JSON object
  101320. * @param scene defines the hosting scene
  101321. */
  101322. parse(serializationObject: any, scene: Nullable<Scene>): void;
  101323. }
  101324. }
  101325. declare module BABYLON {
  101326. /**
  101327. * Particle emitter emitting particles from the inside of a box.
  101328. * It emits the particles randomly between 2 given directions.
  101329. */
  101330. export class BoxParticleEmitter implements IParticleEmitterType {
  101331. /**
  101332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101333. */
  101334. direction1: Vector3;
  101335. /**
  101336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101337. */
  101338. direction2: Vector3;
  101339. /**
  101340. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  101341. */
  101342. minEmitBox: Vector3;
  101343. /**
  101344. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  101345. */
  101346. maxEmitBox: Vector3;
  101347. /**
  101348. * Creates a new instance BoxParticleEmitter
  101349. */
  101350. constructor();
  101351. /**
  101352. * Called by the particle System when the direction is computed for the created particle.
  101353. * @param worldMatrix is the world matrix of the particle system
  101354. * @param directionToUpdate is the direction vector to update with the result
  101355. * @param particle is the particle we are computed the direction for
  101356. * @param isLocal defines if the direction should be set in local space
  101357. */
  101358. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101359. /**
  101360. * Called by the particle System when the position is computed for the created particle.
  101361. * @param worldMatrix is the world matrix of the particle system
  101362. * @param positionToUpdate is the position vector to update with the result
  101363. * @param particle is the particle we are computed the position for
  101364. * @param isLocal defines if the position should be set in local space
  101365. */
  101366. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101367. /**
  101368. * Clones the current emitter and returns a copy of it
  101369. * @returns the new emitter
  101370. */
  101371. clone(): BoxParticleEmitter;
  101372. /**
  101373. * Called by the GPUParticleSystem to setup the update shader
  101374. * @param effect defines the update shader
  101375. */
  101376. applyToShader(effect: Effect): void;
  101377. /**
  101378. * Returns a string to use to update the GPU particles update shader
  101379. * @returns a string containng the defines string
  101380. */
  101381. getEffectDefines(): string;
  101382. /**
  101383. * Returns the string "BoxParticleEmitter"
  101384. * @returns a string containing the class name
  101385. */
  101386. getClassName(): string;
  101387. /**
  101388. * Serializes the particle system to a JSON object.
  101389. * @returns the JSON object
  101390. */
  101391. serialize(): any;
  101392. /**
  101393. * Parse properties from a JSON object
  101394. * @param serializationObject defines the JSON object
  101395. */
  101396. parse(serializationObject: any): void;
  101397. }
  101398. }
  101399. declare module BABYLON {
  101400. /**
  101401. * Particle emitter emitting particles from the inside of a cone.
  101402. * It emits the particles alongside the cone volume from the base to the particle.
  101403. * The emission direction might be randomized.
  101404. */
  101405. export class ConeParticleEmitter implements IParticleEmitterType {
  101406. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101407. directionRandomizer: number;
  101408. private _radius;
  101409. private _angle;
  101410. private _height;
  101411. /**
  101412. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101413. */
  101414. radiusRange: number;
  101415. /**
  101416. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101417. */
  101418. heightRange: number;
  101419. /**
  101420. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101421. */
  101422. emitFromSpawnPointOnly: boolean;
  101423. /**
  101424. * Gets or sets the radius of the emission cone
  101425. */
  101426. get radius(): number;
  101427. set radius(value: number);
  101428. /**
  101429. * Gets or sets the angle of the emission cone
  101430. */
  101431. get angle(): number;
  101432. set angle(value: number);
  101433. private _buildHeight;
  101434. /**
  101435. * Creates a new instance ConeParticleEmitter
  101436. * @param radius the radius of the emission cone (1 by default)
  101437. * @param angle the cone base angle (PI by default)
  101438. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101439. */
  101440. constructor(radius?: number, angle?: number,
  101441. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101442. directionRandomizer?: number);
  101443. /**
  101444. * Called by the particle System when the direction is computed for the created particle.
  101445. * @param worldMatrix is the world matrix of the particle system
  101446. * @param directionToUpdate is the direction vector to update with the result
  101447. * @param particle is the particle we are computed the direction for
  101448. * @param isLocal defines if the direction should be set in local space
  101449. */
  101450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101451. /**
  101452. * Called by the particle System when the position is computed for the created particle.
  101453. * @param worldMatrix is the world matrix of the particle system
  101454. * @param positionToUpdate is the position vector to update with the result
  101455. * @param particle is the particle we are computed the position for
  101456. * @param isLocal defines if the position should be set in local space
  101457. */
  101458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101459. /**
  101460. * Clones the current emitter and returns a copy of it
  101461. * @returns the new emitter
  101462. */
  101463. clone(): ConeParticleEmitter;
  101464. /**
  101465. * Called by the GPUParticleSystem to setup the update shader
  101466. * @param effect defines the update shader
  101467. */
  101468. applyToShader(effect: Effect): void;
  101469. /**
  101470. * Returns a string to use to update the GPU particles update shader
  101471. * @returns a string containng the defines string
  101472. */
  101473. getEffectDefines(): string;
  101474. /**
  101475. * Returns the string "ConeParticleEmitter"
  101476. * @returns a string containing the class name
  101477. */
  101478. getClassName(): string;
  101479. /**
  101480. * Serializes the particle system to a JSON object.
  101481. * @returns the JSON object
  101482. */
  101483. serialize(): any;
  101484. /**
  101485. * Parse properties from a JSON object
  101486. * @param serializationObject defines the JSON object
  101487. */
  101488. parse(serializationObject: any): void;
  101489. }
  101490. }
  101491. declare module BABYLON {
  101492. /**
  101493. * Particle emitter emitting particles from the inside of a cylinder.
  101494. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  101495. */
  101496. export class CylinderParticleEmitter implements IParticleEmitterType {
  101497. /**
  101498. * The radius of the emission cylinder.
  101499. */
  101500. radius: number;
  101501. /**
  101502. * The height of the emission cylinder.
  101503. */
  101504. height: number;
  101505. /**
  101506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101507. */
  101508. radiusRange: number;
  101509. /**
  101510. * How much to randomize the particle direction [0-1].
  101511. */
  101512. directionRandomizer: number;
  101513. /**
  101514. * Creates a new instance CylinderParticleEmitter
  101515. * @param radius the radius of the emission cylinder (1 by default)
  101516. * @param height the height of the emission cylinder (1 by default)
  101517. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101518. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101519. */
  101520. constructor(
  101521. /**
  101522. * The radius of the emission cylinder.
  101523. */
  101524. radius?: number,
  101525. /**
  101526. * The height of the emission cylinder.
  101527. */
  101528. height?: number,
  101529. /**
  101530. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101531. */
  101532. radiusRange?: number,
  101533. /**
  101534. * How much to randomize the particle direction [0-1].
  101535. */
  101536. directionRandomizer?: number);
  101537. /**
  101538. * Called by the particle System when the direction is computed for the created particle.
  101539. * @param worldMatrix is the world matrix of the particle system
  101540. * @param directionToUpdate is the direction vector to update with the result
  101541. * @param particle is the particle we are computed the direction for
  101542. * @param isLocal defines if the direction should be set in local space
  101543. */
  101544. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101545. /**
  101546. * Called by the particle System when the position is computed for the created particle.
  101547. * @param worldMatrix is the world matrix of the particle system
  101548. * @param positionToUpdate is the position vector to update with the result
  101549. * @param particle is the particle we are computed the position for
  101550. * @param isLocal defines if the position should be set in local space
  101551. */
  101552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101553. /**
  101554. * Clones the current emitter and returns a copy of it
  101555. * @returns the new emitter
  101556. */
  101557. clone(): CylinderParticleEmitter;
  101558. /**
  101559. * Called by the GPUParticleSystem to setup the update shader
  101560. * @param effect defines the update shader
  101561. */
  101562. applyToShader(effect: Effect): void;
  101563. /**
  101564. * Returns a string to use to update the GPU particles update shader
  101565. * @returns a string containng the defines string
  101566. */
  101567. getEffectDefines(): string;
  101568. /**
  101569. * Returns the string "CylinderParticleEmitter"
  101570. * @returns a string containing the class name
  101571. */
  101572. getClassName(): string;
  101573. /**
  101574. * Serializes the particle system to a JSON object.
  101575. * @returns the JSON object
  101576. */
  101577. serialize(): any;
  101578. /**
  101579. * Parse properties from a JSON object
  101580. * @param serializationObject defines the JSON object
  101581. */
  101582. parse(serializationObject: any): void;
  101583. }
  101584. /**
  101585. * Particle emitter emitting particles from the inside of a cylinder.
  101586. * It emits the particles randomly between two vectors.
  101587. */
  101588. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  101589. /**
  101590. * The min limit of the emission direction.
  101591. */
  101592. direction1: Vector3;
  101593. /**
  101594. * The max limit of the emission direction.
  101595. */
  101596. direction2: Vector3;
  101597. /**
  101598. * Creates a new instance CylinderDirectedParticleEmitter
  101599. * @param radius the radius of the emission cylinder (1 by default)
  101600. * @param height the height of the emission cylinder (1 by default)
  101601. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101602. * @param direction1 the min limit of the emission direction (up vector by default)
  101603. * @param direction2 the max limit of the emission direction (up vector by default)
  101604. */
  101605. constructor(radius?: number, height?: number, radiusRange?: number,
  101606. /**
  101607. * The min limit of the emission direction.
  101608. */
  101609. direction1?: Vector3,
  101610. /**
  101611. * The max limit of the emission direction.
  101612. */
  101613. direction2?: Vector3);
  101614. /**
  101615. * Called by the particle System when the direction is computed for the created particle.
  101616. * @param worldMatrix is the world matrix of the particle system
  101617. * @param directionToUpdate is the direction vector to update with the result
  101618. * @param particle is the particle we are computed the direction for
  101619. */
  101620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101621. /**
  101622. * Clones the current emitter and returns a copy of it
  101623. * @returns the new emitter
  101624. */
  101625. clone(): CylinderDirectedParticleEmitter;
  101626. /**
  101627. * Called by the GPUParticleSystem to setup the update shader
  101628. * @param effect defines the update shader
  101629. */
  101630. applyToShader(effect: Effect): void;
  101631. /**
  101632. * Returns a string to use to update the GPU particles update shader
  101633. * @returns a string containng the defines string
  101634. */
  101635. getEffectDefines(): string;
  101636. /**
  101637. * Returns the string "CylinderDirectedParticleEmitter"
  101638. * @returns a string containing the class name
  101639. */
  101640. getClassName(): string;
  101641. /**
  101642. * Serializes the particle system to a JSON object.
  101643. * @returns the JSON object
  101644. */
  101645. serialize(): any;
  101646. /**
  101647. * Parse properties from a JSON object
  101648. * @param serializationObject defines the JSON object
  101649. */
  101650. parse(serializationObject: any): void;
  101651. }
  101652. }
  101653. declare module BABYLON {
  101654. /**
  101655. * Particle emitter emitting particles from the inside of a hemisphere.
  101656. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101657. */
  101658. export class HemisphericParticleEmitter implements IParticleEmitterType {
  101659. /**
  101660. * The radius of the emission hemisphere.
  101661. */
  101662. radius: number;
  101663. /**
  101664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101665. */
  101666. radiusRange: number;
  101667. /**
  101668. * How much to randomize the particle direction [0-1].
  101669. */
  101670. directionRandomizer: number;
  101671. /**
  101672. * Creates a new instance HemisphericParticleEmitter
  101673. * @param radius the radius of the emission hemisphere (1 by default)
  101674. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101676. */
  101677. constructor(
  101678. /**
  101679. * The radius of the emission hemisphere.
  101680. */
  101681. radius?: number,
  101682. /**
  101683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101684. */
  101685. radiusRange?: number,
  101686. /**
  101687. * How much to randomize the particle direction [0-1].
  101688. */
  101689. directionRandomizer?: number);
  101690. /**
  101691. * Called by the particle System when the direction is computed for the created particle.
  101692. * @param worldMatrix is the world matrix of the particle system
  101693. * @param directionToUpdate is the direction vector to update with the result
  101694. * @param particle is the particle we are computed the direction for
  101695. * @param isLocal defines if the direction should be set in local space
  101696. */
  101697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101698. /**
  101699. * Called by the particle System when the position is computed for the created particle.
  101700. * @param worldMatrix is the world matrix of the particle system
  101701. * @param positionToUpdate is the position vector to update with the result
  101702. * @param particle is the particle we are computed the position for
  101703. * @param isLocal defines if the position should be set in local space
  101704. */
  101705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101706. /**
  101707. * Clones the current emitter and returns a copy of it
  101708. * @returns the new emitter
  101709. */
  101710. clone(): HemisphericParticleEmitter;
  101711. /**
  101712. * Called by the GPUParticleSystem to setup the update shader
  101713. * @param effect defines the update shader
  101714. */
  101715. applyToShader(effect: Effect): void;
  101716. /**
  101717. * Returns a string to use to update the GPU particles update shader
  101718. * @returns a string containng the defines string
  101719. */
  101720. getEffectDefines(): string;
  101721. /**
  101722. * Returns the string "HemisphericParticleEmitter"
  101723. * @returns a string containing the class name
  101724. */
  101725. getClassName(): string;
  101726. /**
  101727. * Serializes the particle system to a JSON object.
  101728. * @returns the JSON object
  101729. */
  101730. serialize(): any;
  101731. /**
  101732. * Parse properties from a JSON object
  101733. * @param serializationObject defines the JSON object
  101734. */
  101735. parse(serializationObject: any): void;
  101736. }
  101737. }
  101738. declare module BABYLON {
  101739. /**
  101740. * Particle emitter emitting particles from a point.
  101741. * It emits the particles randomly between 2 given directions.
  101742. */
  101743. export class PointParticleEmitter implements IParticleEmitterType {
  101744. /**
  101745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101746. */
  101747. direction1: Vector3;
  101748. /**
  101749. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101750. */
  101751. direction2: Vector3;
  101752. /**
  101753. * Creates a new instance PointParticleEmitter
  101754. */
  101755. constructor();
  101756. /**
  101757. * Called by the particle System when the direction is computed for the created particle.
  101758. * @param worldMatrix is the world matrix of the particle system
  101759. * @param directionToUpdate is the direction vector to update with the result
  101760. * @param particle is the particle we are computed the direction for
  101761. * @param isLocal defines if the direction should be set in local space
  101762. */
  101763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101764. /**
  101765. * Called by the particle System when the position is computed for the created particle.
  101766. * @param worldMatrix is the world matrix of the particle system
  101767. * @param positionToUpdate is the position vector to update with the result
  101768. * @param particle is the particle we are computed the position for
  101769. * @param isLocal defines if the position should be set in local space
  101770. */
  101771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101772. /**
  101773. * Clones the current emitter and returns a copy of it
  101774. * @returns the new emitter
  101775. */
  101776. clone(): PointParticleEmitter;
  101777. /**
  101778. * Called by the GPUParticleSystem to setup the update shader
  101779. * @param effect defines the update shader
  101780. */
  101781. applyToShader(effect: Effect): void;
  101782. /**
  101783. * Returns a string to use to update the GPU particles update shader
  101784. * @returns a string containng the defines string
  101785. */
  101786. getEffectDefines(): string;
  101787. /**
  101788. * Returns the string "PointParticleEmitter"
  101789. * @returns a string containing the class name
  101790. */
  101791. getClassName(): string;
  101792. /**
  101793. * Serializes the particle system to a JSON object.
  101794. * @returns the JSON object
  101795. */
  101796. serialize(): any;
  101797. /**
  101798. * Parse properties from a JSON object
  101799. * @param serializationObject defines the JSON object
  101800. */
  101801. parse(serializationObject: any): void;
  101802. }
  101803. }
  101804. declare module BABYLON {
  101805. /**
  101806. * Particle emitter emitting particles from the inside of a sphere.
  101807. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  101808. */
  101809. export class SphereParticleEmitter implements IParticleEmitterType {
  101810. /**
  101811. * The radius of the emission sphere.
  101812. */
  101813. radius: number;
  101814. /**
  101815. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101816. */
  101817. radiusRange: number;
  101818. /**
  101819. * How much to randomize the particle direction [0-1].
  101820. */
  101821. directionRandomizer: number;
  101822. /**
  101823. * Creates a new instance SphereParticleEmitter
  101824. * @param radius the radius of the emission sphere (1 by default)
  101825. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101826. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101827. */
  101828. constructor(
  101829. /**
  101830. * The radius of the emission sphere.
  101831. */
  101832. radius?: number,
  101833. /**
  101834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101835. */
  101836. radiusRange?: number,
  101837. /**
  101838. * How much to randomize the particle direction [0-1].
  101839. */
  101840. directionRandomizer?: number);
  101841. /**
  101842. * Called by the particle System when the direction is computed for the created particle.
  101843. * @param worldMatrix is the world matrix of the particle system
  101844. * @param directionToUpdate is the direction vector to update with the result
  101845. * @param particle is the particle we are computed the direction for
  101846. * @param isLocal defines if the direction should be set in local space
  101847. */
  101848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101849. /**
  101850. * Called by the particle System when the position is computed for the created particle.
  101851. * @param worldMatrix is the world matrix of the particle system
  101852. * @param positionToUpdate is the position vector to update with the result
  101853. * @param particle is the particle we are computed the position for
  101854. * @param isLocal defines if the position should be set in local space
  101855. */
  101856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101857. /**
  101858. * Clones the current emitter and returns a copy of it
  101859. * @returns the new emitter
  101860. */
  101861. clone(): SphereParticleEmitter;
  101862. /**
  101863. * Called by the GPUParticleSystem to setup the update shader
  101864. * @param effect defines the update shader
  101865. */
  101866. applyToShader(effect: Effect): void;
  101867. /**
  101868. * Returns a string to use to update the GPU particles update shader
  101869. * @returns a string containng the defines string
  101870. */
  101871. getEffectDefines(): string;
  101872. /**
  101873. * Returns the string "SphereParticleEmitter"
  101874. * @returns a string containing the class name
  101875. */
  101876. getClassName(): string;
  101877. /**
  101878. * Serializes the particle system to a JSON object.
  101879. * @returns the JSON object
  101880. */
  101881. serialize(): any;
  101882. /**
  101883. * Parse properties from a JSON object
  101884. * @param serializationObject defines the JSON object
  101885. */
  101886. parse(serializationObject: any): void;
  101887. }
  101888. /**
  101889. * Particle emitter emitting particles from the inside of a sphere.
  101890. * It emits the particles randomly between two vectors.
  101891. */
  101892. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  101893. /**
  101894. * The min limit of the emission direction.
  101895. */
  101896. direction1: Vector3;
  101897. /**
  101898. * The max limit of the emission direction.
  101899. */
  101900. direction2: Vector3;
  101901. /**
  101902. * Creates a new instance SphereDirectedParticleEmitter
  101903. * @param radius the radius of the emission sphere (1 by default)
  101904. * @param direction1 the min limit of the emission direction (up vector by default)
  101905. * @param direction2 the max limit of the emission direction (up vector by default)
  101906. */
  101907. constructor(radius?: number,
  101908. /**
  101909. * The min limit of the emission direction.
  101910. */
  101911. direction1?: Vector3,
  101912. /**
  101913. * The max limit of the emission direction.
  101914. */
  101915. direction2?: Vector3);
  101916. /**
  101917. * Called by the particle System when the direction is computed for the created particle.
  101918. * @param worldMatrix is the world matrix of the particle system
  101919. * @param directionToUpdate is the direction vector to update with the result
  101920. * @param particle is the particle we are computed the direction for
  101921. */
  101922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101923. /**
  101924. * Clones the current emitter and returns a copy of it
  101925. * @returns the new emitter
  101926. */
  101927. clone(): SphereDirectedParticleEmitter;
  101928. /**
  101929. * Called by the GPUParticleSystem to setup the update shader
  101930. * @param effect defines the update shader
  101931. */
  101932. applyToShader(effect: Effect): void;
  101933. /**
  101934. * Returns a string to use to update the GPU particles update shader
  101935. * @returns a string containng the defines string
  101936. */
  101937. getEffectDefines(): string;
  101938. /**
  101939. * Returns the string "SphereDirectedParticleEmitter"
  101940. * @returns a string containing the class name
  101941. */
  101942. getClassName(): string;
  101943. /**
  101944. * Serializes the particle system to a JSON object.
  101945. * @returns the JSON object
  101946. */
  101947. serialize(): any;
  101948. /**
  101949. * Parse properties from a JSON object
  101950. * @param serializationObject defines the JSON object
  101951. */
  101952. parse(serializationObject: any): void;
  101953. }
  101954. }
  101955. declare module BABYLON {
  101956. /**
  101957. * Particle emitter emitting particles from a custom list of positions.
  101958. */
  101959. export class CustomParticleEmitter implements IParticleEmitterType {
  101960. /**
  101961. * Gets or sets the position generator that will create the inital position of each particle.
  101962. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101963. */
  101964. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  101965. /**
  101966. * Gets or sets the destination generator that will create the final destination of each particle.
  101967. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101968. */
  101969. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  101970. /**
  101971. * Creates a new instance CustomParticleEmitter
  101972. */
  101973. constructor();
  101974. /**
  101975. * Called by the particle System when the direction is computed for the created particle.
  101976. * @param worldMatrix is the world matrix of the particle system
  101977. * @param directionToUpdate is the direction vector to update with the result
  101978. * @param particle is the particle we are computed the direction for
  101979. * @param isLocal defines if the direction should be set in local space
  101980. */
  101981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101982. /**
  101983. * Called by the particle System when the position is computed for the created particle.
  101984. * @param worldMatrix is the world matrix of the particle system
  101985. * @param positionToUpdate is the position vector to update with the result
  101986. * @param particle is the particle we are computed the position for
  101987. * @param isLocal defines if the position should be set in local space
  101988. */
  101989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101990. /**
  101991. * Clones the current emitter and returns a copy of it
  101992. * @returns the new emitter
  101993. */
  101994. clone(): CustomParticleEmitter;
  101995. /**
  101996. * Called by the GPUParticleSystem to setup the update shader
  101997. * @param effect defines the update shader
  101998. */
  101999. applyToShader(effect: Effect): void;
  102000. /**
  102001. * Returns a string to use to update the GPU particles update shader
  102002. * @returns a string containng the defines string
  102003. */
  102004. getEffectDefines(): string;
  102005. /**
  102006. * Returns the string "PointParticleEmitter"
  102007. * @returns a string containing the class name
  102008. */
  102009. getClassName(): string;
  102010. /**
  102011. * Serializes the particle system to a JSON object.
  102012. * @returns the JSON object
  102013. */
  102014. serialize(): any;
  102015. /**
  102016. * Parse properties from a JSON object
  102017. * @param serializationObject defines the JSON object
  102018. */
  102019. parse(serializationObject: any): void;
  102020. }
  102021. }
  102022. declare module BABYLON {
  102023. /**
  102024. * Particle emitter emitting particles from the inside of a box.
  102025. * It emits the particles randomly between 2 given directions.
  102026. */
  102027. export class MeshParticleEmitter implements IParticleEmitterType {
  102028. private _indices;
  102029. private _positions;
  102030. private _normals;
  102031. private _storedNormal;
  102032. private _mesh;
  102033. /**
  102034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102035. */
  102036. direction1: Vector3;
  102037. /**
  102038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102039. */
  102040. direction2: Vector3;
  102041. /**
  102042. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  102043. */
  102044. useMeshNormalsForDirection: boolean;
  102045. /** Defines the mesh to use as source */
  102046. get mesh(): Nullable<AbstractMesh>;
  102047. set mesh(value: Nullable<AbstractMesh>);
  102048. /**
  102049. * Creates a new instance MeshParticleEmitter
  102050. * @param mesh defines the mesh to use as source
  102051. */
  102052. constructor(mesh?: Nullable<AbstractMesh>);
  102053. /**
  102054. * Called by the particle System when the direction is computed for the created particle.
  102055. * @param worldMatrix is the world matrix of the particle system
  102056. * @param directionToUpdate is the direction vector to update with the result
  102057. * @param particle is the particle we are computed the direction for
  102058. * @param isLocal defines if the direction should be set in local space
  102059. */
  102060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102061. /**
  102062. * Called by the particle System when the position is computed for the created particle.
  102063. * @param worldMatrix is the world matrix of the particle system
  102064. * @param positionToUpdate is the position vector to update with the result
  102065. * @param particle is the particle we are computed the position for
  102066. * @param isLocal defines if the position should be set in local space
  102067. */
  102068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102069. /**
  102070. * Clones the current emitter and returns a copy of it
  102071. * @returns the new emitter
  102072. */
  102073. clone(): MeshParticleEmitter;
  102074. /**
  102075. * Called by the GPUParticleSystem to setup the update shader
  102076. * @param effect defines the update shader
  102077. */
  102078. applyToShader(effect: Effect): void;
  102079. /**
  102080. * Returns a string to use to update the GPU particles update shader
  102081. * @returns a string containng the defines string
  102082. */
  102083. getEffectDefines(): string;
  102084. /**
  102085. * Returns the string "BoxParticleEmitter"
  102086. * @returns a string containing the class name
  102087. */
  102088. getClassName(): string;
  102089. /**
  102090. * Serializes the particle system to a JSON object.
  102091. * @returns the JSON object
  102092. */
  102093. serialize(): any;
  102094. /**
  102095. * Parse properties from a JSON object
  102096. * @param serializationObject defines the JSON object
  102097. * @param scene defines the hosting scene
  102098. */
  102099. parse(serializationObject: any, scene: Nullable<Scene>): void;
  102100. }
  102101. }
  102102. declare module BABYLON {
  102103. /**
  102104. * Interface representing a particle system in Babylon.js.
  102105. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  102106. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  102107. */
  102108. export interface IParticleSystem {
  102109. /**
  102110. * List of animations used by the particle system.
  102111. */
  102112. animations: Animation[];
  102113. /**
  102114. * The id of the Particle system.
  102115. */
  102116. id: string;
  102117. /**
  102118. * The name of the Particle system.
  102119. */
  102120. name: string;
  102121. /**
  102122. * The emitter represents the Mesh or position we are attaching the particle system to.
  102123. */
  102124. emitter: Nullable<AbstractMesh | Vector3>;
  102125. /**
  102126. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  102127. */
  102128. isBillboardBased: boolean;
  102129. /**
  102130. * The rendering group used by the Particle system to chose when to render.
  102131. */
  102132. renderingGroupId: number;
  102133. /**
  102134. * The layer mask we are rendering the particles through.
  102135. */
  102136. layerMask: number;
  102137. /**
  102138. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  102139. */
  102140. updateSpeed: number;
  102141. /**
  102142. * The amount of time the particle system is running (depends of the overall update speed).
  102143. */
  102144. targetStopDuration: number;
  102145. /**
  102146. * The texture used to render each particle. (this can be a spritesheet)
  102147. */
  102148. particleTexture: Nullable<BaseTexture>;
  102149. /**
  102150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  102151. */
  102152. blendMode: number;
  102153. /**
  102154. * Minimum life time of emitting particles.
  102155. */
  102156. minLifeTime: number;
  102157. /**
  102158. * Maximum life time of emitting particles.
  102159. */
  102160. maxLifeTime: number;
  102161. /**
  102162. * Minimum Size of emitting particles.
  102163. */
  102164. minSize: number;
  102165. /**
  102166. * Maximum Size of emitting particles.
  102167. */
  102168. maxSize: number;
  102169. /**
  102170. * Minimum scale of emitting particles on X axis.
  102171. */
  102172. minScaleX: number;
  102173. /**
  102174. * Maximum scale of emitting particles on X axis.
  102175. */
  102176. maxScaleX: number;
  102177. /**
  102178. * Minimum scale of emitting particles on Y axis.
  102179. */
  102180. minScaleY: number;
  102181. /**
  102182. * Maximum scale of emitting particles on Y axis.
  102183. */
  102184. maxScaleY: number;
  102185. /**
  102186. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  102187. */
  102188. color1: Color4;
  102189. /**
  102190. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  102191. */
  102192. color2: Color4;
  102193. /**
  102194. * Color the particle will have at the end of its lifetime.
  102195. */
  102196. colorDead: Color4;
  102197. /**
  102198. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  102199. */
  102200. emitRate: number;
  102201. /**
  102202. * You can use gravity if you want to give an orientation to your particles.
  102203. */
  102204. gravity: Vector3;
  102205. /**
  102206. * Minimum power of emitting particles.
  102207. */
  102208. minEmitPower: number;
  102209. /**
  102210. * Maximum power of emitting particles.
  102211. */
  102212. maxEmitPower: number;
  102213. /**
  102214. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102215. */
  102216. minAngularSpeed: number;
  102217. /**
  102218. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102219. */
  102220. maxAngularSpeed: number;
  102221. /**
  102222. * Gets or sets the minimal initial rotation in radians.
  102223. */
  102224. minInitialRotation: number;
  102225. /**
  102226. * Gets or sets the maximal initial rotation in radians.
  102227. */
  102228. maxInitialRotation: number;
  102229. /**
  102230. * The particle emitter type defines the emitter used by the particle system.
  102231. * It can be for example box, sphere, or cone...
  102232. */
  102233. particleEmitterType: Nullable<IParticleEmitterType>;
  102234. /**
  102235. * Defines the delay in milliseconds before starting the system (0 by default)
  102236. */
  102237. startDelay: number;
  102238. /**
  102239. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  102240. */
  102241. preWarmCycles: number;
  102242. /**
  102243. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  102244. */
  102245. preWarmStepOffset: number;
  102246. /**
  102247. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  102248. */
  102249. spriteCellChangeSpeed: number;
  102250. /**
  102251. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102252. */
  102253. startSpriteCellID: number;
  102254. /**
  102255. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102256. */
  102257. endSpriteCellID: number;
  102258. /**
  102259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102260. */
  102261. spriteCellWidth: number;
  102262. /**
  102263. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  102264. */
  102265. spriteCellHeight: number;
  102266. /**
  102267. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  102268. */
  102269. spriteRandomStartCell: boolean;
  102270. /**
  102271. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  102272. */
  102273. isAnimationSheetEnabled: boolean;
  102274. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  102275. translationPivot: Vector2;
  102276. /**
  102277. * Gets or sets a texture used to add random noise to particle positions
  102278. */
  102279. noiseTexture: Nullable<BaseTexture>;
  102280. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102281. noiseStrength: Vector3;
  102282. /**
  102283. * Gets or sets the billboard mode to use when isBillboardBased = true.
  102284. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  102285. */
  102286. billboardMode: number;
  102287. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  102288. limitVelocityDamping: number;
  102289. /**
  102290. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  102291. */
  102292. beginAnimationOnStart: boolean;
  102293. /**
  102294. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  102295. */
  102296. beginAnimationFrom: number;
  102297. /**
  102298. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  102299. */
  102300. beginAnimationTo: number;
  102301. /**
  102302. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  102303. */
  102304. beginAnimationLoop: boolean;
  102305. /**
  102306. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102307. */
  102308. disposeOnStop: boolean;
  102309. /**
  102310. * If you want to launch only a few particles at once, that can be done, as well.
  102311. */
  102312. manualEmitCount: number;
  102313. /**
  102314. * Specifies if the particles are updated in emitter local space or world space
  102315. */
  102316. isLocal: boolean;
  102317. /** Snippet ID if the particle system was created from the snippet server */
  102318. snippetId: string;
  102319. /** Gets or sets a matrix to use to compute projection */
  102320. defaultProjectionMatrix: Matrix;
  102321. /**
  102322. * Gets the maximum number of particles active at the same time.
  102323. * @returns The max number of active particles.
  102324. */
  102325. getCapacity(): number;
  102326. /**
  102327. * Gets the number of particles active at the same time.
  102328. * @returns The number of active particles.
  102329. */
  102330. getActiveCount(): number;
  102331. /**
  102332. * Gets if the system has been started. (Note: this will still be true after stop is called)
  102333. * @returns True if it has been started, otherwise false.
  102334. */
  102335. isStarted(): boolean;
  102336. /**
  102337. * Animates the particle system for this frame.
  102338. */
  102339. animate(): void;
  102340. /**
  102341. * Renders the particle system in its current state.
  102342. * @returns the current number of particles
  102343. */
  102344. render(): number;
  102345. /**
  102346. * Dispose the particle system and frees its associated resources.
  102347. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  102348. */
  102349. dispose(disposeTexture?: boolean): void;
  102350. /**
  102351. * An event triggered when the system is disposed
  102352. */
  102353. onDisposeObservable: Observable<IParticleSystem>;
  102354. /**
  102355. * An event triggered when the system is stopped
  102356. */
  102357. onStoppedObservable: Observable<IParticleSystem>;
  102358. /**
  102359. * Clones the particle system.
  102360. * @param name The name of the cloned object
  102361. * @param newEmitter The new emitter to use
  102362. * @returns the cloned particle system
  102363. */
  102364. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  102365. /**
  102366. * Serializes the particle system to a JSON object
  102367. * @param serializeTexture defines if the texture must be serialized as well
  102368. * @returns the JSON object
  102369. */
  102370. serialize(serializeTexture: boolean): any;
  102371. /**
  102372. * Rebuild the particle system
  102373. */
  102374. rebuild(): void;
  102375. /** Force the system to rebuild all gradients that need to be resync */
  102376. forceRefreshGradients(): void;
  102377. /**
  102378. * Starts the particle system and begins to emit
  102379. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  102380. */
  102381. start(delay?: number): void;
  102382. /**
  102383. * Stops the particle system.
  102384. */
  102385. stop(): void;
  102386. /**
  102387. * Remove all active particles
  102388. */
  102389. reset(): void;
  102390. /**
  102391. * Gets a boolean indicating that the system is stopping
  102392. * @returns true if the system is currently stopping
  102393. */
  102394. isStopping(): boolean;
  102395. /**
  102396. * Is this system ready to be used/rendered
  102397. * @return true if the system is ready
  102398. */
  102399. isReady(): boolean;
  102400. /**
  102401. * Returns the string "ParticleSystem"
  102402. * @returns a string containing the class name
  102403. */
  102404. getClassName(): string;
  102405. /**
  102406. * Gets the custom effect used to render the particles
  102407. * @param blendMode Blend mode for which the effect should be retrieved
  102408. * @returns The effect
  102409. */
  102410. getCustomEffect(blendMode: number): Nullable<Effect>;
  102411. /**
  102412. * Sets the custom effect used to render the particles
  102413. * @param effect The effect to set
  102414. * @param blendMode Blend mode for which the effect should be set
  102415. */
  102416. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  102417. /**
  102418. * Fill the defines array according to the current settings of the particle system
  102419. * @param defines Array to be updated
  102420. * @param blendMode blend mode to take into account when updating the array
  102421. */
  102422. fillDefines(defines: Array<string>, blendMode: number): void;
  102423. /**
  102424. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  102425. * @param uniforms Uniforms array to fill
  102426. * @param attributes Attributes array to fill
  102427. * @param samplers Samplers array to fill
  102428. */
  102429. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  102430. /**
  102431. * Observable that will be called just before the particles are drawn
  102432. */
  102433. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  102434. /**
  102435. * Gets the name of the particle vertex shader
  102436. */
  102437. vertexShaderName: string;
  102438. /**
  102439. * Adds a new color gradient
  102440. * @param gradient defines the gradient to use (between 0 and 1)
  102441. * @param color1 defines the color to affect to the specified gradient
  102442. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  102443. * @returns the current particle system
  102444. */
  102445. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  102446. /**
  102447. * Remove a specific color gradient
  102448. * @param gradient defines the gradient to remove
  102449. * @returns the current particle system
  102450. */
  102451. removeColorGradient(gradient: number): IParticleSystem;
  102452. /**
  102453. * Adds a new size gradient
  102454. * @param gradient defines the gradient to use (between 0 and 1)
  102455. * @param factor defines the size factor to affect to the specified gradient
  102456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102457. * @returns the current particle system
  102458. */
  102459. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102460. /**
  102461. * Remove a specific size gradient
  102462. * @param gradient defines the gradient to remove
  102463. * @returns the current particle system
  102464. */
  102465. removeSizeGradient(gradient: number): IParticleSystem;
  102466. /**
  102467. * Gets the current list of color gradients.
  102468. * You must use addColorGradient and removeColorGradient to udpate this list
  102469. * @returns the list of color gradients
  102470. */
  102471. getColorGradients(): Nullable<Array<ColorGradient>>;
  102472. /**
  102473. * Gets the current list of size gradients.
  102474. * You must use addSizeGradient and removeSizeGradient to udpate this list
  102475. * @returns the list of size gradients
  102476. */
  102477. getSizeGradients(): Nullable<Array<FactorGradient>>;
  102478. /**
  102479. * Gets the current list of angular speed gradients.
  102480. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  102481. * @returns the list of angular speed gradients
  102482. */
  102483. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  102484. /**
  102485. * Adds a new angular speed gradient
  102486. * @param gradient defines the gradient to use (between 0 and 1)
  102487. * @param factor defines the angular speed to affect to the specified gradient
  102488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102489. * @returns the current particle system
  102490. */
  102491. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102492. /**
  102493. * Remove a specific angular speed gradient
  102494. * @param gradient defines the gradient to remove
  102495. * @returns the current particle system
  102496. */
  102497. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  102498. /**
  102499. * Gets the current list of velocity gradients.
  102500. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  102501. * @returns the list of velocity gradients
  102502. */
  102503. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  102504. /**
  102505. * Adds a new velocity gradient
  102506. * @param gradient defines the gradient to use (between 0 and 1)
  102507. * @param factor defines the velocity to affect to the specified gradient
  102508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102509. * @returns the current particle system
  102510. */
  102511. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102512. /**
  102513. * Remove a specific velocity gradient
  102514. * @param gradient defines the gradient to remove
  102515. * @returns the current particle system
  102516. */
  102517. removeVelocityGradient(gradient: number): IParticleSystem;
  102518. /**
  102519. * Gets the current list of limit velocity gradients.
  102520. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  102521. * @returns the list of limit velocity gradients
  102522. */
  102523. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  102524. /**
  102525. * Adds a new limit velocity gradient
  102526. * @param gradient defines the gradient to use (between 0 and 1)
  102527. * @param factor defines the limit velocity to affect to the specified gradient
  102528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102529. * @returns the current particle system
  102530. */
  102531. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102532. /**
  102533. * Remove a specific limit velocity gradient
  102534. * @param gradient defines the gradient to remove
  102535. * @returns the current particle system
  102536. */
  102537. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  102538. /**
  102539. * Adds a new drag gradient
  102540. * @param gradient defines the gradient to use (between 0 and 1)
  102541. * @param factor defines the drag to affect to the specified gradient
  102542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102543. * @returns the current particle system
  102544. */
  102545. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102546. /**
  102547. * Remove a specific drag gradient
  102548. * @param gradient defines the gradient to remove
  102549. * @returns the current particle system
  102550. */
  102551. removeDragGradient(gradient: number): IParticleSystem;
  102552. /**
  102553. * Gets the current list of drag gradients.
  102554. * You must use addDragGradient and removeDragGradient to udpate this list
  102555. * @returns the list of drag gradients
  102556. */
  102557. getDragGradients(): Nullable<Array<FactorGradient>>;
  102558. /**
  102559. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  102560. * @param gradient defines the gradient to use (between 0 and 1)
  102561. * @param factor defines the emit rate to affect to the specified gradient
  102562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102563. * @returns the current particle system
  102564. */
  102565. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102566. /**
  102567. * Remove a specific emit rate gradient
  102568. * @param gradient defines the gradient to remove
  102569. * @returns the current particle system
  102570. */
  102571. removeEmitRateGradient(gradient: number): IParticleSystem;
  102572. /**
  102573. * Gets the current list of emit rate gradients.
  102574. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  102575. * @returns the list of emit rate gradients
  102576. */
  102577. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  102578. /**
  102579. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  102580. * @param gradient defines the gradient to use (between 0 and 1)
  102581. * @param factor defines the start size to affect to the specified gradient
  102582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102583. * @returns the current particle system
  102584. */
  102585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102586. /**
  102587. * Remove a specific start size gradient
  102588. * @param gradient defines the gradient to remove
  102589. * @returns the current particle system
  102590. */
  102591. removeStartSizeGradient(gradient: number): IParticleSystem;
  102592. /**
  102593. * Gets the current list of start size gradients.
  102594. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  102595. * @returns the list of start size gradients
  102596. */
  102597. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  102598. /**
  102599. * Adds a new life time gradient
  102600. * @param gradient defines the gradient to use (between 0 and 1)
  102601. * @param factor defines the life time factor to affect to the specified gradient
  102602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102603. * @returns the current particle system
  102604. */
  102605. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102606. /**
  102607. * Remove a specific life time gradient
  102608. * @param gradient defines the gradient to remove
  102609. * @returns the current particle system
  102610. */
  102611. removeLifeTimeGradient(gradient: number): IParticleSystem;
  102612. /**
  102613. * Gets the current list of life time gradients.
  102614. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  102615. * @returns the list of life time gradients
  102616. */
  102617. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  102618. /**
  102619. * Gets the current list of color gradients.
  102620. * You must use addColorGradient and removeColorGradient to udpate this list
  102621. * @returns the list of color gradients
  102622. */
  102623. getColorGradients(): Nullable<Array<ColorGradient>>;
  102624. /**
  102625. * Adds a new ramp gradient used to remap particle colors
  102626. * @param gradient defines the gradient to use (between 0 and 1)
  102627. * @param color defines the color to affect to the specified gradient
  102628. * @returns the current particle system
  102629. */
  102630. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  102631. /**
  102632. * Gets the current list of ramp gradients.
  102633. * You must use addRampGradient and removeRampGradient to udpate this list
  102634. * @returns the list of ramp gradients
  102635. */
  102636. getRampGradients(): Nullable<Array<Color3Gradient>>;
  102637. /** Gets or sets a boolean indicating that ramp gradients must be used
  102638. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  102639. */
  102640. useRampGradients: boolean;
  102641. /**
  102642. * Adds a new color remap gradient
  102643. * @param gradient defines the gradient to use (between 0 and 1)
  102644. * @param min defines the color remap minimal range
  102645. * @param max defines the color remap maximal range
  102646. * @returns the current particle system
  102647. */
  102648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102649. /**
  102650. * Gets the current list of color remap gradients.
  102651. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102652. * @returns the list of color remap gradients
  102653. */
  102654. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  102655. /**
  102656. * Adds a new alpha remap gradient
  102657. * @param gradient defines the gradient to use (between 0 and 1)
  102658. * @param min defines the alpha remap minimal range
  102659. * @param max defines the alpha remap maximal range
  102660. * @returns the current particle system
  102661. */
  102662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102663. /**
  102664. * Gets the current list of alpha remap gradients.
  102665. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102666. * @returns the list of alpha remap gradients
  102667. */
  102668. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  102669. /**
  102670. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102673. * @returns the emitter
  102674. */
  102675. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  102676. /**
  102677. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  102678. * @param radius The radius of the hemisphere to emit from
  102679. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102680. * @returns the emitter
  102681. */
  102682. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  102683. /**
  102684. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  102685. * @param radius The radius of the sphere to emit from
  102686. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102687. * @returns the emitter
  102688. */
  102689. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  102690. /**
  102691. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  102692. * @param radius The radius of the sphere to emit from
  102693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  102694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  102695. * @returns the emitter
  102696. */
  102697. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102698. /**
  102699. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  102700. * @param radius The radius of the emission cylinder
  102701. * @param height The height of the emission cylinder
  102702. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  102703. * @param directionRandomizer How much to randomize the particle direction [0-1]
  102704. * @returns the emitter
  102705. */
  102706. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  102707. /**
  102708. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  102709. * @param radius The radius of the cylinder to emit from
  102710. * @param height The height of the emission cylinder
  102711. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  102713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  102714. * @returns the emitter
  102715. */
  102716. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102717. /**
  102718. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  102719. * @param radius The radius of the cone to emit from
  102720. * @param angle The base angle of the cone
  102721. * @returns the emitter
  102722. */
  102723. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  102724. /**
  102725. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  102726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102728. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102729. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102730. * @returns the emitter
  102731. */
  102732. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  102733. /**
  102734. * Get hosting scene
  102735. * @returns the scene
  102736. */
  102737. getScene(): Nullable<Scene>;
  102738. }
  102739. }
  102740. declare module BABYLON {
  102741. /**
  102742. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102743. */
  102744. export class ColorSplitterBlock extends NodeMaterialBlock {
  102745. /**
  102746. * Create a new ColorSplitterBlock
  102747. * @param name defines the block name
  102748. */
  102749. constructor(name: string);
  102750. /**
  102751. * Gets the current class name
  102752. * @returns the class name
  102753. */
  102754. getClassName(): string;
  102755. /**
  102756. * Gets the rgba component (input)
  102757. */
  102758. get rgba(): NodeMaterialConnectionPoint;
  102759. /**
  102760. * Gets the rgb component (input)
  102761. */
  102762. get rgbIn(): NodeMaterialConnectionPoint;
  102763. /**
  102764. * Gets the rgb component (output)
  102765. */
  102766. get rgbOut(): NodeMaterialConnectionPoint;
  102767. /**
  102768. * Gets the r component (output)
  102769. */
  102770. get r(): NodeMaterialConnectionPoint;
  102771. /**
  102772. * Gets the g component (output)
  102773. */
  102774. get g(): NodeMaterialConnectionPoint;
  102775. /**
  102776. * Gets the b component (output)
  102777. */
  102778. get b(): NodeMaterialConnectionPoint;
  102779. /**
  102780. * Gets the a component (output)
  102781. */
  102782. get a(): NodeMaterialConnectionPoint;
  102783. protected _inputRename(name: string): string;
  102784. protected _outputRename(name: string): string;
  102785. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102786. }
  102787. }
  102788. declare module BABYLON {
  102789. /**
  102790. * Operations supported by the Trigonometry block
  102791. */
  102792. export enum TrigonometryBlockOperations {
  102793. /** Cos */
  102794. Cos = 0,
  102795. /** Sin */
  102796. Sin = 1,
  102797. /** Abs */
  102798. Abs = 2,
  102799. /** Exp */
  102800. Exp = 3,
  102801. /** Exp2 */
  102802. Exp2 = 4,
  102803. /** Round */
  102804. Round = 5,
  102805. /** Floor */
  102806. Floor = 6,
  102807. /** Ceiling */
  102808. Ceiling = 7,
  102809. /** Square root */
  102810. Sqrt = 8,
  102811. /** Log */
  102812. Log = 9,
  102813. /** Tangent */
  102814. Tan = 10,
  102815. /** Arc tangent */
  102816. ArcTan = 11,
  102817. /** Arc cosinus */
  102818. ArcCos = 12,
  102819. /** Arc sinus */
  102820. ArcSin = 13,
  102821. /** Fraction */
  102822. Fract = 14,
  102823. /** Sign */
  102824. Sign = 15,
  102825. /** To radians (from degrees) */
  102826. Radians = 16,
  102827. /** To degrees (from radians) */
  102828. Degrees = 17
  102829. }
  102830. /**
  102831. * Block used to apply trigonometry operation to floats
  102832. */
  102833. export class TrigonometryBlock extends NodeMaterialBlock {
  102834. /**
  102835. * Gets or sets the operation applied by the block
  102836. */
  102837. operation: TrigonometryBlockOperations;
  102838. /**
  102839. * Creates a new TrigonometryBlock
  102840. * @param name defines the block name
  102841. */
  102842. constructor(name: string);
  102843. /**
  102844. * Gets the current class name
  102845. * @returns the class name
  102846. */
  102847. getClassName(): string;
  102848. /**
  102849. * Gets the input component
  102850. */
  102851. get input(): NodeMaterialConnectionPoint;
  102852. /**
  102853. * Gets the output component
  102854. */
  102855. get output(): NodeMaterialConnectionPoint;
  102856. protected _buildBlock(state: NodeMaterialBuildState): this;
  102857. serialize(): any;
  102858. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102859. protected _dumpPropertiesCode(): string;
  102860. }
  102861. }
  102862. declare module BABYLON {
  102863. /**
  102864. * Interface used to configure the node material editor
  102865. */
  102866. export interface INodeMaterialEditorOptions {
  102867. /** Define the URl to load node editor script */
  102868. editorURL?: string;
  102869. }
  102870. /** @hidden */
  102871. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102872. NORMAL: boolean;
  102873. TANGENT: boolean;
  102874. UV1: boolean;
  102875. /** BONES */
  102876. NUM_BONE_INFLUENCERS: number;
  102877. BonesPerMesh: number;
  102878. BONETEXTURE: boolean;
  102879. /** MORPH TARGETS */
  102880. MORPHTARGETS: boolean;
  102881. MORPHTARGETS_NORMAL: boolean;
  102882. MORPHTARGETS_TANGENT: boolean;
  102883. MORPHTARGETS_UV: boolean;
  102884. NUM_MORPH_INFLUENCERS: number;
  102885. /** IMAGE PROCESSING */
  102886. IMAGEPROCESSING: boolean;
  102887. VIGNETTE: boolean;
  102888. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102889. VIGNETTEBLENDMODEOPAQUE: boolean;
  102890. TONEMAPPING: boolean;
  102891. TONEMAPPING_ACES: boolean;
  102892. CONTRAST: boolean;
  102893. EXPOSURE: boolean;
  102894. COLORCURVES: boolean;
  102895. COLORGRADING: boolean;
  102896. COLORGRADING3D: boolean;
  102897. SAMPLER3DGREENDEPTH: boolean;
  102898. SAMPLER3DBGRMAP: boolean;
  102899. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102900. /** MISC. */
  102901. BUMPDIRECTUV: number;
  102902. constructor();
  102903. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102904. }
  102905. /**
  102906. * Class used to configure NodeMaterial
  102907. */
  102908. export interface INodeMaterialOptions {
  102909. /**
  102910. * Defines if blocks should emit comments
  102911. */
  102912. emitComments: boolean;
  102913. }
  102914. /**
  102915. * Class used to create a node based material built by assembling shader blocks
  102916. */
  102917. export class NodeMaterial extends PushMaterial {
  102918. private static _BuildIdGenerator;
  102919. private _options;
  102920. private _vertexCompilationState;
  102921. private _fragmentCompilationState;
  102922. private _sharedData;
  102923. private _buildId;
  102924. private _buildWasSuccessful;
  102925. private _cachedWorldViewMatrix;
  102926. private _cachedWorldViewProjectionMatrix;
  102927. private _optimizers;
  102928. private _animationFrame;
  102929. /** Define the Url to load node editor script */
  102930. static EditorURL: string;
  102931. /** Define the Url to load snippets */
  102932. static SnippetUrl: string;
  102933. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102934. static IgnoreTexturesAtLoadTime: boolean;
  102935. private BJSNODEMATERIALEDITOR;
  102936. /** Get the inspector from bundle or global */
  102937. private _getGlobalNodeMaterialEditor;
  102938. /**
  102939. * Snippet ID if the material was created from the snippet server
  102940. */
  102941. snippetId: string;
  102942. /**
  102943. * Gets or sets data used by visual editor
  102944. * @see https://nme.babylonjs.com
  102945. */
  102946. editorData: any;
  102947. /**
  102948. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  102949. */
  102950. ignoreAlpha: boolean;
  102951. /**
  102952. * Defines the maximum number of lights that can be used in the material
  102953. */
  102954. maxSimultaneousLights: number;
  102955. /**
  102956. * Observable raised when the material is built
  102957. */
  102958. onBuildObservable: Observable<NodeMaterial>;
  102959. /**
  102960. * Gets or sets the root nodes of the material vertex shader
  102961. */
  102962. _vertexOutputNodes: NodeMaterialBlock[];
  102963. /**
  102964. * Gets or sets the root nodes of the material fragment (pixel) shader
  102965. */
  102966. _fragmentOutputNodes: NodeMaterialBlock[];
  102967. /** Gets or sets options to control the node material overall behavior */
  102968. get options(): INodeMaterialOptions;
  102969. set options(options: INodeMaterialOptions);
  102970. /**
  102971. * Default configuration related to image processing available in the standard Material.
  102972. */
  102973. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102974. /**
  102975. * Gets the image processing configuration used either in this material.
  102976. */
  102977. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102978. /**
  102979. * Sets the Default image processing configuration used either in the this material.
  102980. *
  102981. * If sets to null, the scene one is in use.
  102982. */
  102983. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102984. /**
  102985. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102986. */
  102987. attachedBlocks: NodeMaterialBlock[];
  102988. /**
  102989. * Specifies the mode of the node material
  102990. * @hidden
  102991. */
  102992. _mode: NodeMaterialModes;
  102993. /**
  102994. * Gets the mode property
  102995. */
  102996. get mode(): NodeMaterialModes;
  102997. /**
  102998. * A free comment about the material
  102999. */
  103000. comment: string;
  103001. /**
  103002. * Create a new node based material
  103003. * @param name defines the material name
  103004. * @param scene defines the hosting scene
  103005. * @param options defines creation option
  103006. */
  103007. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103008. /**
  103009. * Gets the current class name of the material e.g. "NodeMaterial"
  103010. * @returns the class name
  103011. */
  103012. getClassName(): string;
  103013. /**
  103014. * Keep track of the image processing observer to allow dispose and replace.
  103015. */
  103016. private _imageProcessingObserver;
  103017. /**
  103018. * Attaches a new image processing configuration to the Standard Material.
  103019. * @param configuration
  103020. */
  103021. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103022. /**
  103023. * Get a block by its name
  103024. * @param name defines the name of the block to retrieve
  103025. * @returns the required block or null if not found
  103026. */
  103027. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103028. /**
  103029. * Get a block by its name
  103030. * @param predicate defines the predicate used to find the good candidate
  103031. * @returns the required block or null if not found
  103032. */
  103033. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103034. /**
  103035. * Get an input block by its name
  103036. * @param predicate defines the predicate used to find the good candidate
  103037. * @returns the required input block or null if not found
  103038. */
  103039. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103040. /**
  103041. * Gets the list of input blocks attached to this material
  103042. * @returns an array of InputBlocks
  103043. */
  103044. getInputBlocks(): InputBlock[];
  103045. /**
  103046. * Adds a new optimizer to the list of optimizers
  103047. * @param optimizer defines the optimizers to add
  103048. * @returns the current material
  103049. */
  103050. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103051. /**
  103052. * Remove an optimizer from the list of optimizers
  103053. * @param optimizer defines the optimizers to remove
  103054. * @returns the current material
  103055. */
  103056. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103057. /**
  103058. * Add a new block to the list of output nodes
  103059. * @param node defines the node to add
  103060. * @returns the current material
  103061. */
  103062. addOutputNode(node: NodeMaterialBlock): this;
  103063. /**
  103064. * Remove a block from the list of root nodes
  103065. * @param node defines the node to remove
  103066. * @returns the current material
  103067. */
  103068. removeOutputNode(node: NodeMaterialBlock): this;
  103069. private _addVertexOutputNode;
  103070. private _removeVertexOutputNode;
  103071. private _addFragmentOutputNode;
  103072. private _removeFragmentOutputNode;
  103073. /**
  103074. * Specifies if the material will require alpha blending
  103075. * @returns a boolean specifying if alpha blending is needed
  103076. */
  103077. needAlphaBlending(): boolean;
  103078. /**
  103079. * Specifies if this material should be rendered in alpha test mode
  103080. * @returns a boolean specifying if an alpha test is needed.
  103081. */
  103082. needAlphaTesting(): boolean;
  103083. private _initializeBlock;
  103084. private _resetDualBlocks;
  103085. /**
  103086. * Remove a block from the current node material
  103087. * @param block defines the block to remove
  103088. */
  103089. removeBlock(block: NodeMaterialBlock): void;
  103090. /**
  103091. * Build the material and generates the inner effect
  103092. * @param verbose defines if the build should log activity
  103093. */
  103094. build(verbose?: boolean): void;
  103095. /**
  103096. * Runs an otpimization phase to try to improve the shader code
  103097. */
  103098. optimize(): void;
  103099. private _prepareDefinesForAttributes;
  103100. /**
  103101. * Create a post process from the material
  103102. * @param camera The camera to apply the render pass to.
  103103. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103105. * @param engine The engine which the post process will be applied. (default: current engine)
  103106. * @param reusable If the post process can be reused on the same frame. (default: false)
  103107. * @param textureType Type of textures used when performing the post process. (default: 0)
  103108. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103109. * @returns the post process created
  103110. */
  103111. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103112. /**
  103113. * Create the post process effect from the material
  103114. * @param postProcess The post process to create the effect for
  103115. */
  103116. createEffectForPostProcess(postProcess: PostProcess): void;
  103117. private _createEffectForPostProcess;
  103118. /**
  103119. * Create a new procedural texture based on this node material
  103120. * @param size defines the size of the texture
  103121. * @param scene defines the hosting scene
  103122. * @returns the new procedural texture attached to this node material
  103123. */
  103124. createProceduralTexture(size: number | {
  103125. width: number;
  103126. height: number;
  103127. layers?: number;
  103128. }, scene: Scene): Nullable<ProceduralTexture>;
  103129. private _createEffectForParticles;
  103130. private _checkInternals;
  103131. /**
  103132. * Create the effect to be used as the custom effect for a particle system
  103133. * @param particleSystem Particle system to create the effect for
  103134. * @param onCompiled defines a function to call when the effect creation is successful
  103135. * @param onError defines a function to call when the effect creation has failed
  103136. */
  103137. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103138. private _processDefines;
  103139. /**
  103140. * Get if the submesh is ready to be used and all its information available.
  103141. * Child classes can use it to update shaders
  103142. * @param mesh defines the mesh to check
  103143. * @param subMesh defines which submesh to check
  103144. * @param useInstances specifies that instances should be used
  103145. * @returns a boolean indicating that the submesh is ready or not
  103146. */
  103147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103148. /**
  103149. * Get a string representing the shaders built by the current node graph
  103150. */
  103151. get compiledShaders(): string;
  103152. /**
  103153. * Binds the world matrix to the material
  103154. * @param world defines the world transformation matrix
  103155. */
  103156. bindOnlyWorldMatrix(world: Matrix): void;
  103157. /**
  103158. * Binds the submesh to this material by preparing the effect and shader to draw
  103159. * @param world defines the world transformation matrix
  103160. * @param mesh defines the mesh containing the submesh
  103161. * @param subMesh defines the submesh to bind the material to
  103162. */
  103163. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103164. /**
  103165. * Gets the active textures from the material
  103166. * @returns an array of textures
  103167. */
  103168. getActiveTextures(): BaseTexture[];
  103169. /**
  103170. * Gets the list of texture blocks
  103171. * @returns an array of texture blocks
  103172. */
  103173. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103174. /**
  103175. * Specifies if the material uses a texture
  103176. * @param texture defines the texture to check against the material
  103177. * @returns a boolean specifying if the material uses the texture
  103178. */
  103179. hasTexture(texture: BaseTexture): boolean;
  103180. /**
  103181. * Disposes the material
  103182. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103183. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103184. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103185. */
  103186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103187. /** Creates the node editor window. */
  103188. private _createNodeEditor;
  103189. /**
  103190. * Launch the node material editor
  103191. * @param config Define the configuration of the editor
  103192. * @return a promise fulfilled when the node editor is visible
  103193. */
  103194. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103195. /**
  103196. * Clear the current material
  103197. */
  103198. clear(): void;
  103199. /**
  103200. * Clear the current material and set it to a default state
  103201. */
  103202. setToDefault(): void;
  103203. /**
  103204. * Clear the current material and set it to a default state for post process
  103205. */
  103206. setToDefaultPostProcess(): void;
  103207. /**
  103208. * Clear the current material and set it to a default state for procedural texture
  103209. */
  103210. setToDefaultProceduralTexture(): void;
  103211. /**
  103212. * Clear the current material and set it to a default state for particle
  103213. */
  103214. setToDefaultParticle(): void;
  103215. /**
  103216. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103217. * @param url defines the url to load from
  103218. * @returns a promise that will fullfil when the material is fully loaded
  103219. */
  103220. loadAsync(url: string): Promise<void>;
  103221. private _gatherBlocks;
  103222. /**
  103223. * Generate a string containing the code declaration required to create an equivalent of this material
  103224. * @returns a string
  103225. */
  103226. generateCode(): string;
  103227. /**
  103228. * Serializes this material in a JSON representation
  103229. * @returns the serialized material object
  103230. */
  103231. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103232. private _restoreConnections;
  103233. /**
  103234. * Clear the current graph and load a new one from a serialization object
  103235. * @param source defines the JSON representation of the material
  103236. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103237. * @param merge defines whether or not the source must be merged or replace the current content
  103238. */
  103239. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103240. /**
  103241. * Makes a duplicate of the current material.
  103242. * @param name - name to use for the new material.
  103243. */
  103244. clone(name: string): NodeMaterial;
  103245. /**
  103246. * Creates a node material from parsed material data
  103247. * @param source defines the JSON representation of the material
  103248. * @param scene defines the hosting scene
  103249. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103250. * @returns a new node material
  103251. */
  103252. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103253. /**
  103254. * Creates a node material from a snippet saved in a remote file
  103255. * @param name defines the name of the material to create
  103256. * @param url defines the url to load from
  103257. * @param scene defines the hosting scene
  103258. * @returns a promise that will resolve to the new node material
  103259. */
  103260. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103261. /**
  103262. * Creates a node material from a snippet saved by the node material editor
  103263. * @param snippetId defines the snippet to load
  103264. * @param scene defines the hosting scene
  103265. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103266. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103267. * @returns a promise that will resolve to the new node material
  103268. */
  103269. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103270. /**
  103271. * Creates a new node material set to default basic configuration
  103272. * @param name defines the name of the material
  103273. * @param scene defines the hosting scene
  103274. * @returns a new NodeMaterial
  103275. */
  103276. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103277. }
  103278. }
  103279. declare module BABYLON {
  103280. interface ThinEngine {
  103281. /**
  103282. * Unbind a list of render target textures from the webGL context
  103283. * This is used only when drawBuffer extension or webGL2 are active
  103284. * @param textures defines the render target textures to unbind
  103285. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103286. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103287. */
  103288. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103289. /**
  103290. * Create a multi render target texture
  103291. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103292. * @param size defines the size of the texture
  103293. * @param options defines the creation options
  103294. * @returns the cube texture as an InternalTexture
  103295. */
  103296. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103297. /**
  103298. * Update the sample count for a given multiple render target texture
  103299. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103300. * @param textures defines the textures to update
  103301. * @param samples defines the sample count to set
  103302. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103303. */
  103304. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103305. /**
  103306. * Select a subsets of attachments to draw to.
  103307. * @param attachments gl attachments
  103308. */
  103309. bindAttachments(attachments: number[]): void;
  103310. /**
  103311. * Creates a layout object to draw/clear on specific textures in a MRT
  103312. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103313. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103314. */
  103315. buildTextureLayout(textureStatus: boolean[]): number[];
  103316. /**
  103317. * Restores the webgl state to only draw on the main color attachment
  103318. */
  103319. restoreSingleAttachment(): void;
  103320. /**
  103321. * Clears a list of attachments
  103322. * @param attachments list of the attachments
  103323. * @param colorMain clear color for the main attachment (the first one)
  103324. * @param colorOthers clear color for the other attachments
  103325. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  103326. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  103327. */
  103328. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  103329. }
  103330. }
  103331. declare module BABYLON {
  103332. /**
  103333. * Creation options of the multi render target texture.
  103334. */
  103335. export interface IMultiRenderTargetOptions {
  103336. /**
  103337. * Define if the texture needs to create mip maps after render.
  103338. */
  103339. generateMipMaps?: boolean;
  103340. /**
  103341. * Define the types of all the draw buffers we want to create
  103342. */
  103343. types?: number[];
  103344. /**
  103345. * Define the sampling modes of all the draw buffers we want to create
  103346. */
  103347. samplingModes?: number[];
  103348. /**
  103349. * Define if a depth buffer is required
  103350. */
  103351. generateDepthBuffer?: boolean;
  103352. /**
  103353. * Define if a stencil buffer is required
  103354. */
  103355. generateStencilBuffer?: boolean;
  103356. /**
  103357. * Define if a depth texture is required instead of a depth buffer
  103358. */
  103359. generateDepthTexture?: boolean;
  103360. /**
  103361. * Define the number of desired draw buffers
  103362. */
  103363. textureCount?: number;
  103364. /**
  103365. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103366. */
  103367. doNotChangeAspectRatio?: boolean;
  103368. /**
  103369. * Define the default type of the buffers we are creating
  103370. */
  103371. defaultType?: number;
  103372. }
  103373. /**
  103374. * A multi render target, like a render target provides the ability to render to a texture.
  103375. * Unlike the render target, it can render to several draw buffers in one draw.
  103376. * This is specially interesting in deferred rendering or for any effects requiring more than
  103377. * just one color from a single pass.
  103378. */
  103379. export class MultiRenderTarget extends RenderTargetTexture {
  103380. private _internalTextures;
  103381. private _textures;
  103382. private _multiRenderTargetOptions;
  103383. private _count;
  103384. /**
  103385. * Get if draw buffers are currently supported by the used hardware and browser.
  103386. */
  103387. get isSupported(): boolean;
  103388. /**
  103389. * Get the list of textures generated by the multi render target.
  103390. */
  103391. get textures(): Texture[];
  103392. /**
  103393. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103394. */
  103395. get count(): number;
  103396. /**
  103397. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103398. */
  103399. get depthTexture(): Texture;
  103400. /**
  103401. * Set the wrapping mode on U of all the textures we are rendering to.
  103402. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103403. */
  103404. set wrapU(wrap: number);
  103405. /**
  103406. * Set the wrapping mode on V of all the textures we are rendering to.
  103407. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103408. */
  103409. set wrapV(wrap: number);
  103410. /**
  103411. * Instantiate a new multi render target texture.
  103412. * A multi render target, like a render target provides the ability to render to a texture.
  103413. * Unlike the render target, it can render to several draw buffers in one draw.
  103414. * This is specially interesting in deferred rendering or for any effects requiring more than
  103415. * just one color from a single pass.
  103416. * @param name Define the name of the texture
  103417. * @param size Define the size of the buffers to render to
  103418. * @param count Define the number of target we are rendering into
  103419. * @param scene Define the scene the texture belongs to
  103420. * @param options Define the options used to create the multi render target
  103421. */
  103422. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103423. private _initTypes;
  103424. /** @hidden */
  103425. _rebuild(forceFullRebuild?: boolean): void;
  103426. private _createInternalTextures;
  103427. private _createTextures;
  103428. /**
  103429. * Replaces a texture within the MRT.
  103430. * @param texture The new texture to insert in the MRT
  103431. * @param index The index of the texture to replace
  103432. */
  103433. replaceTexture(texture: Texture, index: number): void;
  103434. /**
  103435. * Define the number of samples used if MSAA is enabled.
  103436. */
  103437. get samples(): number;
  103438. set samples(value: number);
  103439. /**
  103440. * Resize all the textures in the multi render target.
  103441. * Be careful as it will recreate all the data in the new texture.
  103442. * @param size Define the new size
  103443. */
  103444. resize(size: any): void;
  103445. /**
  103446. * Changes the number of render targets in this MRT
  103447. * Be careful as it will recreate all the data in the new texture.
  103448. * @param count new texture count
  103449. * @param options Specifies texture types and sampling modes for new textures
  103450. */
  103451. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103452. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103453. /**
  103454. * Dispose the render targets and their associated resources
  103455. */
  103456. dispose(): void;
  103457. /**
  103458. * Release all the underlying texture used as draw buffers.
  103459. */
  103460. releaseInternalTextures(): void;
  103461. }
  103462. }
  103463. declare module BABYLON {
  103464. /** @hidden */
  103465. export var imageProcessingPixelShader: {
  103466. name: string;
  103467. shader: string;
  103468. };
  103469. }
  103470. declare module BABYLON {
  103471. /**
  103472. * ImageProcessingPostProcess
  103473. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103474. */
  103475. export class ImageProcessingPostProcess extends PostProcess {
  103476. /**
  103477. * Default configuration related to image processing available in the PBR Material.
  103478. */
  103479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103480. /**
  103481. * Gets the image processing configuration used either in this material.
  103482. */
  103483. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103484. /**
  103485. * Sets the Default image processing configuration used either in the this material.
  103486. *
  103487. * If sets to null, the scene one is in use.
  103488. */
  103489. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103490. /**
  103491. * Keep track of the image processing observer to allow dispose and replace.
  103492. */
  103493. private _imageProcessingObserver;
  103494. /**
  103495. * Attaches a new image processing configuration to the PBR Material.
  103496. * @param configuration
  103497. */
  103498. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103499. /**
  103500. * If the post process is supported.
  103501. */
  103502. get isSupported(): boolean;
  103503. /**
  103504. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103505. */
  103506. get colorCurves(): Nullable<ColorCurves>;
  103507. /**
  103508. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103509. */
  103510. set colorCurves(value: Nullable<ColorCurves>);
  103511. /**
  103512. * Gets wether the color curves effect is enabled.
  103513. */
  103514. get colorCurvesEnabled(): boolean;
  103515. /**
  103516. * Sets wether the color curves effect is enabled.
  103517. */
  103518. set colorCurvesEnabled(value: boolean);
  103519. /**
  103520. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103521. */
  103522. get colorGradingTexture(): Nullable<BaseTexture>;
  103523. /**
  103524. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103525. */
  103526. set colorGradingTexture(value: Nullable<BaseTexture>);
  103527. /**
  103528. * Gets wether the color grading effect is enabled.
  103529. */
  103530. get colorGradingEnabled(): boolean;
  103531. /**
  103532. * Gets wether the color grading effect is enabled.
  103533. */
  103534. set colorGradingEnabled(value: boolean);
  103535. /**
  103536. * Gets exposure used in the effect.
  103537. */
  103538. get exposure(): number;
  103539. /**
  103540. * Sets exposure used in the effect.
  103541. */
  103542. set exposure(value: number);
  103543. /**
  103544. * Gets wether tonemapping is enabled or not.
  103545. */
  103546. get toneMappingEnabled(): boolean;
  103547. /**
  103548. * Sets wether tonemapping is enabled or not
  103549. */
  103550. set toneMappingEnabled(value: boolean);
  103551. /**
  103552. * Gets the type of tone mapping effect.
  103553. */
  103554. get toneMappingType(): number;
  103555. /**
  103556. * Sets the type of tone mapping effect.
  103557. */
  103558. set toneMappingType(value: number);
  103559. /**
  103560. * Gets contrast used in the effect.
  103561. */
  103562. get contrast(): number;
  103563. /**
  103564. * Sets contrast used in the effect.
  103565. */
  103566. set contrast(value: number);
  103567. /**
  103568. * Gets Vignette stretch size.
  103569. */
  103570. get vignetteStretch(): number;
  103571. /**
  103572. * Sets Vignette stretch size.
  103573. */
  103574. set vignetteStretch(value: number);
  103575. /**
  103576. * Gets Vignette centre X Offset.
  103577. */
  103578. get vignetteCentreX(): number;
  103579. /**
  103580. * Sets Vignette centre X Offset.
  103581. */
  103582. set vignetteCentreX(value: number);
  103583. /**
  103584. * Gets Vignette centre Y Offset.
  103585. */
  103586. get vignetteCentreY(): number;
  103587. /**
  103588. * Sets Vignette centre Y Offset.
  103589. */
  103590. set vignetteCentreY(value: number);
  103591. /**
  103592. * Gets Vignette weight or intensity of the vignette effect.
  103593. */
  103594. get vignetteWeight(): number;
  103595. /**
  103596. * Sets Vignette weight or intensity of the vignette effect.
  103597. */
  103598. set vignetteWeight(value: number);
  103599. /**
  103600. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103601. * if vignetteEnabled is set to true.
  103602. */
  103603. get vignetteColor(): Color4;
  103604. /**
  103605. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103606. * if vignetteEnabled is set to true.
  103607. */
  103608. set vignetteColor(value: Color4);
  103609. /**
  103610. * Gets Camera field of view used by the Vignette effect.
  103611. */
  103612. get vignetteCameraFov(): number;
  103613. /**
  103614. * Sets Camera field of view used by the Vignette effect.
  103615. */
  103616. set vignetteCameraFov(value: number);
  103617. /**
  103618. * Gets the vignette blend mode allowing different kind of effect.
  103619. */
  103620. get vignetteBlendMode(): number;
  103621. /**
  103622. * Sets the vignette blend mode allowing different kind of effect.
  103623. */
  103624. set vignetteBlendMode(value: number);
  103625. /**
  103626. * Gets wether the vignette effect is enabled.
  103627. */
  103628. get vignetteEnabled(): boolean;
  103629. /**
  103630. * Sets wether the vignette effect is enabled.
  103631. */
  103632. set vignetteEnabled(value: boolean);
  103633. private _fromLinearSpace;
  103634. /**
  103635. * Gets wether the input of the processing is in Gamma or Linear Space.
  103636. */
  103637. get fromLinearSpace(): boolean;
  103638. /**
  103639. * Sets wether the input of the processing is in Gamma or Linear Space.
  103640. */
  103641. set fromLinearSpace(value: boolean);
  103642. /**
  103643. * Defines cache preventing GC.
  103644. */
  103645. private _defines;
  103646. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103647. /**
  103648. * "ImageProcessingPostProcess"
  103649. * @returns "ImageProcessingPostProcess"
  103650. */
  103651. getClassName(): string;
  103652. /**
  103653. * @hidden
  103654. */
  103655. _updateParameters(): void;
  103656. dispose(camera?: Camera): void;
  103657. }
  103658. }
  103659. declare module BABYLON {
  103660. /**
  103661. * Interface for defining prepass effects in the prepass post-process pipeline
  103662. */
  103663. export interface PrePassEffectConfiguration {
  103664. /**
  103665. * Name of the effect
  103666. */
  103667. name: string;
  103668. /**
  103669. * Post process to attach for this effect
  103670. */
  103671. postProcess?: PostProcess;
  103672. /**
  103673. * Textures required in the MRT
  103674. */
  103675. texturesRequired: number[];
  103676. /**
  103677. * Is the effect enabled
  103678. */
  103679. enabled: boolean;
  103680. /**
  103681. * Disposes the effect configuration
  103682. */
  103683. dispose?: () => void;
  103684. /**
  103685. * Creates the associated post process
  103686. */
  103687. createPostProcess?: () => PostProcess;
  103688. }
  103689. }
  103690. declare module BABYLON {
  103691. /**
  103692. * Options to be used when creating a FresnelParameters.
  103693. */
  103694. export type IFresnelParametersCreationOptions = {
  103695. /**
  103696. * Define the color used on edges (grazing angle)
  103697. */
  103698. leftColor?: Color3;
  103699. /**
  103700. * Define the color used on center
  103701. */
  103702. rightColor?: Color3;
  103703. /**
  103704. * Define bias applied to computed fresnel term
  103705. */
  103706. bias?: number;
  103707. /**
  103708. * Defined the power exponent applied to fresnel term
  103709. */
  103710. power?: number;
  103711. /**
  103712. * Define if the fresnel effect is enable or not.
  103713. */
  103714. isEnabled?: boolean;
  103715. };
  103716. /**
  103717. * Serialized format for FresnelParameters.
  103718. */
  103719. export type IFresnelParametersSerialized = {
  103720. /**
  103721. * Define the color used on edges (grazing angle) [as an array]
  103722. */
  103723. leftColor: number[];
  103724. /**
  103725. * Define the color used on center [as an array]
  103726. */
  103727. rightColor: number[];
  103728. /**
  103729. * Define bias applied to computed fresnel term
  103730. */
  103731. bias: number;
  103732. /**
  103733. * Defined the power exponent applied to fresnel term
  103734. */
  103735. power?: number;
  103736. /**
  103737. * Define if the fresnel effect is enable or not.
  103738. */
  103739. isEnabled: boolean;
  103740. };
  103741. /**
  103742. * This represents all the required information to add a fresnel effect on a material:
  103743. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103744. */
  103745. export class FresnelParameters {
  103746. private _isEnabled;
  103747. /**
  103748. * Define if the fresnel effect is enable or not.
  103749. */
  103750. get isEnabled(): boolean;
  103751. set isEnabled(value: boolean);
  103752. /**
  103753. * Define the color used on edges (grazing angle)
  103754. */
  103755. leftColor: Color3;
  103756. /**
  103757. * Define the color used on center
  103758. */
  103759. rightColor: Color3;
  103760. /**
  103761. * Define bias applied to computed fresnel term
  103762. */
  103763. bias: number;
  103764. /**
  103765. * Defined the power exponent applied to fresnel term
  103766. */
  103767. power: number;
  103768. /**
  103769. * Creates a new FresnelParameters object.
  103770. *
  103771. * @param options provide your own settings to optionally to override defaults
  103772. */
  103773. constructor(options?: IFresnelParametersCreationOptions);
  103774. /**
  103775. * Clones the current fresnel and its valuues
  103776. * @returns a clone fresnel configuration
  103777. */
  103778. clone(): FresnelParameters;
  103779. /**
  103780. * Determines equality between FresnelParameters objects
  103781. * @param otherFresnelParameters defines the second operand
  103782. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  103783. */
  103784. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  103785. /**
  103786. * Serializes the current fresnel parameters to a JSON representation.
  103787. * @return the JSON serialization
  103788. */
  103789. serialize(): IFresnelParametersSerialized;
  103790. /**
  103791. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  103792. * @param parsedFresnelParameters Define the JSON representation
  103793. * @returns the parsed parameters
  103794. */
  103795. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  103796. }
  103797. }
  103798. declare module BABYLON {
  103799. /**
  103800. * This groups all the flags used to control the materials channel.
  103801. */
  103802. export class MaterialFlags {
  103803. private static _DiffuseTextureEnabled;
  103804. /**
  103805. * Are diffuse textures enabled in the application.
  103806. */
  103807. static get DiffuseTextureEnabled(): boolean;
  103808. static set DiffuseTextureEnabled(value: boolean);
  103809. private static _DetailTextureEnabled;
  103810. /**
  103811. * Are detail textures enabled in the application.
  103812. */
  103813. static get DetailTextureEnabled(): boolean;
  103814. static set DetailTextureEnabled(value: boolean);
  103815. private static _AmbientTextureEnabled;
  103816. /**
  103817. * Are ambient textures enabled in the application.
  103818. */
  103819. static get AmbientTextureEnabled(): boolean;
  103820. static set AmbientTextureEnabled(value: boolean);
  103821. private static _OpacityTextureEnabled;
  103822. /**
  103823. * Are opacity textures enabled in the application.
  103824. */
  103825. static get OpacityTextureEnabled(): boolean;
  103826. static set OpacityTextureEnabled(value: boolean);
  103827. private static _ReflectionTextureEnabled;
  103828. /**
  103829. * Are reflection textures enabled in the application.
  103830. */
  103831. static get ReflectionTextureEnabled(): boolean;
  103832. static set ReflectionTextureEnabled(value: boolean);
  103833. private static _EmissiveTextureEnabled;
  103834. /**
  103835. * Are emissive textures enabled in the application.
  103836. */
  103837. static get EmissiveTextureEnabled(): boolean;
  103838. static set EmissiveTextureEnabled(value: boolean);
  103839. private static _SpecularTextureEnabled;
  103840. /**
  103841. * Are specular textures enabled in the application.
  103842. */
  103843. static get SpecularTextureEnabled(): boolean;
  103844. static set SpecularTextureEnabled(value: boolean);
  103845. private static _BumpTextureEnabled;
  103846. /**
  103847. * Are bump textures enabled in the application.
  103848. */
  103849. static get BumpTextureEnabled(): boolean;
  103850. static set BumpTextureEnabled(value: boolean);
  103851. private static _LightmapTextureEnabled;
  103852. /**
  103853. * Are lightmap textures enabled in the application.
  103854. */
  103855. static get LightmapTextureEnabled(): boolean;
  103856. static set LightmapTextureEnabled(value: boolean);
  103857. private static _RefractionTextureEnabled;
  103858. /**
  103859. * Are refraction textures enabled in the application.
  103860. */
  103861. static get RefractionTextureEnabled(): boolean;
  103862. static set RefractionTextureEnabled(value: boolean);
  103863. private static _ColorGradingTextureEnabled;
  103864. /**
  103865. * Are color grading textures enabled in the application.
  103866. */
  103867. static get ColorGradingTextureEnabled(): boolean;
  103868. static set ColorGradingTextureEnabled(value: boolean);
  103869. private static _FresnelEnabled;
  103870. /**
  103871. * Are fresnels enabled in the application.
  103872. */
  103873. static get FresnelEnabled(): boolean;
  103874. static set FresnelEnabled(value: boolean);
  103875. private static _ClearCoatTextureEnabled;
  103876. /**
  103877. * Are clear coat textures enabled in the application.
  103878. */
  103879. static get ClearCoatTextureEnabled(): boolean;
  103880. static set ClearCoatTextureEnabled(value: boolean);
  103881. private static _ClearCoatBumpTextureEnabled;
  103882. /**
  103883. * Are clear coat bump textures enabled in the application.
  103884. */
  103885. static get ClearCoatBumpTextureEnabled(): boolean;
  103886. static set ClearCoatBumpTextureEnabled(value: boolean);
  103887. private static _ClearCoatTintTextureEnabled;
  103888. /**
  103889. * Are clear coat tint textures enabled in the application.
  103890. */
  103891. static get ClearCoatTintTextureEnabled(): boolean;
  103892. static set ClearCoatTintTextureEnabled(value: boolean);
  103893. private static _SheenTextureEnabled;
  103894. /**
  103895. * Are sheen textures enabled in the application.
  103896. */
  103897. static get SheenTextureEnabled(): boolean;
  103898. static set SheenTextureEnabled(value: boolean);
  103899. private static _AnisotropicTextureEnabled;
  103900. /**
  103901. * Are anisotropic textures enabled in the application.
  103902. */
  103903. static get AnisotropicTextureEnabled(): boolean;
  103904. static set AnisotropicTextureEnabled(value: boolean);
  103905. private static _ThicknessTextureEnabled;
  103906. /**
  103907. * Are thickness textures enabled in the application.
  103908. */
  103909. static get ThicknessTextureEnabled(): boolean;
  103910. static set ThicknessTextureEnabled(value: boolean);
  103911. }
  103912. }
  103913. declare module BABYLON {
  103914. /** @hidden */
  103915. export var defaultFragmentDeclaration: {
  103916. name: string;
  103917. shader: string;
  103918. };
  103919. }
  103920. declare module BABYLON {
  103921. /** @hidden */
  103922. export var sceneUboDeclaration: {
  103923. name: string;
  103924. shader: string;
  103925. };
  103926. }
  103927. declare module BABYLON {
  103928. /** @hidden */
  103929. export var meshUboDeclaration: {
  103930. name: string;
  103931. shader: string;
  103932. };
  103933. }
  103934. declare module BABYLON {
  103935. /** @hidden */
  103936. export var defaultUboDeclaration: {
  103937. name: string;
  103938. shader: string;
  103939. };
  103940. }
  103941. declare module BABYLON {
  103942. /** @hidden */
  103943. export var prePassDeclaration: {
  103944. name: string;
  103945. shader: string;
  103946. };
  103947. }
  103948. declare module BABYLON {
  103949. /** @hidden */
  103950. export var lightFragmentDeclaration: {
  103951. name: string;
  103952. shader: string;
  103953. };
  103954. }
  103955. declare module BABYLON {
  103956. /** @hidden */
  103957. export var lightUboDeclaration: {
  103958. name: string;
  103959. shader: string;
  103960. };
  103961. }
  103962. declare module BABYLON {
  103963. /** @hidden */
  103964. export var lightsFragmentFunctions: {
  103965. name: string;
  103966. shader: string;
  103967. };
  103968. }
  103969. declare module BABYLON {
  103970. /** @hidden */
  103971. export var shadowsFragmentFunctions: {
  103972. name: string;
  103973. shader: string;
  103974. };
  103975. }
  103976. declare module BABYLON {
  103977. /** @hidden */
  103978. export var fresnelFunction: {
  103979. name: string;
  103980. shader: string;
  103981. };
  103982. }
  103983. declare module BABYLON {
  103984. /** @hidden */
  103985. export var bumpFragmentMainFunctions: {
  103986. name: string;
  103987. shader: string;
  103988. };
  103989. }
  103990. declare module BABYLON {
  103991. /** @hidden */
  103992. export var bumpFragmentFunctions: {
  103993. name: string;
  103994. shader: string;
  103995. };
  103996. }
  103997. declare module BABYLON {
  103998. /** @hidden */
  103999. export var logDepthDeclaration: {
  104000. name: string;
  104001. shader: string;
  104002. };
  104003. }
  104004. declare module BABYLON {
  104005. /** @hidden */
  104006. export var fogFragmentDeclaration: {
  104007. name: string;
  104008. shader: string;
  104009. };
  104010. }
  104011. declare module BABYLON {
  104012. /** @hidden */
  104013. export var bumpFragment: {
  104014. name: string;
  104015. shader: string;
  104016. };
  104017. }
  104018. declare module BABYLON {
  104019. /** @hidden */
  104020. export var depthPrePass: {
  104021. name: string;
  104022. shader: string;
  104023. };
  104024. }
  104025. declare module BABYLON {
  104026. /** @hidden */
  104027. export var lightFragment: {
  104028. name: string;
  104029. shader: string;
  104030. };
  104031. }
  104032. declare module BABYLON {
  104033. /** @hidden */
  104034. export var logDepthFragment: {
  104035. name: string;
  104036. shader: string;
  104037. };
  104038. }
  104039. declare module BABYLON {
  104040. /** @hidden */
  104041. export var fogFragment: {
  104042. name: string;
  104043. shader: string;
  104044. };
  104045. }
  104046. declare module BABYLON {
  104047. /** @hidden */
  104048. export var defaultPixelShader: {
  104049. name: string;
  104050. shader: string;
  104051. };
  104052. }
  104053. declare module BABYLON {
  104054. /** @hidden */
  104055. export var defaultVertexDeclaration: {
  104056. name: string;
  104057. shader: string;
  104058. };
  104059. }
  104060. declare module BABYLON {
  104061. /** @hidden */
  104062. export var bonesDeclaration: {
  104063. name: string;
  104064. shader: string;
  104065. };
  104066. }
  104067. declare module BABYLON {
  104068. /** @hidden */
  104069. export var prePassVertexDeclaration: {
  104070. name: string;
  104071. shader: string;
  104072. };
  104073. }
  104074. declare module BABYLON {
  104075. /** @hidden */
  104076. export var bumpVertexDeclaration: {
  104077. name: string;
  104078. shader: string;
  104079. };
  104080. }
  104081. declare module BABYLON {
  104082. /** @hidden */
  104083. export var fogVertexDeclaration: {
  104084. name: string;
  104085. shader: string;
  104086. };
  104087. }
  104088. declare module BABYLON {
  104089. /** @hidden */
  104090. export var lightVxFragmentDeclaration: {
  104091. name: string;
  104092. shader: string;
  104093. };
  104094. }
  104095. declare module BABYLON {
  104096. /** @hidden */
  104097. export var lightVxUboDeclaration: {
  104098. name: string;
  104099. shader: string;
  104100. };
  104101. }
  104102. declare module BABYLON {
  104103. /** @hidden */
  104104. export var morphTargetsVertexGlobalDeclaration: {
  104105. name: string;
  104106. shader: string;
  104107. };
  104108. }
  104109. declare module BABYLON {
  104110. /** @hidden */
  104111. export var morphTargetsVertexDeclaration: {
  104112. name: string;
  104113. shader: string;
  104114. };
  104115. }
  104116. declare module BABYLON {
  104117. /** @hidden */
  104118. export var morphTargetsVertex: {
  104119. name: string;
  104120. shader: string;
  104121. };
  104122. }
  104123. declare module BABYLON {
  104124. /** @hidden */
  104125. export var instancesVertex: {
  104126. name: string;
  104127. shader: string;
  104128. };
  104129. }
  104130. declare module BABYLON {
  104131. /** @hidden */
  104132. export var bonesVertex: {
  104133. name: string;
  104134. shader: string;
  104135. };
  104136. }
  104137. declare module BABYLON {
  104138. /** @hidden */
  104139. export var prePassVertex: {
  104140. name: string;
  104141. shader: string;
  104142. };
  104143. }
  104144. declare module BABYLON {
  104145. /** @hidden */
  104146. export var bumpVertex: {
  104147. name: string;
  104148. shader: string;
  104149. };
  104150. }
  104151. declare module BABYLON {
  104152. /** @hidden */
  104153. export var fogVertex: {
  104154. name: string;
  104155. shader: string;
  104156. };
  104157. }
  104158. declare module BABYLON {
  104159. /** @hidden */
  104160. export var shadowsVertex: {
  104161. name: string;
  104162. shader: string;
  104163. };
  104164. }
  104165. declare module BABYLON {
  104166. /** @hidden */
  104167. export var pointCloudVertex: {
  104168. name: string;
  104169. shader: string;
  104170. };
  104171. }
  104172. declare module BABYLON {
  104173. /** @hidden */
  104174. export var logDepthVertex: {
  104175. name: string;
  104176. shader: string;
  104177. };
  104178. }
  104179. declare module BABYLON {
  104180. /** @hidden */
  104181. export var defaultVertexShader: {
  104182. name: string;
  104183. shader: string;
  104184. };
  104185. }
  104186. declare module BABYLON {
  104187. /**
  104188. * @hidden
  104189. */
  104190. export interface IMaterialDetailMapDefines {
  104191. DETAIL: boolean;
  104192. DETAILDIRECTUV: number;
  104193. DETAIL_NORMALBLENDMETHOD: number;
  104194. /** @hidden */
  104195. _areTexturesDirty: boolean;
  104196. }
  104197. /**
  104198. * Define the code related to the detail map parameters of a material
  104199. *
  104200. * Inspired from:
  104201. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  104202. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104203. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104204. */
  104205. export class DetailMapConfiguration {
  104206. private _texture;
  104207. /**
  104208. * The detail texture of the material.
  104209. */
  104210. texture: Nullable<BaseTexture>;
  104211. /**
  104212. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104213. * Bigger values mean stronger blending
  104214. */
  104215. diffuseBlendLevel: number;
  104216. /**
  104217. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104218. * Bigger values mean stronger blending. Only used with PBR materials
  104219. */
  104220. roughnessBlendLevel: number;
  104221. /**
  104222. * Defines how strong the bump effect from the detail map is
  104223. * Bigger values mean stronger effect
  104224. */
  104225. bumpLevel: number;
  104226. private _normalBlendMethod;
  104227. /**
  104228. * The method used to blend the bump and detail normals together
  104229. */
  104230. normalBlendMethod: number;
  104231. private _isEnabled;
  104232. /**
  104233. * Enable or disable the detail map on this material
  104234. */
  104235. isEnabled: boolean;
  104236. /** @hidden */
  104237. private _internalMarkAllSubMeshesAsTexturesDirty;
  104238. /** @hidden */
  104239. _markAllSubMeshesAsTexturesDirty(): void;
  104240. /**
  104241. * Instantiate a new detail map
  104242. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104243. */
  104244. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104245. /**
  104246. * Gets whether the submesh is ready to be used or not.
  104247. * @param defines the list of "defines" to update.
  104248. * @param scene defines the scene the material belongs to.
  104249. * @returns - boolean indicating that the submesh is ready or not.
  104250. */
  104251. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104252. /**
  104253. * Update the defines for detail map usage
  104254. * @param defines the list of "defines" to update.
  104255. * @param scene defines the scene the material belongs to.
  104256. */
  104257. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104258. /**
  104259. * Binds the material data.
  104260. * @param uniformBuffer defines the Uniform buffer to fill in.
  104261. * @param scene defines the scene the material belongs to.
  104262. * @param isFrozen defines whether the material is frozen or not.
  104263. */
  104264. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104265. /**
  104266. * Checks to see if a texture is used in the material.
  104267. * @param texture - Base texture to use.
  104268. * @returns - Boolean specifying if a texture is used in the material.
  104269. */
  104270. hasTexture(texture: BaseTexture): boolean;
  104271. /**
  104272. * Returns an array of the actively used textures.
  104273. * @param activeTextures Array of BaseTextures
  104274. */
  104275. getActiveTextures(activeTextures: BaseTexture[]): void;
  104276. /**
  104277. * Returns the animatable textures.
  104278. * @param animatables Array of animatable textures.
  104279. */
  104280. getAnimatables(animatables: IAnimatable[]): void;
  104281. /**
  104282. * Disposes the resources of the material.
  104283. * @param forceDisposeTextures - Forces the disposal of all textures.
  104284. */
  104285. dispose(forceDisposeTextures?: boolean): void;
  104286. /**
  104287. * Get the current class name useful for serialization or dynamic coding.
  104288. * @returns "DetailMap"
  104289. */
  104290. getClassName(): string;
  104291. /**
  104292. * Add the required uniforms to the current list.
  104293. * @param uniforms defines the current uniform list.
  104294. */
  104295. static AddUniforms(uniforms: string[]): void;
  104296. /**
  104297. * Add the required samplers to the current list.
  104298. * @param samplers defines the current sampler list.
  104299. */
  104300. static AddSamplers(samplers: string[]): void;
  104301. /**
  104302. * Add the required uniforms to the current buffer.
  104303. * @param uniformBuffer defines the current uniform buffer.
  104304. */
  104305. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104306. /**
  104307. * Makes a duplicate of the current instance into another one.
  104308. * @param detailMap define the instance where to copy the info
  104309. */
  104310. copyTo(detailMap: DetailMapConfiguration): void;
  104311. /**
  104312. * Serializes this detail map instance
  104313. * @returns - An object with the serialized instance.
  104314. */
  104315. serialize(): any;
  104316. /**
  104317. * Parses a detail map setting from a serialized object.
  104318. * @param source - Serialized object.
  104319. * @param scene Defines the scene we are parsing for
  104320. * @param rootUrl Defines the rootUrl to load from
  104321. */
  104322. parse(source: any, scene: Scene, rootUrl: string): void;
  104323. }
  104324. }
  104325. declare module BABYLON {
  104326. /** @hidden */
  104327. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104328. MAINUV1: boolean;
  104329. MAINUV2: boolean;
  104330. DIFFUSE: boolean;
  104331. DIFFUSEDIRECTUV: number;
  104332. DETAIL: boolean;
  104333. DETAILDIRECTUV: number;
  104334. DETAIL_NORMALBLENDMETHOD: number;
  104335. AMBIENT: boolean;
  104336. AMBIENTDIRECTUV: number;
  104337. OPACITY: boolean;
  104338. OPACITYDIRECTUV: number;
  104339. OPACITYRGB: boolean;
  104340. REFLECTION: boolean;
  104341. EMISSIVE: boolean;
  104342. EMISSIVEDIRECTUV: number;
  104343. SPECULAR: boolean;
  104344. SPECULARDIRECTUV: number;
  104345. BUMP: boolean;
  104346. BUMPDIRECTUV: number;
  104347. PARALLAX: boolean;
  104348. PARALLAXOCCLUSION: boolean;
  104349. SPECULAROVERALPHA: boolean;
  104350. CLIPPLANE: boolean;
  104351. CLIPPLANE2: boolean;
  104352. CLIPPLANE3: boolean;
  104353. CLIPPLANE4: boolean;
  104354. CLIPPLANE5: boolean;
  104355. CLIPPLANE6: boolean;
  104356. ALPHATEST: boolean;
  104357. DEPTHPREPASS: boolean;
  104358. ALPHAFROMDIFFUSE: boolean;
  104359. POINTSIZE: boolean;
  104360. FOG: boolean;
  104361. SPECULARTERM: boolean;
  104362. DIFFUSEFRESNEL: boolean;
  104363. OPACITYFRESNEL: boolean;
  104364. REFLECTIONFRESNEL: boolean;
  104365. REFRACTIONFRESNEL: boolean;
  104366. EMISSIVEFRESNEL: boolean;
  104367. FRESNEL: boolean;
  104368. NORMAL: boolean;
  104369. UV1: boolean;
  104370. UV2: boolean;
  104371. VERTEXCOLOR: boolean;
  104372. VERTEXALPHA: boolean;
  104373. NUM_BONE_INFLUENCERS: number;
  104374. BonesPerMesh: number;
  104375. BONETEXTURE: boolean;
  104376. BONES_VELOCITY_ENABLED: boolean;
  104377. INSTANCES: boolean;
  104378. THIN_INSTANCES: boolean;
  104379. GLOSSINESS: boolean;
  104380. ROUGHNESS: boolean;
  104381. EMISSIVEASILLUMINATION: boolean;
  104382. LINKEMISSIVEWITHDIFFUSE: boolean;
  104383. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104384. LIGHTMAP: boolean;
  104385. LIGHTMAPDIRECTUV: number;
  104386. OBJECTSPACE_NORMALMAP: boolean;
  104387. USELIGHTMAPASSHADOWMAP: boolean;
  104388. REFLECTIONMAP_3D: boolean;
  104389. REFLECTIONMAP_SPHERICAL: boolean;
  104390. REFLECTIONMAP_PLANAR: boolean;
  104391. REFLECTIONMAP_CUBIC: boolean;
  104392. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104393. REFLECTIONMAP_PROJECTION: boolean;
  104394. REFLECTIONMAP_SKYBOX: boolean;
  104395. REFLECTIONMAP_EXPLICIT: boolean;
  104396. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104397. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104398. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104399. REFLECTIONMAP_OPPOSITEZ: boolean;
  104400. INVERTCUBICMAP: boolean;
  104401. LOGARITHMICDEPTH: boolean;
  104402. REFRACTION: boolean;
  104403. REFRACTIONMAP_3D: boolean;
  104404. REFLECTIONOVERALPHA: boolean;
  104405. TWOSIDEDLIGHTING: boolean;
  104406. SHADOWFLOAT: boolean;
  104407. MORPHTARGETS: boolean;
  104408. MORPHTARGETS_NORMAL: boolean;
  104409. MORPHTARGETS_TANGENT: boolean;
  104410. MORPHTARGETS_UV: boolean;
  104411. NUM_MORPH_INFLUENCERS: number;
  104412. NONUNIFORMSCALING: boolean;
  104413. PREMULTIPLYALPHA: boolean;
  104414. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104415. ALPHABLEND: boolean;
  104416. PREPASS: boolean;
  104417. PREPASS_IRRADIANCE: boolean;
  104418. PREPASS_IRRADIANCE_INDEX: number;
  104419. PREPASS_ALBEDO: boolean;
  104420. PREPASS_ALBEDO_INDEX: number;
  104421. PREPASS_DEPTHNORMAL: boolean;
  104422. PREPASS_DEPTHNORMAL_INDEX: number;
  104423. PREPASS_POSITION: boolean;
  104424. PREPASS_POSITION_INDEX: number;
  104425. PREPASS_VELOCITY: boolean;
  104426. PREPASS_VELOCITY_INDEX: number;
  104427. PREPASS_REFLECTIVITY: boolean;
  104428. PREPASS_REFLECTIVITY_INDEX: number;
  104429. SCENE_MRT_COUNT: number;
  104430. RGBDLIGHTMAP: boolean;
  104431. RGBDREFLECTION: boolean;
  104432. RGBDREFRACTION: boolean;
  104433. IMAGEPROCESSING: boolean;
  104434. VIGNETTE: boolean;
  104435. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104436. VIGNETTEBLENDMODEOPAQUE: boolean;
  104437. TONEMAPPING: boolean;
  104438. TONEMAPPING_ACES: boolean;
  104439. CONTRAST: boolean;
  104440. COLORCURVES: boolean;
  104441. COLORGRADING: boolean;
  104442. COLORGRADING3D: boolean;
  104443. SAMPLER3DGREENDEPTH: boolean;
  104444. SAMPLER3DBGRMAP: boolean;
  104445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104446. MULTIVIEW: boolean;
  104447. /**
  104448. * If the reflection texture on this material is in linear color space
  104449. * @hidden
  104450. */
  104451. IS_REFLECTION_LINEAR: boolean;
  104452. /**
  104453. * If the refraction texture on this material is in linear color space
  104454. * @hidden
  104455. */
  104456. IS_REFRACTION_LINEAR: boolean;
  104457. EXPOSURE: boolean;
  104458. constructor();
  104459. setReflectionMode(modeToEnable: string): void;
  104460. }
  104461. /**
  104462. * This is the default material used in Babylon. It is the best trade off between quality
  104463. * and performances.
  104464. * @see https://doc.babylonjs.com/babylon101/materials
  104465. */
  104466. export class StandardMaterial extends PushMaterial {
  104467. private _diffuseTexture;
  104468. /**
  104469. * The basic texture of the material as viewed under a light.
  104470. */
  104471. diffuseTexture: Nullable<BaseTexture>;
  104472. private _ambientTexture;
  104473. /**
  104474. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104475. */
  104476. ambientTexture: Nullable<BaseTexture>;
  104477. private _opacityTexture;
  104478. /**
  104479. * Define the transparency of the material from a texture.
  104480. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104481. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104482. */
  104483. opacityTexture: Nullable<BaseTexture>;
  104484. private _reflectionTexture;
  104485. /**
  104486. * Define the texture used to display the reflection.
  104487. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104488. */
  104489. reflectionTexture: Nullable<BaseTexture>;
  104490. private _emissiveTexture;
  104491. /**
  104492. * Define texture of the material as if self lit.
  104493. * This will be mixed in the final result even in the absence of light.
  104494. */
  104495. emissiveTexture: Nullable<BaseTexture>;
  104496. private _specularTexture;
  104497. /**
  104498. * Define how the color and intensity of the highlight given by the light in the material.
  104499. */
  104500. specularTexture: Nullable<BaseTexture>;
  104501. private _bumpTexture;
  104502. /**
  104503. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104504. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  104505. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104506. */
  104507. bumpTexture: Nullable<BaseTexture>;
  104508. private _lightmapTexture;
  104509. /**
  104510. * Complex lighting can be computationally expensive to compute at runtime.
  104511. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104512. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104513. */
  104514. lightmapTexture: Nullable<BaseTexture>;
  104515. private _refractionTexture;
  104516. /**
  104517. * Define the texture used to display the refraction.
  104518. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104519. */
  104520. refractionTexture: Nullable<BaseTexture>;
  104521. /**
  104522. * The color of the material lit by the environmental background lighting.
  104523. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104524. */
  104525. ambientColor: Color3;
  104526. /**
  104527. * The basic color of the material as viewed under a light.
  104528. */
  104529. diffuseColor: Color3;
  104530. /**
  104531. * Define how the color and intensity of the highlight given by the light in the material.
  104532. */
  104533. specularColor: Color3;
  104534. /**
  104535. * Define the color of the material as if self lit.
  104536. * This will be mixed in the final result even in the absence of light.
  104537. */
  104538. emissiveColor: Color3;
  104539. /**
  104540. * Defines how sharp are the highlights in the material.
  104541. * The bigger the value the sharper giving a more glossy feeling to the result.
  104542. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104543. */
  104544. specularPower: number;
  104545. private _useAlphaFromDiffuseTexture;
  104546. /**
  104547. * Does the transparency come from the diffuse texture alpha channel.
  104548. */
  104549. useAlphaFromDiffuseTexture: boolean;
  104550. private _useEmissiveAsIllumination;
  104551. /**
  104552. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104553. */
  104554. useEmissiveAsIllumination: boolean;
  104555. private _linkEmissiveWithDiffuse;
  104556. /**
  104557. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104558. * the emissive level when the final color is close to one.
  104559. */
  104560. linkEmissiveWithDiffuse: boolean;
  104561. private _useSpecularOverAlpha;
  104562. /**
  104563. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104564. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104565. */
  104566. useSpecularOverAlpha: boolean;
  104567. private _useReflectionOverAlpha;
  104568. /**
  104569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104571. */
  104572. useReflectionOverAlpha: boolean;
  104573. private _disableLighting;
  104574. /**
  104575. * Does lights from the scene impacts this material.
  104576. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104577. */
  104578. disableLighting: boolean;
  104579. private _useObjectSpaceNormalMap;
  104580. /**
  104581. * Allows using an object space normal map (instead of tangent space).
  104582. */
  104583. useObjectSpaceNormalMap: boolean;
  104584. private _useParallax;
  104585. /**
  104586. * Is parallax enabled or not.
  104587. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104588. */
  104589. useParallax: boolean;
  104590. private _useParallaxOcclusion;
  104591. /**
  104592. * Is parallax occlusion enabled or not.
  104593. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104594. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104595. */
  104596. useParallaxOcclusion: boolean;
  104597. /**
  104598. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  104599. */
  104600. parallaxScaleBias: number;
  104601. private _roughness;
  104602. /**
  104603. * Helps to define how blurry the reflections should appears in the material.
  104604. */
  104605. roughness: number;
  104606. /**
  104607. * In case of refraction, define the value of the index of refraction.
  104608. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104609. */
  104610. indexOfRefraction: number;
  104611. /**
  104612. * Invert the refraction texture alongside the y axis.
  104613. * It can be useful with procedural textures or probe for instance.
  104614. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104615. */
  104616. invertRefractionY: boolean;
  104617. /**
  104618. * Defines the alpha limits in alpha test mode.
  104619. */
  104620. alphaCutOff: number;
  104621. private _useLightmapAsShadowmap;
  104622. /**
  104623. * In case of light mapping, define whether the map contains light or shadow informations.
  104624. */
  104625. useLightmapAsShadowmap: boolean;
  104626. private _diffuseFresnelParameters;
  104627. /**
  104628. * Define the diffuse fresnel parameters of the material.
  104629. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104630. */
  104631. diffuseFresnelParameters: FresnelParameters;
  104632. private _opacityFresnelParameters;
  104633. /**
  104634. * Define the opacity fresnel parameters of the material.
  104635. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104636. */
  104637. opacityFresnelParameters: FresnelParameters;
  104638. private _reflectionFresnelParameters;
  104639. /**
  104640. * Define the reflection fresnel parameters of the material.
  104641. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104642. */
  104643. reflectionFresnelParameters: FresnelParameters;
  104644. private _refractionFresnelParameters;
  104645. /**
  104646. * Define the refraction fresnel parameters of the material.
  104647. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104648. */
  104649. refractionFresnelParameters: FresnelParameters;
  104650. private _emissiveFresnelParameters;
  104651. /**
  104652. * Define the emissive fresnel parameters of the material.
  104653. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104654. */
  104655. emissiveFresnelParameters: FresnelParameters;
  104656. private _useReflectionFresnelFromSpecular;
  104657. /**
  104658. * If true automatically deducts the fresnels values from the material specularity.
  104659. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104660. */
  104661. useReflectionFresnelFromSpecular: boolean;
  104662. private _useGlossinessFromSpecularMapAlpha;
  104663. /**
  104664. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104665. */
  104666. useGlossinessFromSpecularMapAlpha: boolean;
  104667. private _maxSimultaneousLights;
  104668. /**
  104669. * Defines the maximum number of lights that can be used in the material
  104670. */
  104671. maxSimultaneousLights: number;
  104672. private _invertNormalMapX;
  104673. /**
  104674. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104675. */
  104676. invertNormalMapX: boolean;
  104677. private _invertNormalMapY;
  104678. /**
  104679. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104680. */
  104681. invertNormalMapY: boolean;
  104682. private _twoSidedLighting;
  104683. /**
  104684. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104685. */
  104686. twoSidedLighting: boolean;
  104687. /**
  104688. * Default configuration related to image processing available in the standard Material.
  104689. */
  104690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104691. /**
  104692. * Gets the image processing configuration used either in this material.
  104693. */
  104694. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104695. /**
  104696. * Sets the Default image processing configuration used either in the this material.
  104697. *
  104698. * If sets to null, the scene one is in use.
  104699. */
  104700. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104701. /**
  104702. * Keep track of the image processing observer to allow dispose and replace.
  104703. */
  104704. private _imageProcessingObserver;
  104705. /**
  104706. * Attaches a new image processing configuration to the Standard Material.
  104707. * @param configuration
  104708. */
  104709. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104710. /**
  104711. * Defines additionnal PrePass parameters for the material.
  104712. */
  104713. readonly prePassConfiguration: PrePassConfiguration;
  104714. /**
  104715. * Gets wether the color curves effect is enabled.
  104716. */
  104717. get cameraColorCurvesEnabled(): boolean;
  104718. /**
  104719. * Sets wether the color curves effect is enabled.
  104720. */
  104721. set cameraColorCurvesEnabled(value: boolean);
  104722. /**
  104723. * Gets wether the color grading effect is enabled.
  104724. */
  104725. get cameraColorGradingEnabled(): boolean;
  104726. /**
  104727. * Gets wether the color grading effect is enabled.
  104728. */
  104729. set cameraColorGradingEnabled(value: boolean);
  104730. /**
  104731. * Gets wether tonemapping is enabled or not.
  104732. */
  104733. get cameraToneMappingEnabled(): boolean;
  104734. /**
  104735. * Sets wether tonemapping is enabled or not
  104736. */
  104737. set cameraToneMappingEnabled(value: boolean);
  104738. /**
  104739. * The camera exposure used on this material.
  104740. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104741. * This corresponds to a photographic exposure.
  104742. */
  104743. get cameraExposure(): number;
  104744. /**
  104745. * The camera exposure used on this material.
  104746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104747. * This corresponds to a photographic exposure.
  104748. */
  104749. set cameraExposure(value: number);
  104750. /**
  104751. * Gets The camera contrast used on this material.
  104752. */
  104753. get cameraContrast(): number;
  104754. /**
  104755. * Sets The camera contrast used on this material.
  104756. */
  104757. set cameraContrast(value: number);
  104758. /**
  104759. * Gets the Color Grading 2D Lookup Texture.
  104760. */
  104761. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104762. /**
  104763. * Sets the Color Grading 2D Lookup Texture.
  104764. */
  104765. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104766. /**
  104767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104769. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  104770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104771. */
  104772. get cameraColorCurves(): Nullable<ColorCurves>;
  104773. /**
  104774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104776. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  104777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104778. */
  104779. set cameraColorCurves(value: Nullable<ColorCurves>);
  104780. /**
  104781. * Can this material render to several textures at once
  104782. */
  104783. get canRenderToMRT(): boolean;
  104784. /**
  104785. * Defines the detail map parameters for the material.
  104786. */
  104787. readonly detailMap: DetailMapConfiguration;
  104788. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104789. protected _worldViewProjectionMatrix: Matrix;
  104790. protected _globalAmbientColor: Color3;
  104791. protected _useLogarithmicDepth: boolean;
  104792. protected _rebuildInParallel: boolean;
  104793. /**
  104794. * Instantiates a new standard material.
  104795. * This is the default material used in Babylon. It is the best trade off between quality
  104796. * and performances.
  104797. * @see https://doc.babylonjs.com/babylon101/materials
  104798. * @param name Define the name of the material in the scene
  104799. * @param scene Define the scene the material belong to
  104800. */
  104801. constructor(name: string, scene: Scene);
  104802. /**
  104803. * Gets a boolean indicating that current material needs to register RTT
  104804. */
  104805. get hasRenderTargetTextures(): boolean;
  104806. /**
  104807. * Gets the current class name of the material e.g. "StandardMaterial"
  104808. * Mainly use in serialization.
  104809. * @returns the class name
  104810. */
  104811. getClassName(): string;
  104812. /**
  104813. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104814. * You can try switching to logarithmic depth.
  104815. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104816. */
  104817. get useLogarithmicDepth(): boolean;
  104818. set useLogarithmicDepth(value: boolean);
  104819. /**
  104820. * Specifies if the material will require alpha blending
  104821. * @returns a boolean specifying if alpha blending is needed
  104822. */
  104823. needAlphaBlending(): boolean;
  104824. /**
  104825. * Specifies if this material should be rendered in alpha test mode
  104826. * @returns a boolean specifying if an alpha test is needed.
  104827. */
  104828. needAlphaTesting(): boolean;
  104829. /**
  104830. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  104831. */
  104832. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104833. /**
  104834. * Specifies whether or not there is a usable alpha channel for transparency.
  104835. */
  104836. protected _hasAlphaChannel(): boolean;
  104837. /**
  104838. * Get the texture used for alpha test purpose.
  104839. * @returns the diffuse texture in case of the standard material.
  104840. */
  104841. getAlphaTestTexture(): Nullable<BaseTexture>;
  104842. /**
  104843. * Get if the submesh is ready to be used and all its information available.
  104844. * Child classes can use it to update shaders
  104845. * @param mesh defines the mesh to check
  104846. * @param subMesh defines which submesh to check
  104847. * @param useInstances specifies that instances should be used
  104848. * @returns a boolean indicating that the submesh is ready or not
  104849. */
  104850. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104851. /**
  104852. * Builds the material UBO layouts.
  104853. * Used internally during the effect preparation.
  104854. */
  104855. buildUniformLayout(): void;
  104856. /**
  104857. * Unbinds the material from the mesh
  104858. */
  104859. unbind(): void;
  104860. /**
  104861. * Binds the submesh to this material by preparing the effect and shader to draw
  104862. * @param world defines the world transformation matrix
  104863. * @param mesh defines the mesh containing the submesh
  104864. * @param subMesh defines the submesh to bind the material to
  104865. */
  104866. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104867. /**
  104868. * Get the list of animatables in the material.
  104869. * @returns the list of animatables object used in the material
  104870. */
  104871. getAnimatables(): IAnimatable[];
  104872. /**
  104873. * Gets the active textures from the material
  104874. * @returns an array of textures
  104875. */
  104876. getActiveTextures(): BaseTexture[];
  104877. /**
  104878. * Specifies if the material uses a texture
  104879. * @param texture defines the texture to check against the material
  104880. * @returns a boolean specifying if the material uses the texture
  104881. */
  104882. hasTexture(texture: BaseTexture): boolean;
  104883. /**
  104884. * Disposes the material
  104885. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104886. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104887. */
  104888. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104889. /**
  104890. * Makes a duplicate of the material, and gives it a new name
  104891. * @param name defines the new name for the duplicated material
  104892. * @returns the cloned material
  104893. */
  104894. clone(name: string): StandardMaterial;
  104895. /**
  104896. * Serializes this material in a JSON representation
  104897. * @returns the serialized material object
  104898. */
  104899. serialize(): any;
  104900. /**
  104901. * Creates a standard material from parsed material data
  104902. * @param source defines the JSON representation of the material
  104903. * @param scene defines the hosting scene
  104904. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104905. * @returns a new standard material
  104906. */
  104907. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104908. /**
  104909. * Are diffuse textures enabled in the application.
  104910. */
  104911. static get DiffuseTextureEnabled(): boolean;
  104912. static set DiffuseTextureEnabled(value: boolean);
  104913. /**
  104914. * Are detail textures enabled in the application.
  104915. */
  104916. static get DetailTextureEnabled(): boolean;
  104917. static set DetailTextureEnabled(value: boolean);
  104918. /**
  104919. * Are ambient textures enabled in the application.
  104920. */
  104921. static get AmbientTextureEnabled(): boolean;
  104922. static set AmbientTextureEnabled(value: boolean);
  104923. /**
  104924. * Are opacity textures enabled in the application.
  104925. */
  104926. static get OpacityTextureEnabled(): boolean;
  104927. static set OpacityTextureEnabled(value: boolean);
  104928. /**
  104929. * Are reflection textures enabled in the application.
  104930. */
  104931. static get ReflectionTextureEnabled(): boolean;
  104932. static set ReflectionTextureEnabled(value: boolean);
  104933. /**
  104934. * Are emissive textures enabled in the application.
  104935. */
  104936. static get EmissiveTextureEnabled(): boolean;
  104937. static set EmissiveTextureEnabled(value: boolean);
  104938. /**
  104939. * Are specular textures enabled in the application.
  104940. */
  104941. static get SpecularTextureEnabled(): boolean;
  104942. static set SpecularTextureEnabled(value: boolean);
  104943. /**
  104944. * Are bump textures enabled in the application.
  104945. */
  104946. static get BumpTextureEnabled(): boolean;
  104947. static set BumpTextureEnabled(value: boolean);
  104948. /**
  104949. * Are lightmap textures enabled in the application.
  104950. */
  104951. static get LightmapTextureEnabled(): boolean;
  104952. static set LightmapTextureEnabled(value: boolean);
  104953. /**
  104954. * Are refraction textures enabled in the application.
  104955. */
  104956. static get RefractionTextureEnabled(): boolean;
  104957. static set RefractionTextureEnabled(value: boolean);
  104958. /**
  104959. * Are color grading textures enabled in the application.
  104960. */
  104961. static get ColorGradingTextureEnabled(): boolean;
  104962. static set ColorGradingTextureEnabled(value: boolean);
  104963. /**
  104964. * Are fresnels enabled in the application.
  104965. */
  104966. static get FresnelEnabled(): boolean;
  104967. static set FresnelEnabled(value: boolean);
  104968. }
  104969. }
  104970. declare module BABYLON {
  104971. /** @hidden */
  104972. export var rgbdDecodePixelShader: {
  104973. name: string;
  104974. shader: string;
  104975. };
  104976. }
  104977. declare module BABYLON {
  104978. /** @hidden */
  104979. export var passPixelShader: {
  104980. name: string;
  104981. shader: string;
  104982. };
  104983. }
  104984. declare module BABYLON {
  104985. /** @hidden */
  104986. export var passCubePixelShader: {
  104987. name: string;
  104988. shader: string;
  104989. };
  104990. }
  104991. declare module BABYLON {
  104992. /**
  104993. * PassPostProcess which produces an output the same as it's input
  104994. */
  104995. export class PassPostProcess extends PostProcess {
  104996. /**
  104997. * Gets a string identifying the name of the class
  104998. * @returns "PassPostProcess" string
  104999. */
  105000. getClassName(): string;
  105001. /**
  105002. * Creates the PassPostProcess
  105003. * @param name The name of the effect.
  105004. * @param options The required width/height ratio to downsize to before computing the render pass.
  105005. * @param camera The camera to apply the render pass to.
  105006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105007. * @param engine The engine which the post process will be applied. (default: current engine)
  105008. * @param reusable If the post process can be reused on the same frame. (default: false)
  105009. * @param textureType The type of texture to be used when performing the post processing.
  105010. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  105011. */
  105012. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105013. /** @hidden */
  105014. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  105015. }
  105016. /**
  105017. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105018. */
  105019. export class PassCubePostProcess extends PostProcess {
  105020. private _face;
  105021. /**
  105022. * Gets or sets the cube face to display.
  105023. * * 0 is +X
  105024. * * 1 is -X
  105025. * * 2 is +Y
  105026. * * 3 is -Y
  105027. * * 4 is +Z
  105028. * * 5 is -Z
  105029. */
  105030. get face(): number;
  105031. set face(value: number);
  105032. /**
  105033. * Gets a string identifying the name of the class
  105034. * @returns "PassCubePostProcess" string
  105035. */
  105036. getClassName(): string;
  105037. /**
  105038. * Creates the PassCubePostProcess
  105039. * @param name The name of the effect.
  105040. * @param options The required width/height ratio to downsize to before computing the render pass.
  105041. * @param camera The camera to apply the render pass to.
  105042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105043. * @param engine The engine which the post process will be applied. (default: current engine)
  105044. * @param reusable If the post process can be reused on the same frame. (default: false)
  105045. * @param textureType The type of texture to be used when performing the post processing.
  105046. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  105047. */
  105048. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105049. /** @hidden */
  105050. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  105051. }
  105052. }
  105053. declare module BABYLON {
  105054. /**
  105055. * Class used to host texture specific utilities
  105056. */
  105057. export class TextureTools {
  105058. /**
  105059. * Uses the GPU to create a copy texture rescaled at a given size
  105060. * @param texture Texture to copy from
  105061. * @param width defines the desired width
  105062. * @param height defines the desired height
  105063. * @param useBilinearMode defines if bilinear mode has to be used
  105064. * @return the generated texture
  105065. */
  105066. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  105067. /**
  105068. * Apply a post process to a texture
  105069. * @param postProcessName name of the fragment post process
  105070. * @param internalTexture the texture to encode
  105071. * @param scene the scene hosting the texture
  105072. * @param type type of the output texture. If not provided, use the one from internalTexture
  105073. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  105074. * @param format format of the output texture. If not provided, use the one from internalTexture
  105075. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  105076. */
  105077. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  105078. }
  105079. }
  105080. declare module BABYLON {
  105081. /**
  105082. * Class used to host RGBD texture specific utilities
  105083. */
  105084. export class RGBDTextureTools {
  105085. /**
  105086. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105087. * @param texture the texture to expand.
  105088. */
  105089. static ExpandRGBDTexture(texture: Texture): void;
  105090. /**
  105091. * Encode the texture to RGBD if possible.
  105092. * @param internalTexture the texture to encode
  105093. * @param scene the scene hosting the texture
  105094. * @param outputTextureType type of the texture in which the encoding is performed
  105095. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  105096. */
  105097. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  105098. }
  105099. }
  105100. declare module BABYLON {
  105101. /**
  105102. * Class used to host texture specific utilities
  105103. */
  105104. export class BRDFTextureTools {
  105105. /**
  105106. * Prevents texture cache collision
  105107. */
  105108. private static _instanceNumber;
  105109. /**
  105110. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105111. * @param scene defines the hosting scene
  105112. * @returns the environment BRDF texture
  105113. */
  105114. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105115. private static _environmentBRDFBase64Texture;
  105116. }
  105117. }
  105118. declare module BABYLON {
  105119. /**
  105120. * @hidden
  105121. */
  105122. export interface IMaterialClearCoatDefines {
  105123. CLEARCOAT: boolean;
  105124. CLEARCOAT_DEFAULTIOR: boolean;
  105125. CLEARCOAT_TEXTURE: boolean;
  105126. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105127. CLEARCOAT_TEXTUREDIRECTUV: number;
  105128. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105129. CLEARCOAT_BUMP: boolean;
  105130. CLEARCOAT_BUMPDIRECTUV: number;
  105131. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105132. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105133. CLEARCOAT_REMAP_F0: boolean;
  105134. CLEARCOAT_TINT: boolean;
  105135. CLEARCOAT_TINT_TEXTURE: boolean;
  105136. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105137. /** @hidden */
  105138. _areTexturesDirty: boolean;
  105139. }
  105140. /**
  105141. * Define the code related to the clear coat parameters of the pbr material.
  105142. */
  105143. export class PBRClearCoatConfiguration {
  105144. /**
  105145. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105146. * The default fits with a polyurethane material.
  105147. * @hidden
  105148. */
  105149. static readonly _DefaultIndexOfRefraction: number;
  105150. private _isEnabled;
  105151. /**
  105152. * Defines if the clear coat is enabled in the material.
  105153. */
  105154. isEnabled: boolean;
  105155. /**
  105156. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105157. */
  105158. intensity: number;
  105159. /**
  105160. * Defines the clear coat layer roughness.
  105161. */
  105162. roughness: number;
  105163. private _indexOfRefraction;
  105164. /**
  105165. * Defines the index of refraction of the clear coat.
  105166. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105167. * The default fits with a polyurethane material.
  105168. * Changing the default value is more performance intensive.
  105169. */
  105170. indexOfRefraction: number;
  105171. private _texture;
  105172. /**
  105173. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105174. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105175. * if textureRoughness is not empty, else no texture roughness is used
  105176. */
  105177. texture: Nullable<BaseTexture>;
  105178. private _useRoughnessFromMainTexture;
  105179. /**
  105180. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105181. * If false, the green channel from textureRoughness is used for roughness
  105182. */
  105183. useRoughnessFromMainTexture: boolean;
  105184. private _textureRoughness;
  105185. /**
  105186. * Stores the clear coat roughness in a texture (green channel)
  105187. * Not used if useRoughnessFromMainTexture is true
  105188. */
  105189. textureRoughness: Nullable<BaseTexture>;
  105190. private _remapF0OnInterfaceChange;
  105191. /**
  105192. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105193. */
  105194. remapF0OnInterfaceChange: boolean;
  105195. private _bumpTexture;
  105196. /**
  105197. * Define the clear coat specific bump texture.
  105198. */
  105199. bumpTexture: Nullable<BaseTexture>;
  105200. private _isTintEnabled;
  105201. /**
  105202. * Defines if the clear coat tint is enabled in the material.
  105203. */
  105204. isTintEnabled: boolean;
  105205. /**
  105206. * Defines the clear coat tint of the material.
  105207. * This is only use if tint is enabled
  105208. */
  105209. tintColor: Color3;
  105210. /**
  105211. * Defines the distance at which the tint color should be found in the
  105212. * clear coat media.
  105213. * This is only use if tint is enabled
  105214. */
  105215. tintColorAtDistance: number;
  105216. /**
  105217. * Defines the clear coat layer thickness.
  105218. * This is only use if tint is enabled
  105219. */
  105220. tintThickness: number;
  105221. private _tintTexture;
  105222. /**
  105223. * Stores the clear tint values in a texture.
  105224. * rgb is tint
  105225. * a is a thickness factor
  105226. */
  105227. tintTexture: Nullable<BaseTexture>;
  105228. /** @hidden */
  105229. private _internalMarkAllSubMeshesAsTexturesDirty;
  105230. /** @hidden */
  105231. _markAllSubMeshesAsTexturesDirty(): void;
  105232. /**
  105233. * Instantiate a new istance of clear coat configuration.
  105234. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105235. */
  105236. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105237. /**
  105238. * Gets wehter the submesh is ready to be used or not.
  105239. * @param defines the list of "defines" to update.
  105240. * @param scene defines the scene the material belongs to.
  105241. * @param engine defines the engine the material belongs to.
  105242. * @param disableBumpMap defines wether the material disables bump or not.
  105243. * @returns - boolean indicating that the submesh is ready or not.
  105244. */
  105245. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105246. /**
  105247. * Checks to see if a texture is used in the material.
  105248. * @param defines the list of "defines" to update.
  105249. * @param scene defines the scene to the material belongs to.
  105250. */
  105251. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105252. /**
  105253. * Binds the material data.
  105254. * @param uniformBuffer defines the Uniform buffer to fill in.
  105255. * @param scene defines the scene the material belongs to.
  105256. * @param engine defines the engine the material belongs to.
  105257. * @param disableBumpMap defines wether the material disables bump or not.
  105258. * @param isFrozen defines wether the material is frozen or not.
  105259. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105260. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105261. * @param subMesh the submesh to bind data for
  105262. */
  105263. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105264. /**
  105265. * Checks to see if a texture is used in the material.
  105266. * @param texture - Base texture to use.
  105267. * @returns - Boolean specifying if a texture is used in the material.
  105268. */
  105269. hasTexture(texture: BaseTexture): boolean;
  105270. /**
  105271. * Returns an array of the actively used textures.
  105272. * @param activeTextures Array of BaseTextures
  105273. */
  105274. getActiveTextures(activeTextures: BaseTexture[]): void;
  105275. /**
  105276. * Returns the animatable textures.
  105277. * @param animatables Array of animatable textures.
  105278. */
  105279. getAnimatables(animatables: IAnimatable[]): void;
  105280. /**
  105281. * Disposes the resources of the material.
  105282. * @param forceDisposeTextures - Forces the disposal of all textures.
  105283. */
  105284. dispose(forceDisposeTextures?: boolean): void;
  105285. /**
  105286. * Get the current class name of the texture useful for serialization or dynamic coding.
  105287. * @returns "PBRClearCoatConfiguration"
  105288. */
  105289. getClassName(): string;
  105290. /**
  105291. * Add fallbacks to the effect fallbacks list.
  105292. * @param defines defines the Base texture to use.
  105293. * @param fallbacks defines the current fallback list.
  105294. * @param currentRank defines the current fallback rank.
  105295. * @returns the new fallback rank.
  105296. */
  105297. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105298. /**
  105299. * Add the required uniforms to the current list.
  105300. * @param uniforms defines the current uniform list.
  105301. */
  105302. static AddUniforms(uniforms: string[]): void;
  105303. /**
  105304. * Add the required samplers to the current list.
  105305. * @param samplers defines the current sampler list.
  105306. */
  105307. static AddSamplers(samplers: string[]): void;
  105308. /**
  105309. * Add the required uniforms to the current buffer.
  105310. * @param uniformBuffer defines the current uniform buffer.
  105311. */
  105312. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105313. /**
  105314. * Makes a duplicate of the current configuration into another one.
  105315. * @param clearCoatConfiguration define the config where to copy the info
  105316. */
  105317. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105318. /**
  105319. * Serializes this clear coat configuration.
  105320. * @returns - An object with the serialized config.
  105321. */
  105322. serialize(): any;
  105323. /**
  105324. * Parses a anisotropy Configuration from a serialized object.
  105325. * @param source - Serialized object.
  105326. * @param scene Defines the scene we are parsing for
  105327. * @param rootUrl Defines the rootUrl to load from
  105328. */
  105329. parse(source: any, scene: Scene, rootUrl: string): void;
  105330. }
  105331. }
  105332. declare module BABYLON {
  105333. /**
  105334. * @hidden
  105335. */
  105336. export interface IMaterialAnisotropicDefines {
  105337. ANISOTROPIC: boolean;
  105338. ANISOTROPIC_TEXTURE: boolean;
  105339. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105340. MAINUV1: boolean;
  105341. _areTexturesDirty: boolean;
  105342. _needUVs: boolean;
  105343. }
  105344. /**
  105345. * Define the code related to the anisotropic parameters of the pbr material.
  105346. */
  105347. export class PBRAnisotropicConfiguration {
  105348. private _isEnabled;
  105349. /**
  105350. * Defines if the anisotropy is enabled in the material.
  105351. */
  105352. isEnabled: boolean;
  105353. /**
  105354. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105355. */
  105356. intensity: number;
  105357. /**
  105358. * Defines if the effect is along the tangents, bitangents or in between.
  105359. * By default, the effect is "strectching" the highlights along the tangents.
  105360. */
  105361. direction: Vector2;
  105362. private _texture;
  105363. /**
  105364. * Stores the anisotropy values in a texture.
  105365. * rg is direction (like normal from -1 to 1)
  105366. * b is a intensity
  105367. */
  105368. texture: Nullable<BaseTexture>;
  105369. /** @hidden */
  105370. private _internalMarkAllSubMeshesAsTexturesDirty;
  105371. /** @hidden */
  105372. _markAllSubMeshesAsTexturesDirty(): void;
  105373. /**
  105374. * Instantiate a new istance of anisotropy configuration.
  105375. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105376. */
  105377. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105378. /**
  105379. * Specifies that the submesh is ready to be used.
  105380. * @param defines the list of "defines" to update.
  105381. * @param scene defines the scene the material belongs to.
  105382. * @returns - boolean indicating that the submesh is ready or not.
  105383. */
  105384. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105385. /**
  105386. * Checks to see if a texture is used in the material.
  105387. * @param defines the list of "defines" to update.
  105388. * @param mesh the mesh we are preparing the defines for.
  105389. * @param scene defines the scene the material belongs to.
  105390. */
  105391. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105392. /**
  105393. * Binds the material data.
  105394. * @param uniformBuffer defines the Uniform buffer to fill in.
  105395. * @param scene defines the scene the material belongs to.
  105396. * @param isFrozen defines wether the material is frozen or not.
  105397. */
  105398. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105399. /**
  105400. * Checks to see if a texture is used in the material.
  105401. * @param texture - Base texture to use.
  105402. * @returns - Boolean specifying if a texture is used in the material.
  105403. */
  105404. hasTexture(texture: BaseTexture): boolean;
  105405. /**
  105406. * Returns an array of the actively used textures.
  105407. * @param activeTextures Array of BaseTextures
  105408. */
  105409. getActiveTextures(activeTextures: BaseTexture[]): void;
  105410. /**
  105411. * Returns the animatable textures.
  105412. * @param animatables Array of animatable textures.
  105413. */
  105414. getAnimatables(animatables: IAnimatable[]): void;
  105415. /**
  105416. * Disposes the resources of the material.
  105417. * @param forceDisposeTextures - Forces the disposal of all textures.
  105418. */
  105419. dispose(forceDisposeTextures?: boolean): void;
  105420. /**
  105421. * Get the current class name of the texture useful for serialization or dynamic coding.
  105422. * @returns "PBRAnisotropicConfiguration"
  105423. */
  105424. getClassName(): string;
  105425. /**
  105426. * Add fallbacks to the effect fallbacks list.
  105427. * @param defines defines the Base texture to use.
  105428. * @param fallbacks defines the current fallback list.
  105429. * @param currentRank defines the current fallback rank.
  105430. * @returns the new fallback rank.
  105431. */
  105432. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105433. /**
  105434. * Add the required uniforms to the current list.
  105435. * @param uniforms defines the current uniform list.
  105436. */
  105437. static AddUniforms(uniforms: string[]): void;
  105438. /**
  105439. * Add the required uniforms to the current buffer.
  105440. * @param uniformBuffer defines the current uniform buffer.
  105441. */
  105442. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105443. /**
  105444. * Add the required samplers to the current list.
  105445. * @param samplers defines the current sampler list.
  105446. */
  105447. static AddSamplers(samplers: string[]): void;
  105448. /**
  105449. * Makes a duplicate of the current configuration into another one.
  105450. * @param anisotropicConfiguration define the config where to copy the info
  105451. */
  105452. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105453. /**
  105454. * Serializes this anisotropy configuration.
  105455. * @returns - An object with the serialized config.
  105456. */
  105457. serialize(): any;
  105458. /**
  105459. * Parses a anisotropy Configuration from a serialized object.
  105460. * @param source - Serialized object.
  105461. * @param scene Defines the scene we are parsing for
  105462. * @param rootUrl Defines the rootUrl to load from
  105463. */
  105464. parse(source: any, scene: Scene, rootUrl: string): void;
  105465. }
  105466. }
  105467. declare module BABYLON {
  105468. /**
  105469. * @hidden
  105470. */
  105471. export interface IMaterialBRDFDefines {
  105472. BRDF_V_HEIGHT_CORRELATED: boolean;
  105473. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105474. SPHERICAL_HARMONICS: boolean;
  105475. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105476. /** @hidden */
  105477. _areMiscDirty: boolean;
  105478. }
  105479. /**
  105480. * Define the code related to the BRDF parameters of the pbr material.
  105481. */
  105482. export class PBRBRDFConfiguration {
  105483. /**
  105484. * Default value used for the energy conservation.
  105485. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105486. */
  105487. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105488. /**
  105489. * Default value used for the Smith Visibility Height Correlated mode.
  105490. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105491. */
  105492. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105493. /**
  105494. * Default value used for the IBL diffuse part.
  105495. * This can help switching back to the polynomials mode globally which is a tiny bit
  105496. * less GPU intensive at the drawback of a lower quality.
  105497. */
  105498. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105499. /**
  105500. * Default value used for activating energy conservation for the specular workflow.
  105501. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105502. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105503. */
  105504. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105505. private _useEnergyConservation;
  105506. /**
  105507. * Defines if the material uses energy conservation.
  105508. */
  105509. useEnergyConservation: boolean;
  105510. private _useSmithVisibilityHeightCorrelated;
  105511. /**
  105512. * LEGACY Mode set to false
  105513. * Defines if the material uses height smith correlated visibility term.
  105514. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105515. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105516. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105517. * Not relying on height correlated will also disable energy conservation.
  105518. */
  105519. useSmithVisibilityHeightCorrelated: boolean;
  105520. private _useSphericalHarmonics;
  105521. /**
  105522. * LEGACY Mode set to false
  105523. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105524. * diffuse part of the IBL.
  105525. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105526. * to the ground truth.
  105527. */
  105528. useSphericalHarmonics: boolean;
  105529. private _useSpecularGlossinessInputEnergyConservation;
  105530. /**
  105531. * Defines if the material uses energy conservation, when the specular workflow is active.
  105532. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105533. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105534. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105535. */
  105536. useSpecularGlossinessInputEnergyConservation: boolean;
  105537. /** @hidden */
  105538. private _internalMarkAllSubMeshesAsMiscDirty;
  105539. /** @hidden */
  105540. _markAllSubMeshesAsMiscDirty(): void;
  105541. /**
  105542. * Instantiate a new istance of clear coat configuration.
  105543. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105544. */
  105545. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105546. /**
  105547. * Checks to see if a texture is used in the material.
  105548. * @param defines the list of "defines" to update.
  105549. */
  105550. prepareDefines(defines: IMaterialBRDFDefines): void;
  105551. /**
  105552. * Get the current class name of the texture useful for serialization or dynamic coding.
  105553. * @returns "PBRClearCoatConfiguration"
  105554. */
  105555. getClassName(): string;
  105556. /**
  105557. * Makes a duplicate of the current configuration into another one.
  105558. * @param brdfConfiguration define the config where to copy the info
  105559. */
  105560. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105561. /**
  105562. * Serializes this BRDF configuration.
  105563. * @returns - An object with the serialized config.
  105564. */
  105565. serialize(): any;
  105566. /**
  105567. * Parses a anisotropy Configuration from a serialized object.
  105568. * @param source - Serialized object.
  105569. * @param scene Defines the scene we are parsing for
  105570. * @param rootUrl Defines the rootUrl to load from
  105571. */
  105572. parse(source: any, scene: Scene, rootUrl: string): void;
  105573. }
  105574. }
  105575. declare module BABYLON {
  105576. /**
  105577. * @hidden
  105578. */
  105579. export interface IMaterialSheenDefines {
  105580. SHEEN: boolean;
  105581. SHEEN_TEXTURE: boolean;
  105582. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105583. SHEEN_TEXTUREDIRECTUV: number;
  105584. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105585. SHEEN_LINKWITHALBEDO: boolean;
  105586. SHEEN_ROUGHNESS: boolean;
  105587. SHEEN_ALBEDOSCALING: boolean;
  105588. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105589. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105590. /** @hidden */
  105591. _areTexturesDirty: boolean;
  105592. }
  105593. /**
  105594. * Define the code related to the Sheen parameters of the pbr material.
  105595. */
  105596. export class PBRSheenConfiguration {
  105597. private _isEnabled;
  105598. /**
  105599. * Defines if the material uses sheen.
  105600. */
  105601. isEnabled: boolean;
  105602. private _linkSheenWithAlbedo;
  105603. /**
  105604. * Defines if the sheen is linked to the sheen color.
  105605. */
  105606. linkSheenWithAlbedo: boolean;
  105607. /**
  105608. * Defines the sheen intensity.
  105609. */
  105610. intensity: number;
  105611. /**
  105612. * Defines the sheen color.
  105613. */
  105614. color: Color3;
  105615. private _texture;
  105616. /**
  105617. * Stores the sheen tint values in a texture.
  105618. * rgb is tint
  105619. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  105620. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105621. */
  105622. texture: Nullable<BaseTexture>;
  105623. private _useRoughnessFromMainTexture;
  105624. /**
  105625. * Indicates that the alpha channel of the texture property will be used for roughness.
  105626. * Has no effect if the roughness (and texture!) property is not defined
  105627. */
  105628. useRoughnessFromMainTexture: boolean;
  105629. private _roughness;
  105630. /**
  105631. * Defines the sheen roughness.
  105632. * It is not taken into account if linkSheenWithAlbedo is true.
  105633. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105634. */
  105635. roughness: Nullable<number>;
  105636. private _textureRoughness;
  105637. /**
  105638. * Stores the sheen roughness in a texture.
  105639. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105640. */
  105641. textureRoughness: Nullable<BaseTexture>;
  105642. private _albedoScaling;
  105643. /**
  105644. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105645. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105646. * making it easier to setup and tweak the effect
  105647. */
  105648. albedoScaling: boolean;
  105649. /** @hidden */
  105650. private _internalMarkAllSubMeshesAsTexturesDirty;
  105651. /** @hidden */
  105652. _markAllSubMeshesAsTexturesDirty(): void;
  105653. /**
  105654. * Instantiate a new istance of clear coat configuration.
  105655. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105656. */
  105657. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105658. /**
  105659. * Specifies that the submesh is ready to be used.
  105660. * @param defines the list of "defines" to update.
  105661. * @param scene defines the scene the material belongs to.
  105662. * @returns - boolean indicating that the submesh is ready or not.
  105663. */
  105664. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105665. /**
  105666. * Checks to see if a texture is used in the material.
  105667. * @param defines the list of "defines" to update.
  105668. * @param scene defines the scene the material belongs to.
  105669. */
  105670. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105671. /**
  105672. * Binds the material data.
  105673. * @param uniformBuffer defines the Uniform buffer to fill in.
  105674. * @param scene defines the scene the material belongs to.
  105675. * @param isFrozen defines wether the material is frozen or not.
  105676. * @param subMesh the submesh to bind data for
  105677. */
  105678. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105679. /**
  105680. * Checks to see if a texture is used in the material.
  105681. * @param texture - Base texture to use.
  105682. * @returns - Boolean specifying if a texture is used in the material.
  105683. */
  105684. hasTexture(texture: BaseTexture): boolean;
  105685. /**
  105686. * Returns an array of the actively used textures.
  105687. * @param activeTextures Array of BaseTextures
  105688. */
  105689. getActiveTextures(activeTextures: BaseTexture[]): void;
  105690. /**
  105691. * Returns the animatable textures.
  105692. * @param animatables Array of animatable textures.
  105693. */
  105694. getAnimatables(animatables: IAnimatable[]): void;
  105695. /**
  105696. * Disposes the resources of the material.
  105697. * @param forceDisposeTextures - Forces the disposal of all textures.
  105698. */
  105699. dispose(forceDisposeTextures?: boolean): void;
  105700. /**
  105701. * Get the current class name of the texture useful for serialization or dynamic coding.
  105702. * @returns "PBRSheenConfiguration"
  105703. */
  105704. getClassName(): string;
  105705. /**
  105706. * Add fallbacks to the effect fallbacks list.
  105707. * @param defines defines the Base texture to use.
  105708. * @param fallbacks defines the current fallback list.
  105709. * @param currentRank defines the current fallback rank.
  105710. * @returns the new fallback rank.
  105711. */
  105712. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105713. /**
  105714. * Add the required uniforms to the current list.
  105715. * @param uniforms defines the current uniform list.
  105716. */
  105717. static AddUniforms(uniforms: string[]): void;
  105718. /**
  105719. * Add the required uniforms to the current buffer.
  105720. * @param uniformBuffer defines the current uniform buffer.
  105721. */
  105722. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105723. /**
  105724. * Add the required samplers to the current list.
  105725. * @param samplers defines the current sampler list.
  105726. */
  105727. static AddSamplers(samplers: string[]): void;
  105728. /**
  105729. * Makes a duplicate of the current configuration into another one.
  105730. * @param sheenConfiguration define the config where to copy the info
  105731. */
  105732. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105733. /**
  105734. * Serializes this BRDF configuration.
  105735. * @returns - An object with the serialized config.
  105736. */
  105737. serialize(): any;
  105738. /**
  105739. * Parses a anisotropy Configuration from a serialized object.
  105740. * @param source - Serialized object.
  105741. * @param scene Defines the scene we are parsing for
  105742. * @param rootUrl Defines the rootUrl to load from
  105743. */
  105744. parse(source: any, scene: Scene, rootUrl: string): void;
  105745. }
  105746. }
  105747. declare module BABYLON {
  105748. /**
  105749. * @hidden
  105750. */
  105751. export interface IMaterialSubSurfaceDefines {
  105752. SUBSURFACE: boolean;
  105753. SS_REFRACTION: boolean;
  105754. SS_TRANSLUCENCY: boolean;
  105755. SS_SCATTERING: boolean;
  105756. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105757. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105758. SS_REFRACTIONMAP_3D: boolean;
  105759. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105760. SS_LODINREFRACTIONALPHA: boolean;
  105761. SS_GAMMAREFRACTION: boolean;
  105762. SS_RGBDREFRACTION: boolean;
  105763. SS_LINEARSPECULARREFRACTION: boolean;
  105764. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105765. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105766. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105767. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  105768. /** @hidden */
  105769. _areTexturesDirty: boolean;
  105770. }
  105771. /**
  105772. * Define the code related to the sub surface parameters of the pbr material.
  105773. */
  105774. export class PBRSubSurfaceConfiguration {
  105775. private _isRefractionEnabled;
  105776. /**
  105777. * Defines if the refraction is enabled in the material.
  105778. */
  105779. isRefractionEnabled: boolean;
  105780. private _isTranslucencyEnabled;
  105781. /**
  105782. * Defines if the translucency is enabled in the material.
  105783. */
  105784. isTranslucencyEnabled: boolean;
  105785. private _isScatteringEnabled;
  105786. /**
  105787. * Defines if the sub surface scattering is enabled in the material.
  105788. */
  105789. isScatteringEnabled: boolean;
  105790. private _scatteringDiffusionProfileIndex;
  105791. /**
  105792. * Diffusion profile for subsurface scattering.
  105793. * Useful for better scattering in the skins or foliages.
  105794. */
  105795. get scatteringDiffusionProfile(): Nullable<Color3>;
  105796. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105797. /**
  105798. * Defines the refraction intensity of the material.
  105799. * The refraction when enabled replaces the Diffuse part of the material.
  105800. * The intensity helps transitionning between diffuse and refraction.
  105801. */
  105802. refractionIntensity: number;
  105803. /**
  105804. * Defines the translucency intensity of the material.
  105805. * When translucency has been enabled, this defines how much of the "translucency"
  105806. * is addded to the diffuse part of the material.
  105807. */
  105808. translucencyIntensity: number;
  105809. /**
  105810. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105811. */
  105812. useAlbedoToTintRefraction: boolean;
  105813. private _thicknessTexture;
  105814. /**
  105815. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105816. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105817. * 0 would mean minimumThickness
  105818. * 1 would mean maximumThickness
  105819. * The other channels might be use as a mask to vary the different effects intensity.
  105820. */
  105821. thicknessTexture: Nullable<BaseTexture>;
  105822. private _refractionTexture;
  105823. /**
  105824. * Defines the texture to use for refraction.
  105825. */
  105826. refractionTexture: Nullable<BaseTexture>;
  105827. private _indexOfRefraction;
  105828. /**
  105829. * Index of refraction of the material base layer.
  105830. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105831. *
  105832. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105833. *
  105834. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105835. */
  105836. indexOfRefraction: number;
  105837. private _volumeIndexOfRefraction;
  105838. /**
  105839. * Index of refraction of the material's volume.
  105840. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105841. *
  105842. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105843. * the volume will use the same IOR as the surface.
  105844. */
  105845. get volumeIndexOfRefraction(): number;
  105846. set volumeIndexOfRefraction(value: number);
  105847. private _invertRefractionY;
  105848. /**
  105849. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105850. */
  105851. invertRefractionY: boolean;
  105852. private _linkRefractionWithTransparency;
  105853. /**
  105854. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105855. * Materials half opaque for instance using refraction could benefit from this control.
  105856. */
  105857. linkRefractionWithTransparency: boolean;
  105858. /**
  105859. * Defines the minimum thickness stored in the thickness map.
  105860. * If no thickness map is defined, this value will be used to simulate thickness.
  105861. */
  105862. minimumThickness: number;
  105863. /**
  105864. * Defines the maximum thickness stored in the thickness map.
  105865. */
  105866. maximumThickness: number;
  105867. /**
  105868. * Defines the volume tint of the material.
  105869. * This is used for both translucency and scattering.
  105870. */
  105871. tintColor: Color3;
  105872. /**
  105873. * Defines the distance at which the tint color should be found in the media.
  105874. * This is used for refraction only.
  105875. */
  105876. tintColorAtDistance: number;
  105877. /**
  105878. * Defines how far each channel transmit through the media.
  105879. * It is defined as a color to simplify it selection.
  105880. */
  105881. diffusionDistance: Color3;
  105882. private _useMaskFromThicknessTexture;
  105883. /**
  105884. * Stores the intensity of the different subsurface effects in the thickness texture.
  105885. * * the green channel is the translucency intensity.
  105886. * * the blue channel is the scattering intensity.
  105887. * * the alpha channel is the refraction intensity.
  105888. */
  105889. useMaskFromThicknessTexture: boolean;
  105890. private _scene;
  105891. private _useMaskFromThicknessTextureGltf;
  105892. /**
  105893. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  105894. * matches the channel-packing that is used by glTF.
  105895. * * the red channel is the transmission/translucency intensity.
  105896. * * the green channel is the thickness.
  105897. */
  105898. useMaskFromThicknessTextureGltf: boolean;
  105899. /** @hidden */
  105900. private _internalMarkAllSubMeshesAsTexturesDirty;
  105901. private _internalMarkScenePrePassDirty;
  105902. /** @hidden */
  105903. _markAllSubMeshesAsTexturesDirty(): void;
  105904. /** @hidden */
  105905. _markScenePrePassDirty(): void;
  105906. /**
  105907. * Instantiate a new istance of sub surface configuration.
  105908. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105909. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105910. * @param scene The scene
  105911. */
  105912. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105913. /**
  105914. * Gets wehter the submesh is ready to be used or not.
  105915. * @param defines the list of "defines" to update.
  105916. * @param scene defines the scene the material belongs to.
  105917. * @returns - boolean indicating that the submesh is ready or not.
  105918. */
  105919. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105920. /**
  105921. * Checks to see if a texture is used in the material.
  105922. * @param defines the list of "defines" to update.
  105923. * @param scene defines the scene to the material belongs to.
  105924. */
  105925. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105926. /**
  105927. * Binds the material data.
  105928. * @param uniformBuffer defines the Uniform buffer to fill in.
  105929. * @param scene defines the scene the material belongs to.
  105930. * @param engine defines the engine the material belongs to.
  105931. * @param isFrozen defines whether the material is frozen or not.
  105932. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105933. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105934. */
  105935. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105936. /**
  105937. * Unbinds the material from the mesh.
  105938. * @param activeEffect defines the effect that should be unbound from.
  105939. * @returns true if unbound, otherwise false
  105940. */
  105941. unbind(activeEffect: Effect): boolean;
  105942. /**
  105943. * Returns the texture used for refraction or null if none is used.
  105944. * @param scene defines the scene the material belongs to.
  105945. * @returns - Refraction texture if present. If no refraction texture and refraction
  105946. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105947. */
  105948. private _getRefractionTexture;
  105949. /**
  105950. * Returns true if alpha blending should be disabled.
  105951. */
  105952. get disableAlphaBlending(): boolean;
  105953. /**
  105954. * Fills the list of render target textures.
  105955. * @param renderTargets the list of render targets to update
  105956. */
  105957. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  105958. /**
  105959. * Checks to see if a texture is used in the material.
  105960. * @param texture - Base texture to use.
  105961. * @returns - Boolean specifying if a texture is used in the material.
  105962. */
  105963. hasTexture(texture: BaseTexture): boolean;
  105964. /**
  105965. * Gets a boolean indicating that current material needs to register RTT
  105966. * @returns true if this uses a render target otherwise false.
  105967. */
  105968. hasRenderTargetTextures(): boolean;
  105969. /**
  105970. * Returns an array of the actively used textures.
  105971. * @param activeTextures Array of BaseTextures
  105972. */
  105973. getActiveTextures(activeTextures: BaseTexture[]): void;
  105974. /**
  105975. * Returns the animatable textures.
  105976. * @param animatables Array of animatable textures.
  105977. */
  105978. getAnimatables(animatables: IAnimatable[]): void;
  105979. /**
  105980. * Disposes the resources of the material.
  105981. * @param forceDisposeTextures - Forces the disposal of all textures.
  105982. */
  105983. dispose(forceDisposeTextures?: boolean): void;
  105984. /**
  105985. * Get the current class name of the texture useful for serialization or dynamic coding.
  105986. * @returns "PBRSubSurfaceConfiguration"
  105987. */
  105988. getClassName(): string;
  105989. /**
  105990. * Add fallbacks to the effect fallbacks list.
  105991. * @param defines defines the Base texture to use.
  105992. * @param fallbacks defines the current fallback list.
  105993. * @param currentRank defines the current fallback rank.
  105994. * @returns the new fallback rank.
  105995. */
  105996. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105997. /**
  105998. * Add the required uniforms to the current list.
  105999. * @param uniforms defines the current uniform list.
  106000. */
  106001. static AddUniforms(uniforms: string[]): void;
  106002. /**
  106003. * Add the required samplers to the current list.
  106004. * @param samplers defines the current sampler list.
  106005. */
  106006. static AddSamplers(samplers: string[]): void;
  106007. /**
  106008. * Add the required uniforms to the current buffer.
  106009. * @param uniformBuffer defines the current uniform buffer.
  106010. */
  106011. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106012. /**
  106013. * Makes a duplicate of the current configuration into another one.
  106014. * @param configuration define the config where to copy the info
  106015. */
  106016. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106017. /**
  106018. * Serializes this Sub Surface configuration.
  106019. * @returns - An object with the serialized config.
  106020. */
  106021. serialize(): any;
  106022. /**
  106023. * Parses a anisotropy Configuration from a serialized object.
  106024. * @param source - Serialized object.
  106025. * @param scene Defines the scene we are parsing for
  106026. * @param rootUrl Defines the rootUrl to load from
  106027. */
  106028. parse(source: any, scene: Scene, rootUrl: string): void;
  106029. }
  106030. }
  106031. declare module BABYLON {
  106032. /**
  106033. * Class representing spherical harmonics coefficients to the 3rd degree
  106034. */
  106035. export class SphericalHarmonics {
  106036. /**
  106037. * Defines whether or not the harmonics have been prescaled for rendering.
  106038. */
  106039. preScaled: boolean;
  106040. /**
  106041. * The l0,0 coefficients of the spherical harmonics
  106042. */
  106043. l00: Vector3;
  106044. /**
  106045. * The l1,-1 coefficients of the spherical harmonics
  106046. */
  106047. l1_1: Vector3;
  106048. /**
  106049. * The l1,0 coefficients of the spherical harmonics
  106050. */
  106051. l10: Vector3;
  106052. /**
  106053. * The l1,1 coefficients of the spherical harmonics
  106054. */
  106055. l11: Vector3;
  106056. /**
  106057. * The l2,-2 coefficients of the spherical harmonics
  106058. */
  106059. l2_2: Vector3;
  106060. /**
  106061. * The l2,-1 coefficients of the spherical harmonics
  106062. */
  106063. l2_1: Vector3;
  106064. /**
  106065. * The l2,0 coefficients of the spherical harmonics
  106066. */
  106067. l20: Vector3;
  106068. /**
  106069. * The l2,1 coefficients of the spherical harmonics
  106070. */
  106071. l21: Vector3;
  106072. /**
  106073. * The l2,2 coefficients of the spherical harmonics
  106074. */
  106075. l22: Vector3;
  106076. /**
  106077. * Adds a light to the spherical harmonics
  106078. * @param direction the direction of the light
  106079. * @param color the color of the light
  106080. * @param deltaSolidAngle the delta solid angle of the light
  106081. */
  106082. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106083. /**
  106084. * Scales the spherical harmonics by the given amount
  106085. * @param scale the amount to scale
  106086. */
  106087. scaleInPlace(scale: number): void;
  106088. /**
  106089. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106090. *
  106091. * ```
  106092. * E_lm = A_l * L_lm
  106093. * ```
  106094. *
  106095. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106096. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106097. * the scaling factors are given in equation 9.
  106098. */
  106099. convertIncidentRadianceToIrradiance(): void;
  106100. /**
  106101. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106102. *
  106103. * ```
  106104. * L = (1/pi) * E * rho
  106105. * ```
  106106. *
  106107. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106108. */
  106109. convertIrradianceToLambertianRadiance(): void;
  106110. /**
  106111. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106112. * required operations at run time.
  106113. *
  106114. * This is simply done by scaling back the SH with Ylm constants parameter.
  106115. * The trigonometric part being applied by the shader at run time.
  106116. */
  106117. preScaleForRendering(): void;
  106118. /**
  106119. * Constructs a spherical harmonics from an array.
  106120. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106121. * @returns the spherical harmonics
  106122. */
  106123. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106124. /**
  106125. * Gets the spherical harmonics from polynomial
  106126. * @param polynomial the spherical polynomial
  106127. * @returns the spherical harmonics
  106128. */
  106129. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106130. }
  106131. /**
  106132. * Class representing spherical polynomial coefficients to the 3rd degree
  106133. */
  106134. export class SphericalPolynomial {
  106135. private _harmonics;
  106136. /**
  106137. * The spherical harmonics used to create the polynomials.
  106138. */
  106139. get preScaledHarmonics(): SphericalHarmonics;
  106140. /**
  106141. * The x coefficients of the spherical polynomial
  106142. */
  106143. x: Vector3;
  106144. /**
  106145. * The y coefficients of the spherical polynomial
  106146. */
  106147. y: Vector3;
  106148. /**
  106149. * The z coefficients of the spherical polynomial
  106150. */
  106151. z: Vector3;
  106152. /**
  106153. * The xx coefficients of the spherical polynomial
  106154. */
  106155. xx: Vector3;
  106156. /**
  106157. * The yy coefficients of the spherical polynomial
  106158. */
  106159. yy: Vector3;
  106160. /**
  106161. * The zz coefficients of the spherical polynomial
  106162. */
  106163. zz: Vector3;
  106164. /**
  106165. * The xy coefficients of the spherical polynomial
  106166. */
  106167. xy: Vector3;
  106168. /**
  106169. * The yz coefficients of the spherical polynomial
  106170. */
  106171. yz: Vector3;
  106172. /**
  106173. * The zx coefficients of the spherical polynomial
  106174. */
  106175. zx: Vector3;
  106176. /**
  106177. * Adds an ambient color to the spherical polynomial
  106178. * @param color the color to add
  106179. */
  106180. addAmbient(color: Color3): void;
  106181. /**
  106182. * Scales the spherical polynomial by the given amount
  106183. * @param scale the amount to scale
  106184. */
  106185. scaleInPlace(scale: number): void;
  106186. /**
  106187. * Gets the spherical polynomial from harmonics
  106188. * @param harmonics the spherical harmonics
  106189. * @returns the spherical polynomial
  106190. */
  106191. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106192. /**
  106193. * Constructs a spherical polynomial from an array.
  106194. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106195. * @returns the spherical polynomial
  106196. */
  106197. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106198. }
  106199. }
  106200. declare module BABYLON {
  106201. /**
  106202. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106203. */
  106204. export interface CubeMapInfo {
  106205. /**
  106206. * The pixel array for the front face.
  106207. * This is stored in format, left to right, up to down format.
  106208. */
  106209. front: Nullable<ArrayBufferView>;
  106210. /**
  106211. * The pixel array for the back face.
  106212. * This is stored in format, left to right, up to down format.
  106213. */
  106214. back: Nullable<ArrayBufferView>;
  106215. /**
  106216. * The pixel array for the left face.
  106217. * This is stored in format, left to right, up to down format.
  106218. */
  106219. left: Nullable<ArrayBufferView>;
  106220. /**
  106221. * The pixel array for the right face.
  106222. * This is stored in format, left to right, up to down format.
  106223. */
  106224. right: Nullable<ArrayBufferView>;
  106225. /**
  106226. * The pixel array for the up face.
  106227. * This is stored in format, left to right, up to down format.
  106228. */
  106229. up: Nullable<ArrayBufferView>;
  106230. /**
  106231. * The pixel array for the down face.
  106232. * This is stored in format, left to right, up to down format.
  106233. */
  106234. down: Nullable<ArrayBufferView>;
  106235. /**
  106236. * The size of the cubemap stored.
  106237. *
  106238. * Each faces will be size * size pixels.
  106239. */
  106240. size: number;
  106241. /**
  106242. * The format of the texture.
  106243. *
  106244. * RGBA, RGB.
  106245. */
  106246. format: number;
  106247. /**
  106248. * The type of the texture data.
  106249. *
  106250. * UNSIGNED_INT, FLOAT.
  106251. */
  106252. type: number;
  106253. /**
  106254. * Specifies whether the texture is in gamma space.
  106255. */
  106256. gammaSpace: boolean;
  106257. }
  106258. /**
  106259. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106260. */
  106261. export class PanoramaToCubeMapTools {
  106262. private static FACE_LEFT;
  106263. private static FACE_RIGHT;
  106264. private static FACE_FRONT;
  106265. private static FACE_BACK;
  106266. private static FACE_DOWN;
  106267. private static FACE_UP;
  106268. /**
  106269. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106270. *
  106271. * @param float32Array The source data.
  106272. * @param inputWidth The width of the input panorama.
  106273. * @param inputHeight The height of the input panorama.
  106274. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106275. * @return The cubemap data
  106276. */
  106277. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106278. private static CreateCubemapTexture;
  106279. private static CalcProjectionSpherical;
  106280. }
  106281. }
  106282. declare module BABYLON {
  106283. /**
  106284. * Helper class dealing with the extraction of spherical polynomial dataArray
  106285. * from a cube map.
  106286. */
  106287. export class CubeMapToSphericalPolynomialTools {
  106288. private static FileFaces;
  106289. /**
  106290. * Converts a texture to the according Spherical Polynomial data.
  106291. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106292. *
  106293. * @param texture The texture to extract the information from.
  106294. * @return The Spherical Polynomial data.
  106295. */
  106296. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  106297. /**
  106298. * Converts a cubemap to the according Spherical Polynomial data.
  106299. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106300. *
  106301. * @param cubeInfo The Cube map to extract the information from.
  106302. * @return The Spherical Polynomial data.
  106303. */
  106304. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106305. }
  106306. }
  106307. declare module BABYLON {
  106308. interface BaseTexture {
  106309. /**
  106310. * Get the polynomial representation of the texture data.
  106311. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106312. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106313. */
  106314. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106315. }
  106316. }
  106317. declare module BABYLON {
  106318. /** @hidden */
  106319. export var pbrFragmentDeclaration: {
  106320. name: string;
  106321. shader: string;
  106322. };
  106323. }
  106324. declare module BABYLON {
  106325. /** @hidden */
  106326. export var pbrUboDeclaration: {
  106327. name: string;
  106328. shader: string;
  106329. };
  106330. }
  106331. declare module BABYLON {
  106332. /** @hidden */
  106333. export var pbrFragmentExtraDeclaration: {
  106334. name: string;
  106335. shader: string;
  106336. };
  106337. }
  106338. declare module BABYLON {
  106339. /** @hidden */
  106340. export var pbrFragmentSamplersDeclaration: {
  106341. name: string;
  106342. shader: string;
  106343. };
  106344. }
  106345. declare module BABYLON {
  106346. /** @hidden */
  106347. export var subSurfaceScatteringFunctions: {
  106348. name: string;
  106349. shader: string;
  106350. };
  106351. }
  106352. declare module BABYLON {
  106353. /** @hidden */
  106354. export var importanceSampling: {
  106355. name: string;
  106356. shader: string;
  106357. };
  106358. }
  106359. declare module BABYLON {
  106360. /** @hidden */
  106361. export var pbrHelperFunctions: {
  106362. name: string;
  106363. shader: string;
  106364. };
  106365. }
  106366. declare module BABYLON {
  106367. /** @hidden */
  106368. export var harmonicsFunctions: {
  106369. name: string;
  106370. shader: string;
  106371. };
  106372. }
  106373. declare module BABYLON {
  106374. /** @hidden */
  106375. export var pbrDirectLightingSetupFunctions: {
  106376. name: string;
  106377. shader: string;
  106378. };
  106379. }
  106380. declare module BABYLON {
  106381. /** @hidden */
  106382. export var pbrDirectLightingFalloffFunctions: {
  106383. name: string;
  106384. shader: string;
  106385. };
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var pbrBRDFFunctions: {
  106390. name: string;
  106391. shader: string;
  106392. };
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var hdrFilteringFunctions: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. /** @hidden */
  106403. export var pbrDirectLightingFunctions: {
  106404. name: string;
  106405. shader: string;
  106406. };
  106407. }
  106408. declare module BABYLON {
  106409. /** @hidden */
  106410. export var pbrIBLFunctions: {
  106411. name: string;
  106412. shader: string;
  106413. };
  106414. }
  106415. declare module BABYLON {
  106416. /** @hidden */
  106417. export var pbrBlockAlbedoOpacity: {
  106418. name: string;
  106419. shader: string;
  106420. };
  106421. }
  106422. declare module BABYLON {
  106423. /** @hidden */
  106424. export var pbrBlockReflectivity: {
  106425. name: string;
  106426. shader: string;
  106427. };
  106428. }
  106429. declare module BABYLON {
  106430. /** @hidden */
  106431. export var pbrBlockAmbientOcclusion: {
  106432. name: string;
  106433. shader: string;
  106434. };
  106435. }
  106436. declare module BABYLON {
  106437. /** @hidden */
  106438. export var pbrBlockAlphaFresnel: {
  106439. name: string;
  106440. shader: string;
  106441. };
  106442. }
  106443. declare module BABYLON {
  106444. /** @hidden */
  106445. export var pbrBlockAnisotropic: {
  106446. name: string;
  106447. shader: string;
  106448. };
  106449. }
  106450. declare module BABYLON {
  106451. /** @hidden */
  106452. export var pbrBlockReflection: {
  106453. name: string;
  106454. shader: string;
  106455. };
  106456. }
  106457. declare module BABYLON {
  106458. /** @hidden */
  106459. export var pbrBlockSheen: {
  106460. name: string;
  106461. shader: string;
  106462. };
  106463. }
  106464. declare module BABYLON {
  106465. /** @hidden */
  106466. export var pbrBlockClearcoat: {
  106467. name: string;
  106468. shader: string;
  106469. };
  106470. }
  106471. declare module BABYLON {
  106472. /** @hidden */
  106473. export var pbrBlockSubSurface: {
  106474. name: string;
  106475. shader: string;
  106476. };
  106477. }
  106478. declare module BABYLON {
  106479. /** @hidden */
  106480. export var pbrBlockNormalGeometric: {
  106481. name: string;
  106482. shader: string;
  106483. };
  106484. }
  106485. declare module BABYLON {
  106486. /** @hidden */
  106487. export var pbrBlockNormalFinal: {
  106488. name: string;
  106489. shader: string;
  106490. };
  106491. }
  106492. declare module BABYLON {
  106493. /** @hidden */
  106494. export var pbrBlockLightmapInit: {
  106495. name: string;
  106496. shader: string;
  106497. };
  106498. }
  106499. declare module BABYLON {
  106500. /** @hidden */
  106501. export var pbrBlockGeometryInfo: {
  106502. name: string;
  106503. shader: string;
  106504. };
  106505. }
  106506. declare module BABYLON {
  106507. /** @hidden */
  106508. export var pbrBlockReflectance0: {
  106509. name: string;
  106510. shader: string;
  106511. };
  106512. }
  106513. declare module BABYLON {
  106514. /** @hidden */
  106515. export var pbrBlockReflectance: {
  106516. name: string;
  106517. shader: string;
  106518. };
  106519. }
  106520. declare module BABYLON {
  106521. /** @hidden */
  106522. export var pbrBlockDirectLighting: {
  106523. name: string;
  106524. shader: string;
  106525. };
  106526. }
  106527. declare module BABYLON {
  106528. /** @hidden */
  106529. export var pbrBlockFinalLitComponents: {
  106530. name: string;
  106531. shader: string;
  106532. };
  106533. }
  106534. declare module BABYLON {
  106535. /** @hidden */
  106536. export var pbrBlockFinalUnlitComponents: {
  106537. name: string;
  106538. shader: string;
  106539. };
  106540. }
  106541. declare module BABYLON {
  106542. /** @hidden */
  106543. export var pbrBlockFinalColorComposition: {
  106544. name: string;
  106545. shader: string;
  106546. };
  106547. }
  106548. declare module BABYLON {
  106549. /** @hidden */
  106550. export var pbrBlockImageProcessing: {
  106551. name: string;
  106552. shader: string;
  106553. };
  106554. }
  106555. declare module BABYLON {
  106556. /** @hidden */
  106557. export var pbrDebug: {
  106558. name: string;
  106559. shader: string;
  106560. };
  106561. }
  106562. declare module BABYLON {
  106563. /** @hidden */
  106564. export var pbrPixelShader: {
  106565. name: string;
  106566. shader: string;
  106567. };
  106568. }
  106569. declare module BABYLON {
  106570. /** @hidden */
  106571. export var pbrVertexDeclaration: {
  106572. name: string;
  106573. shader: string;
  106574. };
  106575. }
  106576. declare module BABYLON {
  106577. /** @hidden */
  106578. export var pbrVertexShader: {
  106579. name: string;
  106580. shader: string;
  106581. };
  106582. }
  106583. declare module BABYLON {
  106584. /**
  106585. * Manages the defines for the PBR Material.
  106586. * @hidden
  106587. */
  106588. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106589. PBR: boolean;
  106590. NUM_SAMPLES: string;
  106591. REALTIME_FILTERING: boolean;
  106592. MAINUV1: boolean;
  106593. MAINUV2: boolean;
  106594. UV1: boolean;
  106595. UV2: boolean;
  106596. ALBEDO: boolean;
  106597. GAMMAALBEDO: boolean;
  106598. ALBEDODIRECTUV: number;
  106599. VERTEXCOLOR: boolean;
  106600. DETAIL: boolean;
  106601. DETAILDIRECTUV: number;
  106602. DETAIL_NORMALBLENDMETHOD: number;
  106603. AMBIENT: boolean;
  106604. AMBIENTDIRECTUV: number;
  106605. AMBIENTINGRAYSCALE: boolean;
  106606. OPACITY: boolean;
  106607. VERTEXALPHA: boolean;
  106608. OPACITYDIRECTUV: number;
  106609. OPACITYRGB: boolean;
  106610. ALPHATEST: boolean;
  106611. DEPTHPREPASS: boolean;
  106612. ALPHABLEND: boolean;
  106613. ALPHAFROMALBEDO: boolean;
  106614. ALPHATESTVALUE: string;
  106615. SPECULAROVERALPHA: boolean;
  106616. RADIANCEOVERALPHA: boolean;
  106617. ALPHAFRESNEL: boolean;
  106618. LINEARALPHAFRESNEL: boolean;
  106619. PREMULTIPLYALPHA: boolean;
  106620. EMISSIVE: boolean;
  106621. EMISSIVEDIRECTUV: number;
  106622. REFLECTIVITY: boolean;
  106623. REFLECTIVITYDIRECTUV: number;
  106624. SPECULARTERM: boolean;
  106625. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106626. MICROSURFACEAUTOMATIC: boolean;
  106627. LODBASEDMICROSFURACE: boolean;
  106628. MICROSURFACEMAP: boolean;
  106629. MICROSURFACEMAPDIRECTUV: number;
  106630. METALLICWORKFLOW: boolean;
  106631. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106632. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106633. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106634. AOSTOREINMETALMAPRED: boolean;
  106635. METALLIC_REFLECTANCE: boolean;
  106636. METALLIC_REFLECTANCEDIRECTUV: number;
  106637. ENVIRONMENTBRDF: boolean;
  106638. ENVIRONMENTBRDF_RGBD: boolean;
  106639. NORMAL: boolean;
  106640. TANGENT: boolean;
  106641. BUMP: boolean;
  106642. BUMPDIRECTUV: number;
  106643. OBJECTSPACE_NORMALMAP: boolean;
  106644. PARALLAX: boolean;
  106645. PARALLAXOCCLUSION: boolean;
  106646. NORMALXYSCALE: boolean;
  106647. LIGHTMAP: boolean;
  106648. LIGHTMAPDIRECTUV: number;
  106649. USELIGHTMAPASSHADOWMAP: boolean;
  106650. GAMMALIGHTMAP: boolean;
  106651. RGBDLIGHTMAP: boolean;
  106652. REFLECTION: boolean;
  106653. REFLECTIONMAP_3D: boolean;
  106654. REFLECTIONMAP_SPHERICAL: boolean;
  106655. REFLECTIONMAP_PLANAR: boolean;
  106656. REFLECTIONMAP_CUBIC: boolean;
  106657. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106658. REFLECTIONMAP_PROJECTION: boolean;
  106659. REFLECTIONMAP_SKYBOX: boolean;
  106660. REFLECTIONMAP_EXPLICIT: boolean;
  106661. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106662. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106663. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106664. INVERTCUBICMAP: boolean;
  106665. USESPHERICALFROMREFLECTIONMAP: boolean;
  106666. USEIRRADIANCEMAP: boolean;
  106667. SPHERICAL_HARMONICS: boolean;
  106668. USESPHERICALINVERTEX: boolean;
  106669. REFLECTIONMAP_OPPOSITEZ: boolean;
  106670. LODINREFLECTIONALPHA: boolean;
  106671. GAMMAREFLECTION: boolean;
  106672. RGBDREFLECTION: boolean;
  106673. LINEARSPECULARREFLECTION: boolean;
  106674. RADIANCEOCCLUSION: boolean;
  106675. HORIZONOCCLUSION: boolean;
  106676. INSTANCES: boolean;
  106677. THIN_INSTANCES: boolean;
  106678. PREPASS: boolean;
  106679. PREPASS_IRRADIANCE: boolean;
  106680. PREPASS_IRRADIANCE_INDEX: number;
  106681. PREPASS_ALBEDO: boolean;
  106682. PREPASS_ALBEDO_INDEX: number;
  106683. PREPASS_DEPTHNORMAL: boolean;
  106684. PREPASS_DEPTHNORMAL_INDEX: number;
  106685. PREPASS_POSITION: boolean;
  106686. PREPASS_POSITION_INDEX: number;
  106687. PREPASS_VELOCITY: boolean;
  106688. PREPASS_VELOCITY_INDEX: number;
  106689. PREPASS_REFLECTIVITY: boolean;
  106690. PREPASS_REFLECTIVITY_INDEX: number;
  106691. SCENE_MRT_COUNT: number;
  106692. NUM_BONE_INFLUENCERS: number;
  106693. BonesPerMesh: number;
  106694. BONETEXTURE: boolean;
  106695. BONES_VELOCITY_ENABLED: boolean;
  106696. NONUNIFORMSCALING: boolean;
  106697. MORPHTARGETS: boolean;
  106698. MORPHTARGETS_NORMAL: boolean;
  106699. MORPHTARGETS_TANGENT: boolean;
  106700. MORPHTARGETS_UV: boolean;
  106701. NUM_MORPH_INFLUENCERS: number;
  106702. IMAGEPROCESSING: boolean;
  106703. VIGNETTE: boolean;
  106704. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106705. VIGNETTEBLENDMODEOPAQUE: boolean;
  106706. TONEMAPPING: boolean;
  106707. TONEMAPPING_ACES: boolean;
  106708. CONTRAST: boolean;
  106709. COLORCURVES: boolean;
  106710. COLORGRADING: boolean;
  106711. COLORGRADING3D: boolean;
  106712. SAMPLER3DGREENDEPTH: boolean;
  106713. SAMPLER3DBGRMAP: boolean;
  106714. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106715. EXPOSURE: boolean;
  106716. MULTIVIEW: boolean;
  106717. USEPHYSICALLIGHTFALLOFF: boolean;
  106718. USEGLTFLIGHTFALLOFF: boolean;
  106719. TWOSIDEDLIGHTING: boolean;
  106720. SHADOWFLOAT: boolean;
  106721. CLIPPLANE: boolean;
  106722. CLIPPLANE2: boolean;
  106723. CLIPPLANE3: boolean;
  106724. CLIPPLANE4: boolean;
  106725. CLIPPLANE5: boolean;
  106726. CLIPPLANE6: boolean;
  106727. POINTSIZE: boolean;
  106728. FOG: boolean;
  106729. LOGARITHMICDEPTH: boolean;
  106730. FORCENORMALFORWARD: boolean;
  106731. SPECULARAA: boolean;
  106732. CLEARCOAT: boolean;
  106733. CLEARCOAT_DEFAULTIOR: boolean;
  106734. CLEARCOAT_TEXTURE: boolean;
  106735. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106736. CLEARCOAT_TEXTUREDIRECTUV: number;
  106737. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106738. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106739. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106740. CLEARCOAT_BUMP: boolean;
  106741. CLEARCOAT_BUMPDIRECTUV: number;
  106742. CLEARCOAT_REMAP_F0: boolean;
  106743. CLEARCOAT_TINT: boolean;
  106744. CLEARCOAT_TINT_TEXTURE: boolean;
  106745. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106746. ANISOTROPIC: boolean;
  106747. ANISOTROPIC_TEXTURE: boolean;
  106748. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106749. BRDF_V_HEIGHT_CORRELATED: boolean;
  106750. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106751. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106752. SHEEN: boolean;
  106753. SHEEN_TEXTURE: boolean;
  106754. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106755. SHEEN_TEXTUREDIRECTUV: number;
  106756. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106757. SHEEN_LINKWITHALBEDO: boolean;
  106758. SHEEN_ROUGHNESS: boolean;
  106759. SHEEN_ALBEDOSCALING: boolean;
  106760. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106761. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106762. SUBSURFACE: boolean;
  106763. SS_REFRACTION: boolean;
  106764. SS_TRANSLUCENCY: boolean;
  106765. SS_SCATTERING: boolean;
  106766. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106767. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106768. SS_REFRACTIONMAP_3D: boolean;
  106769. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106770. SS_LODINREFRACTIONALPHA: boolean;
  106771. SS_GAMMAREFRACTION: boolean;
  106772. SS_RGBDREFRACTION: boolean;
  106773. SS_LINEARSPECULARREFRACTION: boolean;
  106774. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106775. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106776. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106777. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  106778. UNLIT: boolean;
  106779. DEBUGMODE: number;
  106780. /**
  106781. * Initializes the PBR Material defines.
  106782. */
  106783. constructor();
  106784. /**
  106785. * Resets the PBR Material defines.
  106786. */
  106787. reset(): void;
  106788. }
  106789. /**
  106790. * The Physically based material base class of BJS.
  106791. *
  106792. * This offers the main features of a standard PBR material.
  106793. * For more information, please refer to the documentation :
  106794. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106795. */
  106796. export abstract class PBRBaseMaterial extends PushMaterial {
  106797. /**
  106798. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106799. */
  106800. static readonly PBRMATERIAL_OPAQUE: number;
  106801. /**
  106802. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106803. */
  106804. static readonly PBRMATERIAL_ALPHATEST: number;
  106805. /**
  106806. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106807. */
  106808. static readonly PBRMATERIAL_ALPHABLEND: number;
  106809. /**
  106810. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106811. * They are also discarded below the alpha cutoff threshold to improve performances.
  106812. */
  106813. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106814. /**
  106815. * Defines the default value of how much AO map is occluding the analytical lights
  106816. * (point spot...).
  106817. */
  106818. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106819. /**
  106820. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106821. */
  106822. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106823. /**
  106824. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106825. * to enhance interoperability with other engines.
  106826. */
  106827. static readonly LIGHTFALLOFF_GLTF: number;
  106828. /**
  106829. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106830. * to enhance interoperability with other materials.
  106831. */
  106832. static readonly LIGHTFALLOFF_STANDARD: number;
  106833. /**
  106834. * Intensity of the direct lights e.g. the four lights available in your scene.
  106835. * This impacts both the direct diffuse and specular highlights.
  106836. */
  106837. protected _directIntensity: number;
  106838. /**
  106839. * Intensity of the emissive part of the material.
  106840. * This helps controlling the emissive effect without modifying the emissive color.
  106841. */
  106842. protected _emissiveIntensity: number;
  106843. /**
  106844. * Intensity of the environment e.g. how much the environment will light the object
  106845. * either through harmonics for rough material or through the refelction for shiny ones.
  106846. */
  106847. protected _environmentIntensity: number;
  106848. /**
  106849. * This is a special control allowing the reduction of the specular highlights coming from the
  106850. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106851. */
  106852. protected _specularIntensity: number;
  106853. /**
  106854. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106855. */
  106856. private _lightingInfos;
  106857. /**
  106858. * Debug Control allowing disabling the bump map on this material.
  106859. */
  106860. protected _disableBumpMap: boolean;
  106861. /**
  106862. * AKA Diffuse Texture in standard nomenclature.
  106863. */
  106864. protected _albedoTexture: Nullable<BaseTexture>;
  106865. /**
  106866. * AKA Occlusion Texture in other nomenclature.
  106867. */
  106868. protected _ambientTexture: Nullable<BaseTexture>;
  106869. /**
  106870. * AKA Occlusion Texture Intensity in other nomenclature.
  106871. */
  106872. protected _ambientTextureStrength: number;
  106873. /**
  106874. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106875. * 1 means it completely occludes it
  106876. * 0 mean it has no impact
  106877. */
  106878. protected _ambientTextureImpactOnAnalyticalLights: number;
  106879. /**
  106880. * Stores the alpha values in a texture.
  106881. */
  106882. protected _opacityTexture: Nullable<BaseTexture>;
  106883. /**
  106884. * Stores the reflection values in a texture.
  106885. */
  106886. protected _reflectionTexture: Nullable<BaseTexture>;
  106887. /**
  106888. * Stores the emissive values in a texture.
  106889. */
  106890. protected _emissiveTexture: Nullable<BaseTexture>;
  106891. /**
  106892. * AKA Specular texture in other nomenclature.
  106893. */
  106894. protected _reflectivityTexture: Nullable<BaseTexture>;
  106895. /**
  106896. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106897. */
  106898. protected _metallicTexture: Nullable<BaseTexture>;
  106899. /**
  106900. * Specifies the metallic scalar of the metallic/roughness workflow.
  106901. * Can also be used to scale the metalness values of the metallic texture.
  106902. */
  106903. protected _metallic: Nullable<number>;
  106904. /**
  106905. * Specifies the roughness scalar of the metallic/roughness workflow.
  106906. * Can also be used to scale the roughness values of the metallic texture.
  106907. */
  106908. protected _roughness: Nullable<number>;
  106909. /**
  106910. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106911. * By default the indexOfrefraction is used to compute F0;
  106912. *
  106913. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106914. *
  106915. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106916. * F90 = metallicReflectanceColor;
  106917. */
  106918. protected _metallicF0Factor: number;
  106919. /**
  106920. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106921. * By default the F90 is always 1;
  106922. *
  106923. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106924. *
  106925. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106926. * F90 = metallicReflectanceColor;
  106927. */
  106928. protected _metallicReflectanceColor: Color3;
  106929. /**
  106930. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106931. * This is multiply against the scalar values defined in the material.
  106932. */
  106933. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106934. /**
  106935. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106936. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106937. */
  106938. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106939. /**
  106940. * Stores surface normal data used to displace a mesh in a texture.
  106941. */
  106942. protected _bumpTexture: Nullable<BaseTexture>;
  106943. /**
  106944. * Stores the pre-calculated light information of a mesh in a texture.
  106945. */
  106946. protected _lightmapTexture: Nullable<BaseTexture>;
  106947. /**
  106948. * The color of a material in ambient lighting.
  106949. */
  106950. protected _ambientColor: Color3;
  106951. /**
  106952. * AKA Diffuse Color in other nomenclature.
  106953. */
  106954. protected _albedoColor: Color3;
  106955. /**
  106956. * AKA Specular Color in other nomenclature.
  106957. */
  106958. protected _reflectivityColor: Color3;
  106959. /**
  106960. * The color applied when light is reflected from a material.
  106961. */
  106962. protected _reflectionColor: Color3;
  106963. /**
  106964. * The color applied when light is emitted from a material.
  106965. */
  106966. protected _emissiveColor: Color3;
  106967. /**
  106968. * AKA Glossiness in other nomenclature.
  106969. */
  106970. protected _microSurface: number;
  106971. /**
  106972. * Specifies that the material will use the light map as a show map.
  106973. */
  106974. protected _useLightmapAsShadowmap: boolean;
  106975. /**
  106976. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  106977. * makes the reflect vector face the model (under horizon).
  106978. */
  106979. protected _useHorizonOcclusion: boolean;
  106980. /**
  106981. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  106982. * too much the area relying on ambient texture to define their ambient occlusion.
  106983. */
  106984. protected _useRadianceOcclusion: boolean;
  106985. /**
  106986. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106987. */
  106988. protected _useAlphaFromAlbedoTexture: boolean;
  106989. /**
  106990. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  106991. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106992. */
  106993. protected _useSpecularOverAlpha: boolean;
  106994. /**
  106995. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106996. */
  106997. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106998. /**
  106999. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107000. */
  107001. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107002. /**
  107003. * Specifies if the metallic texture contains the roughness information in its green channel.
  107004. */
  107005. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107006. /**
  107007. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107008. */
  107009. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107010. /**
  107011. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107012. */
  107013. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107014. /**
  107015. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107016. */
  107017. protected _useAmbientInGrayScale: boolean;
  107018. /**
  107019. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107020. * The material will try to infer what glossiness each pixel should be.
  107021. */
  107022. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107023. /**
  107024. * Defines the falloff type used in this material.
  107025. * It by default is Physical.
  107026. */
  107027. protected _lightFalloff: number;
  107028. /**
  107029. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107030. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107031. */
  107032. protected _useRadianceOverAlpha: boolean;
  107033. /**
  107034. * Allows using an object space normal map (instead of tangent space).
  107035. */
  107036. protected _useObjectSpaceNormalMap: boolean;
  107037. /**
  107038. * Allows using the bump map in parallax mode.
  107039. */
  107040. protected _useParallax: boolean;
  107041. /**
  107042. * Allows using the bump map in parallax occlusion mode.
  107043. */
  107044. protected _useParallaxOcclusion: boolean;
  107045. /**
  107046. * Controls the scale bias of the parallax mode.
  107047. */
  107048. protected _parallaxScaleBias: number;
  107049. /**
  107050. * If sets to true, disables all the lights affecting the material.
  107051. */
  107052. protected _disableLighting: boolean;
  107053. /**
  107054. * Number of Simultaneous lights allowed on the material.
  107055. */
  107056. protected _maxSimultaneousLights: number;
  107057. /**
  107058. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107059. */
  107060. protected _invertNormalMapX: boolean;
  107061. /**
  107062. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107063. */
  107064. protected _invertNormalMapY: boolean;
  107065. /**
  107066. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107067. */
  107068. protected _twoSidedLighting: boolean;
  107069. /**
  107070. * Defines the alpha limits in alpha test mode.
  107071. */
  107072. protected _alphaCutOff: number;
  107073. /**
  107074. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107075. */
  107076. protected _forceAlphaTest: boolean;
  107077. /**
  107078. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107079. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107080. */
  107081. protected _useAlphaFresnel: boolean;
  107082. /**
  107083. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107084. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107085. */
  107086. protected _useLinearAlphaFresnel: boolean;
  107087. /**
  107088. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107089. * from cos thetav and roughness:
  107090. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107091. */
  107092. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107093. /**
  107094. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107095. */
  107096. protected _forceIrradianceInFragment: boolean;
  107097. private _realTimeFiltering;
  107098. /**
  107099. * Enables realtime filtering on the texture.
  107100. */
  107101. get realTimeFiltering(): boolean;
  107102. set realTimeFiltering(b: boolean);
  107103. private _realTimeFilteringQuality;
  107104. /**
  107105. * Quality switch for realtime filtering
  107106. */
  107107. get realTimeFilteringQuality(): number;
  107108. set realTimeFilteringQuality(n: number);
  107109. /**
  107110. * Can this material render to several textures at once
  107111. */
  107112. get canRenderToMRT(): boolean;
  107113. /**
  107114. * Force normal to face away from face.
  107115. */
  107116. protected _forceNormalForward: boolean;
  107117. /**
  107118. * Enables specular anti aliasing in the PBR shader.
  107119. * It will both interacts on the Geometry for analytical and IBL lighting.
  107120. * It also prefilter the roughness map based on the bump values.
  107121. */
  107122. protected _enableSpecularAntiAliasing: boolean;
  107123. /**
  107124. * Default configuration related to image processing available in the PBR Material.
  107125. */
  107126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107127. /**
  107128. * Keep track of the image processing observer to allow dispose and replace.
  107129. */
  107130. private _imageProcessingObserver;
  107131. /**
  107132. * Attaches a new image processing configuration to the PBR Material.
  107133. * @param configuration
  107134. */
  107135. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107136. /**
  107137. * Stores the available render targets.
  107138. */
  107139. private _renderTargets;
  107140. /**
  107141. * Sets the global ambient color for the material used in lighting calculations.
  107142. */
  107143. private _globalAmbientColor;
  107144. /**
  107145. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107146. */
  107147. private _useLogarithmicDepth;
  107148. /**
  107149. * If set to true, no lighting calculations will be applied.
  107150. */
  107151. private _unlit;
  107152. private _debugMode;
  107153. /**
  107154. * @hidden
  107155. * This is reserved for the inspector.
  107156. * Defines the material debug mode.
  107157. * It helps seeing only some components of the material while troubleshooting.
  107158. */
  107159. debugMode: number;
  107160. /**
  107161. * @hidden
  107162. * This is reserved for the inspector.
  107163. * Specify from where on screen the debug mode should start.
  107164. * The value goes from -1 (full screen) to 1 (not visible)
  107165. * It helps with side by side comparison against the final render
  107166. * This defaults to -1
  107167. */
  107168. private debugLimit;
  107169. /**
  107170. * @hidden
  107171. * This is reserved for the inspector.
  107172. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107173. * You can use the factor to better multiply the final value.
  107174. */
  107175. private debugFactor;
  107176. /**
  107177. * Defines the clear coat layer parameters for the material.
  107178. */
  107179. readonly clearCoat: PBRClearCoatConfiguration;
  107180. /**
  107181. * Defines the anisotropic parameters for the material.
  107182. */
  107183. readonly anisotropy: PBRAnisotropicConfiguration;
  107184. /**
  107185. * Defines the BRDF parameters for the material.
  107186. */
  107187. readonly brdf: PBRBRDFConfiguration;
  107188. /**
  107189. * Defines the Sheen parameters for the material.
  107190. */
  107191. readonly sheen: PBRSheenConfiguration;
  107192. /**
  107193. * Defines the SubSurface parameters for the material.
  107194. */
  107195. readonly subSurface: PBRSubSurfaceConfiguration;
  107196. /**
  107197. * Defines additionnal PrePass parameters for the material.
  107198. */
  107199. readonly prePassConfiguration: PrePassConfiguration;
  107200. /**
  107201. * Defines the detail map parameters for the material.
  107202. */
  107203. readonly detailMap: DetailMapConfiguration;
  107204. protected _rebuildInParallel: boolean;
  107205. /**
  107206. * Instantiates a new PBRMaterial instance.
  107207. *
  107208. * @param name The material name
  107209. * @param scene The scene the material will be use in.
  107210. */
  107211. constructor(name: string, scene: Scene);
  107212. /**
  107213. * Gets a boolean indicating that current material needs to register RTT
  107214. */
  107215. get hasRenderTargetTextures(): boolean;
  107216. /**
  107217. * Gets the name of the material class.
  107218. */
  107219. getClassName(): string;
  107220. /**
  107221. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107222. */
  107223. get useLogarithmicDepth(): boolean;
  107224. /**
  107225. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107226. */
  107227. set useLogarithmicDepth(value: boolean);
  107228. /**
  107229. * Returns true if alpha blending should be disabled.
  107230. */
  107231. protected get _disableAlphaBlending(): boolean;
  107232. /**
  107233. * Specifies whether or not this material should be rendered in alpha blend mode.
  107234. */
  107235. needAlphaBlending(): boolean;
  107236. /**
  107237. * Specifies whether or not this material should be rendered in alpha test mode.
  107238. */
  107239. needAlphaTesting(): boolean;
  107240. /**
  107241. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107242. */
  107243. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107244. /**
  107245. * Specifies whether or not there is a usable alpha channel for transparency.
  107246. */
  107247. protected _hasAlphaChannel(): boolean;
  107248. /**
  107249. * Gets the texture used for the alpha test.
  107250. */
  107251. getAlphaTestTexture(): Nullable<BaseTexture>;
  107252. /**
  107253. * Specifies that the submesh is ready to be used.
  107254. * @param mesh - BJS mesh.
  107255. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107256. * @param useInstances - Specifies that instances should be used.
  107257. * @returns - boolean indicating that the submesh is ready or not.
  107258. */
  107259. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107260. /**
  107261. * Specifies if the material uses metallic roughness workflow.
  107262. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107263. */
  107264. isMetallicWorkflow(): boolean;
  107265. private _prepareEffect;
  107266. private _prepareDefines;
  107267. /**
  107268. * Force shader compilation
  107269. */
  107270. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107271. /**
  107272. * Initializes the uniform buffer layout for the shader.
  107273. */
  107274. buildUniformLayout(): void;
  107275. /**
  107276. * Unbinds the material from the mesh
  107277. */
  107278. unbind(): void;
  107279. /**
  107280. * Binds the submesh data.
  107281. * @param world - The world matrix.
  107282. * @param mesh - The BJS mesh.
  107283. * @param subMesh - A submesh of the BJS mesh.
  107284. */
  107285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107286. /**
  107287. * Returns the animatable textures.
  107288. * @returns - Array of animatable textures.
  107289. */
  107290. getAnimatables(): IAnimatable[];
  107291. /**
  107292. * Returns the texture used for reflections.
  107293. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107294. */
  107295. private _getReflectionTexture;
  107296. /**
  107297. * Returns an array of the actively used textures.
  107298. * @returns - Array of BaseTextures
  107299. */
  107300. getActiveTextures(): BaseTexture[];
  107301. /**
  107302. * Checks to see if a texture is used in the material.
  107303. * @param texture - Base texture to use.
  107304. * @returns - Boolean specifying if a texture is used in the material.
  107305. */
  107306. hasTexture(texture: BaseTexture): boolean;
  107307. /**
  107308. * Sets the required values to the prepass renderer.
  107309. * @param prePassRenderer defines the prepass renderer to setup
  107310. */
  107311. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107312. /**
  107313. * Disposes the resources of the material.
  107314. * @param forceDisposeEffect - Forces the disposal of effects.
  107315. * @param forceDisposeTextures - Forces the disposal of all textures.
  107316. */
  107317. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107318. }
  107319. }
  107320. declare module BABYLON {
  107321. /**
  107322. * The Physically based material of BJS.
  107323. *
  107324. * This offers the main features of a standard PBR material.
  107325. * For more information, please refer to the documentation :
  107326. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107327. */
  107328. export class PBRMaterial extends PBRBaseMaterial {
  107329. /**
  107330. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107331. */
  107332. static readonly PBRMATERIAL_OPAQUE: number;
  107333. /**
  107334. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107335. */
  107336. static readonly PBRMATERIAL_ALPHATEST: number;
  107337. /**
  107338. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107339. */
  107340. static readonly PBRMATERIAL_ALPHABLEND: number;
  107341. /**
  107342. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107343. * They are also discarded below the alpha cutoff threshold to improve performances.
  107344. */
  107345. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107346. /**
  107347. * Defines the default value of how much AO map is occluding the analytical lights
  107348. * (point spot...).
  107349. */
  107350. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107351. /**
  107352. * Intensity of the direct lights e.g. the four lights available in your scene.
  107353. * This impacts both the direct diffuse and specular highlights.
  107354. */
  107355. directIntensity: number;
  107356. /**
  107357. * Intensity of the emissive part of the material.
  107358. * This helps controlling the emissive effect without modifying the emissive color.
  107359. */
  107360. emissiveIntensity: number;
  107361. /**
  107362. * Intensity of the environment e.g. how much the environment will light the object
  107363. * either through harmonics for rough material or through the refelction for shiny ones.
  107364. */
  107365. environmentIntensity: number;
  107366. /**
  107367. * This is a special control allowing the reduction of the specular highlights coming from the
  107368. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107369. */
  107370. specularIntensity: number;
  107371. /**
  107372. * Debug Control allowing disabling the bump map on this material.
  107373. */
  107374. disableBumpMap: boolean;
  107375. /**
  107376. * AKA Diffuse Texture in standard nomenclature.
  107377. */
  107378. albedoTexture: BaseTexture;
  107379. /**
  107380. * AKA Occlusion Texture in other nomenclature.
  107381. */
  107382. ambientTexture: BaseTexture;
  107383. /**
  107384. * AKA Occlusion Texture Intensity in other nomenclature.
  107385. */
  107386. ambientTextureStrength: number;
  107387. /**
  107388. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107389. * 1 means it completely occludes it
  107390. * 0 mean it has no impact
  107391. */
  107392. ambientTextureImpactOnAnalyticalLights: number;
  107393. /**
  107394. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107395. */
  107396. opacityTexture: BaseTexture;
  107397. /**
  107398. * Stores the reflection values in a texture.
  107399. */
  107400. reflectionTexture: Nullable<BaseTexture>;
  107401. /**
  107402. * Stores the emissive values in a texture.
  107403. */
  107404. emissiveTexture: BaseTexture;
  107405. /**
  107406. * AKA Specular texture in other nomenclature.
  107407. */
  107408. reflectivityTexture: BaseTexture;
  107409. /**
  107410. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107411. */
  107412. metallicTexture: BaseTexture;
  107413. /**
  107414. * Specifies the metallic scalar of the metallic/roughness workflow.
  107415. * Can also be used to scale the metalness values of the metallic texture.
  107416. */
  107417. metallic: Nullable<number>;
  107418. /**
  107419. * Specifies the roughness scalar of the metallic/roughness workflow.
  107420. * Can also be used to scale the roughness values of the metallic texture.
  107421. */
  107422. roughness: Nullable<number>;
  107423. /**
  107424. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107425. * By default the indexOfrefraction is used to compute F0;
  107426. *
  107427. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107428. *
  107429. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107430. * F90 = metallicReflectanceColor;
  107431. */
  107432. metallicF0Factor: number;
  107433. /**
  107434. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107435. * By default the F90 is always 1;
  107436. *
  107437. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107438. *
  107439. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107440. * F90 = metallicReflectanceColor;
  107441. */
  107442. metallicReflectanceColor: Color3;
  107443. /**
  107444. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107445. * This is multiply against the scalar values defined in the material.
  107446. */
  107447. metallicReflectanceTexture: Nullable<BaseTexture>;
  107448. /**
  107449. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107450. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107451. */
  107452. microSurfaceTexture: BaseTexture;
  107453. /**
  107454. * Stores surface normal data used to displace a mesh in a texture.
  107455. */
  107456. bumpTexture: BaseTexture;
  107457. /**
  107458. * Stores the pre-calculated light information of a mesh in a texture.
  107459. */
  107460. lightmapTexture: BaseTexture;
  107461. /**
  107462. * Stores the refracted light information in a texture.
  107463. */
  107464. get refractionTexture(): Nullable<BaseTexture>;
  107465. set refractionTexture(value: Nullable<BaseTexture>);
  107466. /**
  107467. * The color of a material in ambient lighting.
  107468. */
  107469. ambientColor: Color3;
  107470. /**
  107471. * AKA Diffuse Color in other nomenclature.
  107472. */
  107473. albedoColor: Color3;
  107474. /**
  107475. * AKA Specular Color in other nomenclature.
  107476. */
  107477. reflectivityColor: Color3;
  107478. /**
  107479. * The color reflected from the material.
  107480. */
  107481. reflectionColor: Color3;
  107482. /**
  107483. * The color emitted from the material.
  107484. */
  107485. emissiveColor: Color3;
  107486. /**
  107487. * AKA Glossiness in other nomenclature.
  107488. */
  107489. microSurface: number;
  107490. /**
  107491. * Index of refraction of the material base layer.
  107492. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107493. *
  107494. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107495. *
  107496. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107497. */
  107498. get indexOfRefraction(): number;
  107499. set indexOfRefraction(value: number);
  107500. /**
  107501. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107502. */
  107503. get invertRefractionY(): boolean;
  107504. set invertRefractionY(value: boolean);
  107505. /**
  107506. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107507. * Materials half opaque for instance using refraction could benefit from this control.
  107508. */
  107509. get linkRefractionWithTransparency(): boolean;
  107510. set linkRefractionWithTransparency(value: boolean);
  107511. /**
  107512. * If true, the light map contains occlusion information instead of lighting info.
  107513. */
  107514. useLightmapAsShadowmap: boolean;
  107515. /**
  107516. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107517. */
  107518. useAlphaFromAlbedoTexture: boolean;
  107519. /**
  107520. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107521. */
  107522. forceAlphaTest: boolean;
  107523. /**
  107524. * Defines the alpha limits in alpha test mode.
  107525. */
  107526. alphaCutOff: number;
  107527. /**
  107528. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107529. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107530. */
  107531. useSpecularOverAlpha: boolean;
  107532. /**
  107533. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107534. */
  107535. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107536. /**
  107537. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107538. */
  107539. useRoughnessFromMetallicTextureAlpha: boolean;
  107540. /**
  107541. * Specifies if the metallic texture contains the roughness information in its green channel.
  107542. */
  107543. useRoughnessFromMetallicTextureGreen: boolean;
  107544. /**
  107545. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107546. */
  107547. useMetallnessFromMetallicTextureBlue: boolean;
  107548. /**
  107549. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107550. */
  107551. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107552. /**
  107553. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107554. */
  107555. useAmbientInGrayScale: boolean;
  107556. /**
  107557. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107558. * The material will try to infer what glossiness each pixel should be.
  107559. */
  107560. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107561. /**
  107562. * BJS is using an harcoded light falloff based on a manually sets up range.
  107563. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107564. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107565. */
  107566. get usePhysicalLightFalloff(): boolean;
  107567. /**
  107568. * BJS is using an harcoded light falloff based on a manually sets up range.
  107569. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107570. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107571. */
  107572. set usePhysicalLightFalloff(value: boolean);
  107573. /**
  107574. * In order to support the falloff compatibility with gltf, a special mode has been added
  107575. * to reproduce the gltf light falloff.
  107576. */
  107577. get useGLTFLightFalloff(): boolean;
  107578. /**
  107579. * In order to support the falloff compatibility with gltf, a special mode has been added
  107580. * to reproduce the gltf light falloff.
  107581. */
  107582. set useGLTFLightFalloff(value: boolean);
  107583. /**
  107584. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107585. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107586. */
  107587. useRadianceOverAlpha: boolean;
  107588. /**
  107589. * Allows using an object space normal map (instead of tangent space).
  107590. */
  107591. useObjectSpaceNormalMap: boolean;
  107592. /**
  107593. * Allows using the bump map in parallax mode.
  107594. */
  107595. useParallax: boolean;
  107596. /**
  107597. * Allows using the bump map in parallax occlusion mode.
  107598. */
  107599. useParallaxOcclusion: boolean;
  107600. /**
  107601. * Controls the scale bias of the parallax mode.
  107602. */
  107603. parallaxScaleBias: number;
  107604. /**
  107605. * If sets to true, disables all the lights affecting the material.
  107606. */
  107607. disableLighting: boolean;
  107608. /**
  107609. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107610. */
  107611. forceIrradianceInFragment: boolean;
  107612. /**
  107613. * Number of Simultaneous lights allowed on the material.
  107614. */
  107615. maxSimultaneousLights: number;
  107616. /**
  107617. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107618. */
  107619. invertNormalMapX: boolean;
  107620. /**
  107621. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107622. */
  107623. invertNormalMapY: boolean;
  107624. /**
  107625. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107626. */
  107627. twoSidedLighting: boolean;
  107628. /**
  107629. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107630. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107631. */
  107632. useAlphaFresnel: boolean;
  107633. /**
  107634. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107635. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107636. */
  107637. useLinearAlphaFresnel: boolean;
  107638. /**
  107639. * Let user defines the brdf lookup texture used for IBL.
  107640. * A default 8bit version is embedded but you could point at :
  107641. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107642. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107643. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107644. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107645. */
  107646. environmentBRDFTexture: Nullable<BaseTexture>;
  107647. /**
  107648. * Force normal to face away from face.
  107649. */
  107650. forceNormalForward: boolean;
  107651. /**
  107652. * Enables specular anti aliasing in the PBR shader.
  107653. * It will both interacts on the Geometry for analytical and IBL lighting.
  107654. * It also prefilter the roughness map based on the bump values.
  107655. */
  107656. enableSpecularAntiAliasing: boolean;
  107657. /**
  107658. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107659. * makes the reflect vector face the model (under horizon).
  107660. */
  107661. useHorizonOcclusion: boolean;
  107662. /**
  107663. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107664. * too much the area relying on ambient texture to define their ambient occlusion.
  107665. */
  107666. useRadianceOcclusion: boolean;
  107667. /**
  107668. * If set to true, no lighting calculations will be applied.
  107669. */
  107670. unlit: boolean;
  107671. /**
  107672. * Gets the image processing configuration used either in this material.
  107673. */
  107674. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107675. /**
  107676. * Sets the Default image processing configuration used either in the this material.
  107677. *
  107678. * If sets to null, the scene one is in use.
  107679. */
  107680. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107681. /**
  107682. * Gets wether the color curves effect is enabled.
  107683. */
  107684. get cameraColorCurvesEnabled(): boolean;
  107685. /**
  107686. * Sets wether the color curves effect is enabled.
  107687. */
  107688. set cameraColorCurvesEnabled(value: boolean);
  107689. /**
  107690. * Gets wether the color grading effect is enabled.
  107691. */
  107692. get cameraColorGradingEnabled(): boolean;
  107693. /**
  107694. * Gets wether the color grading effect is enabled.
  107695. */
  107696. set cameraColorGradingEnabled(value: boolean);
  107697. /**
  107698. * Gets wether tonemapping is enabled or not.
  107699. */
  107700. get cameraToneMappingEnabled(): boolean;
  107701. /**
  107702. * Sets wether tonemapping is enabled or not
  107703. */
  107704. set cameraToneMappingEnabled(value: boolean);
  107705. /**
  107706. * The camera exposure used on this material.
  107707. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107708. * This corresponds to a photographic exposure.
  107709. */
  107710. get cameraExposure(): number;
  107711. /**
  107712. * The camera exposure used on this material.
  107713. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107714. * This corresponds to a photographic exposure.
  107715. */
  107716. set cameraExposure(value: number);
  107717. /**
  107718. * Gets The camera contrast used on this material.
  107719. */
  107720. get cameraContrast(): number;
  107721. /**
  107722. * Sets The camera contrast used on this material.
  107723. */
  107724. set cameraContrast(value: number);
  107725. /**
  107726. * Gets the Color Grading 2D Lookup Texture.
  107727. */
  107728. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107729. /**
  107730. * Sets the Color Grading 2D Lookup Texture.
  107731. */
  107732. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107733. /**
  107734. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107735. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107736. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  107737. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107738. */
  107739. get cameraColorCurves(): Nullable<ColorCurves>;
  107740. /**
  107741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107743. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  107744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107745. */
  107746. set cameraColorCurves(value: Nullable<ColorCurves>);
  107747. /**
  107748. * Instantiates a new PBRMaterial instance.
  107749. *
  107750. * @param name The material name
  107751. * @param scene The scene the material will be use in.
  107752. */
  107753. constructor(name: string, scene: Scene);
  107754. /**
  107755. * Returns the name of this material class.
  107756. */
  107757. getClassName(): string;
  107758. /**
  107759. * Makes a duplicate of the current material.
  107760. * @param name - name to use for the new material.
  107761. */
  107762. clone(name: string): PBRMaterial;
  107763. /**
  107764. * Serializes this PBR Material.
  107765. * @returns - An object with the serialized material.
  107766. */
  107767. serialize(): any;
  107768. /**
  107769. * Parses a PBR Material from a serialized object.
  107770. * @param source - Serialized object.
  107771. * @param scene - BJS scene instance.
  107772. * @param rootUrl - url for the scene object
  107773. * @returns - PBRMaterial
  107774. */
  107775. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107776. }
  107777. }
  107778. declare module BABYLON {
  107779. /** @hidden */
  107780. export var mrtFragmentDeclaration: {
  107781. name: string;
  107782. shader: string;
  107783. };
  107784. }
  107785. declare module BABYLON {
  107786. /** @hidden */
  107787. export var geometryPixelShader: {
  107788. name: string;
  107789. shader: string;
  107790. };
  107791. }
  107792. declare module BABYLON {
  107793. /** @hidden */
  107794. export var instancesDeclaration: {
  107795. name: string;
  107796. shader: string;
  107797. };
  107798. }
  107799. declare module BABYLON {
  107800. /** @hidden */
  107801. export var geometryVertexShader: {
  107802. name: string;
  107803. shader: string;
  107804. };
  107805. }
  107806. declare module BABYLON {
  107807. /** @hidden */
  107808. interface ISavedTransformationMatrix {
  107809. world: Matrix;
  107810. viewProjection: Matrix;
  107811. }
  107812. /**
  107813. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107814. */
  107815. export class GeometryBufferRenderer {
  107816. /**
  107817. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107818. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107819. */
  107820. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107821. /**
  107822. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107823. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107824. */
  107825. static readonly POSITION_TEXTURE_TYPE: number;
  107826. /**
  107827. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107828. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107829. */
  107830. static readonly VELOCITY_TEXTURE_TYPE: number;
  107831. /**
  107832. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107833. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107834. */
  107835. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107836. /**
  107837. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107838. * in order to compute objects velocities when enableVelocity is set to "true"
  107839. * @hidden
  107840. */
  107841. _previousTransformationMatrices: {
  107842. [index: number]: ISavedTransformationMatrix;
  107843. };
  107844. /**
  107845. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107846. * in order to compute objects velocities when enableVelocity is set to "true"
  107847. * @hidden
  107848. */
  107849. _previousBonesTransformationMatrices: {
  107850. [index: number]: Float32Array;
  107851. };
  107852. /**
  107853. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107854. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107855. */
  107856. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107857. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107858. renderTransparentMeshes: boolean;
  107859. private _scene;
  107860. private _resizeObserver;
  107861. private _multiRenderTarget;
  107862. private _ratio;
  107863. private _enablePosition;
  107864. private _enableVelocity;
  107865. private _enableReflectivity;
  107866. private _positionIndex;
  107867. private _velocityIndex;
  107868. private _reflectivityIndex;
  107869. private _depthNormalIndex;
  107870. private _linkedWithPrePass;
  107871. private _prePassRenderer;
  107872. private _attachments;
  107873. protected _effect: Effect;
  107874. protected _cachedDefines: string;
  107875. /**
  107876. * @hidden
  107877. * Sets up internal structures to share outputs with PrePassRenderer
  107878. * This method should only be called by the PrePassRenderer itself
  107879. */
  107880. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107881. /**
  107882. * @hidden
  107883. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107884. * This method should only be called by the PrePassRenderer itself
  107885. */
  107886. _unlinkPrePassRenderer(): void;
  107887. /**
  107888. * @hidden
  107889. * Resets the geometry buffer layout
  107890. */
  107891. _resetLayout(): void;
  107892. /**
  107893. * @hidden
  107894. * Replaces a texture in the geometry buffer renderer
  107895. * Useful when linking textures of the prepass renderer
  107896. */
  107897. _forceTextureType(geometryBufferType: number, index: number): void;
  107898. /**
  107899. * @hidden
  107900. * Sets texture attachments
  107901. * Useful when linking textures of the prepass renderer
  107902. */
  107903. _setAttachments(attachments: number[]): void;
  107904. /**
  107905. * @hidden
  107906. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107907. * Useful when linking textures of the prepass renderer
  107908. */
  107909. _linkInternalTexture(internalTexture: InternalTexture): void;
  107910. /**
  107911. * Gets the render list (meshes to be rendered) used in the G buffer.
  107912. */
  107913. get renderList(): Nullable<AbstractMesh[]>;
  107914. /**
  107915. * Set the render list (meshes to be rendered) used in the G buffer.
  107916. */
  107917. set renderList(meshes: Nullable<AbstractMesh[]>);
  107918. /**
  107919. * Gets wether or not G buffer are supported by the running hardware.
  107920. * This requires draw buffer supports
  107921. */
  107922. get isSupported(): boolean;
  107923. /**
  107924. * Returns the index of the given texture type in the G-Buffer textures array
  107925. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107926. * @returns the index of the given texture type in the G-Buffer textures array
  107927. */
  107928. getTextureIndex(textureType: number): number;
  107929. /**
  107930. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107931. */
  107932. get enablePosition(): boolean;
  107933. /**
  107934. * Sets whether or not objects positions are enabled for the G buffer.
  107935. */
  107936. set enablePosition(enable: boolean);
  107937. /**
  107938. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107939. */
  107940. get enableVelocity(): boolean;
  107941. /**
  107942. * Sets wether or not objects velocities are enabled for the G buffer.
  107943. */
  107944. set enableVelocity(enable: boolean);
  107945. /**
  107946. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107947. */
  107948. get enableReflectivity(): boolean;
  107949. /**
  107950. * Sets wether or not objects roughness are enabled for the G buffer.
  107951. */
  107952. set enableReflectivity(enable: boolean);
  107953. /**
  107954. * Gets the scene associated with the buffer.
  107955. */
  107956. get scene(): Scene;
  107957. /**
  107958. * Gets the ratio used by the buffer during its creation.
  107959. * How big is the buffer related to the main canvas.
  107960. */
  107961. get ratio(): number;
  107962. /** @hidden */
  107963. static _SceneComponentInitialization: (scene: Scene) => void;
  107964. /**
  107965. * Creates a new G Buffer for the scene
  107966. * @param scene The scene the buffer belongs to
  107967. * @param ratio How big is the buffer related to the main canvas.
  107968. */
  107969. constructor(scene: Scene, ratio?: number);
  107970. /**
  107971. * Checks wether everything is ready to render a submesh to the G buffer.
  107972. * @param subMesh the submesh to check readiness for
  107973. * @param useInstances is the mesh drawn using instance or not
  107974. * @returns true if ready otherwise false
  107975. */
  107976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107977. /**
  107978. * Gets the current underlying G Buffer.
  107979. * @returns the buffer
  107980. */
  107981. getGBuffer(): MultiRenderTarget;
  107982. /**
  107983. * Gets the number of samples used to render the buffer (anti aliasing).
  107984. */
  107985. get samples(): number;
  107986. /**
  107987. * Sets the number of samples used to render the buffer (anti aliasing).
  107988. */
  107989. set samples(value: number);
  107990. /**
  107991. * Disposes the renderer and frees up associated resources.
  107992. */
  107993. dispose(): void;
  107994. private _assignRenderTargetIndices;
  107995. protected _createRenderTargets(): void;
  107996. private _copyBonesTransformationMatrices;
  107997. }
  107998. }
  107999. declare module BABYLON {
  108000. /**
  108001. * Renders a pre pass of the scene
  108002. * This means every mesh in the scene will be rendered to a render target texture
  108003. * And then this texture will be composited to the rendering canvas with post processes
  108004. * It is necessary for effects like subsurface scattering or deferred shading
  108005. */
  108006. export class PrePassRenderer {
  108007. /** @hidden */
  108008. static _SceneComponentInitialization: (scene: Scene) => void;
  108009. private _textureFormats;
  108010. /**
  108011. * To save performance, we can excluded skinned meshes from the prepass
  108012. */
  108013. excludedSkinnedMesh: AbstractMesh[];
  108014. /**
  108015. * Force material to be excluded from the prepass
  108016. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108017. * and you don't want a material to show in the effect.
  108018. */
  108019. excludedMaterials: Material[];
  108020. private _textureIndices;
  108021. private _scene;
  108022. private _engine;
  108023. private _isDirty;
  108024. /**
  108025. * Number of textures in the multi render target texture where the scene is directly rendered
  108026. */
  108027. mrtCount: number;
  108028. /**
  108029. * The render target where the scene is directly rendered
  108030. */
  108031. prePassRT: MultiRenderTarget;
  108032. private _multiRenderAttachments;
  108033. private _defaultAttachments;
  108034. private _postProcesses;
  108035. private readonly _clearColor;
  108036. /**
  108037. * Image processing post process for composition
  108038. */
  108039. imageProcessingPostProcess: ImageProcessingPostProcess;
  108040. /**
  108041. * Configuration for prepass effects
  108042. */
  108043. private _effectConfigurations;
  108044. private _mrtFormats;
  108045. private _mrtLayout;
  108046. private _enabled;
  108047. /**
  108048. * Indicates if the prepass is enabled
  108049. */
  108050. get enabled(): boolean;
  108051. /**
  108052. * How many samples are used for MSAA of the scene render target
  108053. */
  108054. get samples(): number;
  108055. set samples(n: number);
  108056. private _geometryBuffer;
  108057. private _useGeometryBufferFallback;
  108058. /**
  108059. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108060. */
  108061. get useGeometryBufferFallback(): boolean;
  108062. set useGeometryBufferFallback(value: boolean);
  108063. /**
  108064. * Set to true to disable gamma transform in PrePass.
  108065. * Can be useful in case you already proceed to gamma transform on a material level
  108066. * and your post processes don't need to be in linear color space.
  108067. */
  108068. disableGammaTransform: boolean;
  108069. /**
  108070. * Instanciates a prepass renderer
  108071. * @param scene The scene
  108072. */
  108073. constructor(scene: Scene);
  108074. private _initializeAttachments;
  108075. private _createCompositionEffect;
  108076. /**
  108077. * Indicates if rendering a prepass is supported
  108078. */
  108079. get isSupported(): boolean;
  108080. /**
  108081. * Sets the proper output textures to draw in the engine.
  108082. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108083. * @param subMesh Submesh on which the effect is applied
  108084. */
  108085. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108086. /**
  108087. * Restores attachments for single texture draw.
  108088. */
  108089. restoreAttachments(): void;
  108090. /**
  108091. * @hidden
  108092. */
  108093. _beforeCameraDraw(): void;
  108094. /**
  108095. * @hidden
  108096. */
  108097. _afterCameraDraw(): void;
  108098. private _checkRTSize;
  108099. private _bindFrameBuffer;
  108100. /**
  108101. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108102. */
  108103. clear(): void;
  108104. private _setState;
  108105. private _updateGeometryBufferLayout;
  108106. /**
  108107. * Adds an effect configuration to the prepass.
  108108. * If an effect has already been added, it won't add it twice and will return the configuration
  108109. * already present.
  108110. * @param cfg the effect configuration
  108111. * @return the effect configuration now used by the prepass
  108112. */
  108113. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108114. /**
  108115. * Returns the index of a texture in the multi render target texture array.
  108116. * @param type Texture type
  108117. * @return The index
  108118. */
  108119. getIndex(type: number): number;
  108120. private _enable;
  108121. private _disable;
  108122. private _resetLayout;
  108123. private _resetPostProcessChain;
  108124. private _bindPostProcessChain;
  108125. /**
  108126. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108127. */
  108128. markAsDirty(): void;
  108129. /**
  108130. * Enables a texture on the MultiRenderTarget for prepass
  108131. */
  108132. private _enableTextures;
  108133. private _update;
  108134. private _markAllMaterialsAsPrePassDirty;
  108135. /**
  108136. * Disposes the prepass renderer.
  108137. */
  108138. dispose(): void;
  108139. }
  108140. }
  108141. declare module BABYLON {
  108142. /**
  108143. * Size options for a post process
  108144. */
  108145. export type PostProcessOptions = {
  108146. width: number;
  108147. height: number;
  108148. };
  108149. /**
  108150. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108151. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108152. */
  108153. export class PostProcess {
  108154. /**
  108155. * Gets or sets the unique id of the post process
  108156. */
  108157. uniqueId: number;
  108158. /** Name of the PostProcess. */
  108159. name: string;
  108160. /**
  108161. * Width of the texture to apply the post process on
  108162. */
  108163. width: number;
  108164. /**
  108165. * Height of the texture to apply the post process on
  108166. */
  108167. height: number;
  108168. /**
  108169. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108170. */
  108171. nodeMaterialSource: Nullable<NodeMaterial>;
  108172. /**
  108173. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108174. * @hidden
  108175. */
  108176. _outputTexture: Nullable<InternalTexture>;
  108177. /**
  108178. * Sampling mode used by the shader
  108179. * See https://doc.babylonjs.com/classes/3.1/texture
  108180. */
  108181. renderTargetSamplingMode: number;
  108182. /**
  108183. * Clear color to use when screen clearing
  108184. */
  108185. clearColor: Color4;
  108186. /**
  108187. * If the buffer needs to be cleared before applying the post process. (default: true)
  108188. * Should be set to false if shader will overwrite all previous pixels.
  108189. */
  108190. autoClear: boolean;
  108191. /**
  108192. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108193. */
  108194. alphaMode: number;
  108195. /**
  108196. * Sets the setAlphaBlendConstants of the babylon engine
  108197. */
  108198. alphaConstants: Color4;
  108199. /**
  108200. * Animations to be used for the post processing
  108201. */
  108202. animations: Animation[];
  108203. /**
  108204. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108205. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108206. */
  108207. enablePixelPerfectMode: boolean;
  108208. /**
  108209. * Force the postprocess to be applied without taking in account viewport
  108210. */
  108211. forceFullscreenViewport: boolean;
  108212. /**
  108213. * List of inspectable custom properties (used by the Inspector)
  108214. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108215. */
  108216. inspectableCustomProperties: IInspectable[];
  108217. /**
  108218. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108219. *
  108220. * | Value | Type | Description |
  108221. * | ----- | ----------------------------------- | ----------- |
  108222. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108223. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108224. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108225. *
  108226. */
  108227. scaleMode: number;
  108228. /**
  108229. * Force textures to be a power of two (default: false)
  108230. */
  108231. alwaysForcePOT: boolean;
  108232. private _samples;
  108233. /**
  108234. * Number of sample textures (default: 1)
  108235. */
  108236. get samples(): number;
  108237. set samples(n: number);
  108238. /**
  108239. * Modify the scale of the post process to be the same as the viewport (default: false)
  108240. */
  108241. adaptScaleToCurrentViewport: boolean;
  108242. private _camera;
  108243. protected _scene: Scene;
  108244. private _engine;
  108245. private _options;
  108246. private _reusable;
  108247. private _textureType;
  108248. private _textureFormat;
  108249. /**
  108250. * Smart array of input and output textures for the post process.
  108251. * @hidden
  108252. */
  108253. _textures: SmartArray<InternalTexture>;
  108254. /**
  108255. * The index in _textures that corresponds to the output texture.
  108256. * @hidden
  108257. */
  108258. _currentRenderTextureInd: number;
  108259. private _effect;
  108260. private _samplers;
  108261. private _fragmentUrl;
  108262. private _vertexUrl;
  108263. private _parameters;
  108264. private _scaleRatio;
  108265. protected _indexParameters: any;
  108266. private _shareOutputWithPostProcess;
  108267. private _texelSize;
  108268. private _forcedOutputTexture;
  108269. /**
  108270. * Prepass configuration in case this post process needs a texture from prepass
  108271. * @hidden
  108272. */
  108273. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108274. /**
  108275. * Returns the fragment url or shader name used in the post process.
  108276. * @returns the fragment url or name in the shader store.
  108277. */
  108278. getEffectName(): string;
  108279. /**
  108280. * An event triggered when the postprocess is activated.
  108281. */
  108282. onActivateObservable: Observable<Camera>;
  108283. private _onActivateObserver;
  108284. /**
  108285. * A function that is added to the onActivateObservable
  108286. */
  108287. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108288. /**
  108289. * An event triggered when the postprocess changes its size.
  108290. */
  108291. onSizeChangedObservable: Observable<PostProcess>;
  108292. private _onSizeChangedObserver;
  108293. /**
  108294. * A function that is added to the onSizeChangedObservable
  108295. */
  108296. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108297. /**
  108298. * An event triggered when the postprocess applies its effect.
  108299. */
  108300. onApplyObservable: Observable<Effect>;
  108301. private _onApplyObserver;
  108302. /**
  108303. * A function that is added to the onApplyObservable
  108304. */
  108305. set onApply(callback: (effect: Effect) => void);
  108306. /**
  108307. * An event triggered before rendering the postprocess
  108308. */
  108309. onBeforeRenderObservable: Observable<Effect>;
  108310. private _onBeforeRenderObserver;
  108311. /**
  108312. * A function that is added to the onBeforeRenderObservable
  108313. */
  108314. set onBeforeRender(callback: (effect: Effect) => void);
  108315. /**
  108316. * An event triggered after rendering the postprocess
  108317. */
  108318. onAfterRenderObservable: Observable<Effect>;
  108319. private _onAfterRenderObserver;
  108320. /**
  108321. * A function that is added to the onAfterRenderObservable
  108322. */
  108323. set onAfterRender(callback: (efect: Effect) => void);
  108324. /**
  108325. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  108326. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108327. */
  108328. get inputTexture(): InternalTexture;
  108329. set inputTexture(value: InternalTexture);
  108330. /**
  108331. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108332. * the only way to unset it is to use this function to restore its internal state
  108333. */
  108334. restoreDefaultInputTexture(): void;
  108335. /**
  108336. * Gets the camera which post process is applied to.
  108337. * @returns The camera the post process is applied to.
  108338. */
  108339. getCamera(): Camera;
  108340. /**
  108341. * Gets the texel size of the postprocess.
  108342. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108343. */
  108344. get texelSize(): Vector2;
  108345. /**
  108346. * Creates a new instance PostProcess
  108347. * @param name The name of the PostProcess.
  108348. * @param fragmentUrl The url of the fragment shader to be used.
  108349. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108350. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108351. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108352. * @param camera The camera to apply the render pass to.
  108353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108354. * @param engine The engine which the post process will be applied. (default: current engine)
  108355. * @param reusable If the post process can be reused on the same frame. (default: false)
  108356. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108357. * @param textureType Type of textures used when performing the post process. (default: 0)
  108358. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108359. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  108360. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108361. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108362. */
  108363. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  108364. /**
  108365. * Gets a string identifying the name of the class
  108366. * @returns "PostProcess" string
  108367. */
  108368. getClassName(): string;
  108369. /**
  108370. * Gets the engine which this post process belongs to.
  108371. * @returns The engine the post process was enabled with.
  108372. */
  108373. getEngine(): Engine;
  108374. /**
  108375. * The effect that is created when initializing the post process.
  108376. * @returns The created effect corresponding the the postprocess.
  108377. */
  108378. getEffect(): Effect;
  108379. /**
  108380. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108381. * @param postProcess The post process to share the output with.
  108382. * @returns This post process.
  108383. */
  108384. shareOutputWith(postProcess: PostProcess): PostProcess;
  108385. /**
  108386. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108387. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108388. */
  108389. useOwnOutput(): void;
  108390. /**
  108391. * Updates the effect with the current post process compile time values and recompiles the shader.
  108392. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108393. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108394. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108395. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  108396. * @param onCompiled Called when the shader has been compiled.
  108397. * @param onError Called if there is an error when compiling a shader.
  108398. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108399. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108400. */
  108401. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  108402. /**
  108403. * The post process is reusable if it can be used multiple times within one frame.
  108404. * @returns If the post process is reusable
  108405. */
  108406. isReusable(): boolean;
  108407. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108408. markTextureDirty(): void;
  108409. /**
  108410. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108411. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  108412. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108413. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108414. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108415. * @returns The target texture that was bound to be written to.
  108416. */
  108417. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108418. /**
  108419. * If the post process is supported.
  108420. */
  108421. get isSupported(): boolean;
  108422. /**
  108423. * The aspect ratio of the output texture.
  108424. */
  108425. get aspectRatio(): number;
  108426. /**
  108427. * Get a value indicating if the post-process is ready to be used
  108428. * @returns true if the post-process is ready (shader is compiled)
  108429. */
  108430. isReady(): boolean;
  108431. /**
  108432. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108433. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108434. */
  108435. apply(): Nullable<Effect>;
  108436. private _disposeTextures;
  108437. /**
  108438. * Sets the required values to the prepass renderer.
  108439. * @param prePassRenderer defines the prepass renderer to setup.
  108440. * @returns true if the pre pass is needed.
  108441. */
  108442. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108443. /**
  108444. * Disposes the post process.
  108445. * @param camera The camera to dispose the post process on.
  108446. */
  108447. dispose(camera?: Camera): void;
  108448. /**
  108449. * Serializes the particle system to a JSON object
  108450. * @returns the JSON object
  108451. */
  108452. serialize(): any;
  108453. /**
  108454. * Creates a material from parsed material data
  108455. * @param parsedPostProcess defines parsed post process data
  108456. * @param scene defines the hosting scene
  108457. * @param rootUrl defines the root URL to use to load textures
  108458. * @returns a new post process
  108459. */
  108460. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108461. }
  108462. }
  108463. declare module BABYLON {
  108464. /** @hidden */
  108465. export var kernelBlurVaryingDeclaration: {
  108466. name: string;
  108467. shader: string;
  108468. };
  108469. }
  108470. declare module BABYLON {
  108471. /** @hidden */
  108472. export var packingFunctions: {
  108473. name: string;
  108474. shader: string;
  108475. };
  108476. }
  108477. declare module BABYLON {
  108478. /** @hidden */
  108479. export var kernelBlurFragment: {
  108480. name: string;
  108481. shader: string;
  108482. };
  108483. }
  108484. declare module BABYLON {
  108485. /** @hidden */
  108486. export var kernelBlurFragment2: {
  108487. name: string;
  108488. shader: string;
  108489. };
  108490. }
  108491. declare module BABYLON {
  108492. /** @hidden */
  108493. export var kernelBlurPixelShader: {
  108494. name: string;
  108495. shader: string;
  108496. };
  108497. }
  108498. declare module BABYLON {
  108499. /** @hidden */
  108500. export var kernelBlurVertex: {
  108501. name: string;
  108502. shader: string;
  108503. };
  108504. }
  108505. declare module BABYLON {
  108506. /** @hidden */
  108507. export var kernelBlurVertexShader: {
  108508. name: string;
  108509. shader: string;
  108510. };
  108511. }
  108512. declare module BABYLON {
  108513. /**
  108514. * The Blur Post Process which blurs an image based on a kernel and direction.
  108515. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108516. */
  108517. export class BlurPostProcess extends PostProcess {
  108518. private blockCompilation;
  108519. protected _kernel: number;
  108520. protected _idealKernel: number;
  108521. protected _packedFloat: boolean;
  108522. private _staticDefines;
  108523. /** The direction in which to blur the image. */
  108524. direction: Vector2;
  108525. /**
  108526. * Sets the length in pixels of the blur sample region
  108527. */
  108528. set kernel(v: number);
  108529. /**
  108530. * Gets the length in pixels of the blur sample region
  108531. */
  108532. get kernel(): number;
  108533. /**
  108534. * Sets wether or not the blur needs to unpack/repack floats
  108535. */
  108536. set packedFloat(v: boolean);
  108537. /**
  108538. * Gets wether or not the blur is unpacking/repacking floats
  108539. */
  108540. get packedFloat(): boolean;
  108541. /**
  108542. * Gets a string identifying the name of the class
  108543. * @returns "BlurPostProcess" string
  108544. */
  108545. getClassName(): string;
  108546. /**
  108547. * Creates a new instance BlurPostProcess
  108548. * @param name The name of the effect.
  108549. * @param direction The direction in which to blur the image.
  108550. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  108551. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108552. * @param camera The camera to apply the render pass to.
  108553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108554. * @param engine The engine which the post process will be applied. (default: current engine)
  108555. * @param reusable If the post process can be reused on the same frame. (default: false)
  108556. * @param textureType Type of textures used when performing the post process. (default: 0)
  108557. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  108558. */
  108559. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  108560. /**
  108561. * Updates the effect with the current post process compile time values and recompiles the shader.
  108562. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108563. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108564. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108565. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  108566. * @param onCompiled Called when the shader has been compiled.
  108567. * @param onError Called if there is an error when compiling a shader.
  108568. */
  108569. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108570. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108571. /**
  108572. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108573. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108574. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108575. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108576. * The gaps between physical kernels are compensated for in the weighting of the samples
  108577. * @param idealKernel Ideal blur kernel.
  108578. * @return Nearest best kernel.
  108579. */
  108580. protected _nearestBestKernel(idealKernel: number): number;
  108581. /**
  108582. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108583. * @param x The point on the Gaussian distribution to sample.
  108584. * @return the value of the Gaussian function at x.
  108585. */
  108586. protected _gaussianWeight(x: number): number;
  108587. /**
  108588. * Generates a string that can be used as a floating point number in GLSL.
  108589. * @param x Value to print.
  108590. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108591. * @return GLSL float string.
  108592. */
  108593. protected _glslFloat(x: number, decimalFigures?: number): string;
  108594. /** @hidden */
  108595. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108596. }
  108597. }
  108598. declare module BABYLON {
  108599. /**
  108600. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108601. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108602. * You can then easily use it as a reflectionTexture on a flat surface.
  108603. * In case the surface is not a plane, please consider relying on reflection probes.
  108604. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108605. */
  108606. export class MirrorTexture extends RenderTargetTexture {
  108607. private scene;
  108608. /**
  108609. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108610. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  108611. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108612. */
  108613. mirrorPlane: Plane;
  108614. /**
  108615. * Define the blur ratio used to blur the reflection if needed.
  108616. */
  108617. set blurRatio(value: number);
  108618. get blurRatio(): number;
  108619. /**
  108620. * Define the adaptive blur kernel used to blur the reflection if needed.
  108621. * This will autocompute the closest best match for the `blurKernel`
  108622. */
  108623. set adaptiveBlurKernel(value: number);
  108624. /**
  108625. * Define the blur kernel used to blur the reflection if needed.
  108626. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108627. */
  108628. set blurKernel(value: number);
  108629. /**
  108630. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108631. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108632. */
  108633. set blurKernelX(value: number);
  108634. get blurKernelX(): number;
  108635. /**
  108636. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108637. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108638. */
  108639. set blurKernelY(value: number);
  108640. get blurKernelY(): number;
  108641. private _autoComputeBlurKernel;
  108642. protected _onRatioRescale(): void;
  108643. private _updateGammaSpace;
  108644. private _imageProcessingConfigChangeObserver;
  108645. private _transformMatrix;
  108646. private _mirrorMatrix;
  108647. private _savedViewMatrix;
  108648. private _blurX;
  108649. private _blurY;
  108650. private _adaptiveBlurKernel;
  108651. private _blurKernelX;
  108652. private _blurKernelY;
  108653. private _blurRatio;
  108654. /**
  108655. * Instantiates a Mirror Texture.
  108656. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108657. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108658. * You can then easily use it as a reflectionTexture on a flat surface.
  108659. * In case the surface is not a plane, please consider relying on reflection probes.
  108660. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108661. * @param name
  108662. * @param size
  108663. * @param scene
  108664. * @param generateMipMaps
  108665. * @param type
  108666. * @param samplingMode
  108667. * @param generateDepthBuffer
  108668. */
  108669. constructor(name: string, size: number | {
  108670. width: number;
  108671. height: number;
  108672. } | {
  108673. ratio: number;
  108674. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108675. private _preparePostProcesses;
  108676. /**
  108677. * Clone the mirror texture.
  108678. * @returns the cloned texture
  108679. */
  108680. clone(): MirrorTexture;
  108681. /**
  108682. * Serialize the texture to a JSON representation you could use in Parse later on
  108683. * @returns the serialized JSON representation
  108684. */
  108685. serialize(): any;
  108686. /**
  108687. * Dispose the texture and release its associated resources.
  108688. */
  108689. dispose(): void;
  108690. }
  108691. }
  108692. declare module BABYLON {
  108693. /**
  108694. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108695. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108696. */
  108697. export class Texture extends BaseTexture {
  108698. /**
  108699. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108700. */
  108701. static SerializeBuffers: boolean;
  108702. /**
  108703. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  108704. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  108705. */
  108706. static ForceSerializeBuffers: boolean;
  108707. /** @hidden */
  108708. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108709. /** @hidden */
  108710. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108711. /** @hidden */
  108712. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108713. /** nearest is mag = nearest and min = nearest and mip = linear */
  108714. static readonly NEAREST_SAMPLINGMODE: number;
  108715. /** nearest is mag = nearest and min = nearest and mip = linear */
  108716. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108717. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108718. static readonly BILINEAR_SAMPLINGMODE: number;
  108719. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108720. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108721. /** Trilinear is mag = linear and min = linear and mip = linear */
  108722. static readonly TRILINEAR_SAMPLINGMODE: number;
  108723. /** Trilinear is mag = linear and min = linear and mip = linear */
  108724. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108725. /** mag = nearest and min = nearest and mip = nearest */
  108726. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108727. /** mag = nearest and min = linear and mip = nearest */
  108728. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108729. /** mag = nearest and min = linear and mip = linear */
  108730. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108731. /** mag = nearest and min = linear and mip = none */
  108732. static readonly NEAREST_LINEAR: number;
  108733. /** mag = nearest and min = nearest and mip = none */
  108734. static readonly NEAREST_NEAREST: number;
  108735. /** mag = linear and min = nearest and mip = nearest */
  108736. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108737. /** mag = linear and min = nearest and mip = linear */
  108738. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108739. /** mag = linear and min = linear and mip = none */
  108740. static readonly LINEAR_LINEAR: number;
  108741. /** mag = linear and min = nearest and mip = none */
  108742. static readonly LINEAR_NEAREST: number;
  108743. /** Explicit coordinates mode */
  108744. static readonly EXPLICIT_MODE: number;
  108745. /** Spherical coordinates mode */
  108746. static readonly SPHERICAL_MODE: number;
  108747. /** Planar coordinates mode */
  108748. static readonly PLANAR_MODE: number;
  108749. /** Cubic coordinates mode */
  108750. static readonly CUBIC_MODE: number;
  108751. /** Projection coordinates mode */
  108752. static readonly PROJECTION_MODE: number;
  108753. /** Inverse Cubic coordinates mode */
  108754. static readonly SKYBOX_MODE: number;
  108755. /** Inverse Cubic coordinates mode */
  108756. static readonly INVCUBIC_MODE: number;
  108757. /** Equirectangular coordinates mode */
  108758. static readonly EQUIRECTANGULAR_MODE: number;
  108759. /** Equirectangular Fixed coordinates mode */
  108760. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108761. /** Equirectangular Fixed Mirrored coordinates mode */
  108762. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108763. /** Texture is not repeating outside of 0..1 UVs */
  108764. static readonly CLAMP_ADDRESSMODE: number;
  108765. /** Texture is repeating outside of 0..1 UVs */
  108766. static readonly WRAP_ADDRESSMODE: number;
  108767. /** Texture is repeating and mirrored */
  108768. static readonly MIRROR_ADDRESSMODE: number;
  108769. /**
  108770. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  108771. */
  108772. static UseSerializedUrlIfAny: boolean;
  108773. /**
  108774. * Define the url of the texture.
  108775. */
  108776. url: Nullable<string>;
  108777. /**
  108778. * Define an offset on the texture to offset the u coordinates of the UVs
  108779. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108780. */
  108781. uOffset: number;
  108782. /**
  108783. * Define an offset on the texture to offset the v coordinates of the UVs
  108784. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108785. */
  108786. vOffset: number;
  108787. /**
  108788. * Define an offset on the texture to scale the u coordinates of the UVs
  108789. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108790. */
  108791. uScale: number;
  108792. /**
  108793. * Define an offset on the texture to scale the v coordinates of the UVs
  108794. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108795. */
  108796. vScale: number;
  108797. /**
  108798. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108799. * @see https://doc.babylonjs.com/how_to/more_materials
  108800. */
  108801. uAng: number;
  108802. /**
  108803. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108804. * @see https://doc.babylonjs.com/how_to/more_materials
  108805. */
  108806. vAng: number;
  108807. /**
  108808. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108809. * @see https://doc.babylonjs.com/how_to/more_materials
  108810. */
  108811. wAng: number;
  108812. /**
  108813. * Defines the center of rotation (U)
  108814. */
  108815. uRotationCenter: number;
  108816. /**
  108817. * Defines the center of rotation (V)
  108818. */
  108819. vRotationCenter: number;
  108820. /**
  108821. * Defines the center of rotation (W)
  108822. */
  108823. wRotationCenter: number;
  108824. /**
  108825. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108826. */
  108827. homogeneousRotationInUVTransform: boolean;
  108828. /**
  108829. * Are mip maps generated for this texture or not.
  108830. */
  108831. get noMipmap(): boolean;
  108832. /**
  108833. * List of inspectable custom properties (used by the Inspector)
  108834. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108835. */
  108836. inspectableCustomProperties: Nullable<IInspectable[]>;
  108837. private _noMipmap;
  108838. /** @hidden */
  108839. _invertY: boolean;
  108840. private _rowGenerationMatrix;
  108841. private _cachedTextureMatrix;
  108842. private _projectionModeMatrix;
  108843. private _t0;
  108844. private _t1;
  108845. private _t2;
  108846. private _cachedUOffset;
  108847. private _cachedVOffset;
  108848. private _cachedUScale;
  108849. private _cachedVScale;
  108850. private _cachedUAng;
  108851. private _cachedVAng;
  108852. private _cachedWAng;
  108853. private _cachedProjectionMatrixId;
  108854. private _cachedURotationCenter;
  108855. private _cachedVRotationCenter;
  108856. private _cachedWRotationCenter;
  108857. private _cachedHomogeneousRotationInUVTransform;
  108858. private _cachedCoordinatesMode;
  108859. /** @hidden */
  108860. protected _initialSamplingMode: number;
  108861. /** @hidden */
  108862. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108863. private _deleteBuffer;
  108864. protected _format: Nullable<number>;
  108865. private _delayedOnLoad;
  108866. private _delayedOnError;
  108867. private _mimeType?;
  108868. private _loaderOptions?;
  108869. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108870. get mimeType(): string | undefined;
  108871. /**
  108872. * Observable triggered once the texture has been loaded.
  108873. */
  108874. onLoadObservable: Observable<Texture>;
  108875. protected _isBlocking: boolean;
  108876. /**
  108877. * Is the texture preventing material to render while loading.
  108878. * If false, a default texture will be used instead of the loading one during the preparation step.
  108879. */
  108880. set isBlocking(value: boolean);
  108881. get isBlocking(): boolean;
  108882. /**
  108883. * Get the current sampling mode associated with the texture.
  108884. */
  108885. get samplingMode(): number;
  108886. /**
  108887. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108888. */
  108889. get invertY(): boolean;
  108890. /**
  108891. * Instantiates a new texture.
  108892. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108893. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108894. * @param url defines the url of the picture to load as a texture
  108895. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108896. * @param noMipmap defines if the texture will require mip maps or not
  108897. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108898. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108899. * @param onLoad defines a callback triggered when the texture has been loaded
  108900. * @param onError defines a callback triggered when an error occurred during the loading session
  108901. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108902. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108903. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108904. * @param mimeType defines an optional mime type information
  108905. * @param loaderOptions options to be passed to the loader
  108906. */
  108907. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  108908. /**
  108909. * Update the url (and optional buffer) of this texture if url was null during construction.
  108910. * @param url the url of the texture
  108911. * @param buffer the buffer of the texture (defaults to null)
  108912. * @param onLoad callback called when the texture is loaded (defaults to null)
  108913. */
  108914. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108915. /**
  108916. * Finish the loading sequence of a texture flagged as delayed load.
  108917. * @hidden
  108918. */
  108919. delayLoad(): void;
  108920. private _prepareRowForTextureGeneration;
  108921. /**
  108922. * Checks if the texture has the same transform matrix than another texture
  108923. * @param texture texture to check against
  108924. * @returns true if the transforms are the same, else false
  108925. */
  108926. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  108927. /**
  108928. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108929. * @returns the transform matrix of the texture.
  108930. */
  108931. getTextureMatrix(uBase?: number): Matrix;
  108932. /**
  108933. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108934. * @returns The reflection texture transform
  108935. */
  108936. getReflectionTextureMatrix(): Matrix;
  108937. /**
  108938. * Clones the texture.
  108939. * @returns the cloned texture
  108940. */
  108941. clone(): Texture;
  108942. /**
  108943. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108944. * @returns The JSON representation of the texture
  108945. */
  108946. serialize(): any;
  108947. /**
  108948. * Get the current class name of the texture useful for serialization or dynamic coding.
  108949. * @returns "Texture"
  108950. */
  108951. getClassName(): string;
  108952. /**
  108953. * Dispose the texture and release its associated resources.
  108954. */
  108955. dispose(): void;
  108956. /**
  108957. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108958. * @param parsedTexture Define the JSON representation of the texture
  108959. * @param scene Define the scene the parsed texture should be instantiated in
  108960. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108961. * @returns The parsed texture if successful
  108962. */
  108963. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108964. /**
  108965. * Creates a texture from its base 64 representation.
  108966. * @param data Define the base64 payload without the data: prefix
  108967. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108968. * @param scene Define the scene the texture should belong to
  108969. * @param noMipmap Forces the texture to not create mip map information if true
  108970. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108971. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108972. * @param onLoad define a callback triggered when the texture has been loaded
  108973. * @param onError define a callback triggered when an error occurred during the loading session
  108974. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108975. * @returns the created texture
  108976. */
  108977. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108978. /**
  108979. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108980. * @param data Define the base64 payload without the data: prefix
  108981. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108982. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108983. * @param scene Define the scene the texture should belong to
  108984. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108985. * @param noMipmap Forces the texture to not create mip map information if true
  108986. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108987. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108988. * @param onLoad define a callback triggered when the texture has been loaded
  108989. * @param onError define a callback triggered when an error occurred during the loading session
  108990. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108991. * @returns the created texture
  108992. */
  108993. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  108994. }
  108995. }
  108996. declare module BABYLON {
  108997. /**
  108998. * ThinSprite Class used to represent a thin sprite
  108999. * This is the base class for sprites but can also directly be used with ThinEngine
  109000. * @see https://doc.babylonjs.com/babylon101/sprites
  109001. */
  109002. export class ThinSprite {
  109003. /** Gets or sets the cell index in the sprite sheet */
  109004. cellIndex: number;
  109005. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  109006. cellRef: string;
  109007. /** Gets or sets the current world position */
  109008. position: IVector3Like;
  109009. /** Gets or sets the main color */
  109010. color: IColor4Like;
  109011. /** Gets or sets the width */
  109012. width: number;
  109013. /** Gets or sets the height */
  109014. height: number;
  109015. /** Gets or sets rotation angle */
  109016. angle: number;
  109017. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  109018. invertU: boolean;
  109019. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  109020. invertV: boolean;
  109021. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  109022. isVisible: boolean;
  109023. /**
  109024. * Returns a boolean indicating if the animation is started
  109025. */
  109026. get animationStarted(): boolean;
  109027. /** Gets the initial key for the animation (setting it will restart the animation) */
  109028. get fromIndex(): number;
  109029. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  109030. get toIndex(): number;
  109031. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  109032. get loopAnimation(): boolean;
  109033. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  109034. get delay(): number;
  109035. /** @hidden */
  109036. _xOffset: number;
  109037. /** @hidden */
  109038. _yOffset: number;
  109039. /** @hidden */
  109040. _xSize: number;
  109041. /** @hidden */
  109042. _ySize: number;
  109043. private _animationStarted;
  109044. protected _loopAnimation: boolean;
  109045. protected _fromIndex: number;
  109046. protected _toIndex: number;
  109047. protected _delay: number;
  109048. private _direction;
  109049. private _time;
  109050. private _onBaseAnimationEnd;
  109051. /**
  109052. * Creates a new Thin Sprite
  109053. */
  109054. constructor();
  109055. /**
  109056. * Starts an animation
  109057. * @param from defines the initial key
  109058. * @param to defines the end key
  109059. * @param loop defines if the animation must loop
  109060. * @param delay defines the start delay (in ms)
  109061. * @param onAnimationEnd defines a callback for when the animation ends
  109062. */
  109063. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  109064. /** Stops current animation (if any) */
  109065. stopAnimation(): void;
  109066. /** @hidden */
  109067. _animate(deltaTime: number): void;
  109068. }
  109069. }
  109070. declare module BABYLON {
  109071. /** @hidden */
  109072. export var imageProcessingCompatibility: {
  109073. name: string;
  109074. shader: string;
  109075. };
  109076. }
  109077. declare module BABYLON {
  109078. /** @hidden */
  109079. export var spritesPixelShader: {
  109080. name: string;
  109081. shader: string;
  109082. };
  109083. }
  109084. declare module BABYLON {
  109085. /** @hidden */
  109086. export var spritesVertexShader: {
  109087. name: string;
  109088. shader: string;
  109089. };
  109090. }
  109091. declare module BABYLON {
  109092. /**
  109093. * Class used to render sprites.
  109094. *
  109095. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  109096. */
  109097. export class SpriteRenderer {
  109098. /**
  109099. * Defines the texture of the spritesheet
  109100. */
  109101. texture: Nullable<ThinTexture>;
  109102. /**
  109103. * Defines the default width of a cell in the spritesheet
  109104. */
  109105. cellWidth: number;
  109106. /**
  109107. * Defines the default height of a cell in the spritesheet
  109108. */
  109109. cellHeight: number;
  109110. /**
  109111. * Blend mode use to render the particle, it can be any of
  109112. * the static Constants.ALPHA_x properties provided in this class.
  109113. * Default value is Constants.ALPHA_COMBINE
  109114. */
  109115. blendMode: number;
  109116. /**
  109117. * Gets or sets a boolean indicating if alpha mode is automatically
  109118. * reset.
  109119. */
  109120. autoResetAlpha: boolean;
  109121. /**
  109122. * Disables writing to the depth buffer when rendering the sprites.
  109123. * It can be handy to disable depth writing when using textures without alpha channel
  109124. * and setting some specific blend modes.
  109125. */
  109126. disableDepthWrite: boolean;
  109127. /**
  109128. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  109129. */
  109130. fogEnabled: boolean;
  109131. /**
  109132. * Gets the capacity of the manager
  109133. */
  109134. get capacity(): number;
  109135. private readonly _engine;
  109136. private readonly _useVAO;
  109137. private readonly _useInstancing;
  109138. private readonly _scene;
  109139. private readonly _capacity;
  109140. private readonly _epsilon;
  109141. private _vertexBufferSize;
  109142. private _vertexData;
  109143. private _buffer;
  109144. private _vertexBuffers;
  109145. private _spriteBuffer;
  109146. private _indexBuffer;
  109147. private _effectBase;
  109148. private _effectFog;
  109149. private _vertexArrayObject;
  109150. /**
  109151. * Creates a new sprite Renderer
  109152. * @param engine defines the engine the renderer works with
  109153. * @param capacity defines the maximum allowed number of sprites
  109154. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  109155. * @param scene defines the hosting scene
  109156. */
  109157. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  109158. /**
  109159. * Render all child sprites
  109160. * @param sprites defines the list of sprites to render
  109161. * @param deltaTime defines the time since last frame
  109162. * @param viewMatrix defines the viewMatrix to use to render the sprites
  109163. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  109164. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  109165. */
  109166. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  109167. private _appendSpriteVertex;
  109168. /**
  109169. * Release associated resources
  109170. */
  109171. dispose(): void;
  109172. }
  109173. }
  109174. declare module BABYLON {
  109175. /**
  109176. * Defines the minimum interface to fullfil in order to be a sprite manager.
  109177. */
  109178. export interface ISpriteManager extends IDisposable {
  109179. /**
  109180. * Gets manager's name
  109181. */
  109182. name: string;
  109183. /**
  109184. * Restricts the camera to viewing objects with the same layerMask.
  109185. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  109186. */
  109187. layerMask: number;
  109188. /**
  109189. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109190. */
  109191. isPickable: boolean;
  109192. /**
  109193. * Gets the hosting scene
  109194. */
  109195. scene: Scene;
  109196. /**
  109197. * Specifies the rendering group id for this mesh (0 by default)
  109198. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109199. */
  109200. renderingGroupId: number;
  109201. /**
  109202. * Defines the list of sprites managed by the manager.
  109203. */
  109204. sprites: Array<Sprite>;
  109205. /**
  109206. * Gets or sets the spritesheet texture
  109207. */
  109208. texture: Texture;
  109209. /** Defines the default width of a cell in the spritesheet */
  109210. cellWidth: number;
  109211. /** Defines the default height of a cell in the spritesheet */
  109212. cellHeight: number;
  109213. /**
  109214. * Tests the intersection of a sprite with a specific ray.
  109215. * @param ray The ray we are sending to test the collision
  109216. * @param camera The camera space we are sending rays in
  109217. * @param predicate A predicate allowing excluding sprites from the list of object to test
  109218. * @param fastCheck defines if the first intersection will be used (and not the closest)
  109219. * @returns picking info or null.
  109220. */
  109221. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  109222. /**
  109223. * Intersects the sprites with a ray
  109224. * @param ray defines the ray to intersect with
  109225. * @param camera defines the current active camera
  109226. * @param predicate defines a predicate used to select candidate sprites
  109227. * @returns null if no hit or a PickingInfo array
  109228. */
  109229. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  109230. /**
  109231. * Renders the list of sprites on screen.
  109232. */
  109233. render(): void;
  109234. }
  109235. /**
  109236. * Class used to manage multiple sprites on the same spritesheet
  109237. * @see https://doc.babylonjs.com/babylon101/sprites
  109238. */
  109239. export class SpriteManager implements ISpriteManager {
  109240. /** defines the manager's name */
  109241. name: string;
  109242. /** Define the Url to load snippets */
  109243. static SnippetUrl: string;
  109244. /** Snippet ID if the manager was created from the snippet server */
  109245. snippetId: string;
  109246. /** Gets the list of sprites */
  109247. sprites: Sprite[];
  109248. /** Gets or sets the rendering group id (0 by default) */
  109249. renderingGroupId: number;
  109250. /** Gets or sets camera layer mask */
  109251. layerMask: number;
  109252. /** Gets or sets a boolean indicating if the sprites are pickable */
  109253. isPickable: boolean;
  109254. /**
  109255. * An event triggered when the manager is disposed.
  109256. */
  109257. onDisposeObservable: Observable<SpriteManager>;
  109258. /**
  109259. * Callback called when the manager is disposed
  109260. */
  109261. set onDispose(callback: () => void);
  109262. /**
  109263. * Gets or sets the unique id of the sprite
  109264. */
  109265. uniqueId: number;
  109266. /**
  109267. * Gets the array of sprites
  109268. */
  109269. get children(): Sprite[];
  109270. /**
  109271. * Gets the hosting scene
  109272. */
  109273. get scene(): Scene;
  109274. /**
  109275. * Gets the capacity of the manager
  109276. */
  109277. get capacity(): number;
  109278. /**
  109279. * Gets or sets the spritesheet texture
  109280. */
  109281. get texture(): Texture;
  109282. set texture(value: Texture);
  109283. /** Defines the default width of a cell in the spritesheet */
  109284. get cellWidth(): number;
  109285. set cellWidth(value: number);
  109286. /** Defines the default height of a cell in the spritesheet */
  109287. get cellHeight(): number;
  109288. set cellHeight(value: number);
  109289. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  109290. get fogEnabled(): boolean;
  109291. set fogEnabled(value: boolean);
  109292. /**
  109293. * Blend mode use to render the particle, it can be any of
  109294. * the static Constants.ALPHA_x properties provided in this class.
  109295. * Default value is Constants.ALPHA_COMBINE
  109296. */
  109297. get blendMode(): number;
  109298. set blendMode(blendMode: number);
  109299. /** Disables writing to the depth buffer when rendering the sprites.
  109300. * It can be handy to disable depth writing when using textures without alpha channel
  109301. * and setting some specific blend modes.
  109302. */
  109303. disableDepthWrite: boolean;
  109304. private _spriteRenderer;
  109305. /** Associative array from JSON sprite data file */
  109306. private _cellData;
  109307. /** Array of sprite names from JSON sprite data file */
  109308. private _spriteMap;
  109309. /** True when packed cell data from JSON file is ready*/
  109310. private _packedAndReady;
  109311. private _textureContent;
  109312. private _onDisposeObserver;
  109313. private _fromPacked;
  109314. private _scene;
  109315. /**
  109316. * Creates a new sprite manager
  109317. * @param name defines the manager's name
  109318. * @param imgUrl defines the sprite sheet url
  109319. * @param capacity defines the maximum allowed number of sprites
  109320. * @param cellSize defines the size of a sprite cell
  109321. * @param scene defines the hosting scene
  109322. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  109323. * @param samplingMode defines the smapling mode to use with spritesheet
  109324. * @param fromPacked set to false; do not alter
  109325. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  109326. */
  109327. constructor(
  109328. /** defines the manager's name */
  109329. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  109330. /**
  109331. * Returns the string "SpriteManager"
  109332. * @returns "SpriteManager"
  109333. */
  109334. getClassName(): string;
  109335. private _makePacked;
  109336. private _checkTextureAlpha;
  109337. /**
  109338. * Intersects the sprites with a ray
  109339. * @param ray defines the ray to intersect with
  109340. * @param camera defines the current active camera
  109341. * @param predicate defines a predicate used to select candidate sprites
  109342. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  109343. * @returns null if no hit or a PickingInfo
  109344. */
  109345. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  109346. /**
  109347. * Intersects the sprites with a ray
  109348. * @param ray defines the ray to intersect with
  109349. * @param camera defines the current active camera
  109350. * @param predicate defines a predicate used to select candidate sprites
  109351. * @returns null if no hit or a PickingInfo array
  109352. */
  109353. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  109354. /**
  109355. * Render all child sprites
  109356. */
  109357. render(): void;
  109358. private _customUpdate;
  109359. /**
  109360. * Release associated resources
  109361. */
  109362. dispose(): void;
  109363. /**
  109364. * Serializes the sprite manager to a JSON object
  109365. * @param serializeTexture defines if the texture must be serialized as well
  109366. * @returns the JSON object
  109367. */
  109368. serialize(serializeTexture?: boolean): any;
  109369. /**
  109370. * Parses a JSON object to create a new sprite manager.
  109371. * @param parsedManager The JSON object to parse
  109372. * @param scene The scene to create the sprite managerin
  109373. * @param rootUrl The root url to use to load external dependencies like texture
  109374. * @returns the new sprite manager
  109375. */
  109376. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  109377. /**
  109378. * Creates a sprite manager from a snippet saved in a remote file
  109379. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  109380. * @param url defines the url to load from
  109381. * @param scene defines the hosting scene
  109382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109383. * @returns a promise that will resolve to the new sprite manager
  109384. */
  109385. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  109386. /**
  109387. * Creates a sprite manager from a snippet saved by the sprite editor
  109388. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  109389. * @param scene defines the hosting scene
  109390. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109391. * @returns a promise that will resolve to the new sprite manager
  109392. */
  109393. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  109394. }
  109395. }
  109396. declare module BABYLON {
  109397. /**
  109398. * Class used to represent a sprite
  109399. * @see https://doc.babylonjs.com/babylon101/sprites
  109400. */
  109401. export class Sprite extends ThinSprite implements IAnimatable {
  109402. /** defines the name */
  109403. name: string;
  109404. /** Gets or sets the current world position */
  109405. position: Vector3;
  109406. /** Gets or sets the main color */
  109407. color: Color4;
  109408. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  109409. disposeWhenFinishedAnimating: boolean;
  109410. /** Gets the list of attached animations */
  109411. animations: Nullable<Array<Animation>>;
  109412. /** Gets or sets a boolean indicating if the sprite can be picked */
  109413. isPickable: boolean;
  109414. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  109415. useAlphaForPicking: boolean;
  109416. /**
  109417. * Gets or sets the associated action manager
  109418. */
  109419. actionManager: Nullable<ActionManager>;
  109420. /**
  109421. * An event triggered when the control has been disposed
  109422. */
  109423. onDisposeObservable: Observable<Sprite>;
  109424. private _manager;
  109425. private _onAnimationEnd;
  109426. /**
  109427. * Gets or sets the sprite size
  109428. */
  109429. get size(): number;
  109430. set size(value: number);
  109431. /**
  109432. * Gets or sets the unique id of the sprite
  109433. */
  109434. uniqueId: number;
  109435. /**
  109436. * Gets the manager of this sprite
  109437. */
  109438. get manager(): ISpriteManager;
  109439. /**
  109440. * Creates a new Sprite
  109441. * @param name defines the name
  109442. * @param manager defines the manager
  109443. */
  109444. constructor(
  109445. /** defines the name */
  109446. name: string, manager: ISpriteManager);
  109447. /**
  109448. * Returns the string "Sprite"
  109449. * @returns "Sprite"
  109450. */
  109451. getClassName(): string;
  109452. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  109453. get fromIndex(): number;
  109454. set fromIndex(value: number);
  109455. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  109456. get toIndex(): number;
  109457. set toIndex(value: number);
  109458. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  109459. get loopAnimation(): boolean;
  109460. set loopAnimation(value: boolean);
  109461. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  109462. get delay(): number;
  109463. set delay(value: number);
  109464. /**
  109465. * Starts an animation
  109466. * @param from defines the initial key
  109467. * @param to defines the end key
  109468. * @param loop defines if the animation must loop
  109469. * @param delay defines the start delay (in ms)
  109470. * @param onAnimationEnd defines a callback to call when animation ends
  109471. */
  109472. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  109473. private _endAnimation;
  109474. /** Release associated resources */
  109475. dispose(): void;
  109476. /**
  109477. * Serializes the sprite to a JSON object
  109478. * @returns the JSON object
  109479. */
  109480. serialize(): any;
  109481. /**
  109482. * Parses a JSON object to create a new sprite
  109483. * @param parsedSprite The JSON object to parse
  109484. * @param manager defines the hosting manager
  109485. * @returns the new sprite
  109486. */
  109487. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  109488. }
  109489. }
  109490. declare module BABYLON {
  109491. /**
  109492. * Information about the result of picking within a scene
  109493. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  109494. */
  109495. export class PickingInfo {
  109496. /** @hidden */
  109497. _pickingUnavailable: boolean;
  109498. /**
  109499. * If the pick collided with an object
  109500. */
  109501. hit: boolean;
  109502. /**
  109503. * Distance away where the pick collided
  109504. */
  109505. distance: number;
  109506. /**
  109507. * The location of pick collision
  109508. */
  109509. pickedPoint: Nullable<Vector3>;
  109510. /**
  109511. * The mesh corresponding the the pick collision
  109512. */
  109513. pickedMesh: Nullable<AbstractMesh>;
  109514. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  109515. bu: number;
  109516. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  109517. bv: number;
  109518. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  109519. faceId: number;
  109520. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  109521. subMeshFaceId: number;
  109522. /** Id of the the submesh that was picked */
  109523. subMeshId: number;
  109524. /** If a sprite was picked, this will be the sprite the pick collided with */
  109525. pickedSprite: Nullable<Sprite>;
  109526. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  109527. thinInstanceIndex: number;
  109528. /**
  109529. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  109530. */
  109531. originMesh: Nullable<AbstractMesh>;
  109532. /**
  109533. * The ray that was used to perform the picking.
  109534. */
  109535. ray: Nullable<Ray>;
  109536. /**
  109537. * Gets the normal correspodning to the face the pick collided with
  109538. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  109539. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  109540. * @returns The normal correspodning to the face the pick collided with
  109541. */
  109542. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  109543. /**
  109544. * Gets the texture coordinates of where the pick occured
  109545. * @returns the vector containing the coordnates of the texture
  109546. */
  109547. getTextureCoordinates(): Nullable<Vector2>;
  109548. }
  109549. }
  109550. declare module BABYLON {
  109551. /**
  109552. * Gather the list of pointer event types as constants.
  109553. */
  109554. export class PointerEventTypes {
  109555. /**
  109556. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  109557. */
  109558. static readonly POINTERDOWN: number;
  109559. /**
  109560. * The pointerup event is fired when a pointer is no longer active.
  109561. */
  109562. static readonly POINTERUP: number;
  109563. /**
  109564. * The pointermove event is fired when a pointer changes coordinates.
  109565. */
  109566. static readonly POINTERMOVE: number;
  109567. /**
  109568. * The pointerwheel event is fired when a mouse wheel has been rotated.
  109569. */
  109570. static readonly POINTERWHEEL: number;
  109571. /**
  109572. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  109573. */
  109574. static readonly POINTERPICK: number;
  109575. /**
  109576. * The pointertap event is fired when a the object has been touched and released without drag.
  109577. */
  109578. static readonly POINTERTAP: number;
  109579. /**
  109580. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  109581. */
  109582. static readonly POINTERDOUBLETAP: number;
  109583. }
  109584. /**
  109585. * Base class of pointer info types.
  109586. */
  109587. export class PointerInfoBase {
  109588. /**
  109589. * Defines the type of event (PointerEventTypes)
  109590. */
  109591. type: number;
  109592. /**
  109593. * Defines the related dom event
  109594. */
  109595. event: PointerEvent | MouseWheelEvent;
  109596. /**
  109597. * Instantiates the base class of pointers info.
  109598. * @param type Defines the type of event (PointerEventTypes)
  109599. * @param event Defines the related dom event
  109600. */
  109601. constructor(
  109602. /**
  109603. * Defines the type of event (PointerEventTypes)
  109604. */
  109605. type: number,
  109606. /**
  109607. * Defines the related dom event
  109608. */
  109609. event: PointerEvent | MouseWheelEvent);
  109610. }
  109611. /**
  109612. * This class is used to store pointer related info for the onPrePointerObservable event.
  109613. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  109614. */
  109615. export class PointerInfoPre extends PointerInfoBase {
  109616. /**
  109617. * Ray from a pointer if availible (eg. 6dof controller)
  109618. */
  109619. ray: Nullable<Ray>;
  109620. /**
  109621. * Defines the local position of the pointer on the canvas.
  109622. */
  109623. localPosition: Vector2;
  109624. /**
  109625. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  109626. */
  109627. skipOnPointerObservable: boolean;
  109628. /**
  109629. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  109630. * @param type Defines the type of event (PointerEventTypes)
  109631. * @param event Defines the related dom event
  109632. * @param localX Defines the local x coordinates of the pointer when the event occured
  109633. * @param localY Defines the local y coordinates of the pointer when the event occured
  109634. */
  109635. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  109636. }
  109637. /**
  109638. * This type contains all the data related to a pointer event in Babylon.js.
  109639. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  109640. */
  109641. export class PointerInfo extends PointerInfoBase {
  109642. /**
  109643. * Defines the picking info associated to the info (if any)\
  109644. */
  109645. pickInfo: Nullable<PickingInfo>;
  109646. /**
  109647. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  109648. * @param type Defines the type of event (PointerEventTypes)
  109649. * @param event Defines the related dom event
  109650. * @param pickInfo Defines the picking info associated to the info (if any)\
  109651. */
  109652. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  109653. /**
  109654. * Defines the picking info associated to the info (if any)\
  109655. */
  109656. pickInfo: Nullable<PickingInfo>);
  109657. }
  109658. /**
  109659. * Data relating to a touch event on the screen.
  109660. */
  109661. export interface PointerTouch {
  109662. /**
  109663. * X coordinate of touch.
  109664. */
  109665. x: number;
  109666. /**
  109667. * Y coordinate of touch.
  109668. */
  109669. y: number;
  109670. /**
  109671. * Id of touch. Unique for each finger.
  109672. */
  109673. pointerId: number;
  109674. /**
  109675. * Event type passed from DOM.
  109676. */
  109677. type: any;
  109678. }
  109679. }
  109680. declare module BABYLON {
  109681. /**
  109682. * Manage the mouse inputs to control the movement of a free camera.
  109683. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109684. */
  109685. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  109686. /**
  109687. * Define if touch is enabled in the mouse input
  109688. */
  109689. touchEnabled: boolean;
  109690. /**
  109691. * Defines the camera the input is attached to.
  109692. */
  109693. camera: FreeCamera;
  109694. /**
  109695. * Defines the buttons associated with the input to handle camera move.
  109696. */
  109697. buttons: number[];
  109698. /**
  109699. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  109700. */
  109701. angularSensibility: number;
  109702. private _pointerInput;
  109703. private _onMouseMove;
  109704. private _observer;
  109705. private previousPosition;
  109706. /**
  109707. * Observable for when a pointer move event occurs containing the move offset
  109708. */
  109709. onPointerMovedObservable: Observable<{
  109710. offsetX: number;
  109711. offsetY: number;
  109712. }>;
  109713. /**
  109714. * @hidden
  109715. * If the camera should be rotated automatically based on pointer movement
  109716. */
  109717. _allowCameraRotation: boolean;
  109718. /**
  109719. * Manage the mouse inputs to control the movement of a free camera.
  109720. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109721. * @param touchEnabled Defines if touch is enabled or not
  109722. */
  109723. constructor(
  109724. /**
  109725. * Define if touch is enabled in the mouse input
  109726. */
  109727. touchEnabled?: boolean);
  109728. /**
  109729. * Attach the input controls to a specific dom element to get the input from.
  109730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109731. */
  109732. attachControl(noPreventDefault?: boolean): void;
  109733. /**
  109734. * Called on JS contextmenu event.
  109735. * Override this method to provide functionality.
  109736. */
  109737. protected onContextMenu(evt: PointerEvent): void;
  109738. /**
  109739. * Detach the current controls from the specified dom element.
  109740. */
  109741. detachControl(): void;
  109742. /**
  109743. * Gets the class name of the current intput.
  109744. * @returns the class name
  109745. */
  109746. getClassName(): string;
  109747. /**
  109748. * Get the friendly name associated with the input class.
  109749. * @returns the input friendly name
  109750. */
  109751. getSimpleName(): string;
  109752. }
  109753. }
  109754. declare module BABYLON {
  109755. /**
  109756. * Base class for mouse wheel input..
  109757. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  109758. * for example usage.
  109759. */
  109760. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  109761. /**
  109762. * Defines the camera the input is attached to.
  109763. */
  109764. abstract camera: Camera;
  109765. /**
  109766. * How fast is the camera moves in relation to X axis mouseWheel events.
  109767. * Use negative value to reverse direction.
  109768. */
  109769. wheelPrecisionX: number;
  109770. /**
  109771. * How fast is the camera moves in relation to Y axis mouseWheel events.
  109772. * Use negative value to reverse direction.
  109773. */
  109774. wheelPrecisionY: number;
  109775. /**
  109776. * How fast is the camera moves in relation to Z axis mouseWheel events.
  109777. * Use negative value to reverse direction.
  109778. */
  109779. wheelPrecisionZ: number;
  109780. /**
  109781. * Observable for when a mouse wheel move event occurs.
  109782. */
  109783. onChangedObservable: Observable<{
  109784. wheelDeltaX: number;
  109785. wheelDeltaY: number;
  109786. wheelDeltaZ: number;
  109787. }>;
  109788. private _wheel;
  109789. private _observer;
  109790. /**
  109791. * Attach the input controls to a specific dom element to get the input from.
  109792. * @param noPreventDefault Defines whether event caught by the controls
  109793. * should call preventdefault().
  109794. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109795. */
  109796. attachControl(noPreventDefault?: boolean): void;
  109797. /**
  109798. * Detach the current controls from the specified dom element.
  109799. */
  109800. detachControl(): void;
  109801. /**
  109802. * Called for each rendered frame.
  109803. */
  109804. checkInputs(): void;
  109805. /**
  109806. * Gets the class name of the current intput.
  109807. * @returns the class name
  109808. */
  109809. getClassName(): string;
  109810. /**
  109811. * Get the friendly name associated with the input class.
  109812. * @returns the input friendly name
  109813. */
  109814. getSimpleName(): string;
  109815. /**
  109816. * Incremental value of multiple mouse wheel movements of the X axis.
  109817. * Should be zero-ed when read.
  109818. */
  109819. protected _wheelDeltaX: number;
  109820. /**
  109821. * Incremental value of multiple mouse wheel movements of the Y axis.
  109822. * Should be zero-ed when read.
  109823. */
  109824. protected _wheelDeltaY: number;
  109825. /**
  109826. * Incremental value of multiple mouse wheel movements of the Z axis.
  109827. * Should be zero-ed when read.
  109828. */
  109829. protected _wheelDeltaZ: number;
  109830. /**
  109831. * Firefox uses a different scheme to report scroll distances to other
  109832. * browsers. Rather than use complicated methods to calculate the exact
  109833. * multiple we need to apply, let's just cheat and use a constant.
  109834. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  109835. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  109836. */
  109837. private readonly _ffMultiplier;
  109838. /**
  109839. * Different event attributes for wheel data fall into a few set ranges.
  109840. * Some relevant but dated date here:
  109841. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  109842. */
  109843. private readonly _normalize;
  109844. }
  109845. }
  109846. declare module BABYLON {
  109847. /**
  109848. * Manage the mouse wheel inputs to control a free camera.
  109849. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109850. */
  109851. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  109852. /**
  109853. * Defines the camera the input is attached to.
  109854. */
  109855. camera: FreeCamera;
  109856. /**
  109857. * Gets the class name of the current input.
  109858. * @returns the class name
  109859. */
  109860. getClassName(): string;
  109861. /**
  109862. * Set which movement axis (relative to camera's orientation) the mouse
  109863. * wheel's X axis controls.
  109864. * @param axis The axis to be moved. Set null to clear.
  109865. */
  109866. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  109867. /**
  109868. * Get the configured movement axis (relative to camera's orientation) the
  109869. * mouse wheel's X axis controls.
  109870. * @returns The configured axis or null if none.
  109871. */
  109872. get wheelXMoveRelative(): Nullable<Coordinate>;
  109873. /**
  109874. * Set which movement axis (relative to camera's orientation) the mouse
  109875. * wheel's Y axis controls.
  109876. * @param axis The axis to be moved. Set null to clear.
  109877. */
  109878. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  109879. /**
  109880. * Get the configured movement axis (relative to camera's orientation) the
  109881. * mouse wheel's Y axis controls.
  109882. * @returns The configured axis or null if none.
  109883. */
  109884. get wheelYMoveRelative(): Nullable<Coordinate>;
  109885. /**
  109886. * Set which movement axis (relative to camera's orientation) the mouse
  109887. * wheel's Z axis controls.
  109888. * @param axis The axis to be moved. Set null to clear.
  109889. */
  109890. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  109891. /**
  109892. * Get the configured movement axis (relative to camera's orientation) the
  109893. * mouse wheel's Z axis controls.
  109894. * @returns The configured axis or null if none.
  109895. */
  109896. get wheelZMoveRelative(): Nullable<Coordinate>;
  109897. /**
  109898. * Set which rotation axis (relative to camera's orientation) the mouse
  109899. * wheel's X axis controls.
  109900. * @param axis The axis to be moved. Set null to clear.
  109901. */
  109902. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  109903. /**
  109904. * Get the configured rotation axis (relative to camera's orientation) the
  109905. * mouse wheel's X axis controls.
  109906. * @returns The configured axis or null if none.
  109907. */
  109908. get wheelXRotateRelative(): Nullable<Coordinate>;
  109909. /**
  109910. * Set which rotation axis (relative to camera's orientation) the mouse
  109911. * wheel's Y axis controls.
  109912. * @param axis The axis to be moved. Set null to clear.
  109913. */
  109914. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  109915. /**
  109916. * Get the configured rotation axis (relative to camera's orientation) the
  109917. * mouse wheel's Y axis controls.
  109918. * @returns The configured axis or null if none.
  109919. */
  109920. get wheelYRotateRelative(): Nullable<Coordinate>;
  109921. /**
  109922. * Set which rotation axis (relative to camera's orientation) the mouse
  109923. * wheel's Z axis controls.
  109924. * @param axis The axis to be moved. Set null to clear.
  109925. */
  109926. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  109927. /**
  109928. * Get the configured rotation axis (relative to camera's orientation) the
  109929. * mouse wheel's Z axis controls.
  109930. * @returns The configured axis or null if none.
  109931. */
  109932. get wheelZRotateRelative(): Nullable<Coordinate>;
  109933. /**
  109934. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  109935. * controls.
  109936. * @param axis The axis to be moved. Set null to clear.
  109937. */
  109938. set wheelXMoveScene(axis: Nullable<Coordinate>);
  109939. /**
  109940. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109941. * X axis controls.
  109942. * @returns The configured axis or null if none.
  109943. */
  109944. get wheelXMoveScene(): Nullable<Coordinate>;
  109945. /**
  109946. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  109947. * controls.
  109948. * @param axis The axis to be moved. Set null to clear.
  109949. */
  109950. set wheelYMoveScene(axis: Nullable<Coordinate>);
  109951. /**
  109952. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109953. * Y axis controls.
  109954. * @returns The configured axis or null if none.
  109955. */
  109956. get wheelYMoveScene(): Nullable<Coordinate>;
  109957. /**
  109958. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  109959. * controls.
  109960. * @param axis The axis to be moved. Set null to clear.
  109961. */
  109962. set wheelZMoveScene(axis: Nullable<Coordinate>);
  109963. /**
  109964. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109965. * Z axis controls.
  109966. * @returns The configured axis or null if none.
  109967. */
  109968. get wheelZMoveScene(): Nullable<Coordinate>;
  109969. /**
  109970. * Called for each rendered frame.
  109971. */
  109972. checkInputs(): void;
  109973. private _moveRelative;
  109974. private _rotateRelative;
  109975. private _moveScene;
  109976. /**
  109977. * These are set to the desired default behaviour.
  109978. */
  109979. private _wheelXAction;
  109980. private _wheelXActionCoordinate;
  109981. private _wheelYAction;
  109982. private _wheelYActionCoordinate;
  109983. private _wheelZAction;
  109984. private _wheelZActionCoordinate;
  109985. /**
  109986. * Update the camera according to any configured properties for the 3
  109987. * mouse-wheel axis.
  109988. */
  109989. private _updateCamera;
  109990. /**
  109991. * Update one property of the camera.
  109992. */
  109993. private _updateCameraProperty;
  109994. }
  109995. }
  109996. declare module BABYLON {
  109997. /**
  109998. * Manage the touch inputs to control the movement of a free camera.
  109999. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110000. */
  110001. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  110002. /**
  110003. * Define if mouse events can be treated as touch events
  110004. */
  110005. allowMouse: boolean;
  110006. /**
  110007. * Defines the camera the input is attached to.
  110008. */
  110009. camera: FreeCamera;
  110010. /**
  110011. * Defines the touch sensibility for rotation.
  110012. * The higher the faster.
  110013. */
  110014. touchAngularSensibility: number;
  110015. /**
  110016. * Defines the touch sensibility for move.
  110017. * The higher the faster.
  110018. */
  110019. touchMoveSensibility: number;
  110020. private _offsetX;
  110021. private _offsetY;
  110022. private _pointerPressed;
  110023. private _pointerInput?;
  110024. private _observer;
  110025. private _onLostFocus;
  110026. /**
  110027. * Manage the touch inputs to control the movement of a free camera.
  110028. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110029. * @param allowMouse Defines if mouse events can be treated as touch events
  110030. */
  110031. constructor(
  110032. /**
  110033. * Define if mouse events can be treated as touch events
  110034. */
  110035. allowMouse?: boolean);
  110036. /**
  110037. * Attach the input controls to a specific dom element to get the input from.
  110038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110039. */
  110040. attachControl(noPreventDefault?: boolean): void;
  110041. /**
  110042. * Detach the current controls from the specified dom element.
  110043. */
  110044. detachControl(): void;
  110045. /**
  110046. * Update the current camera state depending on the inputs that have been used this frame.
  110047. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110048. */
  110049. checkInputs(): void;
  110050. /**
  110051. * Gets the class name of the current intput.
  110052. * @returns the class name
  110053. */
  110054. getClassName(): string;
  110055. /**
  110056. * Get the friendly name associated with the input class.
  110057. * @returns the input friendly name
  110058. */
  110059. getSimpleName(): string;
  110060. }
  110061. }
  110062. declare module BABYLON {
  110063. /**
  110064. * Default Inputs manager for the FreeCamera.
  110065. * It groups all the default supported inputs for ease of use.
  110066. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110067. */
  110068. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  110069. /**
  110070. * @hidden
  110071. */
  110072. _mouseInput: Nullable<FreeCameraMouseInput>;
  110073. /**
  110074. * @hidden
  110075. */
  110076. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  110077. /**
  110078. * Instantiates a new FreeCameraInputsManager.
  110079. * @param camera Defines the camera the inputs belong to
  110080. */
  110081. constructor(camera: FreeCamera);
  110082. /**
  110083. * Add keyboard input support to the input manager.
  110084. * @returns the current input manager
  110085. */
  110086. addKeyboard(): FreeCameraInputsManager;
  110087. /**
  110088. * Add mouse input support to the input manager.
  110089. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  110090. * @returns the current input manager
  110091. */
  110092. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  110093. /**
  110094. * Removes the mouse input support from the manager
  110095. * @returns the current input manager
  110096. */
  110097. removeMouse(): FreeCameraInputsManager;
  110098. /**
  110099. * Add mouse wheel input support to the input manager.
  110100. * @returns the current input manager
  110101. */
  110102. addMouseWheel(): FreeCameraInputsManager;
  110103. /**
  110104. * Removes the mouse wheel input support from the manager
  110105. * @returns the current input manager
  110106. */
  110107. removeMouseWheel(): FreeCameraInputsManager;
  110108. /**
  110109. * Add touch input support to the input manager.
  110110. * @returns the current input manager
  110111. */
  110112. addTouch(): FreeCameraInputsManager;
  110113. /**
  110114. * Remove all attached input methods from a camera
  110115. */
  110116. clear(): void;
  110117. }
  110118. }
  110119. declare module BABYLON {
  110120. /**
  110121. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110122. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  110123. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  110124. */
  110125. export class FreeCamera extends TargetCamera {
  110126. /**
  110127. * Define the collision ellipsoid of the camera.
  110128. * This is helpful to simulate a camera body like the player body around the camera
  110129. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110130. */
  110131. ellipsoid: Vector3;
  110132. /**
  110133. * Define an offset for the position of the ellipsoid around the camera.
  110134. * This can be helpful to determine the center of the body near the gravity center of the body
  110135. * instead of its head.
  110136. */
  110137. ellipsoidOffset: Vector3;
  110138. /**
  110139. * Enable or disable collisions of the camera with the rest of the scene objects.
  110140. */
  110141. checkCollisions: boolean;
  110142. /**
  110143. * Enable or disable gravity on the camera.
  110144. */
  110145. applyGravity: boolean;
  110146. /**
  110147. * Define the input manager associated to the camera.
  110148. */
  110149. inputs: FreeCameraInputsManager;
  110150. /**
  110151. * Gets the input sensibility for a mouse input. (default is 2000.0)
  110152. * Higher values reduce sensitivity.
  110153. */
  110154. get angularSensibility(): number;
  110155. /**
  110156. * Sets the input sensibility for a mouse input. (default is 2000.0)
  110157. * Higher values reduce sensitivity.
  110158. */
  110159. set angularSensibility(value: number);
  110160. /**
  110161. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  110162. */
  110163. get keysUp(): number[];
  110164. set keysUp(value: number[]);
  110165. /**
  110166. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  110167. */
  110168. get keysUpward(): number[];
  110169. set keysUpward(value: number[]);
  110170. /**
  110171. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  110172. */
  110173. get keysDown(): number[];
  110174. set keysDown(value: number[]);
  110175. /**
  110176. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  110177. */
  110178. get keysDownward(): number[];
  110179. set keysDownward(value: number[]);
  110180. /**
  110181. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  110182. */
  110183. get keysLeft(): number[];
  110184. set keysLeft(value: number[]);
  110185. /**
  110186. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  110187. */
  110188. get keysRight(): number[];
  110189. set keysRight(value: number[]);
  110190. /**
  110191. * Event raised when the camera collide with a mesh in the scene.
  110192. */
  110193. onCollide: (collidedMesh: AbstractMesh) => void;
  110194. private _collider;
  110195. private _needMoveForGravity;
  110196. private _oldPosition;
  110197. private _diffPosition;
  110198. private _newPosition;
  110199. /** @hidden */
  110200. _localDirection: Vector3;
  110201. /** @hidden */
  110202. _transformedDirection: Vector3;
  110203. /**
  110204. * Instantiates a Free Camera.
  110205. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110206. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  110207. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  110208. * @param name Define the name of the camera in the scene
  110209. * @param position Define the start position of the camera in the scene
  110210. * @param scene Define the scene the camera belongs to
  110211. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  110212. */
  110213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110214. /**
  110215. * Attach the input controls to a specific dom element to get the input from.
  110216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110217. */
  110218. attachControl(noPreventDefault?: boolean): void;
  110219. /**
  110220. * Attach the input controls to a specific dom element to get the input from.
  110221. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  110222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110223. * BACK COMPAT SIGNATURE ONLY.
  110224. */
  110225. attachControl(ignored: any, noPreventDefault?: boolean): void;
  110226. /**
  110227. * Detach the current controls from the specified dom element.
  110228. */
  110229. detachControl(): void;
  110230. /**
  110231. * Detach the current controls from the specified dom element.
  110232. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  110233. */
  110234. detachControl(ignored: any): void;
  110235. private _collisionMask;
  110236. /**
  110237. * Define a collision mask to limit the list of object the camera can collide with
  110238. */
  110239. get collisionMask(): number;
  110240. set collisionMask(mask: number);
  110241. /** @hidden */
  110242. _collideWithWorld(displacement: Vector3): void;
  110243. private _onCollisionPositionChange;
  110244. /** @hidden */
  110245. _checkInputs(): void;
  110246. /** @hidden */
  110247. _decideIfNeedsToMove(): boolean;
  110248. /** @hidden */
  110249. _updatePosition(): void;
  110250. /**
  110251. * Destroy the camera and release the current resources hold by it.
  110252. */
  110253. dispose(): void;
  110254. /**
  110255. * Gets the current object class name.
  110256. * @return the class name
  110257. */
  110258. getClassName(): string;
  110259. }
  110260. }
  110261. declare module BABYLON {
  110262. /**
  110263. * Represents a gamepad control stick position
  110264. */
  110265. export class StickValues {
  110266. /**
  110267. * The x component of the control stick
  110268. */
  110269. x: number;
  110270. /**
  110271. * The y component of the control stick
  110272. */
  110273. y: number;
  110274. /**
  110275. * Initializes the gamepad x and y control stick values
  110276. * @param x The x component of the gamepad control stick value
  110277. * @param y The y component of the gamepad control stick value
  110278. */
  110279. constructor(
  110280. /**
  110281. * The x component of the control stick
  110282. */
  110283. x: number,
  110284. /**
  110285. * The y component of the control stick
  110286. */
  110287. y: number);
  110288. }
  110289. /**
  110290. * An interface which manages callbacks for gamepad button changes
  110291. */
  110292. export interface GamepadButtonChanges {
  110293. /**
  110294. * Called when a gamepad has been changed
  110295. */
  110296. changed: boolean;
  110297. /**
  110298. * Called when a gamepad press event has been triggered
  110299. */
  110300. pressChanged: boolean;
  110301. /**
  110302. * Called when a touch event has been triggered
  110303. */
  110304. touchChanged: boolean;
  110305. /**
  110306. * Called when a value has changed
  110307. */
  110308. valueChanged: boolean;
  110309. }
  110310. /**
  110311. * Represents a gamepad
  110312. */
  110313. export class Gamepad {
  110314. /**
  110315. * The id of the gamepad
  110316. */
  110317. id: string;
  110318. /**
  110319. * The index of the gamepad
  110320. */
  110321. index: number;
  110322. /**
  110323. * The browser gamepad
  110324. */
  110325. browserGamepad: any;
  110326. /**
  110327. * Specifies what type of gamepad this represents
  110328. */
  110329. type: number;
  110330. private _leftStick;
  110331. private _rightStick;
  110332. /** @hidden */
  110333. _isConnected: boolean;
  110334. private _leftStickAxisX;
  110335. private _leftStickAxisY;
  110336. private _rightStickAxisX;
  110337. private _rightStickAxisY;
  110338. /**
  110339. * Triggered when the left control stick has been changed
  110340. */
  110341. private _onleftstickchanged;
  110342. /**
  110343. * Triggered when the right control stick has been changed
  110344. */
  110345. private _onrightstickchanged;
  110346. /**
  110347. * Represents a gamepad controller
  110348. */
  110349. static GAMEPAD: number;
  110350. /**
  110351. * Represents a generic controller
  110352. */
  110353. static GENERIC: number;
  110354. /**
  110355. * Represents an XBox controller
  110356. */
  110357. static XBOX: number;
  110358. /**
  110359. * Represents a pose-enabled controller
  110360. */
  110361. static POSE_ENABLED: number;
  110362. /**
  110363. * Represents an Dual Shock controller
  110364. */
  110365. static DUALSHOCK: number;
  110366. /**
  110367. * Specifies whether the left control stick should be Y-inverted
  110368. */
  110369. protected _invertLeftStickY: boolean;
  110370. /**
  110371. * Specifies if the gamepad has been connected
  110372. */
  110373. get isConnected(): boolean;
  110374. /**
  110375. * Initializes the gamepad
  110376. * @param id The id of the gamepad
  110377. * @param index The index of the gamepad
  110378. * @param browserGamepad The browser gamepad
  110379. * @param leftStickX The x component of the left joystick
  110380. * @param leftStickY The y component of the left joystick
  110381. * @param rightStickX The x component of the right joystick
  110382. * @param rightStickY The y component of the right joystick
  110383. */
  110384. constructor(
  110385. /**
  110386. * The id of the gamepad
  110387. */
  110388. id: string,
  110389. /**
  110390. * The index of the gamepad
  110391. */
  110392. index: number,
  110393. /**
  110394. * The browser gamepad
  110395. */
  110396. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  110397. /**
  110398. * Callback triggered when the left joystick has changed
  110399. * @param callback
  110400. */
  110401. onleftstickchanged(callback: (values: StickValues) => void): void;
  110402. /**
  110403. * Callback triggered when the right joystick has changed
  110404. * @param callback
  110405. */
  110406. onrightstickchanged(callback: (values: StickValues) => void): void;
  110407. /**
  110408. * Gets the left joystick
  110409. */
  110410. get leftStick(): StickValues;
  110411. /**
  110412. * Sets the left joystick values
  110413. */
  110414. set leftStick(newValues: StickValues);
  110415. /**
  110416. * Gets the right joystick
  110417. */
  110418. get rightStick(): StickValues;
  110419. /**
  110420. * Sets the right joystick value
  110421. */
  110422. set rightStick(newValues: StickValues);
  110423. /**
  110424. * Updates the gamepad joystick positions
  110425. */
  110426. update(): void;
  110427. /**
  110428. * Disposes the gamepad
  110429. */
  110430. dispose(): void;
  110431. }
  110432. /**
  110433. * Represents a generic gamepad
  110434. */
  110435. export class GenericPad extends Gamepad {
  110436. private _buttons;
  110437. private _onbuttondown;
  110438. private _onbuttonup;
  110439. /**
  110440. * Observable triggered when a button has been pressed
  110441. */
  110442. onButtonDownObservable: Observable<number>;
  110443. /**
  110444. * Observable triggered when a button has been released
  110445. */
  110446. onButtonUpObservable: Observable<number>;
  110447. /**
  110448. * Callback triggered when a button has been pressed
  110449. * @param callback Called when a button has been pressed
  110450. */
  110451. onbuttondown(callback: (buttonPressed: number) => void): void;
  110452. /**
  110453. * Callback triggered when a button has been released
  110454. * @param callback Called when a button has been released
  110455. */
  110456. onbuttonup(callback: (buttonReleased: number) => void): void;
  110457. /**
  110458. * Initializes the generic gamepad
  110459. * @param id The id of the generic gamepad
  110460. * @param index The index of the generic gamepad
  110461. * @param browserGamepad The browser gamepad
  110462. */
  110463. constructor(id: string, index: number, browserGamepad: any);
  110464. private _setButtonValue;
  110465. /**
  110466. * Updates the generic gamepad
  110467. */
  110468. update(): void;
  110469. /**
  110470. * Disposes the generic gamepad
  110471. */
  110472. dispose(): void;
  110473. }
  110474. }
  110475. declare module BABYLON {
  110476. /**
  110477. * Defines a runtime animation
  110478. */
  110479. export class RuntimeAnimation {
  110480. private _events;
  110481. /**
  110482. * The current frame of the runtime animation
  110483. */
  110484. private _currentFrame;
  110485. /**
  110486. * The animation used by the runtime animation
  110487. */
  110488. private _animation;
  110489. /**
  110490. * The target of the runtime animation
  110491. */
  110492. private _target;
  110493. /**
  110494. * The initiating animatable
  110495. */
  110496. private _host;
  110497. /**
  110498. * The original value of the runtime animation
  110499. */
  110500. private _originalValue;
  110501. /**
  110502. * The original blend value of the runtime animation
  110503. */
  110504. private _originalBlendValue;
  110505. /**
  110506. * The offsets cache of the runtime animation
  110507. */
  110508. private _offsetsCache;
  110509. /**
  110510. * The high limits cache of the runtime animation
  110511. */
  110512. private _highLimitsCache;
  110513. /**
  110514. * Specifies if the runtime animation has been stopped
  110515. */
  110516. private _stopped;
  110517. /**
  110518. * The blending factor of the runtime animation
  110519. */
  110520. private _blendingFactor;
  110521. /**
  110522. * The BabylonJS scene
  110523. */
  110524. private _scene;
  110525. /**
  110526. * The current value of the runtime animation
  110527. */
  110528. private _currentValue;
  110529. /** @hidden */
  110530. _animationState: _IAnimationState;
  110531. /**
  110532. * The active target of the runtime animation
  110533. */
  110534. private _activeTargets;
  110535. private _currentActiveTarget;
  110536. private _directTarget;
  110537. /**
  110538. * The target path of the runtime animation
  110539. */
  110540. private _targetPath;
  110541. /**
  110542. * The weight of the runtime animation
  110543. */
  110544. private _weight;
  110545. /**
  110546. * The ratio offset of the runtime animation
  110547. */
  110548. private _ratioOffset;
  110549. /**
  110550. * The previous delay of the runtime animation
  110551. */
  110552. private _previousDelay;
  110553. /**
  110554. * The previous ratio of the runtime animation
  110555. */
  110556. private _previousRatio;
  110557. private _enableBlending;
  110558. private _keys;
  110559. private _minFrame;
  110560. private _maxFrame;
  110561. private _minValue;
  110562. private _maxValue;
  110563. private _targetIsArray;
  110564. /**
  110565. * Gets the current frame of the runtime animation
  110566. */
  110567. get currentFrame(): number;
  110568. /**
  110569. * Gets the weight of the runtime animation
  110570. */
  110571. get weight(): number;
  110572. /**
  110573. * Gets the current value of the runtime animation
  110574. */
  110575. get currentValue(): any;
  110576. /**
  110577. * Gets the target path of the runtime animation
  110578. */
  110579. get targetPath(): string;
  110580. /**
  110581. * Gets the actual target of the runtime animation
  110582. */
  110583. get target(): any;
  110584. /**
  110585. * Gets the additive state of the runtime animation
  110586. */
  110587. get isAdditive(): boolean;
  110588. /** @hidden */
  110589. _onLoop: () => void;
  110590. /**
  110591. * Create a new RuntimeAnimation object
  110592. * @param target defines the target of the animation
  110593. * @param animation defines the source animation object
  110594. * @param scene defines the hosting scene
  110595. * @param host defines the initiating Animatable
  110596. */
  110597. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  110598. private _preparePath;
  110599. /**
  110600. * Gets the animation from the runtime animation
  110601. */
  110602. get animation(): Animation;
  110603. /**
  110604. * Resets the runtime animation to the beginning
  110605. * @param restoreOriginal defines whether to restore the target property to the original value
  110606. */
  110607. reset(restoreOriginal?: boolean): void;
  110608. /**
  110609. * Specifies if the runtime animation is stopped
  110610. * @returns Boolean specifying if the runtime animation is stopped
  110611. */
  110612. isStopped(): boolean;
  110613. /**
  110614. * Disposes of the runtime animation
  110615. */
  110616. dispose(): void;
  110617. /**
  110618. * Apply the interpolated value to the target
  110619. * @param currentValue defines the value computed by the animation
  110620. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  110621. */
  110622. setValue(currentValue: any, weight: number): void;
  110623. private _getOriginalValues;
  110624. private _setValue;
  110625. /**
  110626. * Gets the loop pmode of the runtime animation
  110627. * @returns Loop Mode
  110628. */
  110629. private _getCorrectLoopMode;
  110630. /**
  110631. * Move the current animation to a given frame
  110632. * @param frame defines the frame to move to
  110633. */
  110634. goToFrame(frame: number): void;
  110635. /**
  110636. * @hidden Internal use only
  110637. */
  110638. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  110639. /**
  110640. * Execute the current animation
  110641. * @param delay defines the delay to add to the current frame
  110642. * @param from defines the lower bound of the animation range
  110643. * @param to defines the upper bound of the animation range
  110644. * @param loop defines if the current animation must loop
  110645. * @param speedRatio defines the current speed ratio
  110646. * @param weight defines the weight of the animation (default is -1 so no weight)
  110647. * @param onLoop optional callback called when animation loops
  110648. * @returns a boolean indicating if the animation is running
  110649. */
  110650. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  110651. }
  110652. }
  110653. declare module BABYLON {
  110654. /**
  110655. * Class used to store an actual running animation
  110656. */
  110657. export class Animatable {
  110658. /** defines the target object */
  110659. target: any;
  110660. /** defines the starting frame number (default is 0) */
  110661. fromFrame: number;
  110662. /** defines the ending frame number (default is 100) */
  110663. toFrame: number;
  110664. /** defines if the animation must loop (default is false) */
  110665. loopAnimation: boolean;
  110666. /** defines a callback to call when animation ends if it is not looping */
  110667. onAnimationEnd?: (() => void) | null | undefined;
  110668. /** defines a callback to call when animation loops */
  110669. onAnimationLoop?: (() => void) | null | undefined;
  110670. /** defines whether the animation should be evaluated additively */
  110671. isAdditive: boolean;
  110672. private _localDelayOffset;
  110673. private _pausedDelay;
  110674. private _runtimeAnimations;
  110675. private _paused;
  110676. private _scene;
  110677. private _speedRatio;
  110678. private _weight;
  110679. private _syncRoot;
  110680. /**
  110681. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  110682. * This will only apply for non looping animation (default is true)
  110683. */
  110684. disposeOnEnd: boolean;
  110685. /**
  110686. * Gets a boolean indicating if the animation has started
  110687. */
  110688. animationStarted: boolean;
  110689. /**
  110690. * Observer raised when the animation ends
  110691. */
  110692. onAnimationEndObservable: Observable<Animatable>;
  110693. /**
  110694. * Observer raised when the animation loops
  110695. */
  110696. onAnimationLoopObservable: Observable<Animatable>;
  110697. /**
  110698. * Gets the root Animatable used to synchronize and normalize animations
  110699. */
  110700. get syncRoot(): Nullable<Animatable>;
  110701. /**
  110702. * Gets the current frame of the first RuntimeAnimation
  110703. * Used to synchronize Animatables
  110704. */
  110705. get masterFrame(): number;
  110706. /**
  110707. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  110708. */
  110709. get weight(): number;
  110710. set weight(value: number);
  110711. /**
  110712. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  110713. */
  110714. get speedRatio(): number;
  110715. set speedRatio(value: number);
  110716. /**
  110717. * Creates a new Animatable
  110718. * @param scene defines the hosting scene
  110719. * @param target defines the target object
  110720. * @param fromFrame defines the starting frame number (default is 0)
  110721. * @param toFrame defines the ending frame number (default is 100)
  110722. * @param loopAnimation defines if the animation must loop (default is false)
  110723. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  110724. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  110725. * @param animations defines a group of animation to add to the new Animatable
  110726. * @param onAnimationLoop defines a callback to call when animation loops
  110727. * @param isAdditive defines whether the animation should be evaluated additively
  110728. */
  110729. constructor(scene: Scene,
  110730. /** defines the target object */
  110731. target: any,
  110732. /** defines the starting frame number (default is 0) */
  110733. fromFrame?: number,
  110734. /** defines the ending frame number (default is 100) */
  110735. toFrame?: number,
  110736. /** defines if the animation must loop (default is false) */
  110737. loopAnimation?: boolean, speedRatio?: number,
  110738. /** defines a callback to call when animation ends if it is not looping */
  110739. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  110740. /** defines a callback to call when animation loops */
  110741. onAnimationLoop?: (() => void) | null | undefined,
  110742. /** defines whether the animation should be evaluated additively */
  110743. isAdditive?: boolean);
  110744. /**
  110745. * Synchronize and normalize current Animatable with a source Animatable
  110746. * This is useful when using animation weights and when animations are not of the same length
  110747. * @param root defines the root Animatable to synchronize with
  110748. * @returns the current Animatable
  110749. */
  110750. syncWith(root: Animatable): Animatable;
  110751. /**
  110752. * Gets the list of runtime animations
  110753. * @returns an array of RuntimeAnimation
  110754. */
  110755. getAnimations(): RuntimeAnimation[];
  110756. /**
  110757. * Adds more animations to the current animatable
  110758. * @param target defines the target of the animations
  110759. * @param animations defines the new animations to add
  110760. */
  110761. appendAnimations(target: any, animations: Animation[]): void;
  110762. /**
  110763. * Gets the source animation for a specific property
  110764. * @param property defines the propertyu to look for
  110765. * @returns null or the source animation for the given property
  110766. */
  110767. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  110768. /**
  110769. * Gets the runtime animation for a specific property
  110770. * @param property defines the propertyu to look for
  110771. * @returns null or the runtime animation for the given property
  110772. */
  110773. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  110774. /**
  110775. * Resets the animatable to its original state
  110776. */
  110777. reset(): void;
  110778. /**
  110779. * Allows the animatable to blend with current running animations
  110780. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110781. * @param blendingSpeed defines the blending speed to use
  110782. */
  110783. enableBlending(blendingSpeed: number): void;
  110784. /**
  110785. * Disable animation blending
  110786. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110787. */
  110788. disableBlending(): void;
  110789. /**
  110790. * Jump directly to a given frame
  110791. * @param frame defines the frame to jump to
  110792. */
  110793. goToFrame(frame: number): void;
  110794. /**
  110795. * Pause the animation
  110796. */
  110797. pause(): void;
  110798. /**
  110799. * Restart the animation
  110800. */
  110801. restart(): void;
  110802. private _raiseOnAnimationEnd;
  110803. /**
  110804. * Stop and delete the current animation
  110805. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  110806. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  110807. */
  110808. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  110809. /**
  110810. * Wait asynchronously for the animation to end
  110811. * @returns a promise which will be fullfilled when the animation ends
  110812. */
  110813. waitAsync(): Promise<Animatable>;
  110814. /** @hidden */
  110815. _animate(delay: number): boolean;
  110816. }
  110817. interface Scene {
  110818. /** @hidden */
  110819. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  110820. /** @hidden */
  110821. _processLateAnimationBindingsForMatrices(holder: {
  110822. totalWeight: number;
  110823. totalAdditiveWeight: number;
  110824. animations: RuntimeAnimation[];
  110825. additiveAnimations: RuntimeAnimation[];
  110826. originalValue: Matrix;
  110827. }): any;
  110828. /** @hidden */
  110829. _processLateAnimationBindingsForQuaternions(holder: {
  110830. totalWeight: number;
  110831. totalAdditiveWeight: number;
  110832. animations: RuntimeAnimation[];
  110833. additiveAnimations: RuntimeAnimation[];
  110834. originalValue: Quaternion;
  110835. }, refQuaternion: Quaternion): Quaternion;
  110836. /** @hidden */
  110837. _processLateAnimationBindings(): void;
  110838. /**
  110839. * Will start the animation sequence of a given target
  110840. * @param target defines the target
  110841. * @param from defines from which frame should animation start
  110842. * @param to defines until which frame should animation run.
  110843. * @param weight defines the weight to apply to the animation (1.0 by default)
  110844. * @param loop defines if the animation loops
  110845. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110846. * @param onAnimationEnd defines the function to be executed when the animation ends
  110847. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110848. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110849. * @param onAnimationLoop defines the callback to call when an animation loops
  110850. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110851. * @returns the animatable object created for this animation
  110852. */
  110853. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  110854. /**
  110855. * Will start the animation sequence of a given target
  110856. * @param target defines the target
  110857. * @param from defines from which frame should animation start
  110858. * @param to defines until which frame should animation run.
  110859. * @param loop defines if the animation loops
  110860. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110861. * @param onAnimationEnd defines the function to be executed when the animation ends
  110862. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110863. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110864. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  110865. * @param onAnimationLoop defines the callback to call when an animation loops
  110866. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110867. * @returns the animatable object created for this animation
  110868. */
  110869. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  110870. /**
  110871. * Will start the animation sequence of a given target and its hierarchy
  110872. * @param target defines the target
  110873. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  110874. * @param from defines from which frame should animation start
  110875. * @param to defines until which frame should animation run.
  110876. * @param loop defines if the animation loops
  110877. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110878. * @param onAnimationEnd defines the function to be executed when the animation ends
  110879. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110880. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110881. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110882. * @param onAnimationLoop defines the callback to call when an animation loops
  110883. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110884. * @returns the list of created animatables
  110885. */
  110886. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  110887. /**
  110888. * Begin a new animation on a given node
  110889. * @param target defines the target where the animation will take place
  110890. * @param animations defines the list of animations to start
  110891. * @param from defines the initial value
  110892. * @param to defines the final value
  110893. * @param loop defines if you want animation to loop (off by default)
  110894. * @param speedRatio defines the speed ratio to apply to all animations
  110895. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110896. * @param onAnimationLoop defines the callback to call when an animation loops
  110897. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110898. * @returns the list of created animatables
  110899. */
  110900. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  110901. /**
  110902. * Begin a new animation on a given node and its hierarchy
  110903. * @param target defines the root node where the animation will take place
  110904. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  110905. * @param animations defines the list of animations to start
  110906. * @param from defines the initial value
  110907. * @param to defines the final value
  110908. * @param loop defines if you want animation to loop (off by default)
  110909. * @param speedRatio defines the speed ratio to apply to all animations
  110910. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110911. * @param onAnimationLoop defines the callback to call when an animation loops
  110912. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110913. * @returns the list of animatables created for all nodes
  110914. */
  110915. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  110916. /**
  110917. * Gets the animatable associated with a specific target
  110918. * @param target defines the target of the animatable
  110919. * @returns the required animatable if found
  110920. */
  110921. getAnimatableByTarget(target: any): Nullable<Animatable>;
  110922. /**
  110923. * Gets all animatables associated with a given target
  110924. * @param target defines the target to look animatables for
  110925. * @returns an array of Animatables
  110926. */
  110927. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  110928. /**
  110929. * Stops and removes all animations that have been applied to the scene
  110930. */
  110931. stopAllAnimations(): void;
  110932. /**
  110933. * Gets the current delta time used by animation engine
  110934. */
  110935. deltaTime: number;
  110936. }
  110937. interface Bone {
  110938. /**
  110939. * Copy an animation range from another bone
  110940. * @param source defines the source bone
  110941. * @param rangeName defines the range name to copy
  110942. * @param frameOffset defines the frame offset
  110943. * @param rescaleAsRequired defines if rescaling must be applied if required
  110944. * @param skelDimensionsRatio defines the scaling ratio
  110945. * @returns true if operation was successful
  110946. */
  110947. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  110948. }
  110949. }
  110950. declare module BABYLON {
  110951. /**
  110952. * Class used to override all child animations of a given target
  110953. */
  110954. export class AnimationPropertiesOverride {
  110955. /**
  110956. * Gets or sets a value indicating if animation blending must be used
  110957. */
  110958. enableBlending: boolean;
  110959. /**
  110960. * Gets or sets the blending speed to use when enableBlending is true
  110961. */
  110962. blendingSpeed: number;
  110963. /**
  110964. * Gets or sets the default loop mode to use
  110965. */
  110966. loopMode: number;
  110967. }
  110968. }
  110969. declare module BABYLON {
  110970. /**
  110971. * Class used to handle skinning animations
  110972. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110973. */
  110974. export class Skeleton implements IAnimatable {
  110975. /** defines the skeleton name */
  110976. name: string;
  110977. /** defines the skeleton Id */
  110978. id: string;
  110979. /**
  110980. * Defines the list of child bones
  110981. */
  110982. bones: Bone[];
  110983. /**
  110984. * Defines an estimate of the dimension of the skeleton at rest
  110985. */
  110986. dimensionsAtRest: Vector3;
  110987. /**
  110988. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  110989. */
  110990. needInitialSkinMatrix: boolean;
  110991. /**
  110992. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  110993. */
  110994. overrideMesh: Nullable<AbstractMesh>;
  110995. /**
  110996. * Gets the list of animations attached to this skeleton
  110997. */
  110998. animations: Array<Animation>;
  110999. private _scene;
  111000. private _isDirty;
  111001. private _transformMatrices;
  111002. private _transformMatrixTexture;
  111003. private _meshesWithPoseMatrix;
  111004. private _animatables;
  111005. private _identity;
  111006. private _synchronizedWithMesh;
  111007. private _ranges;
  111008. private _lastAbsoluteTransformsUpdateId;
  111009. private _canUseTextureForBones;
  111010. private _uniqueId;
  111011. /** @hidden */
  111012. _numBonesWithLinkedTransformNode: number;
  111013. /** @hidden */
  111014. _hasWaitingData: Nullable<boolean>;
  111015. /** @hidden */
  111016. _waitingOverrideMeshId: Nullable<string>;
  111017. /**
  111018. * Specifies if the skeleton should be serialized
  111019. */
  111020. doNotSerialize: boolean;
  111021. private _useTextureToStoreBoneMatrices;
  111022. /**
  111023. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  111024. * Please note that this option is not available if the hardware does not support it
  111025. */
  111026. get useTextureToStoreBoneMatrices(): boolean;
  111027. set useTextureToStoreBoneMatrices(value: boolean);
  111028. private _animationPropertiesOverride;
  111029. /**
  111030. * Gets or sets the animation properties override
  111031. */
  111032. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111033. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111034. /**
  111035. * List of inspectable custom properties (used by the Inspector)
  111036. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111037. */
  111038. inspectableCustomProperties: IInspectable[];
  111039. /**
  111040. * An observable triggered before computing the skeleton's matrices
  111041. */
  111042. onBeforeComputeObservable: Observable<Skeleton>;
  111043. /**
  111044. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  111045. */
  111046. get isUsingTextureForMatrices(): boolean;
  111047. /**
  111048. * Gets the unique ID of this skeleton
  111049. */
  111050. get uniqueId(): number;
  111051. /**
  111052. * Creates a new skeleton
  111053. * @param name defines the skeleton name
  111054. * @param id defines the skeleton Id
  111055. * @param scene defines the hosting scene
  111056. */
  111057. constructor(
  111058. /** defines the skeleton name */
  111059. name: string,
  111060. /** defines the skeleton Id */
  111061. id: string, scene: Scene);
  111062. /**
  111063. * Gets the current object class name.
  111064. * @return the class name
  111065. */
  111066. getClassName(): string;
  111067. /**
  111068. * Returns an array containing the root bones
  111069. * @returns an array containing the root bones
  111070. */
  111071. getChildren(): Array<Bone>;
  111072. /**
  111073. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  111074. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  111075. * @returns a Float32Array containing matrices data
  111076. */
  111077. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  111078. /**
  111079. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  111080. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  111081. * @returns a raw texture containing the data
  111082. */
  111083. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  111084. /**
  111085. * Gets the current hosting scene
  111086. * @returns a scene object
  111087. */
  111088. getScene(): Scene;
  111089. /**
  111090. * Gets a string representing the current skeleton data
  111091. * @param fullDetails defines a boolean indicating if we want a verbose version
  111092. * @returns a string representing the current skeleton data
  111093. */
  111094. toString(fullDetails?: boolean): string;
  111095. /**
  111096. * Get bone's index searching by name
  111097. * @param name defines bone's name to search for
  111098. * @return the indice of the bone. Returns -1 if not found
  111099. */
  111100. getBoneIndexByName(name: string): number;
  111101. /**
  111102. * Creater a new animation range
  111103. * @param name defines the name of the range
  111104. * @param from defines the start key
  111105. * @param to defines the end key
  111106. */
  111107. createAnimationRange(name: string, from: number, to: number): void;
  111108. /**
  111109. * Delete a specific animation range
  111110. * @param name defines the name of the range
  111111. * @param deleteFrames defines if frames must be removed as well
  111112. */
  111113. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  111114. /**
  111115. * Gets a specific animation range
  111116. * @param name defines the name of the range to look for
  111117. * @returns the requested animation range or null if not found
  111118. */
  111119. getAnimationRange(name: string): Nullable<AnimationRange>;
  111120. /**
  111121. * Gets the list of all animation ranges defined on this skeleton
  111122. * @returns an array
  111123. */
  111124. getAnimationRanges(): Nullable<AnimationRange>[];
  111125. /**
  111126. * Copy animation range from a source skeleton.
  111127. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  111128. * @param source defines the source skeleton
  111129. * @param name defines the name of the range to copy
  111130. * @param rescaleAsRequired defines if rescaling must be applied if required
  111131. * @returns true if operation was successful
  111132. */
  111133. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  111134. /**
  111135. * Forces the skeleton to go to rest pose
  111136. */
  111137. returnToRest(): void;
  111138. private _getHighestAnimationFrame;
  111139. /**
  111140. * Begin a specific animation range
  111141. * @param name defines the name of the range to start
  111142. * @param loop defines if looping must be turned on (false by default)
  111143. * @param speedRatio defines the speed ratio to apply (1 by default)
  111144. * @param onAnimationEnd defines a callback which will be called when animation will end
  111145. * @returns a new animatable
  111146. */
  111147. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  111148. /**
  111149. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  111150. * @param skeleton defines the Skeleton containing the animation range to convert
  111151. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111152. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  111153. * @returns the original skeleton
  111154. */
  111155. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  111156. /** @hidden */
  111157. _markAsDirty(): void;
  111158. /** @hidden */
  111159. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  111160. /** @hidden */
  111161. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  111162. private _computeTransformMatrices;
  111163. /**
  111164. * Build all resources required to render a skeleton
  111165. */
  111166. prepare(): void;
  111167. /**
  111168. * Gets the list of animatables currently running for this skeleton
  111169. * @returns an array of animatables
  111170. */
  111171. getAnimatables(): IAnimatable[];
  111172. /**
  111173. * Clone the current skeleton
  111174. * @param name defines the name of the new skeleton
  111175. * @param id defines the id of the new skeleton
  111176. * @returns the new skeleton
  111177. */
  111178. clone(name: string, id?: string): Skeleton;
  111179. /**
  111180. * Enable animation blending for this skeleton
  111181. * @param blendingSpeed defines the blending speed to apply
  111182. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  111183. */
  111184. enableBlending(blendingSpeed?: number): void;
  111185. /**
  111186. * Releases all resources associated with the current skeleton
  111187. */
  111188. dispose(): void;
  111189. /**
  111190. * Serialize the skeleton in a JSON object
  111191. * @returns a JSON object
  111192. */
  111193. serialize(): any;
  111194. /**
  111195. * Creates a new skeleton from serialized data
  111196. * @param parsedSkeleton defines the serialized data
  111197. * @param scene defines the hosting scene
  111198. * @returns a new skeleton
  111199. */
  111200. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  111201. /**
  111202. * Compute all node absolute transforms
  111203. * @param forceUpdate defines if computation must be done even if cache is up to date
  111204. */
  111205. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  111206. /**
  111207. * Gets the root pose matrix
  111208. * @returns a matrix
  111209. */
  111210. getPoseMatrix(): Nullable<Matrix>;
  111211. /**
  111212. * Sorts bones per internal index
  111213. */
  111214. sortBones(): void;
  111215. private _sortBones;
  111216. /**
  111217. * Set the current local matrix as the restPose for all bones in the skeleton.
  111218. */
  111219. setCurrentPoseAsRest(): void;
  111220. }
  111221. }
  111222. declare module BABYLON {
  111223. /**
  111224. * Class used to store bone information
  111225. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111226. */
  111227. export class Bone extends Node {
  111228. /**
  111229. * defines the bone name
  111230. */
  111231. name: string;
  111232. private static _tmpVecs;
  111233. private static _tmpQuat;
  111234. private static _tmpMats;
  111235. /**
  111236. * Gets the list of child bones
  111237. */
  111238. children: Bone[];
  111239. /** Gets the animations associated with this bone */
  111240. animations: Animation[];
  111241. /**
  111242. * Gets or sets bone length
  111243. */
  111244. length: number;
  111245. /**
  111246. * @hidden Internal only
  111247. * Set this value to map this bone to a different index in the transform matrices
  111248. * Set this value to -1 to exclude the bone from the transform matrices
  111249. */
  111250. _index: Nullable<number>;
  111251. private _skeleton;
  111252. private _localMatrix;
  111253. private _restPose;
  111254. private _bindPose;
  111255. private _baseMatrix;
  111256. private _absoluteTransform;
  111257. private _invertedAbsoluteTransform;
  111258. private _parent;
  111259. private _scalingDeterminant;
  111260. private _worldTransform;
  111261. private _localScaling;
  111262. private _localRotation;
  111263. private _localPosition;
  111264. private _needToDecompose;
  111265. private _needToCompose;
  111266. /** @hidden */
  111267. _linkedTransformNode: Nullable<TransformNode>;
  111268. /** @hidden */
  111269. _waitingTransformNodeId: Nullable<string>;
  111270. /** @hidden */
  111271. get _matrix(): Matrix;
  111272. /** @hidden */
  111273. set _matrix(value: Matrix);
  111274. /**
  111275. * Create a new bone
  111276. * @param name defines the bone name
  111277. * @param skeleton defines the parent skeleton
  111278. * @param parentBone defines the parent (can be null if the bone is the root)
  111279. * @param localMatrix defines the local matrix
  111280. * @param restPose defines the rest pose matrix
  111281. * @param baseMatrix defines the base matrix
  111282. * @param index defines index of the bone in the hiearchy
  111283. */
  111284. constructor(
  111285. /**
  111286. * defines the bone name
  111287. */
  111288. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  111289. /**
  111290. * Gets the current object class name.
  111291. * @return the class name
  111292. */
  111293. getClassName(): string;
  111294. /**
  111295. * Gets the parent skeleton
  111296. * @returns a skeleton
  111297. */
  111298. getSkeleton(): Skeleton;
  111299. /**
  111300. * Gets parent bone
  111301. * @returns a bone or null if the bone is the root of the bone hierarchy
  111302. */
  111303. getParent(): Nullable<Bone>;
  111304. /**
  111305. * Returns an array containing the root bones
  111306. * @returns an array containing the root bones
  111307. */
  111308. getChildren(): Array<Bone>;
  111309. /**
  111310. * Gets the node index in matrix array generated for rendering
  111311. * @returns the node index
  111312. */
  111313. getIndex(): number;
  111314. /**
  111315. * Sets the parent bone
  111316. * @param parent defines the parent (can be null if the bone is the root)
  111317. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  111318. */
  111319. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  111320. /**
  111321. * Gets the local matrix
  111322. * @returns a matrix
  111323. */
  111324. getLocalMatrix(): Matrix;
  111325. /**
  111326. * Gets the base matrix (initial matrix which remains unchanged)
  111327. * @returns a matrix
  111328. */
  111329. getBaseMatrix(): Matrix;
  111330. /**
  111331. * Gets the rest pose matrix
  111332. * @returns a matrix
  111333. */
  111334. getRestPose(): Matrix;
  111335. /**
  111336. * Sets the rest pose matrix
  111337. * @param matrix the local-space rest pose to set for this bone
  111338. */
  111339. setRestPose(matrix: Matrix): void;
  111340. /**
  111341. * Gets the bind pose matrix
  111342. * @returns the bind pose matrix
  111343. */
  111344. getBindPose(): Matrix;
  111345. /**
  111346. * Sets the bind pose matrix
  111347. * @param matrix the local-space bind pose to set for this bone
  111348. */
  111349. setBindPose(matrix: Matrix): void;
  111350. /**
  111351. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  111352. */
  111353. getWorldMatrix(): Matrix;
  111354. /**
  111355. * Sets the local matrix to rest pose matrix
  111356. */
  111357. returnToRest(): void;
  111358. /**
  111359. * Gets the inverse of the absolute transform matrix.
  111360. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  111361. * @returns a matrix
  111362. */
  111363. getInvertedAbsoluteTransform(): Matrix;
  111364. /**
  111365. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  111366. * @returns a matrix
  111367. */
  111368. getAbsoluteTransform(): Matrix;
  111369. /**
  111370. * Links with the given transform node.
  111371. * The local matrix of this bone is copied from the transform node every frame.
  111372. * @param transformNode defines the transform node to link to
  111373. */
  111374. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  111375. /**
  111376. * Gets the node used to drive the bone's transformation
  111377. * @returns a transform node or null
  111378. */
  111379. getTransformNode(): Nullable<TransformNode>;
  111380. /** Gets or sets current position (in local space) */
  111381. get position(): Vector3;
  111382. set position(newPosition: Vector3);
  111383. /** Gets or sets current rotation (in local space) */
  111384. get rotation(): Vector3;
  111385. set rotation(newRotation: Vector3);
  111386. /** Gets or sets current rotation quaternion (in local space) */
  111387. get rotationQuaternion(): Quaternion;
  111388. set rotationQuaternion(newRotation: Quaternion);
  111389. /** Gets or sets current scaling (in local space) */
  111390. get scaling(): Vector3;
  111391. set scaling(newScaling: Vector3);
  111392. /**
  111393. * Gets the animation properties override
  111394. */
  111395. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111396. private _decompose;
  111397. private _compose;
  111398. /**
  111399. * Update the base and local matrices
  111400. * @param matrix defines the new base or local matrix
  111401. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  111402. * @param updateLocalMatrix defines if the local matrix should be updated
  111403. */
  111404. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  111405. /** @hidden */
  111406. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  111407. /**
  111408. * Flag the bone as dirty (Forcing it to update everything)
  111409. */
  111410. markAsDirty(): void;
  111411. /** @hidden */
  111412. _markAsDirtyAndCompose(): void;
  111413. private _markAsDirtyAndDecompose;
  111414. /**
  111415. * Translate the bone in local or world space
  111416. * @param vec The amount to translate the bone
  111417. * @param space The space that the translation is in
  111418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111419. */
  111420. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  111421. /**
  111422. * Set the postion of the bone in local or world space
  111423. * @param position The position to set the bone
  111424. * @param space The space that the position is in
  111425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111426. */
  111427. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  111428. /**
  111429. * Set the absolute position of the bone (world space)
  111430. * @param position The position to set the bone
  111431. * @param mesh The mesh that this bone is attached to
  111432. */
  111433. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  111434. /**
  111435. * Scale the bone on the x, y and z axes (in local space)
  111436. * @param x The amount to scale the bone on the x axis
  111437. * @param y The amount to scale the bone on the y axis
  111438. * @param z The amount to scale the bone on the z axis
  111439. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  111440. */
  111441. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  111442. /**
  111443. * Set the bone scaling in local space
  111444. * @param scale defines the scaling vector
  111445. */
  111446. setScale(scale: Vector3): void;
  111447. /**
  111448. * Gets the current scaling in local space
  111449. * @returns the current scaling vector
  111450. */
  111451. getScale(): Vector3;
  111452. /**
  111453. * Gets the current scaling in local space and stores it in a target vector
  111454. * @param result defines the target vector
  111455. */
  111456. getScaleToRef(result: Vector3): void;
  111457. /**
  111458. * Set the yaw, pitch, and roll of the bone in local or world space
  111459. * @param yaw The rotation of the bone on the y axis
  111460. * @param pitch The rotation of the bone on the x axis
  111461. * @param roll The rotation of the bone on the z axis
  111462. * @param space The space that the axes of rotation are in
  111463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111464. */
  111465. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  111466. /**
  111467. * Add a rotation to the bone on an axis in local or world space
  111468. * @param axis The axis to rotate the bone on
  111469. * @param amount The amount to rotate the bone
  111470. * @param space The space that the axis is in
  111471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111472. */
  111473. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  111474. /**
  111475. * Set the rotation of the bone to a particular axis angle in local or world space
  111476. * @param axis The axis to rotate the bone on
  111477. * @param angle The angle that the bone should be rotated to
  111478. * @param space The space that the axis is in
  111479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111480. */
  111481. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  111482. /**
  111483. * Set the euler rotation of the bone in local or world space
  111484. * @param rotation The euler rotation that the bone should be set to
  111485. * @param space The space that the rotation is in
  111486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111487. */
  111488. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  111489. /**
  111490. * Set the quaternion rotation of the bone in local or world space
  111491. * @param quat The quaternion rotation that the bone should be set to
  111492. * @param space The space that the rotation is in
  111493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111494. */
  111495. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  111496. /**
  111497. * Set the rotation matrix of the bone in local or world space
  111498. * @param rotMat The rotation matrix that the bone should be set to
  111499. * @param space The space that the rotation is in
  111500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111501. */
  111502. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  111503. private _rotateWithMatrix;
  111504. private _getNegativeRotationToRef;
  111505. /**
  111506. * Get the position of the bone in local or world space
  111507. * @param space The space that the returned position is in
  111508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111509. * @returns The position of the bone
  111510. */
  111511. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  111512. /**
  111513. * Copy the position of the bone to a vector3 in local or world space
  111514. * @param space The space that the returned position is in
  111515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111516. * @param result The vector3 to copy the position to
  111517. */
  111518. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  111519. /**
  111520. * Get the absolute position of the bone (world space)
  111521. * @param mesh The mesh that this bone is attached to
  111522. * @returns The absolute position of the bone
  111523. */
  111524. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  111525. /**
  111526. * Copy the absolute position of the bone (world space) to the result param
  111527. * @param mesh The mesh that this bone is attached to
  111528. * @param result The vector3 to copy the absolute position to
  111529. */
  111530. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  111531. /**
  111532. * Compute the absolute transforms of this bone and its children
  111533. */
  111534. computeAbsoluteTransforms(): void;
  111535. /**
  111536. * Get the world direction from an axis that is in the local space of the bone
  111537. * @param localAxis The local direction that is used to compute the world direction
  111538. * @param mesh The mesh that this bone is attached to
  111539. * @returns The world direction
  111540. */
  111541. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  111542. /**
  111543. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  111544. * @param localAxis The local direction that is used to compute the world direction
  111545. * @param mesh The mesh that this bone is attached to
  111546. * @param result The vector3 that the world direction will be copied to
  111547. */
  111548. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111549. /**
  111550. * Get the euler rotation of the bone in local or world space
  111551. * @param space The space that the rotation should be in
  111552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111553. * @returns The euler rotation
  111554. */
  111555. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  111556. /**
  111557. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  111558. * @param space The space that the rotation should be in
  111559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111560. * @param result The vector3 that the rotation should be copied to
  111561. */
  111562. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111563. /**
  111564. * Get the quaternion rotation of the bone in either local or world space
  111565. * @param space The space that the rotation should be in
  111566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111567. * @returns The quaternion rotation
  111568. */
  111569. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  111570. /**
  111571. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  111572. * @param space The space that the rotation should be in
  111573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111574. * @param result The quaternion that the rotation should be copied to
  111575. */
  111576. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  111577. /**
  111578. * Get the rotation matrix of the bone in local or world space
  111579. * @param space The space that the rotation should be in
  111580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111581. * @returns The rotation matrix
  111582. */
  111583. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  111584. /**
  111585. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  111586. * @param space The space that the rotation should be in
  111587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  111588. * @param result The quaternion that the rotation should be copied to
  111589. */
  111590. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  111591. /**
  111592. * Get the world position of a point that is in the local space of the bone
  111593. * @param position The local position
  111594. * @param mesh The mesh that this bone is attached to
  111595. * @returns The world position
  111596. */
  111597. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  111598. /**
  111599. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  111600. * @param position The local position
  111601. * @param mesh The mesh that this bone is attached to
  111602. * @param result The vector3 that the world position should be copied to
  111603. */
  111604. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111605. /**
  111606. * Get the local position of a point that is in world space
  111607. * @param position The world position
  111608. * @param mesh The mesh that this bone is attached to
  111609. * @returns The local position
  111610. */
  111611. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  111612. /**
  111613. * Get the local position of a point that is in world space and copy it to the result param
  111614. * @param position The world position
  111615. * @param mesh The mesh that this bone is attached to
  111616. * @param result The vector3 that the local position should be copied to
  111617. */
  111618. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111619. /**
  111620. * Set the current local matrix as the restPose for this bone.
  111621. */
  111622. setCurrentPoseAsRest(): void;
  111623. }
  111624. }
  111625. declare module BABYLON {
  111626. /**
  111627. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  111628. * @see https://doc.babylonjs.com/how_to/transformnode
  111629. */
  111630. export class TransformNode extends Node {
  111631. /**
  111632. * Object will not rotate to face the camera
  111633. */
  111634. static BILLBOARDMODE_NONE: number;
  111635. /**
  111636. * Object will rotate to face the camera but only on the x axis
  111637. */
  111638. static BILLBOARDMODE_X: number;
  111639. /**
  111640. * Object will rotate to face the camera but only on the y axis
  111641. */
  111642. static BILLBOARDMODE_Y: number;
  111643. /**
  111644. * Object will rotate to face the camera but only on the z axis
  111645. */
  111646. static BILLBOARDMODE_Z: number;
  111647. /**
  111648. * Object will rotate to face the camera
  111649. */
  111650. static BILLBOARDMODE_ALL: number;
  111651. /**
  111652. * Object will rotate to face the camera's position instead of orientation
  111653. */
  111654. static BILLBOARDMODE_USE_POSITION: number;
  111655. private static _TmpRotation;
  111656. private static _TmpScaling;
  111657. private static _TmpTranslation;
  111658. private _forward;
  111659. private _forwardInverted;
  111660. private _up;
  111661. private _right;
  111662. private _rightInverted;
  111663. private _position;
  111664. private _rotation;
  111665. private _rotationQuaternion;
  111666. protected _scaling: Vector3;
  111667. protected _isDirty: boolean;
  111668. private _transformToBoneReferal;
  111669. private _isAbsoluteSynced;
  111670. private _billboardMode;
  111671. /**
  111672. * Gets or sets the billboard mode. Default is 0.
  111673. *
  111674. * | Value | Type | Description |
  111675. * | --- | --- | --- |
  111676. * | 0 | BILLBOARDMODE_NONE | |
  111677. * | 1 | BILLBOARDMODE_X | |
  111678. * | 2 | BILLBOARDMODE_Y | |
  111679. * | 4 | BILLBOARDMODE_Z | |
  111680. * | 7 | BILLBOARDMODE_ALL | |
  111681. *
  111682. */
  111683. get billboardMode(): number;
  111684. set billboardMode(value: number);
  111685. private _preserveParentRotationForBillboard;
  111686. /**
  111687. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  111688. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  111689. */
  111690. get preserveParentRotationForBillboard(): boolean;
  111691. set preserveParentRotationForBillboard(value: boolean);
  111692. /**
  111693. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  111694. */
  111695. scalingDeterminant: number;
  111696. private _infiniteDistance;
  111697. /**
  111698. * Gets or sets the distance of the object to max, often used by skybox
  111699. */
  111700. get infiniteDistance(): boolean;
  111701. set infiniteDistance(value: boolean);
  111702. /**
  111703. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  111704. * By default the system will update normals to compensate
  111705. */
  111706. ignoreNonUniformScaling: boolean;
  111707. /**
  111708. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  111709. */
  111710. reIntegrateRotationIntoRotationQuaternion: boolean;
  111711. /** @hidden */
  111712. _poseMatrix: Nullable<Matrix>;
  111713. /** @hidden */
  111714. _localMatrix: Matrix;
  111715. private _usePivotMatrix;
  111716. private _absolutePosition;
  111717. private _absoluteScaling;
  111718. private _absoluteRotationQuaternion;
  111719. private _pivotMatrix;
  111720. private _pivotMatrixInverse;
  111721. /** @hidden */
  111722. _postMultiplyPivotMatrix: boolean;
  111723. protected _isWorldMatrixFrozen: boolean;
  111724. /** @hidden */
  111725. _indexInSceneTransformNodesArray: number;
  111726. /**
  111727. * An event triggered after the world matrix is updated
  111728. */
  111729. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  111730. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  111731. /**
  111732. * Gets a string identifying the name of the class
  111733. * @returns "TransformNode" string
  111734. */
  111735. getClassName(): string;
  111736. /**
  111737. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  111738. */
  111739. get position(): Vector3;
  111740. set position(newPosition: Vector3);
  111741. /**
  111742. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  111743. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  111744. */
  111745. get rotation(): Vector3;
  111746. set rotation(newRotation: Vector3);
  111747. /**
  111748. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  111749. */
  111750. get scaling(): Vector3;
  111751. set scaling(newScaling: Vector3);
  111752. /**
  111753. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  111754. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  111755. */
  111756. get rotationQuaternion(): Nullable<Quaternion>;
  111757. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  111758. /**
  111759. * The forward direction of that transform in world space.
  111760. */
  111761. get forward(): Vector3;
  111762. /**
  111763. * The up direction of that transform in world space.
  111764. */
  111765. get up(): Vector3;
  111766. /**
  111767. * The right direction of that transform in world space.
  111768. */
  111769. get right(): Vector3;
  111770. /**
  111771. * Copies the parameter passed Matrix into the mesh Pose matrix.
  111772. * @param matrix the matrix to copy the pose from
  111773. * @returns this TransformNode.
  111774. */
  111775. updatePoseMatrix(matrix: Matrix): TransformNode;
  111776. /**
  111777. * Returns the mesh Pose matrix.
  111778. * @returns the pose matrix
  111779. */
  111780. getPoseMatrix(): Matrix;
  111781. /** @hidden */
  111782. _isSynchronized(): boolean;
  111783. /** @hidden */
  111784. _initCache(): void;
  111785. /**
  111786. * Flag the transform node as dirty (Forcing it to update everything)
  111787. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  111788. * @returns this transform node
  111789. */
  111790. markAsDirty(property: string): TransformNode;
  111791. /**
  111792. * Returns the current mesh absolute position.
  111793. * Returns a Vector3.
  111794. */
  111795. get absolutePosition(): Vector3;
  111796. /**
  111797. * Returns the current mesh absolute scaling.
  111798. * Returns a Vector3.
  111799. */
  111800. get absoluteScaling(): Vector3;
  111801. /**
  111802. * Returns the current mesh absolute rotation.
  111803. * Returns a Quaternion.
  111804. */
  111805. get absoluteRotationQuaternion(): Quaternion;
  111806. /**
  111807. * Sets a new matrix to apply before all other transformation
  111808. * @param matrix defines the transform matrix
  111809. * @returns the current TransformNode
  111810. */
  111811. setPreTransformMatrix(matrix: Matrix): TransformNode;
  111812. /**
  111813. * Sets a new pivot matrix to the current node
  111814. * @param matrix defines the new pivot matrix to use
  111815. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  111816. * @returns the current TransformNode
  111817. */
  111818. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  111819. /**
  111820. * Returns the mesh pivot matrix.
  111821. * Default : Identity.
  111822. * @returns the matrix
  111823. */
  111824. getPivotMatrix(): Matrix;
  111825. /**
  111826. * Instantiate (when possible) or clone that node with its hierarchy
  111827. * @param newParent defines the new parent to use for the instance (or clone)
  111828. * @param options defines options to configure how copy is done
  111829. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  111830. * @returns an instance (or a clone) of the current node with its hiearchy
  111831. */
  111832. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  111833. doNotInstantiate: boolean;
  111834. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  111835. /**
  111836. * Prevents the World matrix to be computed any longer
  111837. * @param newWorldMatrix defines an optional matrix to use as world matrix
  111838. * @returns the TransformNode.
  111839. */
  111840. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  111841. /**
  111842. * Allows back the World matrix computation.
  111843. * @returns the TransformNode.
  111844. */
  111845. unfreezeWorldMatrix(): this;
  111846. /**
  111847. * True if the World matrix has been frozen.
  111848. */
  111849. get isWorldMatrixFrozen(): boolean;
  111850. /**
  111851. * Retuns the mesh absolute position in the World.
  111852. * @returns a Vector3.
  111853. */
  111854. getAbsolutePosition(): Vector3;
  111855. /**
  111856. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  111857. * @param absolutePosition the absolute position to set
  111858. * @returns the TransformNode.
  111859. */
  111860. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  111861. /**
  111862. * Sets the mesh position in its local space.
  111863. * @param vector3 the position to set in localspace
  111864. * @returns the TransformNode.
  111865. */
  111866. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  111867. /**
  111868. * Returns the mesh position in the local space from the current World matrix values.
  111869. * @returns a new Vector3.
  111870. */
  111871. getPositionExpressedInLocalSpace(): Vector3;
  111872. /**
  111873. * Translates the mesh along the passed Vector3 in its local space.
  111874. * @param vector3 the distance to translate in localspace
  111875. * @returns the TransformNode.
  111876. */
  111877. locallyTranslate(vector3: Vector3): TransformNode;
  111878. private static _lookAtVectorCache;
  111879. /**
  111880. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  111881. * @param targetPoint the position (must be in same space as current mesh) to look at
  111882. * @param yawCor optional yaw (y-axis) correction in radians
  111883. * @param pitchCor optional pitch (x-axis) correction in radians
  111884. * @param rollCor optional roll (z-axis) correction in radians
  111885. * @param space the choosen space of the target
  111886. * @returns the TransformNode.
  111887. */
  111888. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  111889. /**
  111890. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111891. * This Vector3 is expressed in the World space.
  111892. * @param localAxis axis to rotate
  111893. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111894. */
  111895. getDirection(localAxis: Vector3): Vector3;
  111896. /**
  111897. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  111898. * localAxis is expressed in the mesh local space.
  111899. * result is computed in the Wordl space from the mesh World matrix.
  111900. * @param localAxis axis to rotate
  111901. * @param result the resulting transformnode
  111902. * @returns this TransformNode.
  111903. */
  111904. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  111905. /**
  111906. * Sets this transform node rotation to the given local axis.
  111907. * @param localAxis the axis in local space
  111908. * @param yawCor optional yaw (y-axis) correction in radians
  111909. * @param pitchCor optional pitch (x-axis) correction in radians
  111910. * @param rollCor optional roll (z-axis) correction in radians
  111911. * @returns this TransformNode
  111912. */
  111913. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  111914. /**
  111915. * Sets a new pivot point to the current node
  111916. * @param point defines the new pivot point to use
  111917. * @param space defines if the point is in world or local space (local by default)
  111918. * @returns the current TransformNode
  111919. */
  111920. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  111921. /**
  111922. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  111923. * @returns the pivot point
  111924. */
  111925. getPivotPoint(): Vector3;
  111926. /**
  111927. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  111928. * @param result the vector3 to store the result
  111929. * @returns this TransformNode.
  111930. */
  111931. getPivotPointToRef(result: Vector3): TransformNode;
  111932. /**
  111933. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  111934. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  111935. */
  111936. getAbsolutePivotPoint(): Vector3;
  111937. /**
  111938. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  111939. * @param result vector3 to store the result
  111940. * @returns this TransformNode.
  111941. */
  111942. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  111943. /**
  111944. * Defines the passed node as the parent of the current node.
  111945. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  111946. * @see https://doc.babylonjs.com/how_to/parenting
  111947. * @param node the node ot set as the parent
  111948. * @returns this TransformNode.
  111949. */
  111950. setParent(node: Nullable<Node>): TransformNode;
  111951. private _nonUniformScaling;
  111952. /**
  111953. * True if the scaling property of this object is non uniform eg. (1,2,1)
  111954. */
  111955. get nonUniformScaling(): boolean;
  111956. /** @hidden */
  111957. _updateNonUniformScalingState(value: boolean): boolean;
  111958. /**
  111959. * Attach the current TransformNode to another TransformNode associated with a bone
  111960. * @param bone Bone affecting the TransformNode
  111961. * @param affectedTransformNode TransformNode associated with the bone
  111962. * @returns this object
  111963. */
  111964. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  111965. /**
  111966. * Detach the transform node if its associated with a bone
  111967. * @returns this object
  111968. */
  111969. detachFromBone(): TransformNode;
  111970. private static _rotationAxisCache;
  111971. /**
  111972. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  111973. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111974. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111975. * The passed axis is also normalized.
  111976. * @param axis the axis to rotate around
  111977. * @param amount the amount to rotate in radians
  111978. * @param space Space to rotate in (Default: local)
  111979. * @returns the TransformNode.
  111980. */
  111981. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  111982. /**
  111983. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  111984. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111985. * The passed axis is also normalized. .
  111986. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  111987. * @param point the point to rotate around
  111988. * @param axis the axis to rotate around
  111989. * @param amount the amount to rotate in radians
  111990. * @returns the TransformNode
  111991. */
  111992. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  111993. /**
  111994. * Translates the mesh along the axis vector for the passed distance in the given space.
  111995. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111996. * @param axis the axis to translate in
  111997. * @param distance the distance to translate
  111998. * @param space Space to rotate in (Default: local)
  111999. * @returns the TransformNode.
  112000. */
  112001. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112002. /**
  112003. * Adds a rotation step to the mesh current rotation.
  112004. * x, y, z are Euler angles expressed in radians.
  112005. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  112006. * This means this rotation is made in the mesh local space only.
  112007. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  112008. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  112009. * ```javascript
  112010. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  112011. * ```
  112012. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  112013. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  112014. * @param x Rotation to add
  112015. * @param y Rotation to add
  112016. * @param z Rotation to add
  112017. * @returns the TransformNode.
  112018. */
  112019. addRotation(x: number, y: number, z: number): TransformNode;
  112020. /**
  112021. * @hidden
  112022. */
  112023. protected _getEffectiveParent(): Nullable<Node>;
  112024. /**
  112025. * Computes the world matrix of the node
  112026. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112027. * @returns the world matrix
  112028. */
  112029. computeWorldMatrix(force?: boolean): Matrix;
  112030. /**
  112031. * Resets this nodeTransform's local matrix to Matrix.Identity().
  112032. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  112033. */
  112034. resetLocalMatrix(independentOfChildren?: boolean): void;
  112035. protected _afterComputeWorldMatrix(): void;
  112036. /**
  112037. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  112038. * @param func callback function to add
  112039. *
  112040. * @returns the TransformNode.
  112041. */
  112042. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  112043. /**
  112044. * Removes a registered callback function.
  112045. * @param func callback function to remove
  112046. * @returns the TransformNode.
  112047. */
  112048. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  112049. /**
  112050. * Gets the position of the current mesh in camera space
  112051. * @param camera defines the camera to use
  112052. * @returns a position
  112053. */
  112054. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  112055. /**
  112056. * Returns the distance from the mesh to the active camera
  112057. * @param camera defines the camera to use
  112058. * @returns the distance
  112059. */
  112060. getDistanceToCamera(camera?: Nullable<Camera>): number;
  112061. /**
  112062. * Clone the current transform node
  112063. * @param name Name of the new clone
  112064. * @param newParent New parent for the clone
  112065. * @param doNotCloneChildren Do not clone children hierarchy
  112066. * @returns the new transform node
  112067. */
  112068. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  112069. /**
  112070. * Serializes the objects information.
  112071. * @param currentSerializationObject defines the object to serialize in
  112072. * @returns the serialized object
  112073. */
  112074. serialize(currentSerializationObject?: any): any;
  112075. /**
  112076. * Returns a new TransformNode object parsed from the source provided.
  112077. * @param parsedTransformNode is the source.
  112078. * @param scene the scne the object belongs to
  112079. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  112080. * @returns a new TransformNode object parsed from the source provided.
  112081. */
  112082. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  112083. /**
  112084. * Get all child-transformNodes of this node
  112085. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  112086. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  112087. * @returns an array of TransformNode
  112088. */
  112089. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  112090. /**
  112091. * Releases resources associated with this transform node.
  112092. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112093. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112094. */
  112095. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112096. /**
  112097. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112098. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112099. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112100. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112101. * @returns the current mesh
  112102. */
  112103. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  112104. private _syncAbsoluteScalingAndRotation;
  112105. }
  112106. }
  112107. declare module BABYLON {
  112108. /**
  112109. * Defines the types of pose enabled controllers that are supported
  112110. */
  112111. export enum PoseEnabledControllerType {
  112112. /**
  112113. * HTC Vive
  112114. */
  112115. VIVE = 0,
  112116. /**
  112117. * Oculus Rift
  112118. */
  112119. OCULUS = 1,
  112120. /**
  112121. * Windows mixed reality
  112122. */
  112123. WINDOWS = 2,
  112124. /**
  112125. * Samsung gear VR
  112126. */
  112127. GEAR_VR = 3,
  112128. /**
  112129. * Google Daydream
  112130. */
  112131. DAYDREAM = 4,
  112132. /**
  112133. * Generic
  112134. */
  112135. GENERIC = 5
  112136. }
  112137. /**
  112138. * Defines the MutableGamepadButton interface for the state of a gamepad button
  112139. */
  112140. export interface MutableGamepadButton {
  112141. /**
  112142. * Value of the button/trigger
  112143. */
  112144. value: number;
  112145. /**
  112146. * If the button/trigger is currently touched
  112147. */
  112148. touched: boolean;
  112149. /**
  112150. * If the button/trigger is currently pressed
  112151. */
  112152. pressed: boolean;
  112153. }
  112154. /**
  112155. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  112156. * @hidden
  112157. */
  112158. export interface ExtendedGamepadButton extends GamepadButton {
  112159. /**
  112160. * If the button/trigger is currently pressed
  112161. */
  112162. readonly pressed: boolean;
  112163. /**
  112164. * If the button/trigger is currently touched
  112165. */
  112166. readonly touched: boolean;
  112167. /**
  112168. * Value of the button/trigger
  112169. */
  112170. readonly value: number;
  112171. }
  112172. /** @hidden */
  112173. export interface _GamePadFactory {
  112174. /**
  112175. * Returns whether or not the current gamepad can be created for this type of controller.
  112176. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  112177. * @returns true if it can be created, otherwise false
  112178. */
  112179. canCreate(gamepadInfo: any): boolean;
  112180. /**
  112181. * Creates a new instance of the Gamepad.
  112182. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  112183. * @returns the new gamepad instance
  112184. */
  112185. create(gamepadInfo: any): Gamepad;
  112186. }
  112187. /**
  112188. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  112189. */
  112190. export class PoseEnabledControllerHelper {
  112191. /** @hidden */
  112192. static _ControllerFactories: _GamePadFactory[];
  112193. /** @hidden */
  112194. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  112195. /**
  112196. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  112197. * @param vrGamepad the gamepad to initialized
  112198. * @returns a vr controller of the type the gamepad identified as
  112199. */
  112200. static InitiateController(vrGamepad: any): Gamepad;
  112201. }
  112202. /**
  112203. * Defines the PoseEnabledController object that contains state of a vr capable controller
  112204. */
  112205. export class PoseEnabledController extends Gamepad implements PoseControlled {
  112206. /**
  112207. * If the controller is used in a webXR session
  112208. */
  112209. isXR: boolean;
  112210. private _deviceRoomPosition;
  112211. private _deviceRoomRotationQuaternion;
  112212. /**
  112213. * The device position in babylon space
  112214. */
  112215. devicePosition: Vector3;
  112216. /**
  112217. * The device rotation in babylon space
  112218. */
  112219. deviceRotationQuaternion: Quaternion;
  112220. /**
  112221. * The scale factor of the device in babylon space
  112222. */
  112223. deviceScaleFactor: number;
  112224. /**
  112225. * (Likely devicePosition should be used instead) The device position in its room space
  112226. */
  112227. position: Vector3;
  112228. /**
  112229. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  112230. */
  112231. rotationQuaternion: Quaternion;
  112232. /**
  112233. * The type of controller (Eg. Windows mixed reality)
  112234. */
  112235. controllerType: PoseEnabledControllerType;
  112236. protected _calculatedPosition: Vector3;
  112237. private _calculatedRotation;
  112238. /**
  112239. * The raw pose from the device
  112240. */
  112241. rawPose: DevicePose;
  112242. private _trackPosition;
  112243. private _maxRotationDistFromHeadset;
  112244. private _draggedRoomRotation;
  112245. /**
  112246. * @hidden
  112247. */
  112248. _disableTrackPosition(fixedPosition: Vector3): void;
  112249. /**
  112250. * Internal, the mesh attached to the controller
  112251. * @hidden
  112252. */
  112253. _mesh: Nullable<AbstractMesh>;
  112254. private _poseControlledCamera;
  112255. private _leftHandSystemQuaternion;
  112256. /**
  112257. * Internal, matrix used to convert room space to babylon space
  112258. * @hidden
  112259. */
  112260. _deviceToWorld: Matrix;
  112261. /**
  112262. * Node to be used when casting a ray from the controller
  112263. * @hidden
  112264. */
  112265. _pointingPoseNode: Nullable<TransformNode>;
  112266. /**
  112267. * Name of the child mesh that can be used to cast a ray from the controller
  112268. */
  112269. static readonly POINTING_POSE: string;
  112270. /**
  112271. * Creates a new PoseEnabledController from a gamepad
  112272. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  112273. */
  112274. constructor(browserGamepad: any);
  112275. private _workingMatrix;
  112276. /**
  112277. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  112278. */
  112279. update(): void;
  112280. /**
  112281. * Updates only the pose device and mesh without doing any button event checking
  112282. */
  112283. protected _updatePoseAndMesh(): void;
  112284. /**
  112285. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  112286. * @param poseData raw pose fromthe device
  112287. */
  112288. updateFromDevice(poseData: DevicePose): void;
  112289. /**
  112290. * @hidden
  112291. */
  112292. _meshAttachedObservable: Observable<AbstractMesh>;
  112293. /**
  112294. * Attaches a mesh to the controller
  112295. * @param mesh the mesh to be attached
  112296. */
  112297. attachToMesh(mesh: AbstractMesh): void;
  112298. /**
  112299. * Attaches the controllers mesh to a camera
  112300. * @param camera the camera the mesh should be attached to
  112301. */
  112302. attachToPoseControlledCamera(camera: TargetCamera): void;
  112303. /**
  112304. * Disposes of the controller
  112305. */
  112306. dispose(): void;
  112307. /**
  112308. * The mesh that is attached to the controller
  112309. */
  112310. get mesh(): Nullable<AbstractMesh>;
  112311. /**
  112312. * Gets the ray of the controller in the direction the controller is pointing
  112313. * @param length the length the resulting ray should be
  112314. * @returns a ray in the direction the controller is pointing
  112315. */
  112316. getForwardRay(length?: number): Ray;
  112317. }
  112318. }
  112319. declare module BABYLON {
  112320. /**
  112321. * Defines the WebVRController object that represents controllers tracked in 3D space
  112322. */
  112323. export abstract class WebVRController extends PoseEnabledController {
  112324. /**
  112325. * Internal, the default controller model for the controller
  112326. */
  112327. protected _defaultModel: Nullable<AbstractMesh>;
  112328. /**
  112329. * Fired when the trigger state has changed
  112330. */
  112331. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  112332. /**
  112333. * Fired when the main button state has changed
  112334. */
  112335. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112336. /**
  112337. * Fired when the secondary button state has changed
  112338. */
  112339. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112340. /**
  112341. * Fired when the pad state has changed
  112342. */
  112343. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  112344. /**
  112345. * Fired when controllers stick values have changed
  112346. */
  112347. onPadValuesChangedObservable: Observable<StickValues>;
  112348. /**
  112349. * Array of button availible on the controller
  112350. */
  112351. protected _buttons: Array<MutableGamepadButton>;
  112352. private _onButtonStateChange;
  112353. /**
  112354. * Fired when a controller button's state has changed
  112355. * @param callback the callback containing the button that was modified
  112356. */
  112357. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  112358. /**
  112359. * X and Y axis corresponding to the controllers joystick
  112360. */
  112361. pad: StickValues;
  112362. /**
  112363. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  112364. */
  112365. hand: string;
  112366. /**
  112367. * The default controller model for the controller
  112368. */
  112369. get defaultModel(): Nullable<AbstractMesh>;
  112370. /**
  112371. * Creates a new WebVRController from a gamepad
  112372. * @param vrGamepad the gamepad that the WebVRController should be created from
  112373. */
  112374. constructor(vrGamepad: any);
  112375. /**
  112376. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  112377. */
  112378. update(): void;
  112379. /**
  112380. * Function to be called when a button is modified
  112381. */
  112382. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112383. /**
  112384. * Loads a mesh and attaches it to the controller
  112385. * @param scene the scene the mesh should be added to
  112386. * @param meshLoaded callback for when the mesh has been loaded
  112387. */
  112388. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112389. private _setButtonValue;
  112390. private _changes;
  112391. private _checkChanges;
  112392. /**
  112393. * Disposes of th webVRCOntroller
  112394. */
  112395. dispose(): void;
  112396. }
  112397. }
  112398. declare module BABYLON {
  112399. /**
  112400. * The HemisphericLight simulates the ambient environment light,
  112401. * so the passed direction is the light reflection direction, not the incoming direction.
  112402. */
  112403. export class HemisphericLight extends Light {
  112404. /**
  112405. * The groundColor is the light in the opposite direction to the one specified during creation.
  112406. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  112407. */
  112408. groundColor: Color3;
  112409. /**
  112410. * The light reflection direction, not the incoming direction.
  112411. */
  112412. direction: Vector3;
  112413. /**
  112414. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  112415. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  112416. * The HemisphericLight can't cast shadows.
  112417. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112418. * @param name The friendly name of the light
  112419. * @param direction The direction of the light reflection
  112420. * @param scene The scene the light belongs to
  112421. */
  112422. constructor(name: string, direction: Vector3, scene: Scene);
  112423. protected _buildUniformLayout(): void;
  112424. /**
  112425. * Returns the string "HemisphericLight".
  112426. * @return The class name
  112427. */
  112428. getClassName(): string;
  112429. /**
  112430. * Sets the HemisphericLight direction towards the passed target (Vector3).
  112431. * Returns the updated direction.
  112432. * @param target The target the direction should point to
  112433. * @return The computed direction
  112434. */
  112435. setDirectionToTarget(target: Vector3): Vector3;
  112436. /**
  112437. * Returns the shadow generator associated to the light.
  112438. * @returns Always null for hemispheric lights because it does not support shadows.
  112439. */
  112440. getShadowGenerator(): Nullable<IShadowGenerator>;
  112441. /**
  112442. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  112443. * @param effect The effect to update
  112444. * @param lightIndex The index of the light in the effect to update
  112445. * @returns The hemispheric light
  112446. */
  112447. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  112448. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112449. /**
  112450. * Computes the world matrix of the node
  112451. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112452. * @param useWasUpdatedFlag defines a reserved property
  112453. * @returns the world matrix
  112454. */
  112455. computeWorldMatrix(): Matrix;
  112456. /**
  112457. * Returns the integer 3.
  112458. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112459. */
  112460. getTypeID(): number;
  112461. /**
  112462. * Prepares the list of defines specific to the light type.
  112463. * @param defines the list of defines
  112464. * @param lightIndex defines the index of the light for the effect
  112465. */
  112466. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112467. }
  112468. }
  112469. declare module BABYLON {
  112470. /** @hidden */
  112471. export var vrMultiviewToSingleviewPixelShader: {
  112472. name: string;
  112473. shader: string;
  112474. };
  112475. }
  112476. declare module BABYLON {
  112477. /**
  112478. * Renders to multiple views with a single draw call
  112479. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  112480. */
  112481. export class MultiviewRenderTarget extends RenderTargetTexture {
  112482. /**
  112483. * Creates a multiview render target
  112484. * @param scene scene used with the render target
  112485. * @param size the size of the render target (used for each view)
  112486. */
  112487. constructor(scene: Scene, size?: number | {
  112488. width: number;
  112489. height: number;
  112490. } | {
  112491. ratio: number;
  112492. });
  112493. /**
  112494. * @hidden
  112495. * @param faceIndex the face index, if its a cube texture
  112496. */
  112497. _bindFrameBuffer(faceIndex?: number): void;
  112498. /**
  112499. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  112500. * @returns the view count
  112501. */
  112502. getViewCount(): number;
  112503. }
  112504. }
  112505. declare module BABYLON {
  112506. interface Engine {
  112507. /**
  112508. * Creates a new multiview render target
  112509. * @param width defines the width of the texture
  112510. * @param height defines the height of the texture
  112511. * @returns the created multiview texture
  112512. */
  112513. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  112514. /**
  112515. * Binds a multiview framebuffer to be drawn to
  112516. * @param multiviewTexture texture to bind
  112517. */
  112518. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  112519. }
  112520. interface Camera {
  112521. /**
  112522. * @hidden
  112523. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  112524. */
  112525. _useMultiviewToSingleView: boolean;
  112526. /**
  112527. * @hidden
  112528. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  112529. */
  112530. _multiviewTexture: Nullable<RenderTargetTexture>;
  112531. /**
  112532. * @hidden
  112533. * ensures the multiview texture of the camera exists and has the specified width/height
  112534. * @param width height to set on the multiview texture
  112535. * @param height width to set on the multiview texture
  112536. */
  112537. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  112538. }
  112539. interface Scene {
  112540. /** @hidden */
  112541. _transformMatrixR: Matrix;
  112542. /** @hidden */
  112543. _multiviewSceneUbo: Nullable<UniformBuffer>;
  112544. /** @hidden */
  112545. _createMultiviewUbo(): void;
  112546. /** @hidden */
  112547. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  112548. /** @hidden */
  112549. _renderMultiviewToSingleView(camera: Camera): void;
  112550. }
  112551. }
  112552. declare module BABYLON {
  112553. /**
  112554. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  112555. * This will not be used for webXR as it supports displaying texture arrays directly
  112556. */
  112557. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  112558. /**
  112559. * Gets a string identifying the name of the class
  112560. * @returns "VRMultiviewToSingleviewPostProcess" string
  112561. */
  112562. getClassName(): string;
  112563. /**
  112564. * Initializes a VRMultiviewToSingleview
  112565. * @param name name of the post process
  112566. * @param camera camera to be applied to
  112567. * @param scaleFactor scaling factor to the size of the output texture
  112568. */
  112569. constructor(name: string, camera: Camera, scaleFactor: number);
  112570. }
  112571. }
  112572. declare module BABYLON {
  112573. /**
  112574. * Interface used to define additional presentation attributes
  112575. */
  112576. export interface IVRPresentationAttributes {
  112577. /**
  112578. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  112579. */
  112580. highRefreshRate: boolean;
  112581. /**
  112582. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  112583. */
  112584. foveationLevel: number;
  112585. }
  112586. interface Engine {
  112587. /** @hidden */
  112588. _vrDisplay: any;
  112589. /** @hidden */
  112590. _vrSupported: boolean;
  112591. /** @hidden */
  112592. _oldSize: Size;
  112593. /** @hidden */
  112594. _oldHardwareScaleFactor: number;
  112595. /** @hidden */
  112596. _vrExclusivePointerMode: boolean;
  112597. /** @hidden */
  112598. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  112599. /** @hidden */
  112600. _onVRDisplayPointerRestricted: () => void;
  112601. /** @hidden */
  112602. _onVRDisplayPointerUnrestricted: () => void;
  112603. /** @hidden */
  112604. _onVrDisplayConnect: Nullable<(display: any) => void>;
  112605. /** @hidden */
  112606. _onVrDisplayDisconnect: Nullable<() => void>;
  112607. /** @hidden */
  112608. _onVrDisplayPresentChange: Nullable<() => void>;
  112609. /**
  112610. * Observable signaled when VR display mode changes
  112611. */
  112612. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  112613. /**
  112614. * Observable signaled when VR request present is complete
  112615. */
  112616. onVRRequestPresentComplete: Observable<boolean>;
  112617. /**
  112618. * Observable signaled when VR request present starts
  112619. */
  112620. onVRRequestPresentStart: Observable<Engine>;
  112621. /**
  112622. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  112623. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  112624. */
  112625. isInVRExclusivePointerMode: boolean;
  112626. /**
  112627. * Gets a boolean indicating if a webVR device was detected
  112628. * @returns true if a webVR device was detected
  112629. */
  112630. isVRDevicePresent(): boolean;
  112631. /**
  112632. * Gets the current webVR device
  112633. * @returns the current webVR device (or null)
  112634. */
  112635. getVRDevice(): any;
  112636. /**
  112637. * Initializes a webVR display and starts listening to display change events
  112638. * The onVRDisplayChangedObservable will be notified upon these changes
  112639. * @returns A promise containing a VRDisplay and if vr is supported
  112640. */
  112641. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  112642. /** @hidden */
  112643. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  112644. /**
  112645. * Gets or sets the presentation attributes used to configure VR rendering
  112646. */
  112647. vrPresentationAttributes?: IVRPresentationAttributes;
  112648. /**
  112649. * Call this function to switch to webVR mode
  112650. * Will do nothing if webVR is not supported or if there is no webVR device
  112651. * @param options the webvr options provided to the camera. mainly used for multiview
  112652. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112653. */
  112654. enableVR(options: WebVROptions): void;
  112655. /** @hidden */
  112656. _onVRFullScreenTriggered(): void;
  112657. }
  112658. }
  112659. declare module BABYLON {
  112660. /**
  112661. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  112662. * IMPORTANT!! The data is right-hand data.
  112663. * @export
  112664. * @interface DevicePose
  112665. */
  112666. export interface DevicePose {
  112667. /**
  112668. * The position of the device, values in array are [x,y,z].
  112669. */
  112670. readonly position: Nullable<Float32Array>;
  112671. /**
  112672. * The linearVelocity of the device, values in array are [x,y,z].
  112673. */
  112674. readonly linearVelocity: Nullable<Float32Array>;
  112675. /**
  112676. * The linearAcceleration of the device, values in array are [x,y,z].
  112677. */
  112678. readonly linearAcceleration: Nullable<Float32Array>;
  112679. /**
  112680. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  112681. */
  112682. readonly orientation: Nullable<Float32Array>;
  112683. /**
  112684. * The angularVelocity of the device, values in array are [x,y,z].
  112685. */
  112686. readonly angularVelocity: Nullable<Float32Array>;
  112687. /**
  112688. * The angularAcceleration of the device, values in array are [x,y,z].
  112689. */
  112690. readonly angularAcceleration: Nullable<Float32Array>;
  112691. }
  112692. /**
  112693. * Interface representing a pose controlled object in Babylon.
  112694. * A pose controlled object has both regular pose values as well as pose values
  112695. * from an external device such as a VR head mounted display
  112696. */
  112697. export interface PoseControlled {
  112698. /**
  112699. * The position of the object in babylon space.
  112700. */
  112701. position: Vector3;
  112702. /**
  112703. * The rotation quaternion of the object in babylon space.
  112704. */
  112705. rotationQuaternion: Quaternion;
  112706. /**
  112707. * The position of the device in babylon space.
  112708. */
  112709. devicePosition?: Vector3;
  112710. /**
  112711. * The rotation quaternion of the device in babylon space.
  112712. */
  112713. deviceRotationQuaternion: Quaternion;
  112714. /**
  112715. * The raw pose coming from the device.
  112716. */
  112717. rawPose: Nullable<DevicePose>;
  112718. /**
  112719. * The scale of the device to be used when translating from device space to babylon space.
  112720. */
  112721. deviceScaleFactor: number;
  112722. /**
  112723. * Updates the poseControlled values based on the input device pose.
  112724. * @param poseData the pose data to update the object with
  112725. */
  112726. updateFromDevice(poseData: DevicePose): void;
  112727. }
  112728. /**
  112729. * Set of options to customize the webVRCamera
  112730. */
  112731. export interface WebVROptions {
  112732. /**
  112733. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  112734. */
  112735. trackPosition?: boolean;
  112736. /**
  112737. * Sets the scale of the vrDevice in babylon space. (default: 1)
  112738. */
  112739. positionScale?: number;
  112740. /**
  112741. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  112742. */
  112743. displayName?: string;
  112744. /**
  112745. * Should the native controller meshes be initialized. (default: true)
  112746. */
  112747. controllerMeshes?: boolean;
  112748. /**
  112749. * Creating a default HemiLight only on controllers. (default: true)
  112750. */
  112751. defaultLightingOnControllers?: boolean;
  112752. /**
  112753. * If you don't want to use the default VR button of the helper. (default: false)
  112754. */
  112755. useCustomVRButton?: boolean;
  112756. /**
  112757. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  112758. */
  112759. customVRButton?: HTMLButtonElement;
  112760. /**
  112761. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  112762. */
  112763. rayLength?: number;
  112764. /**
  112765. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  112766. */
  112767. defaultHeight?: number;
  112768. /**
  112769. * If multiview should be used if availible (default: false)
  112770. */
  112771. useMultiview?: boolean;
  112772. }
  112773. /**
  112774. * This represents a WebVR camera.
  112775. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  112776. * @example https://doc.babylonjs.com/how_to/webvr_camera
  112777. */
  112778. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  112779. private webVROptions;
  112780. /**
  112781. * @hidden
  112782. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  112783. */
  112784. _vrDevice: any;
  112785. /**
  112786. * The rawPose of the vrDevice.
  112787. */
  112788. rawPose: Nullable<DevicePose>;
  112789. private _onVREnabled;
  112790. private _specsVersion;
  112791. private _attached;
  112792. private _frameData;
  112793. protected _descendants: Array<Node>;
  112794. private _deviceRoomPosition;
  112795. /** @hidden */
  112796. _deviceRoomRotationQuaternion: Quaternion;
  112797. private _standingMatrix;
  112798. /**
  112799. * Represents device position in babylon space.
  112800. */
  112801. devicePosition: Vector3;
  112802. /**
  112803. * Represents device rotation in babylon space.
  112804. */
  112805. deviceRotationQuaternion: Quaternion;
  112806. /**
  112807. * The scale of the device to be used when translating from device space to babylon space.
  112808. */
  112809. deviceScaleFactor: number;
  112810. private _deviceToWorld;
  112811. private _worldToDevice;
  112812. /**
  112813. * References to the webVR controllers for the vrDevice.
  112814. */
  112815. controllers: Array<WebVRController>;
  112816. /**
  112817. * Emits an event when a controller is attached.
  112818. */
  112819. onControllersAttachedObservable: Observable<WebVRController[]>;
  112820. /**
  112821. * Emits an event when a controller's mesh has been loaded;
  112822. */
  112823. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112824. /**
  112825. * Emits an event when the HMD's pose has been updated.
  112826. */
  112827. onPoseUpdatedFromDeviceObservable: Observable<any>;
  112828. private _poseSet;
  112829. /**
  112830. * If the rig cameras be used as parent instead of this camera.
  112831. */
  112832. rigParenting: boolean;
  112833. private _lightOnControllers;
  112834. private _defaultHeight?;
  112835. /**
  112836. * Instantiates a WebVRFreeCamera.
  112837. * @param name The name of the WebVRFreeCamera
  112838. * @param position The starting anchor position for the camera
  112839. * @param scene The scene the camera belongs to
  112840. * @param webVROptions a set of customizable options for the webVRCamera
  112841. */
  112842. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  112843. /**
  112844. * Gets the device distance from the ground in meters.
  112845. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  112846. */
  112847. deviceDistanceToRoomGround(): number;
  112848. /**
  112849. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112850. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  112851. */
  112852. useStandingMatrix(callback?: (bool: boolean) => void): void;
  112853. /**
  112854. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112855. * @returns A promise with a boolean set to if the standing matrix is supported.
  112856. */
  112857. useStandingMatrixAsync(): Promise<boolean>;
  112858. /**
  112859. * Disposes the camera
  112860. */
  112861. dispose(): void;
  112862. /**
  112863. * Gets a vrController by name.
  112864. * @param name The name of the controller to retreive
  112865. * @returns the controller matching the name specified or null if not found
  112866. */
  112867. getControllerByName(name: string): Nullable<WebVRController>;
  112868. private _leftController;
  112869. /**
  112870. * The controller corresponding to the users left hand.
  112871. */
  112872. get leftController(): Nullable<WebVRController>;
  112873. private _rightController;
  112874. /**
  112875. * The controller corresponding to the users right hand.
  112876. */
  112877. get rightController(): Nullable<WebVRController>;
  112878. /**
  112879. * Casts a ray forward from the vrCamera's gaze.
  112880. * @param length Length of the ray (default: 100)
  112881. * @returns the ray corresponding to the gaze
  112882. */
  112883. getForwardRay(length?: number): Ray;
  112884. /**
  112885. * @hidden
  112886. * Updates the camera based on device's frame data
  112887. */
  112888. _checkInputs(): void;
  112889. /**
  112890. * Updates the poseControlled values based on the input device pose.
  112891. * @param poseData Pose coming from the device
  112892. */
  112893. updateFromDevice(poseData: DevicePose): void;
  112894. private _detachIfAttached;
  112895. /**
  112896. * WebVR's attach control will start broadcasting frames to the device.
  112897. * Note that in certain browsers (chrome for example) this function must be called
  112898. * within a user-interaction callback. Example:
  112899. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  112900. *
  112901. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  112902. */
  112903. attachControl(noPreventDefault?: boolean): void;
  112904. /**
  112905. * Detach the current controls from the specified dom element.
  112906. */
  112907. detachControl(): void;
  112908. /**
  112909. * @returns the name of this class
  112910. */
  112911. getClassName(): string;
  112912. /**
  112913. * Calls resetPose on the vrDisplay
  112914. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  112915. */
  112916. resetToCurrentRotation(): void;
  112917. /**
  112918. * @hidden
  112919. * Updates the rig cameras (left and right eye)
  112920. */
  112921. _updateRigCameras(): void;
  112922. private _workingVector;
  112923. private _oneVector;
  112924. private _workingMatrix;
  112925. private updateCacheCalled;
  112926. private _correctPositionIfNotTrackPosition;
  112927. /**
  112928. * @hidden
  112929. * Updates the cached values of the camera
  112930. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  112931. */
  112932. _updateCache(ignoreParentClass?: boolean): void;
  112933. /**
  112934. * @hidden
  112935. * Get current device position in babylon world
  112936. */
  112937. _computeDevicePosition(): void;
  112938. /**
  112939. * Updates the current device position and rotation in the babylon world
  112940. */
  112941. update(): void;
  112942. /**
  112943. * @hidden
  112944. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  112945. * @returns an identity matrix
  112946. */
  112947. _getViewMatrix(): Matrix;
  112948. private _tmpMatrix;
  112949. /**
  112950. * This function is called by the two RIG cameras.
  112951. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  112952. * @hidden
  112953. */
  112954. _getWebVRViewMatrix(): Matrix;
  112955. /** @hidden */
  112956. _getWebVRProjectionMatrix(): Matrix;
  112957. private _onGamepadConnectedObserver;
  112958. private _onGamepadDisconnectedObserver;
  112959. private _updateCacheWhenTrackingDisabledObserver;
  112960. /**
  112961. * Initializes the controllers and their meshes
  112962. */
  112963. initControllers(): void;
  112964. }
  112965. }
  112966. declare module BABYLON {
  112967. /**
  112968. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  112969. *
  112970. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  112971. *
  112972. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  112973. */
  112974. export class MaterialHelper {
  112975. /**
  112976. * Bind the current view position to an effect.
  112977. * @param effect The effect to be bound
  112978. * @param scene The scene the eyes position is used from
  112979. * @param variableName name of the shader variable that will hold the eye position
  112980. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  112981. * @return the computed eye position
  112982. */
  112983. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  112984. /**
  112985. * Helps preparing the defines values about the UVs in used in the effect.
  112986. * UVs are shared as much as we can accross channels in the shaders.
  112987. * @param texture The texture we are preparing the UVs for
  112988. * @param defines The defines to update
  112989. * @param key The channel key "diffuse", "specular"... used in the shader
  112990. */
  112991. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  112992. /**
  112993. * Binds a texture matrix value to its corrsponding uniform
  112994. * @param texture The texture to bind the matrix for
  112995. * @param uniformBuffer The uniform buffer receivin the data
  112996. * @param key The channel key "diffuse", "specular"... used in the shader
  112997. */
  112998. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  112999. /**
  113000. * Gets the current status of the fog (should it be enabled?)
  113001. * @param mesh defines the mesh to evaluate for fog support
  113002. * @param scene defines the hosting scene
  113003. * @returns true if fog must be enabled
  113004. */
  113005. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  113006. /**
  113007. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  113008. * @param mesh defines the current mesh
  113009. * @param scene defines the current scene
  113010. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  113011. * @param pointsCloud defines if point cloud rendering has to be turned on
  113012. * @param fogEnabled defines if fog has to be turned on
  113013. * @param alphaTest defines if alpha testing has to be turned on
  113014. * @param defines defines the current list of defines
  113015. */
  113016. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  113017. /**
  113018. * Helper used to prepare the list of defines associated with frame values for shader compilation
  113019. * @param scene defines the current scene
  113020. * @param engine defines the current engine
  113021. * @param defines specifies the list of active defines
  113022. * @param useInstances defines if instances have to be turned on
  113023. * @param useClipPlane defines if clip plane have to be turned on
  113024. * @param useInstances defines if instances have to be turned on
  113025. * @param useThinInstances defines if thin instances have to be turned on
  113026. */
  113027. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  113028. /**
  113029. * Prepares the defines for bones
  113030. * @param mesh The mesh containing the geometry data we will draw
  113031. * @param defines The defines to update
  113032. */
  113033. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  113034. /**
  113035. * Prepares the defines for morph targets
  113036. * @param mesh The mesh containing the geometry data we will draw
  113037. * @param defines The defines to update
  113038. */
  113039. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  113040. /**
  113041. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  113042. * @param mesh The mesh containing the geometry data we will draw
  113043. * @param defines The defines to update
  113044. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  113045. * @param useBones Precise whether bones should be used or not (override mesh info)
  113046. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  113047. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  113048. * @returns false if defines are considered not dirty and have not been checked
  113049. */
  113050. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  113051. /**
  113052. * Prepares the defines related to multiview
  113053. * @param scene The scene we are intending to draw
  113054. * @param defines The defines to update
  113055. */
  113056. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  113057. /**
  113058. * Prepares the defines related to the prepass
  113059. * @param scene The scene we are intending to draw
  113060. * @param defines The defines to update
  113061. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  113062. */
  113063. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  113064. /**
  113065. * Prepares the defines related to the light information passed in parameter
  113066. * @param scene The scene we are intending to draw
  113067. * @param mesh The mesh the effect is compiling for
  113068. * @param light The light the effect is compiling for
  113069. * @param lightIndex The index of the light
  113070. * @param defines The defines to update
  113071. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  113072. * @param state Defines the current state regarding what is needed (normals, etc...)
  113073. */
  113074. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  113075. needNormals: boolean;
  113076. needRebuild: boolean;
  113077. shadowEnabled: boolean;
  113078. specularEnabled: boolean;
  113079. lightmapMode: boolean;
  113080. }): void;
  113081. /**
  113082. * Prepares the defines related to the light information passed in parameter
  113083. * @param scene The scene we are intending to draw
  113084. * @param mesh The mesh the effect is compiling for
  113085. * @param defines The defines to update
  113086. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  113087. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  113088. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  113089. * @returns true if normals will be required for the rest of the effect
  113090. */
  113091. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  113092. /**
  113093. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  113094. * @param lightIndex defines the light index
  113095. * @param uniformsList The uniform list
  113096. * @param samplersList The sampler list
  113097. * @param projectedLightTexture defines if projected texture must be used
  113098. * @param uniformBuffersList defines an optional list of uniform buffers
  113099. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  113100. */
  113101. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  113102. /**
  113103. * Prepares the uniforms and samplers list to be used in the effect
  113104. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  113105. * @param samplersList The sampler list
  113106. * @param defines The defines helping in the list generation
  113107. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  113108. */
  113109. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  113110. /**
  113111. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  113112. * @param defines The defines to update while falling back
  113113. * @param fallbacks The authorized effect fallbacks
  113114. * @param maxSimultaneousLights The maximum number of lights allowed
  113115. * @param rank the current rank of the Effect
  113116. * @returns The newly affected rank
  113117. */
  113118. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  113119. private static _TmpMorphInfluencers;
  113120. /**
  113121. * Prepares the list of attributes required for morph targets according to the effect defines.
  113122. * @param attribs The current list of supported attribs
  113123. * @param mesh The mesh to prepare the morph targets attributes for
  113124. * @param influencers The number of influencers
  113125. */
  113126. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  113127. /**
  113128. * Prepares the list of attributes required for morph targets according to the effect defines.
  113129. * @param attribs The current list of supported attribs
  113130. * @param mesh The mesh to prepare the morph targets attributes for
  113131. * @param defines The current Defines of the effect
  113132. */
  113133. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  113134. /**
  113135. * Prepares the list of attributes required for bones according to the effect defines.
  113136. * @param attribs The current list of supported attribs
  113137. * @param mesh The mesh to prepare the bones attributes for
  113138. * @param defines The current Defines of the effect
  113139. * @param fallbacks The current efffect fallback strategy
  113140. */
  113141. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  113142. /**
  113143. * Check and prepare the list of attributes required for instances according to the effect defines.
  113144. * @param attribs The current list of supported attribs
  113145. * @param defines The current MaterialDefines of the effect
  113146. */
  113147. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  113148. /**
  113149. * Add the list of attributes required for instances to the attribs array.
  113150. * @param attribs The current list of supported attribs
  113151. */
  113152. static PushAttributesForInstances(attribs: string[]): void;
  113153. /**
  113154. * Binds the light information to the effect.
  113155. * @param light The light containing the generator
  113156. * @param effect The effect we are binding the data to
  113157. * @param lightIndex The light index in the effect used to render
  113158. */
  113159. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  113160. /**
  113161. * Binds the lights information from the scene to the effect for the given mesh.
  113162. * @param light Light to bind
  113163. * @param lightIndex Light index
  113164. * @param scene The scene where the light belongs to
  113165. * @param effect The effect we are binding the data to
  113166. * @param useSpecular Defines if specular is supported
  113167. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  113168. */
  113169. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  113170. /**
  113171. * Binds the lights information from the scene to the effect for the given mesh.
  113172. * @param scene The scene the lights belongs to
  113173. * @param mesh The mesh we are binding the information to render
  113174. * @param effect The effect we are binding the data to
  113175. * @param defines The generated defines for the effect
  113176. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  113177. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  113178. */
  113179. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  113180. private static _tempFogColor;
  113181. /**
  113182. * Binds the fog information from the scene to the effect for the given mesh.
  113183. * @param scene The scene the lights belongs to
  113184. * @param mesh The mesh we are binding the information to render
  113185. * @param effect The effect we are binding the data to
  113186. * @param linearSpace Defines if the fog effect is applied in linear space
  113187. */
  113188. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  113189. /**
  113190. * Binds the bones information from the mesh to the effect.
  113191. * @param mesh The mesh we are binding the information to render
  113192. * @param effect The effect we are binding the data to
  113193. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  113194. */
  113195. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  113196. private static _CopyBonesTransformationMatrices;
  113197. /**
  113198. * Binds the morph targets information from the mesh to the effect.
  113199. * @param abstractMesh The mesh we are binding the information to render
  113200. * @param effect The effect we are binding the data to
  113201. */
  113202. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  113203. /**
  113204. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  113205. * @param defines The generated defines used in the effect
  113206. * @param effect The effect we are binding the data to
  113207. * @param scene The scene we are willing to render with logarithmic scale for
  113208. */
  113209. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  113210. /**
  113211. * Binds the clip plane information from the scene to the effect.
  113212. * @param scene The scene the clip plane information are extracted from
  113213. * @param effect The effect we are binding the data to
  113214. */
  113215. static BindClipPlane(effect: Effect, scene: Scene): void;
  113216. }
  113217. }
  113218. declare module BABYLON {
  113219. /** @hidden */
  113220. export var bayerDitherFunctions: {
  113221. name: string;
  113222. shader: string;
  113223. };
  113224. }
  113225. declare module BABYLON {
  113226. /** @hidden */
  113227. export var shadowMapFragmentDeclaration: {
  113228. name: string;
  113229. shader: string;
  113230. };
  113231. }
  113232. declare module BABYLON {
  113233. /** @hidden */
  113234. export var shadowMapFragment: {
  113235. name: string;
  113236. shader: string;
  113237. };
  113238. }
  113239. declare module BABYLON {
  113240. /** @hidden */
  113241. export var shadowMapPixelShader: {
  113242. name: string;
  113243. shader: string;
  113244. };
  113245. }
  113246. declare module BABYLON {
  113247. /** @hidden */
  113248. export var shadowMapVertexDeclaration: {
  113249. name: string;
  113250. shader: string;
  113251. };
  113252. }
  113253. declare module BABYLON {
  113254. /** @hidden */
  113255. export var shadowMapVertexNormalBias: {
  113256. name: string;
  113257. shader: string;
  113258. };
  113259. }
  113260. declare module BABYLON {
  113261. /** @hidden */
  113262. export var shadowMapVertexMetric: {
  113263. name: string;
  113264. shader: string;
  113265. };
  113266. }
  113267. declare module BABYLON {
  113268. /** @hidden */
  113269. export var shadowMapVertexShader: {
  113270. name: string;
  113271. shader: string;
  113272. };
  113273. }
  113274. declare module BABYLON {
  113275. /** @hidden */
  113276. export var depthBoxBlurPixelShader: {
  113277. name: string;
  113278. shader: string;
  113279. };
  113280. }
  113281. declare module BABYLON {
  113282. /** @hidden */
  113283. export var shadowMapFragmentSoftTransparentShadow: {
  113284. name: string;
  113285. shader: string;
  113286. };
  113287. }
  113288. declare module BABYLON {
  113289. /**
  113290. * Creates an instance based on a source mesh.
  113291. */
  113292. export class InstancedMesh extends AbstractMesh {
  113293. private _sourceMesh;
  113294. private _currentLOD;
  113295. /** @hidden */
  113296. _indexInSourceMeshInstanceArray: number;
  113297. constructor(name: string, source: Mesh);
  113298. /**
  113299. * Returns the string "InstancedMesh".
  113300. */
  113301. getClassName(): string;
  113302. /** Gets the list of lights affecting that mesh */
  113303. get lightSources(): Light[];
  113304. _resyncLightSources(): void;
  113305. _resyncLightSource(light: Light): void;
  113306. _removeLightSource(light: Light, dispose: boolean): void;
  113307. /**
  113308. * If the source mesh receives shadows
  113309. */
  113310. get receiveShadows(): boolean;
  113311. /**
  113312. * The material of the source mesh
  113313. */
  113314. get material(): Nullable<Material>;
  113315. /**
  113316. * Visibility of the source mesh
  113317. */
  113318. get visibility(): number;
  113319. /**
  113320. * Skeleton of the source mesh
  113321. */
  113322. get skeleton(): Nullable<Skeleton>;
  113323. /**
  113324. * Rendering ground id of the source mesh
  113325. */
  113326. get renderingGroupId(): number;
  113327. set renderingGroupId(value: number);
  113328. /**
  113329. * Returns the total number of vertices (integer).
  113330. */
  113331. getTotalVertices(): number;
  113332. /**
  113333. * Returns a positive integer : the total number of indices in this mesh geometry.
  113334. * @returns the numner of indices or zero if the mesh has no geometry.
  113335. */
  113336. getTotalIndices(): number;
  113337. /**
  113338. * The source mesh of the instance
  113339. */
  113340. get sourceMesh(): Mesh;
  113341. /**
  113342. * Creates a new InstancedMesh object from the mesh model.
  113343. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113344. * @param name defines the name of the new instance
  113345. * @returns a new InstancedMesh
  113346. */
  113347. createInstance(name: string): InstancedMesh;
  113348. /**
  113349. * Is this node ready to be used/rendered
  113350. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113351. * @return {boolean} is it ready
  113352. */
  113353. isReady(completeCheck?: boolean): boolean;
  113354. /**
  113355. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113356. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  113357. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  113358. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  113359. */
  113360. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  113361. /**
  113362. * Sets the vertex data of the mesh geometry for the requested `kind`.
  113363. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  113364. * The `data` are either a numeric array either a Float32Array.
  113365. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  113366. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  113367. * Note that a new underlying VertexBuffer object is created each call.
  113368. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  113369. *
  113370. * Possible `kind` values :
  113371. * - VertexBuffer.PositionKind
  113372. * - VertexBuffer.UVKind
  113373. * - VertexBuffer.UV2Kind
  113374. * - VertexBuffer.UV3Kind
  113375. * - VertexBuffer.UV4Kind
  113376. * - VertexBuffer.UV5Kind
  113377. * - VertexBuffer.UV6Kind
  113378. * - VertexBuffer.ColorKind
  113379. * - VertexBuffer.MatricesIndicesKind
  113380. * - VertexBuffer.MatricesIndicesExtraKind
  113381. * - VertexBuffer.MatricesWeightsKind
  113382. * - VertexBuffer.MatricesWeightsExtraKind
  113383. *
  113384. * Returns the Mesh.
  113385. */
  113386. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113387. /**
  113388. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  113389. * If the mesh has no geometry, it is simply returned as it is.
  113390. * The `data` are either a numeric array either a Float32Array.
  113391. * No new underlying VertexBuffer object is created.
  113392. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  113393. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  113394. *
  113395. * Possible `kind` values :
  113396. * - VertexBuffer.PositionKind
  113397. * - VertexBuffer.UVKind
  113398. * - VertexBuffer.UV2Kind
  113399. * - VertexBuffer.UV3Kind
  113400. * - VertexBuffer.UV4Kind
  113401. * - VertexBuffer.UV5Kind
  113402. * - VertexBuffer.UV6Kind
  113403. * - VertexBuffer.ColorKind
  113404. * - VertexBuffer.MatricesIndicesKind
  113405. * - VertexBuffer.MatricesIndicesExtraKind
  113406. * - VertexBuffer.MatricesWeightsKind
  113407. * - VertexBuffer.MatricesWeightsExtraKind
  113408. *
  113409. * Returns the Mesh.
  113410. */
  113411. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  113412. /**
  113413. * Sets the mesh indices.
  113414. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  113415. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  113416. * This method creates a new index buffer each call.
  113417. * Returns the Mesh.
  113418. */
  113419. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  113420. /**
  113421. * Boolean : True if the mesh owns the requested kind of data.
  113422. */
  113423. isVerticesDataPresent(kind: string): boolean;
  113424. /**
  113425. * Returns an array of indices (IndicesArray).
  113426. */
  113427. getIndices(): Nullable<IndicesArray>;
  113428. get _positions(): Nullable<Vector3[]>;
  113429. /**
  113430. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113431. * This means the mesh underlying bounding box and sphere are recomputed.
  113432. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113433. * @returns the current mesh
  113434. */
  113435. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  113436. /** @hidden */
  113437. _preActivate(): InstancedMesh;
  113438. /** @hidden */
  113439. _activate(renderId: number, intermediateRendering: boolean): boolean;
  113440. /** @hidden */
  113441. _postActivate(): void;
  113442. getWorldMatrix(): Matrix;
  113443. get isAnInstance(): boolean;
  113444. /**
  113445. * Returns the current associated LOD AbstractMesh.
  113446. */
  113447. getLOD(camera: Camera): AbstractMesh;
  113448. /** @hidden */
  113449. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113450. /** @hidden */
  113451. _syncSubMeshes(): InstancedMesh;
  113452. /** @hidden */
  113453. _generatePointsArray(): boolean;
  113454. /** @hidden */
  113455. _updateBoundingInfo(): AbstractMesh;
  113456. /**
  113457. * Creates a new InstancedMesh from the current mesh.
  113458. * - name (string) : the cloned mesh name
  113459. * - newParent (optional Node) : the optional Node to parent the clone to.
  113460. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  113461. *
  113462. * Returns the clone.
  113463. */
  113464. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  113465. /**
  113466. * Disposes the InstancedMesh.
  113467. * Returns nothing.
  113468. */
  113469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113470. }
  113471. interface Mesh {
  113472. /**
  113473. * Register a custom buffer that will be instanced
  113474. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  113475. * @param kind defines the buffer kind
  113476. * @param stride defines the stride in floats
  113477. */
  113478. registerInstancedBuffer(kind: string, stride: number): void;
  113479. /**
  113480. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  113481. */
  113482. _invalidateInstanceVertexArrayObject(): void;
  113483. /**
  113484. * true to use the edge renderer for all instances of this mesh
  113485. */
  113486. edgesShareWithInstances: boolean;
  113487. /** @hidden */
  113488. _userInstancedBuffersStorage: {
  113489. data: {
  113490. [key: string]: Float32Array;
  113491. };
  113492. sizes: {
  113493. [key: string]: number;
  113494. };
  113495. vertexBuffers: {
  113496. [key: string]: Nullable<VertexBuffer>;
  113497. };
  113498. strides: {
  113499. [key: string]: number;
  113500. };
  113501. vertexArrayObjects?: {
  113502. [key: string]: WebGLVertexArrayObject;
  113503. };
  113504. };
  113505. }
  113506. interface AbstractMesh {
  113507. /**
  113508. * Object used to store instanced buffers defined by user
  113509. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  113510. */
  113511. instancedBuffers: {
  113512. [key: string]: any;
  113513. };
  113514. }
  113515. }
  113516. declare module BABYLON {
  113517. /**
  113518. * Defines the options associated with the creation of a shader material.
  113519. */
  113520. export interface IShaderMaterialOptions {
  113521. /**
  113522. * Does the material work in alpha blend mode
  113523. */
  113524. needAlphaBlending: boolean;
  113525. /**
  113526. * Does the material work in alpha test mode
  113527. */
  113528. needAlphaTesting: boolean;
  113529. /**
  113530. * The list of attribute names used in the shader
  113531. */
  113532. attributes: string[];
  113533. /**
  113534. * The list of unifrom names used in the shader
  113535. */
  113536. uniforms: string[];
  113537. /**
  113538. * The list of UBO names used in the shader
  113539. */
  113540. uniformBuffers: string[];
  113541. /**
  113542. * The list of sampler names used in the shader
  113543. */
  113544. samplers: string[];
  113545. /**
  113546. * The list of defines used in the shader
  113547. */
  113548. defines: string[];
  113549. }
  113550. /**
  113551. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  113552. *
  113553. * This returned material effects how the mesh will look based on the code in the shaders.
  113554. *
  113555. * @see https://doc.babylonjs.com/how_to/shader_material
  113556. */
  113557. export class ShaderMaterial extends Material {
  113558. private _shaderPath;
  113559. private _options;
  113560. private _textures;
  113561. private _textureArrays;
  113562. private _floats;
  113563. private _ints;
  113564. private _floatsArrays;
  113565. private _colors3;
  113566. private _colors3Arrays;
  113567. private _colors4;
  113568. private _colors4Arrays;
  113569. private _vectors2;
  113570. private _vectors3;
  113571. private _vectors4;
  113572. private _matrices;
  113573. private _matrixArrays;
  113574. private _matrices3x3;
  113575. private _matrices2x2;
  113576. private _vectors2Arrays;
  113577. private _vectors3Arrays;
  113578. private _vectors4Arrays;
  113579. private _cachedWorldViewMatrix;
  113580. private _cachedWorldViewProjectionMatrix;
  113581. private _renderId;
  113582. private _multiview;
  113583. private _cachedDefines;
  113584. /** Define the Url to load snippets */
  113585. static SnippetUrl: string;
  113586. /** Snippet ID if the material was created from the snippet server */
  113587. snippetId: string;
  113588. /**
  113589. * Instantiate a new shader material.
  113590. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  113591. * This returned material effects how the mesh will look based on the code in the shaders.
  113592. * @see https://doc.babylonjs.com/how_to/shader_material
  113593. * @param name Define the name of the material in the scene
  113594. * @param scene Define the scene the material belongs to
  113595. * @param shaderPath Defines the route to the shader code in one of three ways:
  113596. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  113597. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  113598. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  113599. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  113600. * @param options Define the options used to create the shader
  113601. */
  113602. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  113603. /**
  113604. * Gets the shader path used to define the shader code
  113605. * It can be modified to trigger a new compilation
  113606. */
  113607. get shaderPath(): any;
  113608. /**
  113609. * Sets the shader path used to define the shader code
  113610. * It can be modified to trigger a new compilation
  113611. */
  113612. set shaderPath(shaderPath: any);
  113613. /**
  113614. * Gets the options used to compile the shader.
  113615. * They can be modified to trigger a new compilation
  113616. */
  113617. get options(): IShaderMaterialOptions;
  113618. /**
  113619. * Gets the current class name of the material e.g. "ShaderMaterial"
  113620. * Mainly use in serialization.
  113621. * @returns the class name
  113622. */
  113623. getClassName(): string;
  113624. /**
  113625. * Specifies if the material will require alpha blending
  113626. * @returns a boolean specifying if alpha blending is needed
  113627. */
  113628. needAlphaBlending(): boolean;
  113629. /**
  113630. * Specifies if this material should be rendered in alpha test mode
  113631. * @returns a boolean specifying if an alpha test is needed.
  113632. */
  113633. needAlphaTesting(): boolean;
  113634. private _checkUniform;
  113635. /**
  113636. * Set a texture in the shader.
  113637. * @param name Define the name of the uniform samplers as defined in the shader
  113638. * @param texture Define the texture to bind to this sampler
  113639. * @return the material itself allowing "fluent" like uniform updates
  113640. */
  113641. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  113642. /**
  113643. * Set a texture array in the shader.
  113644. * @param name Define the name of the uniform sampler array as defined in the shader
  113645. * @param textures Define the list of textures to bind to this sampler
  113646. * @return the material itself allowing "fluent" like uniform updates
  113647. */
  113648. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  113649. /**
  113650. * Set a float in the shader.
  113651. * @param name Define the name of the uniform as defined in the shader
  113652. * @param value Define the value to give to the uniform
  113653. * @return the material itself allowing "fluent" like uniform updates
  113654. */
  113655. setFloat(name: string, value: number): ShaderMaterial;
  113656. /**
  113657. * Set a int in the shader.
  113658. * @param name Define the name of the uniform as defined in the shader
  113659. * @param value Define the value to give to the uniform
  113660. * @return the material itself allowing "fluent" like uniform updates
  113661. */
  113662. setInt(name: string, value: number): ShaderMaterial;
  113663. /**
  113664. * Set an array of floats in the shader.
  113665. * @param name Define the name of the uniform as defined in the shader
  113666. * @param value Define the value to give to the uniform
  113667. * @return the material itself allowing "fluent" like uniform updates
  113668. */
  113669. setFloats(name: string, value: number[]): ShaderMaterial;
  113670. /**
  113671. * Set a vec3 in the shader from a Color3.
  113672. * @param name Define the name of the uniform as defined in the shader
  113673. * @param value Define the value to give to the uniform
  113674. * @return the material itself allowing "fluent" like uniform updates
  113675. */
  113676. setColor3(name: string, value: Color3): ShaderMaterial;
  113677. /**
  113678. * Set a vec3 array in the shader from a Color3 array.
  113679. * @param name Define the name of the uniform as defined in the shader
  113680. * @param value Define the value to give to the uniform
  113681. * @return the material itself allowing "fluent" like uniform updates
  113682. */
  113683. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  113684. /**
  113685. * Set a vec4 in the shader from a Color4.
  113686. * @param name Define the name of the uniform as defined in the shader
  113687. * @param value Define the value to give to the uniform
  113688. * @return the material itself allowing "fluent" like uniform updates
  113689. */
  113690. setColor4(name: string, value: Color4): ShaderMaterial;
  113691. /**
  113692. * Set a vec4 array in the shader from a Color4 array.
  113693. * @param name Define the name of the uniform as defined in the shader
  113694. * @param value Define the value to give to the uniform
  113695. * @return the material itself allowing "fluent" like uniform updates
  113696. */
  113697. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  113698. /**
  113699. * Set a vec2 in the shader from a Vector2.
  113700. * @param name Define the name of the uniform as defined in the shader
  113701. * @param value Define the value to give to the uniform
  113702. * @return the material itself allowing "fluent" like uniform updates
  113703. */
  113704. setVector2(name: string, value: Vector2): ShaderMaterial;
  113705. /**
  113706. * Set a vec3 in the shader from a Vector3.
  113707. * @param name Define the name of the uniform as defined in the shader
  113708. * @param value Define the value to give to the uniform
  113709. * @return the material itself allowing "fluent" like uniform updates
  113710. */
  113711. setVector3(name: string, value: Vector3): ShaderMaterial;
  113712. /**
  113713. * Set a vec4 in the shader from a Vector4.
  113714. * @param name Define the name of the uniform as defined in the shader
  113715. * @param value Define the value to give to the uniform
  113716. * @return the material itself allowing "fluent" like uniform updates
  113717. */
  113718. setVector4(name: string, value: Vector4): ShaderMaterial;
  113719. /**
  113720. * Set a mat4 in the shader from a Matrix.
  113721. * @param name Define the name of the uniform as defined in the shader
  113722. * @param value Define the value to give to the uniform
  113723. * @return the material itself allowing "fluent" like uniform updates
  113724. */
  113725. setMatrix(name: string, value: Matrix): ShaderMaterial;
  113726. /**
  113727. * Set a float32Array in the shader from a matrix array.
  113728. * @param name Define the name of the uniform as defined in the shader
  113729. * @param value Define the value to give to the uniform
  113730. * @return the material itself allowing "fluent" like uniform updates
  113731. */
  113732. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  113733. /**
  113734. * Set a mat3 in the shader from a Float32Array.
  113735. * @param name Define the name of the uniform as defined in the shader
  113736. * @param value Define the value to give to the uniform
  113737. * @return the material itself allowing "fluent" like uniform updates
  113738. */
  113739. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113740. /**
  113741. * Set a mat2 in the shader from a Float32Array.
  113742. * @param name Define the name of the uniform as defined in the shader
  113743. * @param value Define the value to give to the uniform
  113744. * @return the material itself allowing "fluent" like uniform updates
  113745. */
  113746. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113747. /**
  113748. * Set a vec2 array in the shader from a number array.
  113749. * @param name Define the name of the uniform as defined in the shader
  113750. * @param value Define the value to give to the uniform
  113751. * @return the material itself allowing "fluent" like uniform updates
  113752. */
  113753. setArray2(name: string, value: number[]): ShaderMaterial;
  113754. /**
  113755. * Set a vec3 array in the shader from a number array.
  113756. * @param name Define the name of the uniform as defined in the shader
  113757. * @param value Define the value to give to the uniform
  113758. * @return the material itself allowing "fluent" like uniform updates
  113759. */
  113760. setArray3(name: string, value: number[]): ShaderMaterial;
  113761. /**
  113762. * Set a vec4 array in the shader from a number array.
  113763. * @param name Define the name of the uniform as defined in the shader
  113764. * @param value Define the value to give to the uniform
  113765. * @return the material itself allowing "fluent" like uniform updates
  113766. */
  113767. setArray4(name: string, value: number[]): ShaderMaterial;
  113768. private _checkCache;
  113769. /**
  113770. * Specifies that the submesh is ready to be used
  113771. * @param mesh defines the mesh to check
  113772. * @param subMesh defines which submesh to check
  113773. * @param useInstances specifies that instances should be used
  113774. * @returns a boolean indicating that the submesh is ready or not
  113775. */
  113776. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113777. /**
  113778. * Checks if the material is ready to render the requested mesh
  113779. * @param mesh Define the mesh to render
  113780. * @param useInstances Define whether or not the material is used with instances
  113781. * @returns true if ready, otherwise false
  113782. */
  113783. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  113784. /**
  113785. * Binds the world matrix to the material
  113786. * @param world defines the world transformation matrix
  113787. * @param effectOverride - If provided, use this effect instead of internal effect
  113788. */
  113789. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  113790. /**
  113791. * Binds the submesh to this material by preparing the effect and shader to draw
  113792. * @param world defines the world transformation matrix
  113793. * @param mesh defines the mesh containing the submesh
  113794. * @param subMesh defines the submesh to bind the material to
  113795. */
  113796. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113797. /**
  113798. * Binds the material to the mesh
  113799. * @param world defines the world transformation matrix
  113800. * @param mesh defines the mesh to bind the material to
  113801. * @param effectOverride - If provided, use this effect instead of internal effect
  113802. */
  113803. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  113804. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  113805. /**
  113806. * Gets the active textures from the material
  113807. * @returns an array of textures
  113808. */
  113809. getActiveTextures(): BaseTexture[];
  113810. /**
  113811. * Specifies if the material uses a texture
  113812. * @param texture defines the texture to check against the material
  113813. * @returns a boolean specifying if the material uses the texture
  113814. */
  113815. hasTexture(texture: BaseTexture): boolean;
  113816. /**
  113817. * Makes a duplicate of the material, and gives it a new name
  113818. * @param name defines the new name for the duplicated material
  113819. * @returns the cloned material
  113820. */
  113821. clone(name: string): ShaderMaterial;
  113822. /**
  113823. * Disposes the material
  113824. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113825. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113826. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113827. */
  113828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113829. /**
  113830. * Serializes this material in a JSON representation
  113831. * @returns the serialized material object
  113832. */
  113833. serialize(): any;
  113834. /**
  113835. * Creates a shader material from parsed shader material data
  113836. * @param source defines the JSON represnetation of the material
  113837. * @param scene defines the hosting scene
  113838. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113839. * @returns a new material
  113840. */
  113841. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  113842. /**
  113843. * Creates a new ShaderMaterial from a snippet saved in a remote file
  113844. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  113845. * @param url defines the url to load from
  113846. * @param scene defines the hosting scene
  113847. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113848. * @returns a promise that will resolve to the new ShaderMaterial
  113849. */
  113850. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113851. /**
  113852. * Creates a ShaderMaterial from a snippet saved by the Inspector
  113853. * @param snippetId defines the snippet to load
  113854. * @param scene defines the hosting scene
  113855. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113856. * @returns a promise that will resolve to the new ShaderMaterial
  113857. */
  113858. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113859. }
  113860. }
  113861. declare module BABYLON {
  113862. /** @hidden */
  113863. export var colorPixelShader: {
  113864. name: string;
  113865. shader: string;
  113866. };
  113867. }
  113868. declare module BABYLON {
  113869. /** @hidden */
  113870. export var colorVertexShader: {
  113871. name: string;
  113872. shader: string;
  113873. };
  113874. }
  113875. declare module BABYLON {
  113876. /**
  113877. * Line mesh
  113878. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  113879. */
  113880. export class LinesMesh extends Mesh {
  113881. /**
  113882. * If vertex color should be applied to the mesh
  113883. */
  113884. readonly useVertexColor?: boolean | undefined;
  113885. /**
  113886. * If vertex alpha should be applied to the mesh
  113887. */
  113888. readonly useVertexAlpha?: boolean | undefined;
  113889. /**
  113890. * Color of the line (Default: White)
  113891. */
  113892. color: Color3;
  113893. /**
  113894. * Alpha of the line (Default: 1)
  113895. */
  113896. alpha: number;
  113897. /**
  113898. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113899. * This margin is expressed in world space coordinates, so its value may vary.
  113900. * Default value is 0.1
  113901. */
  113902. intersectionThreshold: number;
  113903. private _colorShader;
  113904. private color4;
  113905. /**
  113906. * Creates a new LinesMesh
  113907. * @param name defines the name
  113908. * @param scene defines the hosting scene
  113909. * @param parent defines the parent mesh if any
  113910. * @param source defines the optional source LinesMesh used to clone data from
  113911. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113912. * When false, achieved by calling a clone(), also passing False.
  113913. * This will make creation of children, recursive.
  113914. * @param useVertexColor defines if this LinesMesh supports vertex color
  113915. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  113916. */
  113917. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  113918. /**
  113919. * If vertex color should be applied to the mesh
  113920. */
  113921. useVertexColor?: boolean | undefined,
  113922. /**
  113923. * If vertex alpha should be applied to the mesh
  113924. */
  113925. useVertexAlpha?: boolean | undefined);
  113926. private _addClipPlaneDefine;
  113927. private _removeClipPlaneDefine;
  113928. isReady(): boolean;
  113929. /**
  113930. * Returns the string "LineMesh"
  113931. */
  113932. getClassName(): string;
  113933. /**
  113934. * @hidden
  113935. */
  113936. get material(): Material;
  113937. /**
  113938. * @hidden
  113939. */
  113940. set material(value: Material);
  113941. /**
  113942. * @hidden
  113943. */
  113944. get checkCollisions(): boolean;
  113945. set checkCollisions(value: boolean);
  113946. /** @hidden */
  113947. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113948. /** @hidden */
  113949. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113950. /**
  113951. * Disposes of the line mesh
  113952. * @param doNotRecurse If children should be disposed
  113953. */
  113954. dispose(doNotRecurse?: boolean): void;
  113955. /**
  113956. * Returns a new LineMesh object cloned from the current one.
  113957. */
  113958. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  113959. /**
  113960. * Creates a new InstancedLinesMesh object from the mesh model.
  113961. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113962. * @param name defines the name of the new instance
  113963. * @returns a new InstancedLinesMesh
  113964. */
  113965. createInstance(name: string): InstancedLinesMesh;
  113966. }
  113967. /**
  113968. * Creates an instance based on a source LinesMesh
  113969. */
  113970. export class InstancedLinesMesh extends InstancedMesh {
  113971. /**
  113972. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113973. * This margin is expressed in world space coordinates, so its value may vary.
  113974. * Initilized with the intersectionThreshold value of the source LinesMesh
  113975. */
  113976. intersectionThreshold: number;
  113977. constructor(name: string, source: LinesMesh);
  113978. /**
  113979. * Returns the string "InstancedLinesMesh".
  113980. */
  113981. getClassName(): string;
  113982. }
  113983. }
  113984. declare module BABYLON {
  113985. /** @hidden */
  113986. export var linePixelShader: {
  113987. name: string;
  113988. shader: string;
  113989. };
  113990. }
  113991. declare module BABYLON {
  113992. /** @hidden */
  113993. export var lineVertexShader: {
  113994. name: string;
  113995. shader: string;
  113996. };
  113997. }
  113998. declare module BABYLON {
  113999. interface Scene {
  114000. /** @hidden */
  114001. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  114002. }
  114003. interface AbstractMesh {
  114004. /**
  114005. * Gets the edgesRenderer associated with the mesh
  114006. */
  114007. edgesRenderer: Nullable<EdgesRenderer>;
  114008. }
  114009. interface LinesMesh {
  114010. /**
  114011. * Enables the edge rendering mode on the mesh.
  114012. * This mode makes the mesh edges visible
  114013. * @param epsilon defines the maximal distance between two angles to detect a face
  114014. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  114015. * @returns the currentAbstractMesh
  114016. * @see https://www.babylonjs-playground.com/#19O9TU#0
  114017. */
  114018. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  114019. }
  114020. interface InstancedLinesMesh {
  114021. /**
  114022. * Enables the edge rendering mode on the mesh.
  114023. * This mode makes the mesh edges visible
  114024. * @param epsilon defines the maximal distance between two angles to detect a face
  114025. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  114026. * @returns the current InstancedLinesMesh
  114027. * @see https://www.babylonjs-playground.com/#19O9TU#0
  114028. */
  114029. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  114030. }
  114031. /**
  114032. * Defines the minimum contract an Edges renderer should follow.
  114033. */
  114034. export interface IEdgesRenderer extends IDisposable {
  114035. /**
  114036. * Gets or sets a boolean indicating if the edgesRenderer is active
  114037. */
  114038. isEnabled: boolean;
  114039. /**
  114040. * Renders the edges of the attached mesh,
  114041. */
  114042. render(): void;
  114043. /**
  114044. * Checks wether or not the edges renderer is ready to render.
  114045. * @return true if ready, otherwise false.
  114046. */
  114047. isReady(): boolean;
  114048. /**
  114049. * List of instances to render in case the source mesh has instances
  114050. */
  114051. customInstances: SmartArray<Matrix>;
  114052. }
  114053. /**
  114054. * Defines the additional options of the edges renderer
  114055. */
  114056. export interface IEdgesRendererOptions {
  114057. /**
  114058. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  114059. * If not defined, the default value is true
  114060. */
  114061. useAlternateEdgeFinder?: boolean;
  114062. /**
  114063. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  114064. * If not defined, the default value is true.
  114065. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  114066. * This option is used only if useAlternateEdgeFinder = true
  114067. */
  114068. useFastVertexMerger?: boolean;
  114069. /**
  114070. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  114071. * The default value is 1e-6
  114072. * This option is used only if useAlternateEdgeFinder = true
  114073. */
  114074. epsilonVertexMerge?: number;
  114075. /**
  114076. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  114077. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  114078. * This option is used only if useAlternateEdgeFinder = true
  114079. */
  114080. applyTessellation?: boolean;
  114081. /**
  114082. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  114083. * The default value is 1e-6
  114084. * This option is used only if useAlternateEdgeFinder = true
  114085. */
  114086. epsilonVertexAligned?: number;
  114087. }
  114088. /**
  114089. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  114090. */
  114091. export class EdgesRenderer implements IEdgesRenderer {
  114092. /**
  114093. * Define the size of the edges with an orthographic camera
  114094. */
  114095. edgesWidthScalerForOrthographic: number;
  114096. /**
  114097. * Define the size of the edges with a perspective camera
  114098. */
  114099. edgesWidthScalerForPerspective: number;
  114100. protected _source: AbstractMesh;
  114101. protected _linesPositions: number[];
  114102. protected _linesNormals: number[];
  114103. protected _linesIndices: number[];
  114104. protected _epsilon: number;
  114105. protected _indicesCount: number;
  114106. protected _lineShader: ShaderMaterial;
  114107. protected _ib: DataBuffer;
  114108. protected _buffers: {
  114109. [key: string]: Nullable<VertexBuffer>;
  114110. };
  114111. protected _buffersForInstances: {
  114112. [key: string]: Nullable<VertexBuffer>;
  114113. };
  114114. protected _checkVerticesInsteadOfIndices: boolean;
  114115. protected _options: Nullable<IEdgesRendererOptions>;
  114116. private _meshRebuildObserver;
  114117. private _meshDisposeObserver;
  114118. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  114119. isEnabled: boolean;
  114120. /** Gets the vertices generated by the edge renderer */
  114121. get linesPositions(): Immutable<Array<number>>;
  114122. /** Gets the normals generated by the edge renderer */
  114123. get linesNormals(): Immutable<Array<number>>;
  114124. /** Gets the indices generated by the edge renderer */
  114125. get linesIndices(): Immutable<Array<number>>;
  114126. /**
  114127. * List of instances to render in case the source mesh has instances
  114128. */
  114129. customInstances: SmartArray<Matrix>;
  114130. private static GetShader;
  114131. /**
  114132. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  114133. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  114134. * @param source Mesh used to create edges
  114135. * @param epsilon sum of angles in adjacency to check for edge
  114136. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  114137. * @param generateEdgesLines - should generate Lines or only prepare resources.
  114138. * @param options The options to apply when generating the edges
  114139. */
  114140. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  114141. protected _prepareRessources(): void;
  114142. /** @hidden */
  114143. _rebuild(): void;
  114144. /**
  114145. * Releases the required resources for the edges renderer
  114146. */
  114147. dispose(): void;
  114148. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  114149. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  114150. /**
  114151. * Checks if the pair of p0 and p1 is en edge
  114152. * @param faceIndex
  114153. * @param edge
  114154. * @param faceNormals
  114155. * @param p0
  114156. * @param p1
  114157. * @private
  114158. */
  114159. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  114160. /**
  114161. * push line into the position, normal and index buffer
  114162. * @protected
  114163. */
  114164. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  114165. /**
  114166. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  114167. */
  114168. private _tessellateTriangle;
  114169. private _generateEdgesLinesAlternate;
  114170. /**
  114171. * Generates lines edges from adjacencjes
  114172. * @private
  114173. */
  114174. _generateEdgesLines(): void;
  114175. /**
  114176. * Checks wether or not the edges renderer is ready to render.
  114177. * @return true if ready, otherwise false.
  114178. */
  114179. isReady(): boolean;
  114180. /**
  114181. * Renders the edges of the attached mesh,
  114182. */
  114183. render(): void;
  114184. }
  114185. /**
  114186. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  114187. */
  114188. export class LineEdgesRenderer extends EdgesRenderer {
  114189. /**
  114190. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  114191. * @param source LineMesh used to generate edges
  114192. * @param epsilon not important (specified angle for edge detection)
  114193. * @param checkVerticesInsteadOfIndices not important for LineMesh
  114194. */
  114195. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  114196. /**
  114197. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  114198. */
  114199. _generateEdgesLines(): void;
  114200. }
  114201. }
  114202. declare module BABYLON {
  114203. /**
  114204. * This represents the object necessary to create a rendering group.
  114205. * This is exclusively used and created by the rendering manager.
  114206. * To modify the behavior, you use the available helpers in your scene or meshes.
  114207. * @hidden
  114208. */
  114209. export class RenderingGroup {
  114210. index: number;
  114211. private static _zeroVector;
  114212. private _scene;
  114213. private _opaqueSubMeshes;
  114214. private _transparentSubMeshes;
  114215. private _alphaTestSubMeshes;
  114216. private _depthOnlySubMeshes;
  114217. private _particleSystems;
  114218. private _spriteManagers;
  114219. private _opaqueSortCompareFn;
  114220. private _alphaTestSortCompareFn;
  114221. private _transparentSortCompareFn;
  114222. private _renderOpaque;
  114223. private _renderAlphaTest;
  114224. private _renderTransparent;
  114225. /** @hidden */
  114226. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  114227. onBeforeTransparentRendering: () => void;
  114228. /**
  114229. * Set the opaque sort comparison function.
  114230. * If null the sub meshes will be render in the order they were created
  114231. */
  114232. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114233. /**
  114234. * Set the alpha test sort comparison function.
  114235. * If null the sub meshes will be render in the order they were created
  114236. */
  114237. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114238. /**
  114239. * Set the transparent sort comparison function.
  114240. * If null the sub meshes will be render in the order they were created
  114241. */
  114242. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114243. /**
  114244. * Creates a new rendering group.
  114245. * @param index The rendering group index
  114246. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  114247. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  114248. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  114249. */
  114250. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114251. /**
  114252. * Render all the sub meshes contained in the group.
  114253. * @param customRenderFunction Used to override the default render behaviour of the group.
  114254. * @returns true if rendered some submeshes.
  114255. */
  114256. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  114257. /**
  114258. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  114259. * @param subMeshes The submeshes to render
  114260. */
  114261. private renderOpaqueSorted;
  114262. /**
  114263. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  114264. * @param subMeshes The submeshes to render
  114265. */
  114266. private renderAlphaTestSorted;
  114267. /**
  114268. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  114269. * @param subMeshes The submeshes to render
  114270. */
  114271. private renderTransparentSorted;
  114272. /**
  114273. * Renders the submeshes in a specified order.
  114274. * @param subMeshes The submeshes to sort before render
  114275. * @param sortCompareFn The comparison function use to sort
  114276. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  114277. * @param transparent Specifies to activate blending if true
  114278. */
  114279. private static renderSorted;
  114280. /**
  114281. * Renders the submeshes in the order they were dispatched (no sort applied).
  114282. * @param subMeshes The submeshes to render
  114283. */
  114284. private static renderUnsorted;
  114285. /**
  114286. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114287. * are rendered back to front if in the same alpha index.
  114288. *
  114289. * @param a The first submesh
  114290. * @param b The second submesh
  114291. * @returns The result of the comparison
  114292. */
  114293. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  114294. /**
  114295. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114296. * are rendered back to front.
  114297. *
  114298. * @param a The first submesh
  114299. * @param b The second submesh
  114300. * @returns The result of the comparison
  114301. */
  114302. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  114303. /**
  114304. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114305. * are rendered front to back (prevent overdraw).
  114306. *
  114307. * @param a The first submesh
  114308. * @param b The second submesh
  114309. * @returns The result of the comparison
  114310. */
  114311. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  114312. /**
  114313. * Resets the different lists of submeshes to prepare a new frame.
  114314. */
  114315. prepare(): void;
  114316. dispose(): void;
  114317. /**
  114318. * Inserts the submesh in its correct queue depending on its material.
  114319. * @param subMesh The submesh to dispatch
  114320. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  114321. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  114322. */
  114323. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  114324. dispatchSprites(spriteManager: ISpriteManager): void;
  114325. dispatchParticles(particleSystem: IParticleSystem): void;
  114326. private _renderParticles;
  114327. private _renderSprites;
  114328. }
  114329. }
  114330. declare module BABYLON {
  114331. /**
  114332. * Interface describing the different options available in the rendering manager
  114333. * regarding Auto Clear between groups.
  114334. */
  114335. export interface IRenderingManagerAutoClearSetup {
  114336. /**
  114337. * Defines whether or not autoclear is enable.
  114338. */
  114339. autoClear: boolean;
  114340. /**
  114341. * Defines whether or not to autoclear the depth buffer.
  114342. */
  114343. depth: boolean;
  114344. /**
  114345. * Defines whether or not to autoclear the stencil buffer.
  114346. */
  114347. stencil: boolean;
  114348. }
  114349. /**
  114350. * This class is used by the onRenderingGroupObservable
  114351. */
  114352. export class RenderingGroupInfo {
  114353. /**
  114354. * The Scene that being rendered
  114355. */
  114356. scene: Scene;
  114357. /**
  114358. * The camera currently used for the rendering pass
  114359. */
  114360. camera: Nullable<Camera>;
  114361. /**
  114362. * The ID of the renderingGroup being processed
  114363. */
  114364. renderingGroupId: number;
  114365. }
  114366. /**
  114367. * This is the manager responsible of all the rendering for meshes sprites and particles.
  114368. * It is enable to manage the different groups as well as the different necessary sort functions.
  114369. * This should not be used directly aside of the few static configurations
  114370. */
  114371. export class RenderingManager {
  114372. /**
  114373. * The max id used for rendering groups (not included)
  114374. */
  114375. static MAX_RENDERINGGROUPS: number;
  114376. /**
  114377. * The min id used for rendering groups (included)
  114378. */
  114379. static MIN_RENDERINGGROUPS: number;
  114380. /**
  114381. * Used to globally prevent autoclearing scenes.
  114382. */
  114383. static AUTOCLEAR: boolean;
  114384. /**
  114385. * @hidden
  114386. */
  114387. _useSceneAutoClearSetup: boolean;
  114388. private _scene;
  114389. private _renderingGroups;
  114390. private _depthStencilBufferAlreadyCleaned;
  114391. private _autoClearDepthStencil;
  114392. private _customOpaqueSortCompareFn;
  114393. private _customAlphaTestSortCompareFn;
  114394. private _customTransparentSortCompareFn;
  114395. private _renderingGroupInfo;
  114396. /**
  114397. * Instantiates a new rendering group for a particular scene
  114398. * @param scene Defines the scene the groups belongs to
  114399. */
  114400. constructor(scene: Scene);
  114401. private _clearDepthStencilBuffer;
  114402. /**
  114403. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  114404. * @hidden
  114405. */
  114406. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  114407. /**
  114408. * Resets the different information of the group to prepare a new frame
  114409. * @hidden
  114410. */
  114411. reset(): void;
  114412. /**
  114413. * Dispose and release the group and its associated resources.
  114414. * @hidden
  114415. */
  114416. dispose(): void;
  114417. /**
  114418. * Clear the info related to rendering groups preventing retention points during dispose.
  114419. */
  114420. freeRenderingGroups(): void;
  114421. private _prepareRenderingGroup;
  114422. /**
  114423. * Add a sprite manager to the rendering manager in order to render it this frame.
  114424. * @param spriteManager Define the sprite manager to render
  114425. */
  114426. dispatchSprites(spriteManager: ISpriteManager): void;
  114427. /**
  114428. * Add a particle system to the rendering manager in order to render it this frame.
  114429. * @param particleSystem Define the particle system to render
  114430. */
  114431. dispatchParticles(particleSystem: IParticleSystem): void;
  114432. /**
  114433. * Add a submesh to the manager in order to render it this frame
  114434. * @param subMesh The submesh to dispatch
  114435. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  114436. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  114437. */
  114438. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  114439. /**
  114440. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  114441. * This allowed control for front to back rendering or reversly depending of the special needs.
  114442. *
  114443. * @param renderingGroupId The rendering group id corresponding to its index
  114444. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  114445. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  114446. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  114447. */
  114448. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  114449. /**
  114450. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  114451. *
  114452. * @param renderingGroupId The rendering group id corresponding to its index
  114453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114454. * @param depth Automatically clears depth between groups if true and autoClear is true.
  114455. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  114456. */
  114457. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  114458. /**
  114459. * Gets the current auto clear configuration for one rendering group of the rendering
  114460. * manager.
  114461. * @param index the rendering group index to get the information for
  114462. * @returns The auto clear setup for the requested rendering group
  114463. */
  114464. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  114465. }
  114466. }
  114467. declare module BABYLON {
  114468. /**
  114469. * Defines the options associated with the creation of a custom shader for a shadow generator.
  114470. */
  114471. export interface ICustomShaderOptions {
  114472. /**
  114473. * Gets or sets the custom shader name to use
  114474. */
  114475. shaderName: string;
  114476. /**
  114477. * The list of attribute names used in the shader
  114478. */
  114479. attributes?: string[];
  114480. /**
  114481. * The list of unifrom names used in the shader
  114482. */
  114483. uniforms?: string[];
  114484. /**
  114485. * The list of sampler names used in the shader
  114486. */
  114487. samplers?: string[];
  114488. /**
  114489. * The list of defines used in the shader
  114490. */
  114491. defines?: string[];
  114492. }
  114493. /**
  114494. * Interface to implement to create a shadow generator compatible with BJS.
  114495. */
  114496. export interface IShadowGenerator {
  114497. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  114498. id: string;
  114499. /**
  114500. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  114501. * @returns The render target texture if present otherwise, null
  114502. */
  114503. getShadowMap(): Nullable<RenderTargetTexture>;
  114504. /**
  114505. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  114506. * @param subMesh The submesh we want to render in the shadow map
  114507. * @param useInstances Defines wether will draw in the map using instances
  114508. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  114509. * @returns true if ready otherwise, false
  114510. */
  114511. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  114512. /**
  114513. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  114514. * @param defines Defines of the material we want to update
  114515. * @param lightIndex Index of the light in the enabled light list of the material
  114516. */
  114517. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  114518. /**
  114519. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  114520. * defined in the generator but impacting the effect).
  114521. * It implies the unifroms available on the materials are the standard BJS ones.
  114522. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  114523. * @param effect The effect we are binfing the information for
  114524. */
  114525. bindShadowLight(lightIndex: string, effect: Effect): void;
  114526. /**
  114527. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  114528. * (eq to shadow prjection matrix * light transform matrix)
  114529. * @returns The transform matrix used to create the shadow map
  114530. */
  114531. getTransformMatrix(): Matrix;
  114532. /**
  114533. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  114534. * Cube and 2D textures for instance.
  114535. */
  114536. recreateShadowMap(): void;
  114537. /**
  114538. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114539. * @param onCompiled Callback triggered at the and of the effects compilation
  114540. * @param options Sets of optional options forcing the compilation with different modes
  114541. */
  114542. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  114543. useInstances: boolean;
  114544. }>): void;
  114545. /**
  114546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114547. * @param options Sets of optional options forcing the compilation with different modes
  114548. * @returns A promise that resolves when the compilation completes
  114549. */
  114550. forceCompilationAsync(options?: Partial<{
  114551. useInstances: boolean;
  114552. }>): Promise<void>;
  114553. /**
  114554. * Serializes the shadow generator setup to a json object.
  114555. * @returns The serialized JSON object
  114556. */
  114557. serialize(): any;
  114558. /**
  114559. * Disposes the Shadow map and related Textures and effects.
  114560. */
  114561. dispose(): void;
  114562. }
  114563. /**
  114564. * Default implementation IShadowGenerator.
  114565. * This is the main object responsible of generating shadows in the framework.
  114566. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  114567. */
  114568. export class ShadowGenerator implements IShadowGenerator {
  114569. private static _Counter;
  114570. /**
  114571. * Name of the shadow generator class
  114572. */
  114573. static CLASSNAME: string;
  114574. /**
  114575. * Shadow generator mode None: no filtering applied.
  114576. */
  114577. static readonly FILTER_NONE: number;
  114578. /**
  114579. * Shadow generator mode ESM: Exponential Shadow Mapping.
  114580. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114581. */
  114582. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  114583. /**
  114584. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  114585. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  114586. */
  114587. static readonly FILTER_POISSONSAMPLING: number;
  114588. /**
  114589. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  114590. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114591. */
  114592. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  114593. /**
  114594. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  114595. * edge artifacts on steep falloff.
  114596. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114597. */
  114598. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  114599. /**
  114600. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  114601. * edge artifacts on steep falloff.
  114602. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  114603. */
  114604. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  114605. /**
  114606. * Shadow generator mode PCF: Percentage Closer Filtering
  114607. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  114608. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  114609. */
  114610. static readonly FILTER_PCF: number;
  114611. /**
  114612. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  114613. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  114614. * Contact Hardening
  114615. */
  114616. static readonly FILTER_PCSS: number;
  114617. /**
  114618. * Reserved for PCF and PCSS
  114619. * Highest Quality.
  114620. *
  114621. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  114622. *
  114623. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  114624. */
  114625. static readonly QUALITY_HIGH: number;
  114626. /**
  114627. * Reserved for PCF and PCSS
  114628. * Good tradeoff for quality/perf cross devices
  114629. *
  114630. * Execute PCF on a 3*3 kernel.
  114631. *
  114632. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  114633. */
  114634. static readonly QUALITY_MEDIUM: number;
  114635. /**
  114636. * Reserved for PCF and PCSS
  114637. * The lowest quality but the fastest.
  114638. *
  114639. * Execute PCF on a 1*1 kernel.
  114640. *
  114641. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  114642. */
  114643. static readonly QUALITY_LOW: number;
  114644. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  114645. id: string;
  114646. /** Gets or sets the custom shader name to use */
  114647. customShaderOptions: ICustomShaderOptions;
  114648. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  114649. customAllowRendering: (subMesh: SubMesh) => boolean;
  114650. /**
  114651. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  114652. */
  114653. onBeforeShadowMapRenderObservable: Observable<Effect>;
  114654. /**
  114655. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  114656. */
  114657. onAfterShadowMapRenderObservable: Observable<Effect>;
  114658. /**
  114659. * Observable triggered before a mesh is rendered in the shadow map.
  114660. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  114661. */
  114662. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  114663. /**
  114664. * Observable triggered after a mesh is rendered in the shadow map.
  114665. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  114666. */
  114667. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  114668. protected _bias: number;
  114669. /**
  114670. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  114671. */
  114672. get bias(): number;
  114673. /**
  114674. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  114675. */
  114676. set bias(bias: number);
  114677. protected _normalBias: number;
  114678. /**
  114679. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114680. */
  114681. get normalBias(): number;
  114682. /**
  114683. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114684. */
  114685. set normalBias(normalBias: number);
  114686. protected _blurBoxOffset: number;
  114687. /**
  114688. * Gets the blur box offset: offset applied during the blur pass.
  114689. * Only useful if useKernelBlur = false
  114690. */
  114691. get blurBoxOffset(): number;
  114692. /**
  114693. * Sets the blur box offset: offset applied during the blur pass.
  114694. * Only useful if useKernelBlur = false
  114695. */
  114696. set blurBoxOffset(value: number);
  114697. protected _blurScale: number;
  114698. /**
  114699. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  114700. * 2 means half of the size.
  114701. */
  114702. get blurScale(): number;
  114703. /**
  114704. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  114705. * 2 means half of the size.
  114706. */
  114707. set blurScale(value: number);
  114708. protected _blurKernel: number;
  114709. /**
  114710. * Gets the blur kernel: kernel size of the blur pass.
  114711. * Only useful if useKernelBlur = true
  114712. */
  114713. get blurKernel(): number;
  114714. /**
  114715. * Sets the blur kernel: kernel size of the blur pass.
  114716. * Only useful if useKernelBlur = true
  114717. */
  114718. set blurKernel(value: number);
  114719. protected _useKernelBlur: boolean;
  114720. /**
  114721. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  114722. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114723. */
  114724. get useKernelBlur(): boolean;
  114725. /**
  114726. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  114727. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114728. */
  114729. set useKernelBlur(value: boolean);
  114730. protected _depthScale: number;
  114731. /**
  114732. * Gets the depth scale used in ESM mode.
  114733. */
  114734. get depthScale(): number;
  114735. /**
  114736. * Sets the depth scale used in ESM mode.
  114737. * This can override the scale stored on the light.
  114738. */
  114739. set depthScale(value: number);
  114740. protected _validateFilter(filter: number): number;
  114741. protected _filter: number;
  114742. /**
  114743. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  114744. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114745. */
  114746. get filter(): number;
  114747. /**
  114748. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  114749. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114750. */
  114751. set filter(value: number);
  114752. /**
  114753. * Gets if the current filter is set to Poisson Sampling.
  114754. */
  114755. get usePoissonSampling(): boolean;
  114756. /**
  114757. * Sets the current filter to Poisson Sampling.
  114758. */
  114759. set usePoissonSampling(value: boolean);
  114760. /**
  114761. * Gets if the current filter is set to ESM.
  114762. */
  114763. get useExponentialShadowMap(): boolean;
  114764. /**
  114765. * Sets the current filter is to ESM.
  114766. */
  114767. set useExponentialShadowMap(value: boolean);
  114768. /**
  114769. * Gets if the current filter is set to filtered ESM.
  114770. */
  114771. get useBlurExponentialShadowMap(): boolean;
  114772. /**
  114773. * Gets if the current filter is set to filtered ESM.
  114774. */
  114775. set useBlurExponentialShadowMap(value: boolean);
  114776. /**
  114777. * Gets if the current filter is set to "close ESM" (using the inverse of the
  114778. * exponential to prevent steep falloff artifacts).
  114779. */
  114780. get useCloseExponentialShadowMap(): boolean;
  114781. /**
  114782. * Sets the current filter to "close ESM" (using the inverse of the
  114783. * exponential to prevent steep falloff artifacts).
  114784. */
  114785. set useCloseExponentialShadowMap(value: boolean);
  114786. /**
  114787. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  114788. * exponential to prevent steep falloff artifacts).
  114789. */
  114790. get useBlurCloseExponentialShadowMap(): boolean;
  114791. /**
  114792. * Sets the current filter to filtered "close ESM" (using the inverse of the
  114793. * exponential to prevent steep falloff artifacts).
  114794. */
  114795. set useBlurCloseExponentialShadowMap(value: boolean);
  114796. /**
  114797. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  114798. */
  114799. get usePercentageCloserFiltering(): boolean;
  114800. /**
  114801. * Sets the current filter to "PCF" (percentage closer filtering).
  114802. */
  114803. set usePercentageCloserFiltering(value: boolean);
  114804. protected _filteringQuality: number;
  114805. /**
  114806. * Gets the PCF or PCSS Quality.
  114807. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114808. */
  114809. get filteringQuality(): number;
  114810. /**
  114811. * Sets the PCF or PCSS Quality.
  114812. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114813. */
  114814. set filteringQuality(filteringQuality: number);
  114815. /**
  114816. * Gets if the current filter is set to "PCSS" (contact hardening).
  114817. */
  114818. get useContactHardeningShadow(): boolean;
  114819. /**
  114820. * Sets the current filter to "PCSS" (contact hardening).
  114821. */
  114822. set useContactHardeningShadow(value: boolean);
  114823. protected _contactHardeningLightSizeUVRatio: number;
  114824. /**
  114825. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114826. * Using a ratio helps keeping shape stability independently of the map size.
  114827. *
  114828. * It does not account for the light projection as it was having too much
  114829. * instability during the light setup or during light position changes.
  114830. *
  114831. * Only valid if useContactHardeningShadow is true.
  114832. */
  114833. get contactHardeningLightSizeUVRatio(): number;
  114834. /**
  114835. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114836. * Using a ratio helps keeping shape stability independently of the map size.
  114837. *
  114838. * It does not account for the light projection as it was having too much
  114839. * instability during the light setup or during light position changes.
  114840. *
  114841. * Only valid if useContactHardeningShadow is true.
  114842. */
  114843. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  114844. protected _darkness: number;
  114845. /** Gets or sets the actual darkness of a shadow */
  114846. get darkness(): number;
  114847. set darkness(value: number);
  114848. /**
  114849. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  114850. * 0 means strongest and 1 would means no shadow.
  114851. * @returns the darkness.
  114852. */
  114853. getDarkness(): number;
  114854. /**
  114855. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  114856. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  114857. * @returns the shadow generator allowing fluent coding.
  114858. */
  114859. setDarkness(darkness: number): ShadowGenerator;
  114860. protected _transparencyShadow: boolean;
  114861. /** Gets or sets the ability to have transparent shadow */
  114862. get transparencyShadow(): boolean;
  114863. set transparencyShadow(value: boolean);
  114864. /**
  114865. * Sets the ability to have transparent shadow (boolean).
  114866. * @param transparent True if transparent else False
  114867. * @returns the shadow generator allowing fluent coding
  114868. */
  114869. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  114870. /**
  114871. * Enables or disables shadows with varying strength based on the transparency
  114872. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  114873. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  114874. * mesh.visibility * alphaTexture.a
  114875. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  114876. */
  114877. enableSoftTransparentShadow: boolean;
  114878. protected _shadowMap: Nullable<RenderTargetTexture>;
  114879. protected _shadowMap2: Nullable<RenderTargetTexture>;
  114880. /**
  114881. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  114882. * @returns The render target texture if present otherwise, null
  114883. */
  114884. getShadowMap(): Nullable<RenderTargetTexture>;
  114885. /**
  114886. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  114887. * @returns The render target texture if the shadow map is present otherwise, null
  114888. */
  114889. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  114890. /**
  114891. * Gets the class name of that object
  114892. * @returns "ShadowGenerator"
  114893. */
  114894. getClassName(): string;
  114895. /**
  114896. * Helper function to add a mesh and its descendants to the list of shadow casters.
  114897. * @param mesh Mesh to add
  114898. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  114899. * @returns the Shadow Generator itself
  114900. */
  114901. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114902. /**
  114903. * Helper function to remove a mesh and its descendants from the list of shadow casters
  114904. * @param mesh Mesh to remove
  114905. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  114906. * @returns the Shadow Generator itself
  114907. */
  114908. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114909. /**
  114910. * Controls the extent to which the shadows fade out at the edge of the frustum
  114911. */
  114912. frustumEdgeFalloff: number;
  114913. protected _light: IShadowLight;
  114914. /**
  114915. * Returns the associated light object.
  114916. * @returns the light generating the shadow
  114917. */
  114918. getLight(): IShadowLight;
  114919. /**
  114920. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  114921. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  114922. * It might on the other hand introduce peter panning.
  114923. */
  114924. forceBackFacesOnly: boolean;
  114925. protected _scene: Scene;
  114926. protected _lightDirection: Vector3;
  114927. protected _viewMatrix: Matrix;
  114928. protected _projectionMatrix: Matrix;
  114929. protected _transformMatrix: Matrix;
  114930. protected _cachedPosition: Vector3;
  114931. protected _cachedDirection: Vector3;
  114932. protected _cachedDefines: string;
  114933. protected _currentRenderID: number;
  114934. protected _boxBlurPostprocess: Nullable<PostProcess>;
  114935. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  114936. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  114937. protected _blurPostProcesses: PostProcess[];
  114938. protected _mapSize: number;
  114939. protected _currentFaceIndex: number;
  114940. protected _currentFaceIndexCache: number;
  114941. protected _textureType: number;
  114942. protected _defaultTextureMatrix: Matrix;
  114943. protected _storedUniqueId: Nullable<number>;
  114944. protected _nameForCustomEffect: string;
  114945. /** @hidden */
  114946. static _SceneComponentInitialization: (scene: Scene) => void;
  114947. /**
  114948. * Gets or sets the size of the texture what stores the shadows
  114949. */
  114950. get mapSize(): number;
  114951. set mapSize(size: number);
  114952. /**
  114953. * Creates a ShadowGenerator object.
  114954. * A ShadowGenerator is the required tool to use the shadows.
  114955. * Each light casting shadows needs to use its own ShadowGenerator.
  114956. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  114957. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  114958. * @param light The light object generating the shadows.
  114959. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  114960. */
  114961. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  114962. protected _initializeGenerator(): void;
  114963. protected _createTargetRenderTexture(): void;
  114964. protected _initializeShadowMap(): void;
  114965. protected _initializeBlurRTTAndPostProcesses(): void;
  114966. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  114967. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  114968. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  114969. protected _applyFilterValues(): void;
  114970. /**
  114971. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114972. * @param onCompiled Callback triggered at the and of the effects compilation
  114973. * @param options Sets of optional options forcing the compilation with different modes
  114974. */
  114975. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  114976. useInstances: boolean;
  114977. }>): void;
  114978. /**
  114979. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114980. * @param options Sets of optional options forcing the compilation with different modes
  114981. * @returns A promise that resolves when the compilation completes
  114982. */
  114983. forceCompilationAsync(options?: Partial<{
  114984. useInstances: boolean;
  114985. }>): Promise<void>;
  114986. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  114987. private _prepareShadowDefines;
  114988. /**
  114989. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  114990. * @param subMesh The submesh we want to render in the shadow map
  114991. * @param useInstances Defines wether will draw in the map using instances
  114992. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  114993. * @returns true if ready otherwise, false
  114994. */
  114995. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  114996. /**
  114997. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  114998. * @param defines Defines of the material we want to update
  114999. * @param lightIndex Index of the light in the enabled light list of the material
  115000. */
  115001. prepareDefines(defines: any, lightIndex: number): void;
  115002. /**
  115003. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  115004. * defined in the generator but impacting the effect).
  115005. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  115006. * @param effect The effect we are binfing the information for
  115007. */
  115008. bindShadowLight(lightIndex: string, effect: Effect): void;
  115009. /**
  115010. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  115011. * (eq to shadow prjection matrix * light transform matrix)
  115012. * @returns The transform matrix used to create the shadow map
  115013. */
  115014. getTransformMatrix(): Matrix;
  115015. /**
  115016. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  115017. * Cube and 2D textures for instance.
  115018. */
  115019. recreateShadowMap(): void;
  115020. protected _disposeBlurPostProcesses(): void;
  115021. protected _disposeRTTandPostProcesses(): void;
  115022. /**
  115023. * Disposes the ShadowGenerator.
  115024. * Returns nothing.
  115025. */
  115026. dispose(): void;
  115027. /**
  115028. * Serializes the shadow generator setup to a json object.
  115029. * @returns The serialized JSON object
  115030. */
  115031. serialize(): any;
  115032. /**
  115033. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  115034. * @param parsedShadowGenerator The JSON object to parse
  115035. * @param scene The scene to create the shadow map for
  115036. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  115037. * @returns The parsed shadow generator
  115038. */
  115039. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  115040. }
  115041. }
  115042. declare module BABYLON {
  115043. /**
  115044. * Options to be used when creating a shadow depth material
  115045. */
  115046. export interface IIOptionShadowDepthMaterial {
  115047. /** Variables in the vertex shader code that need to have their names remapped.
  115048. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  115049. * "var_name" should be either: worldPos or vNormalW
  115050. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  115051. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  115052. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  115053. */
  115054. remappedVariables?: string[];
  115055. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  115056. standalone?: boolean;
  115057. }
  115058. /**
  115059. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  115060. */
  115061. export class ShadowDepthWrapper {
  115062. private _scene;
  115063. private _options?;
  115064. private _baseMaterial;
  115065. private _onEffectCreatedObserver;
  115066. private _subMeshToEffect;
  115067. private _subMeshToDepthEffect;
  115068. private _meshes;
  115069. /** @hidden */
  115070. _matriceNames: any;
  115071. /** Gets the standalone status of the wrapper */
  115072. get standalone(): boolean;
  115073. /** Gets the base material the wrapper is built upon */
  115074. get baseMaterial(): Material;
  115075. /**
  115076. * Instantiate a new shadow depth wrapper.
  115077. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  115078. * generate the shadow depth map. For more information, please refer to the documentation:
  115079. * https://doc.babylonjs.com/babylon101/shadows
  115080. * @param baseMaterial Material to wrap
  115081. * @param scene Define the scene the material belongs to
  115082. * @param options Options used to create the wrapper
  115083. */
  115084. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  115085. /**
  115086. * Gets the effect to use to generate the depth map
  115087. * @param subMesh subMesh to get the effect for
  115088. * @param shadowGenerator shadow generator to get the effect for
  115089. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  115090. */
  115091. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  115092. /**
  115093. * Specifies that the submesh is ready to be used for depth rendering
  115094. * @param subMesh submesh to check
  115095. * @param defines the list of defines to take into account when checking the effect
  115096. * @param shadowGenerator combined with subMesh, it defines the effect to check
  115097. * @param useInstances specifies that instances should be used
  115098. * @returns a boolean indicating that the submesh is ready or not
  115099. */
  115100. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  115101. /**
  115102. * Disposes the resources
  115103. */
  115104. dispose(): void;
  115105. private _makeEffect;
  115106. }
  115107. }
  115108. declare module BABYLON {
  115109. /**
  115110. * Options for compiling materials.
  115111. */
  115112. export interface IMaterialCompilationOptions {
  115113. /**
  115114. * Defines whether clip planes are enabled.
  115115. */
  115116. clipPlane: boolean;
  115117. /**
  115118. * Defines whether instances are enabled.
  115119. */
  115120. useInstances: boolean;
  115121. }
  115122. /**
  115123. * Options passed when calling customShaderNameResolve
  115124. */
  115125. export interface ICustomShaderNameResolveOptions {
  115126. /**
  115127. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  115128. */
  115129. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  115130. }
  115131. /**
  115132. * Base class for the main features of a material in Babylon.js
  115133. */
  115134. export class Material implements IAnimatable {
  115135. /**
  115136. * Returns the triangle fill mode
  115137. */
  115138. static readonly TriangleFillMode: number;
  115139. /**
  115140. * Returns the wireframe mode
  115141. */
  115142. static readonly WireFrameFillMode: number;
  115143. /**
  115144. * Returns the point fill mode
  115145. */
  115146. static readonly PointFillMode: number;
  115147. /**
  115148. * Returns the point list draw mode
  115149. */
  115150. static readonly PointListDrawMode: number;
  115151. /**
  115152. * Returns the line list draw mode
  115153. */
  115154. static readonly LineListDrawMode: number;
  115155. /**
  115156. * Returns the line loop draw mode
  115157. */
  115158. static readonly LineLoopDrawMode: number;
  115159. /**
  115160. * Returns the line strip draw mode
  115161. */
  115162. static readonly LineStripDrawMode: number;
  115163. /**
  115164. * Returns the triangle strip draw mode
  115165. */
  115166. static readonly TriangleStripDrawMode: number;
  115167. /**
  115168. * Returns the triangle fan draw mode
  115169. */
  115170. static readonly TriangleFanDrawMode: number;
  115171. /**
  115172. * Stores the clock-wise side orientation
  115173. */
  115174. static readonly ClockWiseSideOrientation: number;
  115175. /**
  115176. * Stores the counter clock-wise side orientation
  115177. */
  115178. static readonly CounterClockWiseSideOrientation: number;
  115179. /**
  115180. * The dirty texture flag value
  115181. */
  115182. static readonly TextureDirtyFlag: number;
  115183. /**
  115184. * The dirty light flag value
  115185. */
  115186. static readonly LightDirtyFlag: number;
  115187. /**
  115188. * The dirty fresnel flag value
  115189. */
  115190. static readonly FresnelDirtyFlag: number;
  115191. /**
  115192. * The dirty attribute flag value
  115193. */
  115194. static readonly AttributesDirtyFlag: number;
  115195. /**
  115196. * The dirty misc flag value
  115197. */
  115198. static readonly MiscDirtyFlag: number;
  115199. /**
  115200. * The dirty prepass flag value
  115201. */
  115202. static readonly PrePassDirtyFlag: number;
  115203. /**
  115204. * The all dirty flag value
  115205. */
  115206. static readonly AllDirtyFlag: number;
  115207. /**
  115208. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115209. */
  115210. static readonly MATERIAL_OPAQUE: number;
  115211. /**
  115212. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115213. */
  115214. static readonly MATERIAL_ALPHATEST: number;
  115215. /**
  115216. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115217. */
  115218. static readonly MATERIAL_ALPHABLEND: number;
  115219. /**
  115220. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115221. * They are also discarded below the alpha cutoff threshold to improve performances.
  115222. */
  115223. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  115224. /**
  115225. * The Whiteout method is used to blend normals.
  115226. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  115227. */
  115228. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  115229. /**
  115230. * The Reoriented Normal Mapping method is used to blend normals.
  115231. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  115232. */
  115233. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  115234. /**
  115235. * Custom callback helping to override the default shader used in the material.
  115236. */
  115237. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  115238. /**
  115239. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  115240. */
  115241. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  115242. /**
  115243. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  115244. * This means that the material can keep using a previous shader while a new one is being compiled.
  115245. * This is mostly used when shader parallel compilation is supported (true by default)
  115246. */
  115247. allowShaderHotSwapping: boolean;
  115248. /**
  115249. * The ID of the material
  115250. */
  115251. id: string;
  115252. /**
  115253. * Gets or sets the unique id of the material
  115254. */
  115255. uniqueId: number;
  115256. /**
  115257. * The name of the material
  115258. */
  115259. name: string;
  115260. /**
  115261. * Gets or sets user defined metadata
  115262. */
  115263. metadata: any;
  115264. /**
  115265. * For internal use only. Please do not use.
  115266. */
  115267. reservedDataStore: any;
  115268. /**
  115269. * Specifies if the ready state should be checked on each call
  115270. */
  115271. checkReadyOnEveryCall: boolean;
  115272. /**
  115273. * Specifies if the ready state should be checked once
  115274. */
  115275. checkReadyOnlyOnce: boolean;
  115276. /**
  115277. * The state of the material
  115278. */
  115279. state: string;
  115280. /**
  115281. * If the material can be rendered to several textures with MRT extension
  115282. */
  115283. get canRenderToMRT(): boolean;
  115284. /**
  115285. * The alpha value of the material
  115286. */
  115287. protected _alpha: number;
  115288. /**
  115289. * List of inspectable custom properties (used by the Inspector)
  115290. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  115291. */
  115292. inspectableCustomProperties: IInspectable[];
  115293. /**
  115294. * Sets the alpha value of the material
  115295. */
  115296. set alpha(value: number);
  115297. /**
  115298. * Gets the alpha value of the material
  115299. */
  115300. get alpha(): number;
  115301. /**
  115302. * Specifies if back face culling is enabled
  115303. */
  115304. protected _backFaceCulling: boolean;
  115305. /**
  115306. * Sets the back-face culling state
  115307. */
  115308. set backFaceCulling(value: boolean);
  115309. /**
  115310. * Gets the back-face culling state
  115311. */
  115312. get backFaceCulling(): boolean;
  115313. /**
  115314. * Stores the value for side orientation
  115315. */
  115316. sideOrientation: number;
  115317. /**
  115318. * Callback triggered when the material is compiled
  115319. */
  115320. onCompiled: Nullable<(effect: Effect) => void>;
  115321. /**
  115322. * Callback triggered when an error occurs
  115323. */
  115324. onError: Nullable<(effect: Effect, errors: string) => void>;
  115325. /**
  115326. * Callback triggered to get the render target textures
  115327. */
  115328. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  115329. /**
  115330. * Gets a boolean indicating that current material needs to register RTT
  115331. */
  115332. get hasRenderTargetTextures(): boolean;
  115333. /**
  115334. * Specifies if the material should be serialized
  115335. */
  115336. doNotSerialize: boolean;
  115337. /**
  115338. * @hidden
  115339. */
  115340. _storeEffectOnSubMeshes: boolean;
  115341. /**
  115342. * Stores the animations for the material
  115343. */
  115344. animations: Nullable<Array<Animation>>;
  115345. /**
  115346. * An event triggered when the material is disposed
  115347. */
  115348. onDisposeObservable: Observable<Material>;
  115349. /**
  115350. * An observer which watches for dispose events
  115351. */
  115352. private _onDisposeObserver;
  115353. private _onUnBindObservable;
  115354. /**
  115355. * Called during a dispose event
  115356. */
  115357. set onDispose(callback: () => void);
  115358. private _onBindObservable;
  115359. /**
  115360. * An event triggered when the material is bound
  115361. */
  115362. get onBindObservable(): Observable<AbstractMesh>;
  115363. /**
  115364. * An observer which watches for bind events
  115365. */
  115366. private _onBindObserver;
  115367. /**
  115368. * Called during a bind event
  115369. */
  115370. set onBind(callback: (Mesh: AbstractMesh) => void);
  115371. /**
  115372. * An event triggered when the material is unbound
  115373. */
  115374. get onUnBindObservable(): Observable<Material>;
  115375. protected _onEffectCreatedObservable: Nullable<Observable<{
  115376. effect: Effect;
  115377. subMesh: Nullable<SubMesh>;
  115378. }>>;
  115379. /**
  115380. * An event triggered when the effect is (re)created
  115381. */
  115382. get onEffectCreatedObservable(): Observable<{
  115383. effect: Effect;
  115384. subMesh: Nullable<SubMesh>;
  115385. }>;
  115386. /**
  115387. * Stores the value of the alpha mode
  115388. */
  115389. private _alphaMode;
  115390. /**
  115391. * Sets the value of the alpha mode.
  115392. *
  115393. * | Value | Type | Description |
  115394. * | --- | --- | --- |
  115395. * | 0 | ALPHA_DISABLE | |
  115396. * | 1 | ALPHA_ADD | |
  115397. * | 2 | ALPHA_COMBINE | |
  115398. * | 3 | ALPHA_SUBTRACT | |
  115399. * | 4 | ALPHA_MULTIPLY | |
  115400. * | 5 | ALPHA_MAXIMIZED | |
  115401. * | 6 | ALPHA_ONEONE | |
  115402. * | 7 | ALPHA_PREMULTIPLIED | |
  115403. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  115404. * | 9 | ALPHA_INTERPOLATE | |
  115405. * | 10 | ALPHA_SCREENMODE | |
  115406. *
  115407. */
  115408. set alphaMode(value: number);
  115409. /**
  115410. * Gets the value of the alpha mode
  115411. */
  115412. get alphaMode(): number;
  115413. /**
  115414. * Stores the state of the need depth pre-pass value
  115415. */
  115416. private _needDepthPrePass;
  115417. /**
  115418. * Sets the need depth pre-pass value
  115419. */
  115420. set needDepthPrePass(value: boolean);
  115421. /**
  115422. * Gets the depth pre-pass value
  115423. */
  115424. get needDepthPrePass(): boolean;
  115425. /**
  115426. * Specifies if depth writing should be disabled
  115427. */
  115428. disableDepthWrite: boolean;
  115429. /**
  115430. * Specifies if color writing should be disabled
  115431. */
  115432. disableColorWrite: boolean;
  115433. /**
  115434. * Specifies if depth writing should be forced
  115435. */
  115436. forceDepthWrite: boolean;
  115437. /**
  115438. * Specifies the depth function that should be used. 0 means the default engine function
  115439. */
  115440. depthFunction: number;
  115441. /**
  115442. * Specifies if there should be a separate pass for culling
  115443. */
  115444. separateCullingPass: boolean;
  115445. /**
  115446. * Stores the state specifing if fog should be enabled
  115447. */
  115448. private _fogEnabled;
  115449. /**
  115450. * Sets the state for enabling fog
  115451. */
  115452. set fogEnabled(value: boolean);
  115453. /**
  115454. * Gets the value of the fog enabled state
  115455. */
  115456. get fogEnabled(): boolean;
  115457. /**
  115458. * Stores the size of points
  115459. */
  115460. pointSize: number;
  115461. /**
  115462. * Stores the z offset value
  115463. */
  115464. zOffset: number;
  115465. get wireframe(): boolean;
  115466. /**
  115467. * Sets the state of wireframe mode
  115468. */
  115469. set wireframe(value: boolean);
  115470. /**
  115471. * Gets the value specifying if point clouds are enabled
  115472. */
  115473. get pointsCloud(): boolean;
  115474. /**
  115475. * Sets the state of point cloud mode
  115476. */
  115477. set pointsCloud(value: boolean);
  115478. /**
  115479. * Gets the material fill mode
  115480. */
  115481. get fillMode(): number;
  115482. /**
  115483. * Sets the material fill mode
  115484. */
  115485. set fillMode(value: number);
  115486. /**
  115487. * @hidden
  115488. * Stores the effects for the material
  115489. */
  115490. _effect: Nullable<Effect>;
  115491. /**
  115492. * Specifies if uniform buffers should be used
  115493. */
  115494. private _useUBO;
  115495. /**
  115496. * Stores a reference to the scene
  115497. */
  115498. private _scene;
  115499. private _needToBindSceneUbo;
  115500. /**
  115501. * Stores the fill mode state
  115502. */
  115503. private _fillMode;
  115504. /**
  115505. * Specifies if the depth write state should be cached
  115506. */
  115507. private _cachedDepthWriteState;
  115508. /**
  115509. * Specifies if the color write state should be cached
  115510. */
  115511. private _cachedColorWriteState;
  115512. /**
  115513. * Specifies if the depth function state should be cached
  115514. */
  115515. private _cachedDepthFunctionState;
  115516. /**
  115517. * Stores the uniform buffer
  115518. */
  115519. protected _uniformBuffer: UniformBuffer;
  115520. /** @hidden */
  115521. _indexInSceneMaterialArray: number;
  115522. /** @hidden */
  115523. meshMap: Nullable<{
  115524. [id: string]: AbstractMesh | undefined;
  115525. }>;
  115526. /**
  115527. * Creates a material instance
  115528. * @param name defines the name of the material
  115529. * @param scene defines the scene to reference
  115530. * @param doNotAdd specifies if the material should be added to the scene
  115531. */
  115532. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  115533. /**
  115534. * Returns a string representation of the current material
  115535. * @param fullDetails defines a boolean indicating which levels of logging is desired
  115536. * @returns a string with material information
  115537. */
  115538. toString(fullDetails?: boolean): string;
  115539. /**
  115540. * Gets the class name of the material
  115541. * @returns a string with the class name of the material
  115542. */
  115543. getClassName(): string;
  115544. /**
  115545. * Specifies if updates for the material been locked
  115546. */
  115547. get isFrozen(): boolean;
  115548. /**
  115549. * Locks updates for the material
  115550. */
  115551. freeze(): void;
  115552. /**
  115553. * Unlocks updates for the material
  115554. */
  115555. unfreeze(): void;
  115556. /**
  115557. * Specifies if the material is ready to be used
  115558. * @param mesh defines the mesh to check
  115559. * @param useInstances specifies if instances should be used
  115560. * @returns a boolean indicating if the material is ready to be used
  115561. */
  115562. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  115563. /**
  115564. * Specifies that the submesh is ready to be used
  115565. * @param mesh defines the mesh to check
  115566. * @param subMesh defines which submesh to check
  115567. * @param useInstances specifies that instances should be used
  115568. * @returns a boolean indicating that the submesh is ready or not
  115569. */
  115570. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115571. /**
  115572. * Returns the material effect
  115573. * @returns the effect associated with the material
  115574. */
  115575. getEffect(): Nullable<Effect>;
  115576. /**
  115577. * Returns the current scene
  115578. * @returns a Scene
  115579. */
  115580. getScene(): Scene;
  115581. /**
  115582. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115583. */
  115584. protected _forceAlphaTest: boolean;
  115585. /**
  115586. * The transparency mode of the material.
  115587. */
  115588. protected _transparencyMode: Nullable<number>;
  115589. /**
  115590. * Gets the current transparency mode.
  115591. */
  115592. get transparencyMode(): Nullable<number>;
  115593. /**
  115594. * Sets the transparency mode of the material.
  115595. *
  115596. * | Value | Type | Description |
  115597. * | ----- | ----------------------------------- | ----------- |
  115598. * | 0 | OPAQUE | |
  115599. * | 1 | ALPHATEST | |
  115600. * | 2 | ALPHABLEND | |
  115601. * | 3 | ALPHATESTANDBLEND | |
  115602. *
  115603. */
  115604. set transparencyMode(value: Nullable<number>);
  115605. /**
  115606. * Returns true if alpha blending should be disabled.
  115607. */
  115608. protected get _disableAlphaBlending(): boolean;
  115609. /**
  115610. * Specifies whether or not this material should be rendered in alpha blend mode.
  115611. * @returns a boolean specifying if alpha blending is needed
  115612. */
  115613. needAlphaBlending(): boolean;
  115614. /**
  115615. * Specifies if the mesh will require alpha blending
  115616. * @param mesh defines the mesh to check
  115617. * @returns a boolean specifying if alpha blending is needed for the mesh
  115618. */
  115619. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115620. /**
  115621. * Specifies whether or not this material should be rendered in alpha test mode.
  115622. * @returns a boolean specifying if an alpha test is needed.
  115623. */
  115624. needAlphaTesting(): boolean;
  115625. /**
  115626. * Specifies if material alpha testing should be turned on for the mesh
  115627. * @param mesh defines the mesh to check
  115628. */
  115629. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  115630. /**
  115631. * Gets the texture used for the alpha test
  115632. * @returns the texture to use for alpha testing
  115633. */
  115634. getAlphaTestTexture(): Nullable<BaseTexture>;
  115635. /**
  115636. * Marks the material to indicate that it needs to be re-calculated
  115637. */
  115638. markDirty(): void;
  115639. /** @hidden */
  115640. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  115641. /**
  115642. * Binds the material to the mesh
  115643. * @param world defines the world transformation matrix
  115644. * @param mesh defines the mesh to bind the material to
  115645. */
  115646. bind(world: Matrix, mesh?: Mesh): void;
  115647. /**
  115648. * Binds the submesh to the material
  115649. * @param world defines the world transformation matrix
  115650. * @param mesh defines the mesh containing the submesh
  115651. * @param subMesh defines the submesh to bind the material to
  115652. */
  115653. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115654. /**
  115655. * Binds the world matrix to the material
  115656. * @param world defines the world transformation matrix
  115657. */
  115658. bindOnlyWorldMatrix(world: Matrix): void;
  115659. /**
  115660. * Update the scene ubo before it can be used in rendering processing
  115661. * @param scene the scene to retrieve the ubo from
  115662. * @returns the scene UniformBuffer
  115663. */
  115664. finalizeSceneUbo(scene: Scene): UniformBuffer;
  115665. /**
  115666. * Binds the scene's uniform buffer to the effect.
  115667. * @param effect defines the effect to bind to the scene uniform buffer
  115668. * @param sceneUbo defines the uniform buffer storing scene data
  115669. */
  115670. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  115671. /**
  115672. * Binds the view matrix to the effect
  115673. * @param effect defines the effect to bind the view matrix to
  115674. */
  115675. bindView(effect: Effect): void;
  115676. /**
  115677. * Binds the view projection and projection matrices to the effect
  115678. * @param effect defines the effect to bind the view projection and projection matrices to
  115679. */
  115680. bindViewProjection(effect: Effect): void;
  115681. /**
  115682. * Binds the view matrix to the effect
  115683. * @param effect defines the effect to bind the view matrix to
  115684. * @param variableName name of the shader variable that will hold the eye position
  115685. */
  115686. bindEyePosition(effect: Effect, variableName?: string): void;
  115687. /**
  115688. * Processes to execute after binding the material to a mesh
  115689. * @param mesh defines the rendered mesh
  115690. */
  115691. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  115692. /**
  115693. * Unbinds the material from the mesh
  115694. */
  115695. unbind(): void;
  115696. /**
  115697. * Gets the active textures from the material
  115698. * @returns an array of textures
  115699. */
  115700. getActiveTextures(): BaseTexture[];
  115701. /**
  115702. * Specifies if the material uses a texture
  115703. * @param texture defines the texture to check against the material
  115704. * @returns a boolean specifying if the material uses the texture
  115705. */
  115706. hasTexture(texture: BaseTexture): boolean;
  115707. /**
  115708. * Makes a duplicate of the material, and gives it a new name
  115709. * @param name defines the new name for the duplicated material
  115710. * @returns the cloned material
  115711. */
  115712. clone(name: string): Nullable<Material>;
  115713. /**
  115714. * Gets the meshes bound to the material
  115715. * @returns an array of meshes bound to the material
  115716. */
  115717. getBindedMeshes(): AbstractMesh[];
  115718. /**
  115719. * Force shader compilation
  115720. * @param mesh defines the mesh associated with this material
  115721. * @param onCompiled defines a function to execute once the material is compiled
  115722. * @param options defines the options to configure the compilation
  115723. * @param onError defines a function to execute if the material fails compiling
  115724. */
  115725. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  115726. /**
  115727. * Force shader compilation
  115728. * @param mesh defines the mesh that will use this material
  115729. * @param options defines additional options for compiling the shaders
  115730. * @returns a promise that resolves when the compilation completes
  115731. */
  115732. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  115733. private static readonly _AllDirtyCallBack;
  115734. private static readonly _ImageProcessingDirtyCallBack;
  115735. private static readonly _TextureDirtyCallBack;
  115736. private static readonly _FresnelDirtyCallBack;
  115737. private static readonly _MiscDirtyCallBack;
  115738. private static readonly _PrePassDirtyCallBack;
  115739. private static readonly _LightsDirtyCallBack;
  115740. private static readonly _AttributeDirtyCallBack;
  115741. private static _FresnelAndMiscDirtyCallBack;
  115742. private static _TextureAndMiscDirtyCallBack;
  115743. private static readonly _DirtyCallbackArray;
  115744. private static readonly _RunDirtyCallBacks;
  115745. /**
  115746. * Marks a define in the material to indicate that it needs to be re-computed
  115747. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  115748. */
  115749. markAsDirty(flag: number): void;
  115750. /**
  115751. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  115752. * @param func defines a function which checks material defines against the submeshes
  115753. */
  115754. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  115755. /**
  115756. * Indicates that the scene should check if the rendering now needs a prepass
  115757. */
  115758. protected _markScenePrePassDirty(): void;
  115759. /**
  115760. * Indicates that we need to re-calculated for all submeshes
  115761. */
  115762. protected _markAllSubMeshesAsAllDirty(): void;
  115763. /**
  115764. * Indicates that image processing needs to be re-calculated for all submeshes
  115765. */
  115766. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  115767. /**
  115768. * Indicates that textures need to be re-calculated for all submeshes
  115769. */
  115770. protected _markAllSubMeshesAsTexturesDirty(): void;
  115771. /**
  115772. * Indicates that fresnel needs to be re-calculated for all submeshes
  115773. */
  115774. protected _markAllSubMeshesAsFresnelDirty(): void;
  115775. /**
  115776. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  115777. */
  115778. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  115779. /**
  115780. * Indicates that lights need to be re-calculated for all submeshes
  115781. */
  115782. protected _markAllSubMeshesAsLightsDirty(): void;
  115783. /**
  115784. * Indicates that attributes need to be re-calculated for all submeshes
  115785. */
  115786. protected _markAllSubMeshesAsAttributesDirty(): void;
  115787. /**
  115788. * Indicates that misc needs to be re-calculated for all submeshes
  115789. */
  115790. protected _markAllSubMeshesAsMiscDirty(): void;
  115791. /**
  115792. * Indicates that prepass needs to be re-calculated for all submeshes
  115793. */
  115794. protected _markAllSubMeshesAsPrePassDirty(): void;
  115795. /**
  115796. * Indicates that textures and misc need to be re-calculated for all submeshes
  115797. */
  115798. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  115799. /**
  115800. * Sets the required values to the prepass renderer.
  115801. * @param prePassRenderer defines the prepass renderer to setup.
  115802. * @returns true if the pre pass is needed.
  115803. */
  115804. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  115805. /**
  115806. * Disposes the material
  115807. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115808. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115809. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115810. */
  115811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115812. /** @hidden */
  115813. private releaseVertexArrayObject;
  115814. /**
  115815. * Serializes this material
  115816. * @returns the serialized material object
  115817. */
  115818. serialize(): any;
  115819. /**
  115820. * Creates a material from parsed material data
  115821. * @param parsedMaterial defines parsed material data
  115822. * @param scene defines the hosting scene
  115823. * @param rootUrl defines the root URL to use to load textures
  115824. * @returns a new material
  115825. */
  115826. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  115827. }
  115828. }
  115829. declare module BABYLON {
  115830. /**
  115831. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115832. * separate meshes. This can be use to improve performances.
  115833. * @see https://doc.babylonjs.com/how_to/multi_materials
  115834. */
  115835. export class MultiMaterial extends Material {
  115836. private _subMaterials;
  115837. /**
  115838. * Gets or Sets the list of Materials used within the multi material.
  115839. * They need to be ordered according to the submeshes order in the associated mesh
  115840. */
  115841. get subMaterials(): Nullable<Material>[];
  115842. set subMaterials(value: Nullable<Material>[]);
  115843. /**
  115844. * Function used to align with Node.getChildren()
  115845. * @returns the list of Materials used within the multi material
  115846. */
  115847. getChildren(): Nullable<Material>[];
  115848. /**
  115849. * Instantiates a new Multi Material
  115850. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115851. * separate meshes. This can be use to improve performances.
  115852. * @see https://doc.babylonjs.com/how_to/multi_materials
  115853. * @param name Define the name in the scene
  115854. * @param scene Define the scene the material belongs to
  115855. */
  115856. constructor(name: string, scene: Scene);
  115857. private _hookArray;
  115858. /**
  115859. * Get one of the submaterial by its index in the submaterials array
  115860. * @param index The index to look the sub material at
  115861. * @returns The Material if the index has been defined
  115862. */
  115863. getSubMaterial(index: number): Nullable<Material>;
  115864. /**
  115865. * Get the list of active textures for the whole sub materials list.
  115866. * @returns All the textures that will be used during the rendering
  115867. */
  115868. getActiveTextures(): BaseTexture[];
  115869. /**
  115870. * Specifies if any sub-materials of this multi-material use a given texture.
  115871. * @param texture Defines the texture to check against this multi-material's sub-materials.
  115872. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  115873. */
  115874. hasTexture(texture: BaseTexture): boolean;
  115875. /**
  115876. * Gets the current class name of the material e.g. "MultiMaterial"
  115877. * Mainly use in serialization.
  115878. * @returns the class name
  115879. */
  115880. getClassName(): string;
  115881. /**
  115882. * Checks if the material is ready to render the requested sub mesh
  115883. * @param mesh Define the mesh the submesh belongs to
  115884. * @param subMesh Define the sub mesh to look readyness for
  115885. * @param useInstances Define whether or not the material is used with instances
  115886. * @returns true if ready, otherwise false
  115887. */
  115888. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115889. /**
  115890. * Clones the current material and its related sub materials
  115891. * @param name Define the name of the newly cloned material
  115892. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  115893. * @returns the cloned material
  115894. */
  115895. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  115896. /**
  115897. * Serializes the materials into a JSON representation.
  115898. * @returns the JSON representation
  115899. */
  115900. serialize(): any;
  115901. /**
  115902. * Dispose the material and release its associated resources
  115903. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  115904. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  115905. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  115906. */
  115907. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  115908. /**
  115909. * Creates a MultiMaterial from parsed MultiMaterial data.
  115910. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  115911. * @param scene defines the hosting scene
  115912. * @returns a new MultiMaterial
  115913. */
  115914. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  115915. }
  115916. }
  115917. declare module BABYLON {
  115918. /** @hidden */
  115919. export interface ICustomEffect {
  115920. effect: Effect;
  115921. defines: string;
  115922. }
  115923. /**
  115924. * Defines a subdivision inside a mesh
  115925. */
  115926. export class SubMesh implements ICullable {
  115927. /** the material index to use */
  115928. materialIndex: number;
  115929. /** vertex index start */
  115930. verticesStart: number;
  115931. /** vertices count */
  115932. verticesCount: number;
  115933. /** index start */
  115934. indexStart: number;
  115935. /** indices count */
  115936. indexCount: number;
  115937. /** @hidden */
  115938. _materialDefines: Nullable<MaterialDefines>;
  115939. /** @hidden */
  115940. _materialEffect: Nullable<Effect>;
  115941. /** @hidden */
  115942. _effectOverride: Nullable<Effect>;
  115943. private _customEffects;
  115944. /**
  115945. * Gets material defines used by the effect associated to the sub mesh
  115946. */
  115947. get materialDefines(): Nullable<MaterialDefines>;
  115948. /**
  115949. * Sets material defines used by the effect associated to the sub mesh
  115950. */
  115951. set materialDefines(defines: Nullable<MaterialDefines>);
  115952. /** @hidden */
  115953. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  115954. /** @hidden */
  115955. _removeCustomEffect(name: string): void;
  115956. /**
  115957. * Gets associated effect
  115958. */
  115959. get effect(): Nullable<Effect>;
  115960. /**
  115961. * Sets associated effect (effect used to render this submesh)
  115962. * @param effect defines the effect to associate with
  115963. * @param defines defines the set of defines used to compile this effect
  115964. */
  115965. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  115966. /** @hidden */
  115967. _linesIndexCount: number;
  115968. private _mesh;
  115969. private _renderingMesh;
  115970. private _boundingInfo;
  115971. private _linesIndexBuffer;
  115972. /** @hidden */
  115973. _lastColliderWorldVertices: Nullable<Vector3[]>;
  115974. /** @hidden */
  115975. _trianglePlanes: Plane[];
  115976. /** @hidden */
  115977. _lastColliderTransformMatrix: Nullable<Matrix>;
  115978. /** @hidden */
  115979. _renderId: number;
  115980. /** @hidden */
  115981. _alphaIndex: number;
  115982. /** @hidden */
  115983. _distanceToCamera: number;
  115984. /** @hidden */
  115985. _id: number;
  115986. private _currentMaterial;
  115987. /**
  115988. * Add a new submesh to a mesh
  115989. * @param materialIndex defines the material index to use
  115990. * @param verticesStart defines vertex index start
  115991. * @param verticesCount defines vertices count
  115992. * @param indexStart defines index start
  115993. * @param indexCount defines indices count
  115994. * @param mesh defines the parent mesh
  115995. * @param renderingMesh defines an optional rendering mesh
  115996. * @param createBoundingBox defines if bounding box should be created for this submesh
  115997. * @returns the new submesh
  115998. */
  115999. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  116000. /**
  116001. * Creates a new submesh
  116002. * @param materialIndex defines the material index to use
  116003. * @param verticesStart defines vertex index start
  116004. * @param verticesCount defines vertices count
  116005. * @param indexStart defines index start
  116006. * @param indexCount defines indices count
  116007. * @param mesh defines the parent mesh
  116008. * @param renderingMesh defines an optional rendering mesh
  116009. * @param createBoundingBox defines if bounding box should be created for this submesh
  116010. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  116011. */
  116012. constructor(
  116013. /** the material index to use */
  116014. materialIndex: number,
  116015. /** vertex index start */
  116016. verticesStart: number,
  116017. /** vertices count */
  116018. verticesCount: number,
  116019. /** index start */
  116020. indexStart: number,
  116021. /** indices count */
  116022. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  116023. /**
  116024. * Returns true if this submesh covers the entire parent mesh
  116025. * @ignorenaming
  116026. */
  116027. get IsGlobal(): boolean;
  116028. /**
  116029. * Returns the submesh BoudingInfo object
  116030. * @returns current bounding info (or mesh's one if the submesh is global)
  116031. */
  116032. getBoundingInfo(): BoundingInfo;
  116033. /**
  116034. * Sets the submesh BoundingInfo
  116035. * @param boundingInfo defines the new bounding info to use
  116036. * @returns the SubMesh
  116037. */
  116038. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  116039. /**
  116040. * Returns the mesh of the current submesh
  116041. * @return the parent mesh
  116042. */
  116043. getMesh(): AbstractMesh;
  116044. /**
  116045. * Returns the rendering mesh of the submesh
  116046. * @returns the rendering mesh (could be different from parent mesh)
  116047. */
  116048. getRenderingMesh(): Mesh;
  116049. /**
  116050. * Returns the replacement mesh of the submesh
  116051. * @returns the replacement mesh (could be different from parent mesh)
  116052. */
  116053. getReplacementMesh(): Nullable<AbstractMesh>;
  116054. /**
  116055. * Returns the effective mesh of the submesh
  116056. * @returns the effective mesh (could be different from parent mesh)
  116057. */
  116058. getEffectiveMesh(): AbstractMesh;
  116059. /**
  116060. * Returns the submesh material
  116061. * @returns null or the current material
  116062. */
  116063. getMaterial(): Nullable<Material>;
  116064. private _IsMultiMaterial;
  116065. /**
  116066. * Sets a new updated BoundingInfo object to the submesh
  116067. * @param data defines an optional position array to use to determine the bounding info
  116068. * @returns the SubMesh
  116069. */
  116070. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  116071. /** @hidden */
  116072. _checkCollision(collider: Collider): boolean;
  116073. /**
  116074. * Updates the submesh BoundingInfo
  116075. * @param world defines the world matrix to use to update the bounding info
  116076. * @returns the submesh
  116077. */
  116078. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  116079. /**
  116080. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  116081. * @param frustumPlanes defines the frustum planes
  116082. * @returns true if the submesh is intersecting with the frustum
  116083. */
  116084. isInFrustum(frustumPlanes: Plane[]): boolean;
  116085. /**
  116086. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  116087. * @param frustumPlanes defines the frustum planes
  116088. * @returns true if the submesh is inside the frustum
  116089. */
  116090. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116091. /**
  116092. * Renders the submesh
  116093. * @param enableAlphaMode defines if alpha needs to be used
  116094. * @returns the submesh
  116095. */
  116096. render(enableAlphaMode: boolean): SubMesh;
  116097. /**
  116098. * @hidden
  116099. */
  116100. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  116101. /**
  116102. * Checks if the submesh intersects with a ray
  116103. * @param ray defines the ray to test
  116104. * @returns true is the passed ray intersects the submesh bounding box
  116105. */
  116106. canIntersects(ray: Ray): boolean;
  116107. /**
  116108. * Intersects current submesh with a ray
  116109. * @param ray defines the ray to test
  116110. * @param positions defines mesh's positions array
  116111. * @param indices defines mesh's indices array
  116112. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116113. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116114. * @returns intersection info or null if no intersection
  116115. */
  116116. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  116117. /** @hidden */
  116118. private _intersectLines;
  116119. /** @hidden */
  116120. private _intersectUnIndexedLines;
  116121. /** @hidden */
  116122. private _intersectTriangles;
  116123. /** @hidden */
  116124. private _intersectUnIndexedTriangles;
  116125. /** @hidden */
  116126. _rebuild(): void;
  116127. /**
  116128. * Creates a new submesh from the passed mesh
  116129. * @param newMesh defines the new hosting mesh
  116130. * @param newRenderingMesh defines an optional rendering mesh
  116131. * @returns the new submesh
  116132. */
  116133. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  116134. /**
  116135. * Release associated resources
  116136. */
  116137. dispose(): void;
  116138. /**
  116139. * Gets the class name
  116140. * @returns the string "SubMesh".
  116141. */
  116142. getClassName(): string;
  116143. /**
  116144. * Creates a new submesh from indices data
  116145. * @param materialIndex the index of the main mesh material
  116146. * @param startIndex the index where to start the copy in the mesh indices array
  116147. * @param indexCount the number of indices to copy then from the startIndex
  116148. * @param mesh the main mesh to create the submesh from
  116149. * @param renderingMesh the optional rendering mesh
  116150. * @returns a new submesh
  116151. */
  116152. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  116153. }
  116154. }
  116155. declare module BABYLON {
  116156. /**
  116157. * Class used to represent data loading progression
  116158. */
  116159. export class SceneLoaderFlags {
  116160. private static _ForceFullSceneLoadingForIncremental;
  116161. private static _ShowLoadingScreen;
  116162. private static _CleanBoneMatrixWeights;
  116163. private static _loggingLevel;
  116164. /**
  116165. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116166. */
  116167. static get ForceFullSceneLoadingForIncremental(): boolean;
  116168. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116169. /**
  116170. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116171. */
  116172. static get ShowLoadingScreen(): boolean;
  116173. static set ShowLoadingScreen(value: boolean);
  116174. /**
  116175. * Defines the current logging level (while loading the scene)
  116176. * @ignorenaming
  116177. */
  116178. static get loggingLevel(): number;
  116179. static set loggingLevel(value: number);
  116180. /**
  116181. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116182. */
  116183. static get CleanBoneMatrixWeights(): boolean;
  116184. static set CleanBoneMatrixWeights(value: boolean);
  116185. }
  116186. }
  116187. declare module BABYLON {
  116188. /**
  116189. * Class used to store geometry data (vertex buffers + index buffer)
  116190. */
  116191. export class Geometry implements IGetSetVerticesData {
  116192. /**
  116193. * Gets or sets the ID of the geometry
  116194. */
  116195. id: string;
  116196. /**
  116197. * Gets or sets the unique ID of the geometry
  116198. */
  116199. uniqueId: number;
  116200. /**
  116201. * Gets the delay loading state of the geometry (none by default which means not delayed)
  116202. */
  116203. delayLoadState: number;
  116204. /**
  116205. * Gets the file containing the data to load when running in delay load state
  116206. */
  116207. delayLoadingFile: Nullable<string>;
  116208. /**
  116209. * Callback called when the geometry is updated
  116210. */
  116211. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  116212. private _scene;
  116213. private _engine;
  116214. private _meshes;
  116215. private _totalVertices;
  116216. /** @hidden */
  116217. _indices: IndicesArray;
  116218. /** @hidden */
  116219. _vertexBuffers: {
  116220. [key: string]: VertexBuffer;
  116221. };
  116222. private _isDisposed;
  116223. private _extend;
  116224. private _boundingBias;
  116225. /** @hidden */
  116226. _delayInfo: Array<string>;
  116227. private _indexBuffer;
  116228. private _indexBufferIsUpdatable;
  116229. /** @hidden */
  116230. _boundingInfo: Nullable<BoundingInfo>;
  116231. /** @hidden */
  116232. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  116233. /** @hidden */
  116234. _softwareSkinningFrameId: number;
  116235. private _vertexArrayObjects;
  116236. private _updatable;
  116237. /** @hidden */
  116238. _positions: Nullable<Vector3[]>;
  116239. private _positionsCache;
  116240. /**
  116241. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  116242. */
  116243. get boundingBias(): Vector2;
  116244. /**
  116245. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  116246. */
  116247. set boundingBias(value: Vector2);
  116248. /**
  116249. * Static function used to attach a new empty geometry to a mesh
  116250. * @param mesh defines the mesh to attach the geometry to
  116251. * @returns the new Geometry
  116252. */
  116253. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  116254. /** Get the list of meshes using this geometry */
  116255. get meshes(): Mesh[];
  116256. /**
  116257. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  116258. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  116259. */
  116260. useBoundingInfoFromGeometry: boolean;
  116261. /**
  116262. * Creates a new geometry
  116263. * @param id defines the unique ID
  116264. * @param scene defines the hosting scene
  116265. * @param vertexData defines the VertexData used to get geometry data
  116266. * @param updatable defines if geometry must be updatable (false by default)
  116267. * @param mesh defines the mesh that will be associated with the geometry
  116268. */
  116269. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  116270. /**
  116271. * Gets the current extend of the geometry
  116272. */
  116273. get extend(): {
  116274. minimum: Vector3;
  116275. maximum: Vector3;
  116276. };
  116277. /**
  116278. * Gets the hosting scene
  116279. * @returns the hosting Scene
  116280. */
  116281. getScene(): Scene;
  116282. /**
  116283. * Gets the hosting engine
  116284. * @returns the hosting Engine
  116285. */
  116286. getEngine(): Engine;
  116287. /**
  116288. * Defines if the geometry is ready to use
  116289. * @returns true if the geometry is ready to be used
  116290. */
  116291. isReady(): boolean;
  116292. /**
  116293. * Gets a value indicating that the geometry should not be serialized
  116294. */
  116295. get doNotSerialize(): boolean;
  116296. /** @hidden */
  116297. _rebuild(): void;
  116298. /**
  116299. * Affects all geometry data in one call
  116300. * @param vertexData defines the geometry data
  116301. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  116302. */
  116303. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  116304. /**
  116305. * Set specific vertex data
  116306. * @param kind defines the data kind (Position, normal, etc...)
  116307. * @param data defines the vertex data to use
  116308. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  116309. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  116310. */
  116311. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  116312. /**
  116313. * Removes a specific vertex data
  116314. * @param kind defines the data kind (Position, normal, etc...)
  116315. */
  116316. removeVerticesData(kind: string): void;
  116317. /**
  116318. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  116319. * @param buffer defines the vertex buffer to use
  116320. * @param totalVertices defines the total number of vertices for position kind (could be null)
  116321. */
  116322. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  116323. /**
  116324. * Update a specific vertex buffer
  116325. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  116326. * It will do nothing if the buffer is not updatable
  116327. * @param kind defines the data kind (Position, normal, etc...)
  116328. * @param data defines the data to use
  116329. * @param offset defines the offset in the target buffer where to store the data
  116330. * @param useBytes set to true if the offset is in bytes
  116331. */
  116332. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  116333. /**
  116334. * Update a specific vertex buffer
  116335. * This function will create a new buffer if the current one is not updatable
  116336. * @param kind defines the data kind (Position, normal, etc...)
  116337. * @param data defines the data to use
  116338. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  116339. */
  116340. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  116341. private _updateBoundingInfo;
  116342. /** @hidden */
  116343. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  116344. [kind: string]: Nullable<VertexBuffer>;
  116345. }, overrideVertexArrayObjects?: {
  116346. [key: string]: WebGLVertexArrayObject;
  116347. }): void;
  116348. /**
  116349. * Gets total number of vertices
  116350. * @returns the total number of vertices
  116351. */
  116352. getTotalVertices(): number;
  116353. /**
  116354. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  116355. * @param kind defines the data kind (Position, normal, etc...)
  116356. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  116357. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  116358. * @returns a float array containing vertex data
  116359. */
  116360. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  116361. /**
  116362. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  116363. * @param kind defines the data kind (Position, normal, etc...)
  116364. * @returns true if the vertex buffer with the specified kind is updatable
  116365. */
  116366. isVertexBufferUpdatable(kind: string): boolean;
  116367. /**
  116368. * Gets a specific vertex buffer
  116369. * @param kind defines the data kind (Position, normal, etc...)
  116370. * @returns a VertexBuffer
  116371. */
  116372. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  116373. /**
  116374. * Returns all vertex buffers
  116375. * @return an object holding all vertex buffers indexed by kind
  116376. */
  116377. getVertexBuffers(): Nullable<{
  116378. [key: string]: VertexBuffer;
  116379. }>;
  116380. /**
  116381. * Gets a boolean indicating if specific vertex buffer is present
  116382. * @param kind defines the data kind (Position, normal, etc...)
  116383. * @returns true if data is present
  116384. */
  116385. isVerticesDataPresent(kind: string): boolean;
  116386. /**
  116387. * Gets a list of all attached data kinds (Position, normal, etc...)
  116388. * @returns a list of string containing all kinds
  116389. */
  116390. getVerticesDataKinds(): string[];
  116391. /**
  116392. * Update index buffer
  116393. * @param indices defines the indices to store in the index buffer
  116394. * @param offset defines the offset in the target buffer where to store the data
  116395. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  116396. */
  116397. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  116398. /**
  116399. * Creates a new index buffer
  116400. * @param indices defines the indices to store in the index buffer
  116401. * @param totalVertices defines the total number of vertices (could be null)
  116402. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  116403. */
  116404. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  116405. /**
  116406. * Return the total number of indices
  116407. * @returns the total number of indices
  116408. */
  116409. getTotalIndices(): number;
  116410. /**
  116411. * Gets the index buffer array
  116412. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  116413. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  116414. * @returns the index buffer array
  116415. */
  116416. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  116417. /**
  116418. * Gets the index buffer
  116419. * @return the index buffer
  116420. */
  116421. getIndexBuffer(): Nullable<DataBuffer>;
  116422. /** @hidden */
  116423. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  116424. /**
  116425. * Release the associated resources for a specific mesh
  116426. * @param mesh defines the source mesh
  116427. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  116428. */
  116429. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  116430. /**
  116431. * Apply current geometry to a given mesh
  116432. * @param mesh defines the mesh to apply geometry to
  116433. */
  116434. applyToMesh(mesh: Mesh): void;
  116435. private _updateExtend;
  116436. private _applyToMesh;
  116437. private notifyUpdate;
  116438. /**
  116439. * Load the geometry if it was flagged as delay loaded
  116440. * @param scene defines the hosting scene
  116441. * @param onLoaded defines a callback called when the geometry is loaded
  116442. */
  116443. load(scene: Scene, onLoaded?: () => void): void;
  116444. private _queueLoad;
  116445. /**
  116446. * Invert the geometry to move from a right handed system to a left handed one.
  116447. */
  116448. toLeftHanded(): void;
  116449. /** @hidden */
  116450. _resetPointsArrayCache(): void;
  116451. /** @hidden */
  116452. _generatePointsArray(): boolean;
  116453. /**
  116454. * Gets a value indicating if the geometry is disposed
  116455. * @returns true if the geometry was disposed
  116456. */
  116457. isDisposed(): boolean;
  116458. private _disposeVertexArrayObjects;
  116459. /**
  116460. * Free all associated resources
  116461. */
  116462. dispose(): void;
  116463. /**
  116464. * Clone the current geometry into a new geometry
  116465. * @param id defines the unique ID of the new geometry
  116466. * @returns a new geometry object
  116467. */
  116468. copy(id: string): Geometry;
  116469. /**
  116470. * Serialize the current geometry info (and not the vertices data) into a JSON object
  116471. * @return a JSON representation of the current geometry data (without the vertices data)
  116472. */
  116473. serialize(): any;
  116474. private toNumberArray;
  116475. /**
  116476. * Serialize all vertices data into a JSON oject
  116477. * @returns a JSON representation of the current geometry data
  116478. */
  116479. serializeVerticeData(): any;
  116480. /**
  116481. * Extracts a clone of a mesh geometry
  116482. * @param mesh defines the source mesh
  116483. * @param id defines the unique ID of the new geometry object
  116484. * @returns the new geometry object
  116485. */
  116486. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  116487. /**
  116488. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  116489. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  116490. * Be aware Math.random() could cause collisions, but:
  116491. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  116492. * @returns a string containing a new GUID
  116493. */
  116494. static RandomId(): string;
  116495. /** @hidden */
  116496. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  116497. private static _CleanMatricesWeights;
  116498. /**
  116499. * Create a new geometry from persisted data (Using .babylon file format)
  116500. * @param parsedVertexData defines the persisted data
  116501. * @param scene defines the hosting scene
  116502. * @param rootUrl defines the root url to use to load assets (like delayed data)
  116503. * @returns the new geometry object
  116504. */
  116505. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  116506. }
  116507. }
  116508. declare module BABYLON {
  116509. /**
  116510. * Defines a target to use with MorphTargetManager
  116511. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  116512. */
  116513. export class MorphTarget implements IAnimatable {
  116514. /** defines the name of the target */
  116515. name: string;
  116516. /**
  116517. * Gets or sets the list of animations
  116518. */
  116519. animations: Animation[];
  116520. private _scene;
  116521. private _positions;
  116522. private _normals;
  116523. private _tangents;
  116524. private _uvs;
  116525. private _influence;
  116526. private _uniqueId;
  116527. /**
  116528. * Observable raised when the influence changes
  116529. */
  116530. onInfluenceChanged: Observable<boolean>;
  116531. /** @hidden */
  116532. _onDataLayoutChanged: Observable<void>;
  116533. /**
  116534. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  116535. */
  116536. get influence(): number;
  116537. set influence(influence: number);
  116538. /**
  116539. * Gets or sets the id of the morph Target
  116540. */
  116541. id: string;
  116542. private _animationPropertiesOverride;
  116543. /**
  116544. * Gets or sets the animation properties override
  116545. */
  116546. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116547. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116548. /**
  116549. * Creates a new MorphTarget
  116550. * @param name defines the name of the target
  116551. * @param influence defines the influence to use
  116552. * @param scene defines the scene the morphtarget belongs to
  116553. */
  116554. constructor(
  116555. /** defines the name of the target */
  116556. name: string, influence?: number, scene?: Nullable<Scene>);
  116557. /**
  116558. * Gets the unique ID of this manager
  116559. */
  116560. get uniqueId(): number;
  116561. /**
  116562. * Gets a boolean defining if the target contains position data
  116563. */
  116564. get hasPositions(): boolean;
  116565. /**
  116566. * Gets a boolean defining if the target contains normal data
  116567. */
  116568. get hasNormals(): boolean;
  116569. /**
  116570. * Gets a boolean defining if the target contains tangent data
  116571. */
  116572. get hasTangents(): boolean;
  116573. /**
  116574. * Gets a boolean defining if the target contains texture coordinates data
  116575. */
  116576. get hasUVs(): boolean;
  116577. /**
  116578. * Affects position data to this target
  116579. * @param data defines the position data to use
  116580. */
  116581. setPositions(data: Nullable<FloatArray>): void;
  116582. /**
  116583. * Gets the position data stored in this target
  116584. * @returns a FloatArray containing the position data (or null if not present)
  116585. */
  116586. getPositions(): Nullable<FloatArray>;
  116587. /**
  116588. * Affects normal data to this target
  116589. * @param data defines the normal data to use
  116590. */
  116591. setNormals(data: Nullable<FloatArray>): void;
  116592. /**
  116593. * Gets the normal data stored in this target
  116594. * @returns a FloatArray containing the normal data (or null if not present)
  116595. */
  116596. getNormals(): Nullable<FloatArray>;
  116597. /**
  116598. * Affects tangent data to this target
  116599. * @param data defines the tangent data to use
  116600. */
  116601. setTangents(data: Nullable<FloatArray>): void;
  116602. /**
  116603. * Gets the tangent data stored in this target
  116604. * @returns a FloatArray containing the tangent data (or null if not present)
  116605. */
  116606. getTangents(): Nullable<FloatArray>;
  116607. /**
  116608. * Affects texture coordinates data to this target
  116609. * @param data defines the texture coordinates data to use
  116610. */
  116611. setUVs(data: Nullable<FloatArray>): void;
  116612. /**
  116613. * Gets the texture coordinates data stored in this target
  116614. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  116615. */
  116616. getUVs(): Nullable<FloatArray>;
  116617. /**
  116618. * Clone the current target
  116619. * @returns a new MorphTarget
  116620. */
  116621. clone(): MorphTarget;
  116622. /**
  116623. * Serializes the current target into a Serialization object
  116624. * @returns the serialized object
  116625. */
  116626. serialize(): any;
  116627. /**
  116628. * Returns the string "MorphTarget"
  116629. * @returns "MorphTarget"
  116630. */
  116631. getClassName(): string;
  116632. /**
  116633. * Creates a new target from serialized data
  116634. * @param serializationObject defines the serialized data to use
  116635. * @returns a new MorphTarget
  116636. */
  116637. static Parse(serializationObject: any): MorphTarget;
  116638. /**
  116639. * Creates a MorphTarget from mesh data
  116640. * @param mesh defines the source mesh
  116641. * @param name defines the name to use for the new target
  116642. * @param influence defines the influence to attach to the target
  116643. * @returns a new MorphTarget
  116644. */
  116645. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  116646. }
  116647. }
  116648. declare module BABYLON {
  116649. /**
  116650. * This class is used to deform meshes using morphing between different targets
  116651. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  116652. */
  116653. export class MorphTargetManager {
  116654. private _targets;
  116655. private _targetInfluenceChangedObservers;
  116656. private _targetDataLayoutChangedObservers;
  116657. private _activeTargets;
  116658. private _scene;
  116659. private _influences;
  116660. private _supportsNormals;
  116661. private _supportsTangents;
  116662. private _supportsUVs;
  116663. private _vertexCount;
  116664. private _uniqueId;
  116665. private _tempInfluences;
  116666. /**
  116667. * Gets or sets a boolean indicating if normals must be morphed
  116668. */
  116669. enableNormalMorphing: boolean;
  116670. /**
  116671. * Gets or sets a boolean indicating if tangents must be morphed
  116672. */
  116673. enableTangentMorphing: boolean;
  116674. /**
  116675. * Gets or sets a boolean indicating if UV must be morphed
  116676. */
  116677. enableUVMorphing: boolean;
  116678. /**
  116679. * Creates a new MorphTargetManager
  116680. * @param scene defines the current scene
  116681. */
  116682. constructor(scene?: Nullable<Scene>);
  116683. /**
  116684. * Gets the unique ID of this manager
  116685. */
  116686. get uniqueId(): number;
  116687. /**
  116688. * Gets the number of vertices handled by this manager
  116689. */
  116690. get vertexCount(): number;
  116691. /**
  116692. * Gets a boolean indicating if this manager supports morphing of normals
  116693. */
  116694. get supportsNormals(): boolean;
  116695. /**
  116696. * Gets a boolean indicating if this manager supports morphing of tangents
  116697. */
  116698. get supportsTangents(): boolean;
  116699. /**
  116700. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  116701. */
  116702. get supportsUVs(): boolean;
  116703. /**
  116704. * Gets the number of targets stored in this manager
  116705. */
  116706. get numTargets(): number;
  116707. /**
  116708. * Gets the number of influencers (ie. the number of targets with influences > 0)
  116709. */
  116710. get numInfluencers(): number;
  116711. /**
  116712. * Gets the list of influences (one per target)
  116713. */
  116714. get influences(): Float32Array;
  116715. /**
  116716. * Gets the active target at specified index. An active target is a target with an influence > 0
  116717. * @param index defines the index to check
  116718. * @returns the requested target
  116719. */
  116720. getActiveTarget(index: number): MorphTarget;
  116721. /**
  116722. * Gets the target at specified index
  116723. * @param index defines the index to check
  116724. * @returns the requested target
  116725. */
  116726. getTarget(index: number): MorphTarget;
  116727. /**
  116728. * Add a new target to this manager
  116729. * @param target defines the target to add
  116730. */
  116731. addTarget(target: MorphTarget): void;
  116732. /**
  116733. * Removes a target from the manager
  116734. * @param target defines the target to remove
  116735. */
  116736. removeTarget(target: MorphTarget): void;
  116737. /**
  116738. * Clone the current manager
  116739. * @returns a new MorphTargetManager
  116740. */
  116741. clone(): MorphTargetManager;
  116742. /**
  116743. * Serializes the current manager into a Serialization object
  116744. * @returns the serialized object
  116745. */
  116746. serialize(): any;
  116747. private _syncActiveTargets;
  116748. /**
  116749. * Syncrhonize the targets with all the meshes using this morph target manager
  116750. */
  116751. synchronize(): void;
  116752. /**
  116753. * Creates a new MorphTargetManager from serialized data
  116754. * @param serializationObject defines the serialized data
  116755. * @param scene defines the hosting scene
  116756. * @returns the new MorphTargetManager
  116757. */
  116758. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  116759. }
  116760. }
  116761. declare module BABYLON {
  116762. /**
  116763. * Class used to represent a specific level of detail of a mesh
  116764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  116765. */
  116766. export class MeshLODLevel {
  116767. /** Defines the distance where this level should start being displayed */
  116768. distance: number;
  116769. /** Defines the mesh to use to render this level */
  116770. mesh: Nullable<Mesh>;
  116771. /**
  116772. * Creates a new LOD level
  116773. * @param distance defines the distance where this level should star being displayed
  116774. * @param mesh defines the mesh to use to render this level
  116775. */
  116776. constructor(
  116777. /** Defines the distance where this level should start being displayed */
  116778. distance: number,
  116779. /** Defines the mesh to use to render this level */
  116780. mesh: Nullable<Mesh>);
  116781. }
  116782. }
  116783. declare module BABYLON {
  116784. /**
  116785. * Helper class used to generate a canvas to manipulate images
  116786. */
  116787. export class CanvasGenerator {
  116788. /**
  116789. * Create a new canvas (or offscreen canvas depending on the context)
  116790. * @param width defines the expected width
  116791. * @param height defines the expected height
  116792. * @return a new canvas or offscreen canvas
  116793. */
  116794. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  116795. }
  116796. }
  116797. declare module BABYLON {
  116798. /**
  116799. * Mesh representing the gorund
  116800. */
  116801. export class GroundMesh extends Mesh {
  116802. /** If octree should be generated */
  116803. generateOctree: boolean;
  116804. private _heightQuads;
  116805. /** @hidden */
  116806. _subdivisionsX: number;
  116807. /** @hidden */
  116808. _subdivisionsY: number;
  116809. /** @hidden */
  116810. _width: number;
  116811. /** @hidden */
  116812. _height: number;
  116813. /** @hidden */
  116814. _minX: number;
  116815. /** @hidden */
  116816. _maxX: number;
  116817. /** @hidden */
  116818. _minZ: number;
  116819. /** @hidden */
  116820. _maxZ: number;
  116821. constructor(name: string, scene: Scene);
  116822. /**
  116823. * "GroundMesh"
  116824. * @returns "GroundMesh"
  116825. */
  116826. getClassName(): string;
  116827. /**
  116828. * The minimum of x and y subdivisions
  116829. */
  116830. get subdivisions(): number;
  116831. /**
  116832. * X subdivisions
  116833. */
  116834. get subdivisionsX(): number;
  116835. /**
  116836. * Y subdivisions
  116837. */
  116838. get subdivisionsY(): number;
  116839. /**
  116840. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  116841. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  116842. * @param chunksCount the number of subdivisions for x and y
  116843. * @param octreeBlocksSize (Default: 32)
  116844. */
  116845. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  116846. /**
  116847. * Returns a height (y) value in the Worl system :
  116848. * the ground altitude at the coordinates (x, z) expressed in the World system.
  116849. * @param x x coordinate
  116850. * @param z z coordinate
  116851. * @returns the ground y position if (x, z) are outside the ground surface.
  116852. */
  116853. getHeightAtCoordinates(x: number, z: number): number;
  116854. /**
  116855. * Returns a normalized vector (Vector3) orthogonal to the ground
  116856. * at the ground coordinates (x, z) expressed in the World system.
  116857. * @param x x coordinate
  116858. * @param z z coordinate
  116859. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  116860. */
  116861. getNormalAtCoordinates(x: number, z: number): Vector3;
  116862. /**
  116863. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  116864. * at the ground coordinates (x, z) expressed in the World system.
  116865. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  116866. * @param x x coordinate
  116867. * @param z z coordinate
  116868. * @param ref vector to store the result
  116869. * @returns the GroundMesh.
  116870. */
  116871. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  116872. /**
  116873. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  116874. * if the ground has been updated.
  116875. * This can be used in the render loop.
  116876. * @returns the GroundMesh.
  116877. */
  116878. updateCoordinateHeights(): GroundMesh;
  116879. private _getFacetAt;
  116880. private _initHeightQuads;
  116881. private _computeHeightQuads;
  116882. /**
  116883. * Serializes this ground mesh
  116884. * @param serializationObject object to write serialization to
  116885. */
  116886. serialize(serializationObject: any): void;
  116887. /**
  116888. * Parses a serialized ground mesh
  116889. * @param parsedMesh the serialized mesh
  116890. * @param scene the scene to create the ground mesh in
  116891. * @returns the created ground mesh
  116892. */
  116893. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  116894. }
  116895. }
  116896. declare module BABYLON {
  116897. /**
  116898. * Interface for Physics-Joint data
  116899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116900. */
  116901. export interface PhysicsJointData {
  116902. /**
  116903. * The main pivot of the joint
  116904. */
  116905. mainPivot?: Vector3;
  116906. /**
  116907. * The connected pivot of the joint
  116908. */
  116909. connectedPivot?: Vector3;
  116910. /**
  116911. * The main axis of the joint
  116912. */
  116913. mainAxis?: Vector3;
  116914. /**
  116915. * The connected axis of the joint
  116916. */
  116917. connectedAxis?: Vector3;
  116918. /**
  116919. * The collision of the joint
  116920. */
  116921. collision?: boolean;
  116922. /**
  116923. * Native Oimo/Cannon/Energy data
  116924. */
  116925. nativeParams?: any;
  116926. }
  116927. /**
  116928. * This is a holder class for the physics joint created by the physics plugin
  116929. * It holds a set of functions to control the underlying joint
  116930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116931. */
  116932. export class PhysicsJoint {
  116933. /**
  116934. * The type of the physics joint
  116935. */
  116936. type: number;
  116937. /**
  116938. * The data for the physics joint
  116939. */
  116940. jointData: PhysicsJointData;
  116941. private _physicsJoint;
  116942. protected _physicsPlugin: IPhysicsEnginePlugin;
  116943. /**
  116944. * Initializes the physics joint
  116945. * @param type The type of the physics joint
  116946. * @param jointData The data for the physics joint
  116947. */
  116948. constructor(
  116949. /**
  116950. * The type of the physics joint
  116951. */
  116952. type: number,
  116953. /**
  116954. * The data for the physics joint
  116955. */
  116956. jointData: PhysicsJointData);
  116957. /**
  116958. * Gets the physics joint
  116959. */
  116960. get physicsJoint(): any;
  116961. /**
  116962. * Sets the physics joint
  116963. */
  116964. set physicsJoint(newJoint: any);
  116965. /**
  116966. * Sets the physics plugin
  116967. */
  116968. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  116969. /**
  116970. * Execute a function that is physics-plugin specific.
  116971. * @param {Function} func the function that will be executed.
  116972. * It accepts two parameters: the physics world and the physics joint
  116973. */
  116974. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  116975. /**
  116976. * Distance-Joint type
  116977. */
  116978. static DistanceJoint: number;
  116979. /**
  116980. * Hinge-Joint type
  116981. */
  116982. static HingeJoint: number;
  116983. /**
  116984. * Ball-and-Socket joint type
  116985. */
  116986. static BallAndSocketJoint: number;
  116987. /**
  116988. * Wheel-Joint type
  116989. */
  116990. static WheelJoint: number;
  116991. /**
  116992. * Slider-Joint type
  116993. */
  116994. static SliderJoint: number;
  116995. /**
  116996. * Prismatic-Joint type
  116997. */
  116998. static PrismaticJoint: number;
  116999. /**
  117000. * Universal-Joint type
  117001. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  117002. */
  117003. static UniversalJoint: number;
  117004. /**
  117005. * Hinge-Joint 2 type
  117006. */
  117007. static Hinge2Joint: number;
  117008. /**
  117009. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  117010. */
  117011. static PointToPointJoint: number;
  117012. /**
  117013. * Spring-Joint type
  117014. */
  117015. static SpringJoint: number;
  117016. /**
  117017. * Lock-Joint type
  117018. */
  117019. static LockJoint: number;
  117020. }
  117021. /**
  117022. * A class representing a physics distance joint
  117023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117024. */
  117025. export class DistanceJoint extends PhysicsJoint {
  117026. /**
  117027. *
  117028. * @param jointData The data for the Distance-Joint
  117029. */
  117030. constructor(jointData: DistanceJointData);
  117031. /**
  117032. * Update the predefined distance.
  117033. * @param maxDistance The maximum preferred distance
  117034. * @param minDistance The minimum preferred distance
  117035. */
  117036. updateDistance(maxDistance: number, minDistance?: number): void;
  117037. }
  117038. /**
  117039. * Represents a Motor-Enabled Joint
  117040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117041. */
  117042. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  117043. /**
  117044. * Initializes the Motor-Enabled Joint
  117045. * @param type The type of the joint
  117046. * @param jointData The physica joint data for the joint
  117047. */
  117048. constructor(type: number, jointData: PhysicsJointData);
  117049. /**
  117050. * Set the motor values.
  117051. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117052. * @param force the force to apply
  117053. * @param maxForce max force for this motor.
  117054. */
  117055. setMotor(force?: number, maxForce?: number): void;
  117056. /**
  117057. * Set the motor's limits.
  117058. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117059. * @param upperLimit The upper limit of the motor
  117060. * @param lowerLimit The lower limit of the motor
  117061. */
  117062. setLimit(upperLimit: number, lowerLimit?: number): void;
  117063. }
  117064. /**
  117065. * This class represents a single physics Hinge-Joint
  117066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117067. */
  117068. export class HingeJoint extends MotorEnabledJoint {
  117069. /**
  117070. * Initializes the Hinge-Joint
  117071. * @param jointData The joint data for the Hinge-Joint
  117072. */
  117073. constructor(jointData: PhysicsJointData);
  117074. /**
  117075. * Set the motor values.
  117076. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117077. * @param {number} force the force to apply
  117078. * @param {number} maxForce max force for this motor.
  117079. */
  117080. setMotor(force?: number, maxForce?: number): void;
  117081. /**
  117082. * Set the motor's limits.
  117083. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117084. * @param upperLimit The upper limit of the motor
  117085. * @param lowerLimit The lower limit of the motor
  117086. */
  117087. setLimit(upperLimit: number, lowerLimit?: number): void;
  117088. }
  117089. /**
  117090. * This class represents a dual hinge physics joint (same as wheel joint)
  117091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117092. */
  117093. export class Hinge2Joint extends MotorEnabledJoint {
  117094. /**
  117095. * Initializes the Hinge2-Joint
  117096. * @param jointData The joint data for the Hinge2-Joint
  117097. */
  117098. constructor(jointData: PhysicsJointData);
  117099. /**
  117100. * Set the motor values.
  117101. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117102. * @param {number} targetSpeed the speed the motor is to reach
  117103. * @param {number} maxForce max force for this motor.
  117104. * @param {motorIndex} the motor's index, 0 or 1.
  117105. */
  117106. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  117107. /**
  117108. * Set the motor limits.
  117109. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117110. * @param {number} upperLimit the upper limit
  117111. * @param {number} lowerLimit lower limit
  117112. * @param {motorIndex} the motor's index, 0 or 1.
  117113. */
  117114. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117115. }
  117116. /**
  117117. * Interface for a motor enabled joint
  117118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117119. */
  117120. export interface IMotorEnabledJoint {
  117121. /**
  117122. * Physics joint
  117123. */
  117124. physicsJoint: any;
  117125. /**
  117126. * Sets the motor of the motor-enabled joint
  117127. * @param force The force of the motor
  117128. * @param maxForce The maximum force of the motor
  117129. * @param motorIndex The index of the motor
  117130. */
  117131. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  117132. /**
  117133. * Sets the limit of the motor
  117134. * @param upperLimit The upper limit of the motor
  117135. * @param lowerLimit The lower limit of the motor
  117136. * @param motorIndex The index of the motor
  117137. */
  117138. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117139. }
  117140. /**
  117141. * Joint data for a Distance-Joint
  117142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117143. */
  117144. export interface DistanceJointData extends PhysicsJointData {
  117145. /**
  117146. * Max distance the 2 joint objects can be apart
  117147. */
  117148. maxDistance: number;
  117149. }
  117150. /**
  117151. * Joint data from a spring joint
  117152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117153. */
  117154. export interface SpringJointData extends PhysicsJointData {
  117155. /**
  117156. * Length of the spring
  117157. */
  117158. length: number;
  117159. /**
  117160. * Stiffness of the spring
  117161. */
  117162. stiffness: number;
  117163. /**
  117164. * Damping of the spring
  117165. */
  117166. damping: number;
  117167. /** this callback will be called when applying the force to the impostors. */
  117168. forceApplicationCallback: () => void;
  117169. }
  117170. }
  117171. declare module BABYLON {
  117172. /**
  117173. * Holds the data for the raycast result
  117174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117175. */
  117176. export class PhysicsRaycastResult {
  117177. private _hasHit;
  117178. private _hitDistance;
  117179. private _hitNormalWorld;
  117180. private _hitPointWorld;
  117181. private _rayFromWorld;
  117182. private _rayToWorld;
  117183. /**
  117184. * Gets if there was a hit
  117185. */
  117186. get hasHit(): boolean;
  117187. /**
  117188. * Gets the distance from the hit
  117189. */
  117190. get hitDistance(): number;
  117191. /**
  117192. * Gets the hit normal/direction in the world
  117193. */
  117194. get hitNormalWorld(): Vector3;
  117195. /**
  117196. * Gets the hit point in the world
  117197. */
  117198. get hitPointWorld(): Vector3;
  117199. /**
  117200. * Gets the ray "start point" of the ray in the world
  117201. */
  117202. get rayFromWorld(): Vector3;
  117203. /**
  117204. * Gets the ray "end point" of the ray in the world
  117205. */
  117206. get rayToWorld(): Vector3;
  117207. /**
  117208. * Sets the hit data (normal & point in world space)
  117209. * @param hitNormalWorld defines the normal in world space
  117210. * @param hitPointWorld defines the point in world space
  117211. */
  117212. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  117213. /**
  117214. * Sets the distance from the start point to the hit point
  117215. * @param distance
  117216. */
  117217. setHitDistance(distance: number): void;
  117218. /**
  117219. * Calculates the distance manually
  117220. */
  117221. calculateHitDistance(): void;
  117222. /**
  117223. * Resets all the values to default
  117224. * @param from The from point on world space
  117225. * @param to The to point on world space
  117226. */
  117227. reset(from?: Vector3, to?: Vector3): void;
  117228. }
  117229. /**
  117230. * Interface for the size containing width and height
  117231. */
  117232. interface IXYZ {
  117233. /**
  117234. * X
  117235. */
  117236. x: number;
  117237. /**
  117238. * Y
  117239. */
  117240. y: number;
  117241. /**
  117242. * Z
  117243. */
  117244. z: number;
  117245. }
  117246. }
  117247. declare module BABYLON {
  117248. /**
  117249. * Interface used to describe a physics joint
  117250. */
  117251. export interface PhysicsImpostorJoint {
  117252. /** Defines the main impostor to which the joint is linked */
  117253. mainImpostor: PhysicsImpostor;
  117254. /** Defines the impostor that is connected to the main impostor using this joint */
  117255. connectedImpostor: PhysicsImpostor;
  117256. /** Defines the joint itself */
  117257. joint: PhysicsJoint;
  117258. }
  117259. /** @hidden */
  117260. export interface IPhysicsEnginePlugin {
  117261. world: any;
  117262. name: string;
  117263. setGravity(gravity: Vector3): void;
  117264. setTimeStep(timeStep: number): void;
  117265. getTimeStep(): number;
  117266. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117267. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117268. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117269. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117270. removePhysicsBody(impostor: PhysicsImpostor): void;
  117271. generateJoint(joint: PhysicsImpostorJoint): void;
  117272. removeJoint(joint: PhysicsImpostorJoint): void;
  117273. isSupported(): boolean;
  117274. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117275. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117276. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  117277. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  117278. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117279. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117280. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117281. getBodyMass(impostor: PhysicsImpostor): number;
  117282. getBodyFriction(impostor: PhysicsImpostor): number;
  117283. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117284. getBodyRestitution(impostor: PhysicsImpostor): number;
  117285. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117286. getBodyPressure?(impostor: PhysicsImpostor): number;
  117287. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  117288. getBodyStiffness?(impostor: PhysicsImpostor): number;
  117289. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  117290. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  117291. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  117292. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  117293. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  117294. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  117295. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  117296. sleepBody(impostor: PhysicsImpostor): void;
  117297. wakeUpBody(impostor: PhysicsImpostor): void;
  117298. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117299. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117300. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  117301. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117302. getRadius(impostor: PhysicsImpostor): number;
  117303. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117304. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117305. dispose(): void;
  117306. }
  117307. /**
  117308. * Interface used to define a physics engine
  117309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117310. */
  117311. export interface IPhysicsEngine {
  117312. /**
  117313. * Gets the gravity vector used by the simulation
  117314. */
  117315. gravity: Vector3;
  117316. /**
  117317. * Sets the gravity vector used by the simulation
  117318. * @param gravity defines the gravity vector to use
  117319. */
  117320. setGravity(gravity: Vector3): void;
  117321. /**
  117322. * Set the time step of the physics engine.
  117323. * Default is 1/60.
  117324. * To slow it down, enter 1/600 for example.
  117325. * To speed it up, 1/30
  117326. * @param newTimeStep the new timestep to apply to this world.
  117327. */
  117328. setTimeStep(newTimeStep: number): void;
  117329. /**
  117330. * Get the time step of the physics engine.
  117331. * @returns the current time step
  117332. */
  117333. getTimeStep(): number;
  117334. /**
  117335. * Set the sub time step of the physics engine.
  117336. * Default is 0 meaning there is no sub steps
  117337. * To increase physics resolution precision, set a small value (like 1 ms)
  117338. * @param subTimeStep defines the new sub timestep used for physics resolution.
  117339. */
  117340. setSubTimeStep(subTimeStep: number): void;
  117341. /**
  117342. * Get the sub time step of the physics engine.
  117343. * @returns the current sub time step
  117344. */
  117345. getSubTimeStep(): number;
  117346. /**
  117347. * Release all resources
  117348. */
  117349. dispose(): void;
  117350. /**
  117351. * Gets the name of the current physics plugin
  117352. * @returns the name of the plugin
  117353. */
  117354. getPhysicsPluginName(): string;
  117355. /**
  117356. * Adding a new impostor for the impostor tracking.
  117357. * This will be done by the impostor itself.
  117358. * @param impostor the impostor to add
  117359. */
  117360. addImpostor(impostor: PhysicsImpostor): void;
  117361. /**
  117362. * Remove an impostor from the engine.
  117363. * This impostor and its mesh will not longer be updated by the physics engine.
  117364. * @param impostor the impostor to remove
  117365. */
  117366. removeImpostor(impostor: PhysicsImpostor): void;
  117367. /**
  117368. * Add a joint to the physics engine
  117369. * @param mainImpostor defines the main impostor to which the joint is added.
  117370. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117371. * @param joint defines the joint that will connect both impostors.
  117372. */
  117373. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117374. /**
  117375. * Removes a joint from the simulation
  117376. * @param mainImpostor defines the impostor used with the joint
  117377. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117378. * @param joint defines the joint to remove
  117379. */
  117380. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117381. /**
  117382. * Gets the current plugin used to run the simulation
  117383. * @returns current plugin
  117384. */
  117385. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117386. /**
  117387. * Gets the list of physic impostors
  117388. * @returns an array of PhysicsImpostor
  117389. */
  117390. getImpostors(): Array<PhysicsImpostor>;
  117391. /**
  117392. * Gets the impostor for a physics enabled object
  117393. * @param object defines the object impersonated by the impostor
  117394. * @returns the PhysicsImpostor or null if not found
  117395. */
  117396. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117397. /**
  117398. * Gets the impostor for a physics body object
  117399. * @param body defines physics body used by the impostor
  117400. * @returns the PhysicsImpostor or null if not found
  117401. */
  117402. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117403. /**
  117404. * Does a raycast in the physics world
  117405. * @param from when should the ray start?
  117406. * @param to when should the ray end?
  117407. * @returns PhysicsRaycastResult
  117408. */
  117409. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117410. /**
  117411. * Called by the scene. No need to call it.
  117412. * @param delta defines the timespam between frames
  117413. */
  117414. _step(delta: number): void;
  117415. }
  117416. }
  117417. declare module BABYLON {
  117418. /**
  117419. * The interface for the physics imposter parameters
  117420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117421. */
  117422. export interface PhysicsImpostorParameters {
  117423. /**
  117424. * The mass of the physics imposter
  117425. */
  117426. mass: number;
  117427. /**
  117428. * The friction of the physics imposter
  117429. */
  117430. friction?: number;
  117431. /**
  117432. * The coefficient of restitution of the physics imposter
  117433. */
  117434. restitution?: number;
  117435. /**
  117436. * The native options of the physics imposter
  117437. */
  117438. nativeOptions?: any;
  117439. /**
  117440. * Specifies if the parent should be ignored
  117441. */
  117442. ignoreParent?: boolean;
  117443. /**
  117444. * Specifies if bi-directional transformations should be disabled
  117445. */
  117446. disableBidirectionalTransformation?: boolean;
  117447. /**
  117448. * The pressure inside the physics imposter, soft object only
  117449. */
  117450. pressure?: number;
  117451. /**
  117452. * The stiffness the physics imposter, soft object only
  117453. */
  117454. stiffness?: number;
  117455. /**
  117456. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  117457. */
  117458. velocityIterations?: number;
  117459. /**
  117460. * The number of iterations used in maintaining consistent vertex positions, soft object only
  117461. */
  117462. positionIterations?: number;
  117463. /**
  117464. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  117465. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  117466. * Add to fix multiple points
  117467. */
  117468. fixedPoints?: number;
  117469. /**
  117470. * The collision margin around a soft object
  117471. */
  117472. margin?: number;
  117473. /**
  117474. * The collision margin around a soft object
  117475. */
  117476. damping?: number;
  117477. /**
  117478. * The path for a rope based on an extrusion
  117479. */
  117480. path?: any;
  117481. /**
  117482. * The shape of an extrusion used for a rope based on an extrusion
  117483. */
  117484. shape?: any;
  117485. }
  117486. /**
  117487. * Interface for a physics-enabled object
  117488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117489. */
  117490. export interface IPhysicsEnabledObject {
  117491. /**
  117492. * The position of the physics-enabled object
  117493. */
  117494. position: Vector3;
  117495. /**
  117496. * The rotation of the physics-enabled object
  117497. */
  117498. rotationQuaternion: Nullable<Quaternion>;
  117499. /**
  117500. * The scale of the physics-enabled object
  117501. */
  117502. scaling: Vector3;
  117503. /**
  117504. * The rotation of the physics-enabled object
  117505. */
  117506. rotation?: Vector3;
  117507. /**
  117508. * The parent of the physics-enabled object
  117509. */
  117510. parent?: any;
  117511. /**
  117512. * The bounding info of the physics-enabled object
  117513. * @returns The bounding info of the physics-enabled object
  117514. */
  117515. getBoundingInfo(): BoundingInfo;
  117516. /**
  117517. * Computes the world matrix
  117518. * @param force Specifies if the world matrix should be computed by force
  117519. * @returns A world matrix
  117520. */
  117521. computeWorldMatrix(force: boolean): Matrix;
  117522. /**
  117523. * Gets the world matrix
  117524. * @returns A world matrix
  117525. */
  117526. getWorldMatrix?(): Matrix;
  117527. /**
  117528. * Gets the child meshes
  117529. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  117530. * @returns An array of abstract meshes
  117531. */
  117532. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  117533. /**
  117534. * Gets the vertex data
  117535. * @param kind The type of vertex data
  117536. * @returns A nullable array of numbers, or a float32 array
  117537. */
  117538. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  117539. /**
  117540. * Gets the indices from the mesh
  117541. * @returns A nullable array of index arrays
  117542. */
  117543. getIndices?(): Nullable<IndicesArray>;
  117544. /**
  117545. * Gets the scene from the mesh
  117546. * @returns the indices array or null
  117547. */
  117548. getScene?(): Scene;
  117549. /**
  117550. * Gets the absolute position from the mesh
  117551. * @returns the absolute position
  117552. */
  117553. getAbsolutePosition(): Vector3;
  117554. /**
  117555. * Gets the absolute pivot point from the mesh
  117556. * @returns the absolute pivot point
  117557. */
  117558. getAbsolutePivotPoint(): Vector3;
  117559. /**
  117560. * Rotates the mesh
  117561. * @param axis The axis of rotation
  117562. * @param amount The amount of rotation
  117563. * @param space The space of the rotation
  117564. * @returns The rotation transform node
  117565. */
  117566. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  117567. /**
  117568. * Translates the mesh
  117569. * @param axis The axis of translation
  117570. * @param distance The distance of translation
  117571. * @param space The space of the translation
  117572. * @returns The transform node
  117573. */
  117574. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  117575. /**
  117576. * Sets the absolute position of the mesh
  117577. * @param absolutePosition The absolute position of the mesh
  117578. * @returns The transform node
  117579. */
  117580. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  117581. /**
  117582. * Gets the class name of the mesh
  117583. * @returns The class name
  117584. */
  117585. getClassName(): string;
  117586. }
  117587. /**
  117588. * Represents a physics imposter
  117589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117590. */
  117591. export class PhysicsImpostor {
  117592. /**
  117593. * The physics-enabled object used as the physics imposter
  117594. */
  117595. object: IPhysicsEnabledObject;
  117596. /**
  117597. * The type of the physics imposter
  117598. */
  117599. type: number;
  117600. private _options;
  117601. private _scene?;
  117602. /**
  117603. * The default object size of the imposter
  117604. */
  117605. static DEFAULT_OBJECT_SIZE: Vector3;
  117606. /**
  117607. * The identity quaternion of the imposter
  117608. */
  117609. static IDENTITY_QUATERNION: Quaternion;
  117610. /** @hidden */
  117611. _pluginData: any;
  117612. private _physicsEngine;
  117613. private _physicsBody;
  117614. private _bodyUpdateRequired;
  117615. private _onBeforePhysicsStepCallbacks;
  117616. private _onAfterPhysicsStepCallbacks;
  117617. /** @hidden */
  117618. _onPhysicsCollideCallbacks: Array<{
  117619. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  117620. otherImpostors: Array<PhysicsImpostor>;
  117621. }>;
  117622. private _deltaPosition;
  117623. private _deltaRotation;
  117624. private _deltaRotationConjugated;
  117625. /** @hidden */
  117626. _isFromLine: boolean;
  117627. private _parent;
  117628. private _isDisposed;
  117629. private static _tmpVecs;
  117630. private static _tmpQuat;
  117631. /**
  117632. * Specifies if the physics imposter is disposed
  117633. */
  117634. get isDisposed(): boolean;
  117635. /**
  117636. * Gets the mass of the physics imposter
  117637. */
  117638. get mass(): number;
  117639. set mass(value: number);
  117640. /**
  117641. * Gets the coefficient of friction
  117642. */
  117643. get friction(): number;
  117644. /**
  117645. * Sets the coefficient of friction
  117646. */
  117647. set friction(value: number);
  117648. /**
  117649. * Gets the coefficient of restitution
  117650. */
  117651. get restitution(): number;
  117652. /**
  117653. * Sets the coefficient of restitution
  117654. */
  117655. set restitution(value: number);
  117656. /**
  117657. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  117658. */
  117659. get pressure(): number;
  117660. /**
  117661. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  117662. */
  117663. set pressure(value: number);
  117664. /**
  117665. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117666. */
  117667. get stiffness(): number;
  117668. /**
  117669. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117670. */
  117671. set stiffness(value: number);
  117672. /**
  117673. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117674. */
  117675. get velocityIterations(): number;
  117676. /**
  117677. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117678. */
  117679. set velocityIterations(value: number);
  117680. /**
  117681. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117682. */
  117683. get positionIterations(): number;
  117684. /**
  117685. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117686. */
  117687. set positionIterations(value: number);
  117688. /**
  117689. * The unique id of the physics imposter
  117690. * set by the physics engine when adding this impostor to the array
  117691. */
  117692. uniqueId: number;
  117693. /**
  117694. * @hidden
  117695. */
  117696. soft: boolean;
  117697. /**
  117698. * @hidden
  117699. */
  117700. segments: number;
  117701. private _joints;
  117702. /**
  117703. * Initializes the physics imposter
  117704. * @param object The physics-enabled object used as the physics imposter
  117705. * @param type The type of the physics imposter
  117706. * @param _options The options for the physics imposter
  117707. * @param _scene The Babylon scene
  117708. */
  117709. constructor(
  117710. /**
  117711. * The physics-enabled object used as the physics imposter
  117712. */
  117713. object: IPhysicsEnabledObject,
  117714. /**
  117715. * The type of the physics imposter
  117716. */
  117717. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  117718. /**
  117719. * This function will completly initialize this impostor.
  117720. * It will create a new body - but only if this mesh has no parent.
  117721. * If it has, this impostor will not be used other than to define the impostor
  117722. * of the child mesh.
  117723. * @hidden
  117724. */
  117725. _init(): void;
  117726. private _getPhysicsParent;
  117727. /**
  117728. * Should a new body be generated.
  117729. * @returns boolean specifying if body initialization is required
  117730. */
  117731. isBodyInitRequired(): boolean;
  117732. /**
  117733. * Sets the updated scaling
  117734. * @param updated Specifies if the scaling is updated
  117735. */
  117736. setScalingUpdated(): void;
  117737. /**
  117738. * Force a regeneration of this or the parent's impostor's body.
  117739. * Use under cautious - This will remove all joints already implemented.
  117740. */
  117741. forceUpdate(): void;
  117742. /**
  117743. * Gets the body that holds this impostor. Either its own, or its parent.
  117744. */
  117745. get physicsBody(): any;
  117746. /**
  117747. * Get the parent of the physics imposter
  117748. * @returns Physics imposter or null
  117749. */
  117750. get parent(): Nullable<PhysicsImpostor>;
  117751. /**
  117752. * Sets the parent of the physics imposter
  117753. */
  117754. set parent(value: Nullable<PhysicsImpostor>);
  117755. /**
  117756. * Set the physics body. Used mainly by the physics engine/plugin
  117757. */
  117758. set physicsBody(physicsBody: any);
  117759. /**
  117760. * Resets the update flags
  117761. */
  117762. resetUpdateFlags(): void;
  117763. /**
  117764. * Gets the object extend size
  117765. * @returns the object extend size
  117766. */
  117767. getObjectExtendSize(): Vector3;
  117768. /**
  117769. * Gets the object center
  117770. * @returns The object center
  117771. */
  117772. getObjectCenter(): Vector3;
  117773. /**
  117774. * Get a specific parameter from the options parameters
  117775. * @param paramName The object parameter name
  117776. * @returns The object parameter
  117777. */
  117778. getParam(paramName: string): any;
  117779. /**
  117780. * Sets a specific parameter in the options given to the physics plugin
  117781. * @param paramName The parameter name
  117782. * @param value The value of the parameter
  117783. */
  117784. setParam(paramName: string, value: number): void;
  117785. /**
  117786. * Specifically change the body's mass option. Won't recreate the physics body object
  117787. * @param mass The mass of the physics imposter
  117788. */
  117789. setMass(mass: number): void;
  117790. /**
  117791. * Gets the linear velocity
  117792. * @returns linear velocity or null
  117793. */
  117794. getLinearVelocity(): Nullable<Vector3>;
  117795. /**
  117796. * Sets the linear velocity
  117797. * @param velocity linear velocity or null
  117798. */
  117799. setLinearVelocity(velocity: Nullable<Vector3>): void;
  117800. /**
  117801. * Gets the angular velocity
  117802. * @returns angular velocity or null
  117803. */
  117804. getAngularVelocity(): Nullable<Vector3>;
  117805. /**
  117806. * Sets the angular velocity
  117807. * @param velocity The velocity or null
  117808. */
  117809. setAngularVelocity(velocity: Nullable<Vector3>): void;
  117810. /**
  117811. * Execute a function with the physics plugin native code
  117812. * Provide a function the will have two variables - the world object and the physics body object
  117813. * @param func The function to execute with the physics plugin native code
  117814. */
  117815. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  117816. /**
  117817. * Register a function that will be executed before the physics world is stepping forward
  117818. * @param func The function to execute before the physics world is stepped forward
  117819. */
  117820. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117821. /**
  117822. * Unregister a function that will be executed before the physics world is stepping forward
  117823. * @param func The function to execute before the physics world is stepped forward
  117824. */
  117825. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117826. /**
  117827. * Register a function that will be executed after the physics step
  117828. * @param func The function to execute after physics step
  117829. */
  117830. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117831. /**
  117832. * Unregisters a function that will be executed after the physics step
  117833. * @param func The function to execute after physics step
  117834. */
  117835. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117836. /**
  117837. * register a function that will be executed when this impostor collides against a different body
  117838. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  117839. * @param func Callback that is executed on collision
  117840. */
  117841. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  117842. /**
  117843. * Unregisters the physics imposter on contact
  117844. * @param collideAgainst The physics object to collide against
  117845. * @param func Callback to execute on collision
  117846. */
  117847. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  117848. private _tmpQuat;
  117849. private _tmpQuat2;
  117850. /**
  117851. * Get the parent rotation
  117852. * @returns The parent rotation
  117853. */
  117854. getParentsRotation(): Quaternion;
  117855. /**
  117856. * this function is executed by the physics engine.
  117857. */
  117858. beforeStep: () => void;
  117859. /**
  117860. * this function is executed by the physics engine
  117861. */
  117862. afterStep: () => void;
  117863. /**
  117864. * Legacy collision detection event support
  117865. */
  117866. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  117867. /**
  117868. * event and body object due to cannon's event-based architecture.
  117869. */
  117870. onCollide: (e: {
  117871. body: any;
  117872. point: Nullable<Vector3>;
  117873. }) => void;
  117874. /**
  117875. * Apply a force
  117876. * @param force The force to apply
  117877. * @param contactPoint The contact point for the force
  117878. * @returns The physics imposter
  117879. */
  117880. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117881. /**
  117882. * Apply an impulse
  117883. * @param force The impulse force
  117884. * @param contactPoint The contact point for the impulse force
  117885. * @returns The physics imposter
  117886. */
  117887. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117888. /**
  117889. * A help function to create a joint
  117890. * @param otherImpostor A physics imposter used to create a joint
  117891. * @param jointType The type of joint
  117892. * @param jointData The data for the joint
  117893. * @returns The physics imposter
  117894. */
  117895. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  117896. /**
  117897. * Add a joint to this impostor with a different impostor
  117898. * @param otherImpostor A physics imposter used to add a joint
  117899. * @param joint The joint to add
  117900. * @returns The physics imposter
  117901. */
  117902. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  117903. /**
  117904. * Add an anchor to a cloth impostor
  117905. * @param otherImpostor rigid impostor to anchor to
  117906. * @param width ratio across width from 0 to 1
  117907. * @param height ratio up height from 0 to 1
  117908. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117909. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  117910. * @returns impostor the soft imposter
  117911. */
  117912. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117913. /**
  117914. * Add a hook to a rope impostor
  117915. * @param otherImpostor rigid impostor to anchor to
  117916. * @param length ratio across rope from 0 to 1
  117917. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  117918. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117919. * @returns impostor the rope imposter
  117920. */
  117921. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117922. /**
  117923. * Will keep this body still, in a sleep mode.
  117924. * @returns the physics imposter
  117925. */
  117926. sleep(): PhysicsImpostor;
  117927. /**
  117928. * Wake the body up.
  117929. * @returns The physics imposter
  117930. */
  117931. wakeUp(): PhysicsImpostor;
  117932. /**
  117933. * Clones the physics imposter
  117934. * @param newObject The physics imposter clones to this physics-enabled object
  117935. * @returns A nullable physics imposter
  117936. */
  117937. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117938. /**
  117939. * Disposes the physics imposter
  117940. */
  117941. dispose(): void;
  117942. /**
  117943. * Sets the delta position
  117944. * @param position The delta position amount
  117945. */
  117946. setDeltaPosition(position: Vector3): void;
  117947. /**
  117948. * Sets the delta rotation
  117949. * @param rotation The delta rotation amount
  117950. */
  117951. setDeltaRotation(rotation: Quaternion): void;
  117952. /**
  117953. * Gets the box size of the physics imposter and stores the result in the input parameter
  117954. * @param result Stores the box size
  117955. * @returns The physics imposter
  117956. */
  117957. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  117958. /**
  117959. * Gets the radius of the physics imposter
  117960. * @returns Radius of the physics imposter
  117961. */
  117962. getRadius(): number;
  117963. /**
  117964. * Sync a bone with this impostor
  117965. * @param bone The bone to sync to the impostor.
  117966. * @param boneMesh The mesh that the bone is influencing.
  117967. * @param jointPivot The pivot of the joint / bone in local space.
  117968. * @param distToJoint Optional distance from the impostor to the joint.
  117969. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117970. */
  117971. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  117972. /**
  117973. * Sync impostor to a bone
  117974. * @param bone The bone that the impostor will be synced to.
  117975. * @param boneMesh The mesh that the bone is influencing.
  117976. * @param jointPivot The pivot of the joint / bone in local space.
  117977. * @param distToJoint Optional distance from the impostor to the joint.
  117978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117979. * @param boneAxis Optional vector3 axis the bone is aligned with
  117980. */
  117981. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  117982. /**
  117983. * No-Imposter type
  117984. */
  117985. static NoImpostor: number;
  117986. /**
  117987. * Sphere-Imposter type
  117988. */
  117989. static SphereImpostor: number;
  117990. /**
  117991. * Box-Imposter type
  117992. */
  117993. static BoxImpostor: number;
  117994. /**
  117995. * Plane-Imposter type
  117996. */
  117997. static PlaneImpostor: number;
  117998. /**
  117999. * Mesh-imposter type
  118000. */
  118001. static MeshImpostor: number;
  118002. /**
  118003. * Capsule-Impostor type (Ammo.js plugin only)
  118004. */
  118005. static CapsuleImpostor: number;
  118006. /**
  118007. * Cylinder-Imposter type
  118008. */
  118009. static CylinderImpostor: number;
  118010. /**
  118011. * Particle-Imposter type
  118012. */
  118013. static ParticleImpostor: number;
  118014. /**
  118015. * Heightmap-Imposter type
  118016. */
  118017. static HeightmapImpostor: number;
  118018. /**
  118019. * ConvexHull-Impostor type (Ammo.js plugin only)
  118020. */
  118021. static ConvexHullImpostor: number;
  118022. /**
  118023. * Custom-Imposter type (Ammo.js plugin only)
  118024. */
  118025. static CustomImpostor: number;
  118026. /**
  118027. * Rope-Imposter type
  118028. */
  118029. static RopeImpostor: number;
  118030. /**
  118031. * Cloth-Imposter type
  118032. */
  118033. static ClothImpostor: number;
  118034. /**
  118035. * Softbody-Imposter type
  118036. */
  118037. static SoftbodyImpostor: number;
  118038. }
  118039. }
  118040. declare module BABYLON {
  118041. /**
  118042. * @hidden
  118043. **/
  118044. export class _CreationDataStorage {
  118045. closePath?: boolean;
  118046. closeArray?: boolean;
  118047. idx: number[];
  118048. dashSize: number;
  118049. gapSize: number;
  118050. path3D: Path3D;
  118051. pathArray: Vector3[][];
  118052. arc: number;
  118053. radius: number;
  118054. cap: number;
  118055. tessellation: number;
  118056. }
  118057. /**
  118058. * @hidden
  118059. **/
  118060. class _InstanceDataStorage {
  118061. visibleInstances: any;
  118062. batchCache: _InstancesBatch;
  118063. instancesBufferSize: number;
  118064. instancesBuffer: Nullable<Buffer>;
  118065. instancesData: Float32Array;
  118066. overridenInstanceCount: number;
  118067. isFrozen: boolean;
  118068. previousBatch: Nullable<_InstancesBatch>;
  118069. hardwareInstancedRendering: boolean;
  118070. sideOrientation: number;
  118071. manualUpdate: boolean;
  118072. previousRenderId: number;
  118073. }
  118074. /**
  118075. * @hidden
  118076. **/
  118077. export class _InstancesBatch {
  118078. mustReturn: boolean;
  118079. visibleInstances: Nullable<InstancedMesh[]>[];
  118080. renderSelf: boolean[];
  118081. hardwareInstancedRendering: boolean[];
  118082. }
  118083. /**
  118084. * @hidden
  118085. **/
  118086. class _ThinInstanceDataStorage {
  118087. instancesCount: number;
  118088. matrixBuffer: Nullable<Buffer>;
  118089. matrixBufferSize: number;
  118090. matrixData: Nullable<Float32Array>;
  118091. boundingVectors: Array<Vector3>;
  118092. worldMatrices: Nullable<Matrix[]>;
  118093. }
  118094. /**
  118095. * Class used to represent renderable models
  118096. */
  118097. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  118098. /**
  118099. * Mesh side orientation : usually the external or front surface
  118100. */
  118101. static readonly FRONTSIDE: number;
  118102. /**
  118103. * Mesh side orientation : usually the internal or back surface
  118104. */
  118105. static readonly BACKSIDE: number;
  118106. /**
  118107. * Mesh side orientation : both internal and external or front and back surfaces
  118108. */
  118109. static readonly DOUBLESIDE: number;
  118110. /**
  118111. * Mesh side orientation : by default, `FRONTSIDE`
  118112. */
  118113. static readonly DEFAULTSIDE: number;
  118114. /**
  118115. * Mesh cap setting : no cap
  118116. */
  118117. static readonly NO_CAP: number;
  118118. /**
  118119. * Mesh cap setting : one cap at the beginning of the mesh
  118120. */
  118121. static readonly CAP_START: number;
  118122. /**
  118123. * Mesh cap setting : one cap at the end of the mesh
  118124. */
  118125. static readonly CAP_END: number;
  118126. /**
  118127. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  118128. */
  118129. static readonly CAP_ALL: number;
  118130. /**
  118131. * Mesh pattern setting : no flip or rotate
  118132. */
  118133. static readonly NO_FLIP: number;
  118134. /**
  118135. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  118136. */
  118137. static readonly FLIP_TILE: number;
  118138. /**
  118139. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  118140. */
  118141. static readonly ROTATE_TILE: number;
  118142. /**
  118143. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  118144. */
  118145. static readonly FLIP_ROW: number;
  118146. /**
  118147. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  118148. */
  118149. static readonly ROTATE_ROW: number;
  118150. /**
  118151. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  118152. */
  118153. static readonly FLIP_N_ROTATE_TILE: number;
  118154. /**
  118155. * Mesh pattern setting : rotate pattern and rotate
  118156. */
  118157. static readonly FLIP_N_ROTATE_ROW: number;
  118158. /**
  118159. * Mesh tile positioning : part tiles same on left/right or top/bottom
  118160. */
  118161. static readonly CENTER: number;
  118162. /**
  118163. * Mesh tile positioning : part tiles on left
  118164. */
  118165. static readonly LEFT: number;
  118166. /**
  118167. * Mesh tile positioning : part tiles on right
  118168. */
  118169. static readonly RIGHT: number;
  118170. /**
  118171. * Mesh tile positioning : part tiles on top
  118172. */
  118173. static readonly TOP: number;
  118174. /**
  118175. * Mesh tile positioning : part tiles on bottom
  118176. */
  118177. static readonly BOTTOM: number;
  118178. /**
  118179. * Gets the default side orientation.
  118180. * @param orientation the orientation to value to attempt to get
  118181. * @returns the default orientation
  118182. * @hidden
  118183. */
  118184. static _GetDefaultSideOrientation(orientation?: number): number;
  118185. private _internalMeshDataInfo;
  118186. get computeBonesUsingShaders(): boolean;
  118187. set computeBonesUsingShaders(value: boolean);
  118188. /**
  118189. * An event triggered before rendering the mesh
  118190. */
  118191. get onBeforeRenderObservable(): Observable<Mesh>;
  118192. /**
  118193. * An event triggered before binding the mesh
  118194. */
  118195. get onBeforeBindObservable(): Observable<Mesh>;
  118196. /**
  118197. * An event triggered after rendering the mesh
  118198. */
  118199. get onAfterRenderObservable(): Observable<Mesh>;
  118200. /**
  118201. * An event triggered before drawing the mesh
  118202. */
  118203. get onBeforeDrawObservable(): Observable<Mesh>;
  118204. private _onBeforeDrawObserver;
  118205. /**
  118206. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  118207. */
  118208. set onBeforeDraw(callback: () => void);
  118209. get hasInstances(): boolean;
  118210. get hasThinInstances(): boolean;
  118211. /**
  118212. * Gets the delay loading state of the mesh (when delay loading is turned on)
  118213. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  118214. */
  118215. delayLoadState: number;
  118216. /**
  118217. * Gets the list of instances created from this mesh
  118218. * it is not supposed to be modified manually.
  118219. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  118220. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118221. */
  118222. instances: InstancedMesh[];
  118223. /**
  118224. * Gets the file containing delay loading data for this mesh
  118225. */
  118226. delayLoadingFile: string;
  118227. /** @hidden */
  118228. _binaryInfo: any;
  118229. /**
  118230. * User defined function used to change how LOD level selection is done
  118231. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118232. */
  118233. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  118234. /**
  118235. * Gets or sets the morph target manager
  118236. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  118237. */
  118238. get morphTargetManager(): Nullable<MorphTargetManager>;
  118239. set morphTargetManager(value: Nullable<MorphTargetManager>);
  118240. /** @hidden */
  118241. _creationDataStorage: Nullable<_CreationDataStorage>;
  118242. /** @hidden */
  118243. _geometry: Nullable<Geometry>;
  118244. /** @hidden */
  118245. _delayInfo: Array<string>;
  118246. /** @hidden */
  118247. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  118248. /** @hidden */
  118249. _instanceDataStorage: _InstanceDataStorage;
  118250. /** @hidden */
  118251. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  118252. private _effectiveMaterial;
  118253. /** @hidden */
  118254. _shouldGenerateFlatShading: boolean;
  118255. /** @hidden */
  118256. _originalBuilderSideOrientation: number;
  118257. /**
  118258. * Use this property to change the original side orientation defined at construction time
  118259. */
  118260. overrideMaterialSideOrientation: Nullable<number>;
  118261. /**
  118262. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  118263. * Note this will reduce performance when set to true.
  118264. */
  118265. ignoreCameraMaxZ: boolean;
  118266. /**
  118267. * Gets the source mesh (the one used to clone this one from)
  118268. */
  118269. get source(): Nullable<Mesh>;
  118270. /**
  118271. * Gets the list of clones of this mesh
  118272. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  118273. * Note that useClonedMeshMap=true is the default setting
  118274. */
  118275. get cloneMeshMap(): Nullable<{
  118276. [id: string]: Mesh | undefined;
  118277. }>;
  118278. /**
  118279. * Gets or sets a boolean indicating that this mesh does not use index buffer
  118280. */
  118281. get isUnIndexed(): boolean;
  118282. set isUnIndexed(value: boolean);
  118283. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  118284. get worldMatrixInstancedBuffer(): Float32Array;
  118285. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  118286. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  118287. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  118288. /**
  118289. * @constructor
  118290. * @param name The value used by scene.getMeshByName() to do a lookup.
  118291. * @param scene The scene to add this mesh to.
  118292. * @param parent The parent of this mesh, if it has one
  118293. * @param source An optional Mesh from which geometry is shared, cloned.
  118294. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  118295. * When false, achieved by calling a clone(), also passing False.
  118296. * This will make creation of children, recursive.
  118297. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  118298. */
  118299. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  118300. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  118301. doNotInstantiate: boolean;
  118302. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  118303. /**
  118304. * Gets the class name
  118305. * @returns the string "Mesh".
  118306. */
  118307. getClassName(): string;
  118308. /** @hidden */
  118309. get _isMesh(): boolean;
  118310. /**
  118311. * Returns a description of this mesh
  118312. * @param fullDetails define if full details about this mesh must be used
  118313. * @returns a descriptive string representing this mesh
  118314. */
  118315. toString(fullDetails?: boolean): string;
  118316. /** @hidden */
  118317. _unBindEffect(): void;
  118318. /**
  118319. * Gets a boolean indicating if this mesh has LOD
  118320. */
  118321. get hasLODLevels(): boolean;
  118322. /**
  118323. * Gets the list of MeshLODLevel associated with the current mesh
  118324. * @returns an array of MeshLODLevel
  118325. */
  118326. getLODLevels(): MeshLODLevel[];
  118327. private _sortLODLevels;
  118328. /**
  118329. * Add a mesh as LOD level triggered at the given distance.
  118330. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118331. * @param distance The distance from the center of the object to show this level
  118332. * @param mesh The mesh to be added as LOD level (can be null)
  118333. * @return This mesh (for chaining)
  118334. */
  118335. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  118336. /**
  118337. * Returns the LOD level mesh at the passed distance or null if not found.
  118338. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118339. * @param distance The distance from the center of the object to show this level
  118340. * @returns a Mesh or `null`
  118341. */
  118342. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  118343. /**
  118344. * Remove a mesh from the LOD array
  118345. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118346. * @param mesh defines the mesh to be removed
  118347. * @return This mesh (for chaining)
  118348. */
  118349. removeLODLevel(mesh: Mesh): Mesh;
  118350. /**
  118351. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  118352. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118353. * @param camera defines the camera to use to compute distance
  118354. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  118355. * @return This mesh (for chaining)
  118356. */
  118357. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  118358. /**
  118359. * Gets the mesh internal Geometry object
  118360. */
  118361. get geometry(): Nullable<Geometry>;
  118362. /**
  118363. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  118364. * @returns the total number of vertices
  118365. */
  118366. getTotalVertices(): number;
  118367. /**
  118368. * Returns the content of an associated vertex buffer
  118369. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  118370. * - VertexBuffer.PositionKind
  118371. * - VertexBuffer.UVKind
  118372. * - VertexBuffer.UV2Kind
  118373. * - VertexBuffer.UV3Kind
  118374. * - VertexBuffer.UV4Kind
  118375. * - VertexBuffer.UV5Kind
  118376. * - VertexBuffer.UV6Kind
  118377. * - VertexBuffer.ColorKind
  118378. * - VertexBuffer.MatricesIndicesKind
  118379. * - VertexBuffer.MatricesIndicesExtraKind
  118380. * - VertexBuffer.MatricesWeightsKind
  118381. * - VertexBuffer.MatricesWeightsExtraKind
  118382. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  118383. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  118384. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  118385. */
  118386. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  118387. /**
  118388. * Returns the mesh VertexBuffer object from the requested `kind`
  118389. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  118390. * - VertexBuffer.PositionKind
  118391. * - VertexBuffer.NormalKind
  118392. * - VertexBuffer.UVKind
  118393. * - VertexBuffer.UV2Kind
  118394. * - VertexBuffer.UV3Kind
  118395. * - VertexBuffer.UV4Kind
  118396. * - VertexBuffer.UV5Kind
  118397. * - VertexBuffer.UV6Kind
  118398. * - VertexBuffer.ColorKind
  118399. * - VertexBuffer.MatricesIndicesKind
  118400. * - VertexBuffer.MatricesIndicesExtraKind
  118401. * - VertexBuffer.MatricesWeightsKind
  118402. * - VertexBuffer.MatricesWeightsExtraKind
  118403. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  118404. */
  118405. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  118406. /**
  118407. * Tests if a specific vertex buffer is associated with this mesh
  118408. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  118409. * - VertexBuffer.PositionKind
  118410. * - VertexBuffer.NormalKind
  118411. * - VertexBuffer.UVKind
  118412. * - VertexBuffer.UV2Kind
  118413. * - VertexBuffer.UV3Kind
  118414. * - VertexBuffer.UV4Kind
  118415. * - VertexBuffer.UV5Kind
  118416. * - VertexBuffer.UV6Kind
  118417. * - VertexBuffer.ColorKind
  118418. * - VertexBuffer.MatricesIndicesKind
  118419. * - VertexBuffer.MatricesIndicesExtraKind
  118420. * - VertexBuffer.MatricesWeightsKind
  118421. * - VertexBuffer.MatricesWeightsExtraKind
  118422. * @returns a boolean
  118423. */
  118424. isVerticesDataPresent(kind: string): boolean;
  118425. /**
  118426. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  118427. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  118428. * - VertexBuffer.PositionKind
  118429. * - VertexBuffer.UVKind
  118430. * - VertexBuffer.UV2Kind
  118431. * - VertexBuffer.UV3Kind
  118432. * - VertexBuffer.UV4Kind
  118433. * - VertexBuffer.UV5Kind
  118434. * - VertexBuffer.UV6Kind
  118435. * - VertexBuffer.ColorKind
  118436. * - VertexBuffer.MatricesIndicesKind
  118437. * - VertexBuffer.MatricesIndicesExtraKind
  118438. * - VertexBuffer.MatricesWeightsKind
  118439. * - VertexBuffer.MatricesWeightsExtraKind
  118440. * @returns a boolean
  118441. */
  118442. isVertexBufferUpdatable(kind: string): boolean;
  118443. /**
  118444. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  118445. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  118446. * - VertexBuffer.PositionKind
  118447. * - VertexBuffer.NormalKind
  118448. * - VertexBuffer.UVKind
  118449. * - VertexBuffer.UV2Kind
  118450. * - VertexBuffer.UV3Kind
  118451. * - VertexBuffer.UV4Kind
  118452. * - VertexBuffer.UV5Kind
  118453. * - VertexBuffer.UV6Kind
  118454. * - VertexBuffer.ColorKind
  118455. * - VertexBuffer.MatricesIndicesKind
  118456. * - VertexBuffer.MatricesIndicesExtraKind
  118457. * - VertexBuffer.MatricesWeightsKind
  118458. * - VertexBuffer.MatricesWeightsExtraKind
  118459. * @returns an array of strings
  118460. */
  118461. getVerticesDataKinds(): string[];
  118462. /**
  118463. * Returns a positive integer : the total number of indices in this mesh geometry.
  118464. * @returns the numner of indices or zero if the mesh has no geometry.
  118465. */
  118466. getTotalIndices(): number;
  118467. /**
  118468. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  118469. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  118470. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  118471. * @returns the indices array or an empty array if the mesh has no geometry
  118472. */
  118473. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  118474. get isBlocked(): boolean;
  118475. /**
  118476. * Determine if the current mesh is ready to be rendered
  118477. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  118478. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  118479. * @returns true if all associated assets are ready (material, textures, shaders)
  118480. */
  118481. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  118482. /**
  118483. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  118484. */
  118485. get areNormalsFrozen(): boolean;
  118486. /**
  118487. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  118488. * @returns the current mesh
  118489. */
  118490. freezeNormals(): Mesh;
  118491. /**
  118492. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  118493. * @returns the current mesh
  118494. */
  118495. unfreezeNormals(): Mesh;
  118496. /**
  118497. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  118498. */
  118499. set overridenInstanceCount(count: number);
  118500. /** @hidden */
  118501. _preActivate(): Mesh;
  118502. /** @hidden */
  118503. _preActivateForIntermediateRendering(renderId: number): Mesh;
  118504. /** @hidden */
  118505. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  118506. protected _afterComputeWorldMatrix(): void;
  118507. /** @hidden */
  118508. _postActivate(): void;
  118509. /**
  118510. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  118511. * This means the mesh underlying bounding box and sphere are recomputed.
  118512. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  118513. * @returns the current mesh
  118514. */
  118515. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  118516. /** @hidden */
  118517. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  118518. /**
  118519. * This function will subdivide the mesh into multiple submeshes
  118520. * @param count defines the expected number of submeshes
  118521. */
  118522. subdivide(count: number): void;
  118523. /**
  118524. * Copy a FloatArray into a specific associated vertex buffer
  118525. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  118526. * - VertexBuffer.PositionKind
  118527. * - VertexBuffer.UVKind
  118528. * - VertexBuffer.UV2Kind
  118529. * - VertexBuffer.UV3Kind
  118530. * - VertexBuffer.UV4Kind
  118531. * - VertexBuffer.UV5Kind
  118532. * - VertexBuffer.UV6Kind
  118533. * - VertexBuffer.ColorKind
  118534. * - VertexBuffer.MatricesIndicesKind
  118535. * - VertexBuffer.MatricesIndicesExtraKind
  118536. * - VertexBuffer.MatricesWeightsKind
  118537. * - VertexBuffer.MatricesWeightsExtraKind
  118538. * @param data defines the data source
  118539. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  118540. * @param stride defines the data stride size (can be null)
  118541. * @returns the current mesh
  118542. */
  118543. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  118544. /**
  118545. * Delete a vertex buffer associated with this mesh
  118546. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  118547. * - VertexBuffer.PositionKind
  118548. * - VertexBuffer.UVKind
  118549. * - VertexBuffer.UV2Kind
  118550. * - VertexBuffer.UV3Kind
  118551. * - VertexBuffer.UV4Kind
  118552. * - VertexBuffer.UV5Kind
  118553. * - VertexBuffer.UV6Kind
  118554. * - VertexBuffer.ColorKind
  118555. * - VertexBuffer.MatricesIndicesKind
  118556. * - VertexBuffer.MatricesIndicesExtraKind
  118557. * - VertexBuffer.MatricesWeightsKind
  118558. * - VertexBuffer.MatricesWeightsExtraKind
  118559. */
  118560. removeVerticesData(kind: string): void;
  118561. /**
  118562. * Flags an associated vertex buffer as updatable
  118563. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  118564. * - VertexBuffer.PositionKind
  118565. * - VertexBuffer.UVKind
  118566. * - VertexBuffer.UV2Kind
  118567. * - VertexBuffer.UV3Kind
  118568. * - VertexBuffer.UV4Kind
  118569. * - VertexBuffer.UV5Kind
  118570. * - VertexBuffer.UV6Kind
  118571. * - VertexBuffer.ColorKind
  118572. * - VertexBuffer.MatricesIndicesKind
  118573. * - VertexBuffer.MatricesIndicesExtraKind
  118574. * - VertexBuffer.MatricesWeightsKind
  118575. * - VertexBuffer.MatricesWeightsExtraKind
  118576. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  118577. */
  118578. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  118579. /**
  118580. * Sets the mesh global Vertex Buffer
  118581. * @param buffer defines the buffer to use
  118582. * @returns the current mesh
  118583. */
  118584. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  118585. /**
  118586. * Update a specific associated vertex buffer
  118587. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  118588. * - VertexBuffer.PositionKind
  118589. * - VertexBuffer.UVKind
  118590. * - VertexBuffer.UV2Kind
  118591. * - VertexBuffer.UV3Kind
  118592. * - VertexBuffer.UV4Kind
  118593. * - VertexBuffer.UV5Kind
  118594. * - VertexBuffer.UV6Kind
  118595. * - VertexBuffer.ColorKind
  118596. * - VertexBuffer.MatricesIndicesKind
  118597. * - VertexBuffer.MatricesIndicesExtraKind
  118598. * - VertexBuffer.MatricesWeightsKind
  118599. * - VertexBuffer.MatricesWeightsExtraKind
  118600. * @param data defines the data source
  118601. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  118602. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  118603. * @returns the current mesh
  118604. */
  118605. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  118606. /**
  118607. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  118608. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  118609. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  118610. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  118611. * @returns the current mesh
  118612. */
  118613. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  118614. /**
  118615. * Creates a un-shared specific occurence of the geometry for the mesh.
  118616. * @returns the current mesh
  118617. */
  118618. makeGeometryUnique(): Mesh;
  118619. /**
  118620. * Set the index buffer of this mesh
  118621. * @param indices defines the source data
  118622. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  118623. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  118624. * @returns the current mesh
  118625. */
  118626. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  118627. /**
  118628. * Update the current index buffer
  118629. * @param indices defines the source data
  118630. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  118631. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  118632. * @returns the current mesh
  118633. */
  118634. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  118635. /**
  118636. * Invert the geometry to move from a right handed system to a left handed one.
  118637. * @returns the current mesh
  118638. */
  118639. toLeftHanded(): Mesh;
  118640. /** @hidden */
  118641. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  118642. /** @hidden */
  118643. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  118644. /**
  118645. * Registers for this mesh a javascript function called just before the rendering process
  118646. * @param func defines the function to call before rendering this mesh
  118647. * @returns the current mesh
  118648. */
  118649. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118650. /**
  118651. * Disposes a previously registered javascript function called before the rendering
  118652. * @param func defines the function to remove
  118653. * @returns the current mesh
  118654. */
  118655. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118656. /**
  118657. * Registers for this mesh a javascript function called just after the rendering is complete
  118658. * @param func defines the function to call after rendering this mesh
  118659. * @returns the current mesh
  118660. */
  118661. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118662. /**
  118663. * Disposes a previously registered javascript function called after the rendering.
  118664. * @param func defines the function to remove
  118665. * @returns the current mesh
  118666. */
  118667. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118668. /** @hidden */
  118669. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  118670. /** @hidden */
  118671. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  118672. /** @hidden */
  118673. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  118674. /** @hidden */
  118675. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  118676. /** @hidden */
  118677. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  118678. /** @hidden */
  118679. _rebuild(): void;
  118680. /** @hidden */
  118681. _freeze(): void;
  118682. /** @hidden */
  118683. _unFreeze(): void;
  118684. /**
  118685. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  118686. * @param subMesh defines the subMesh to render
  118687. * @param enableAlphaMode defines if alpha mode can be changed
  118688. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  118689. * @returns the current mesh
  118690. */
  118691. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  118692. private _onBeforeDraw;
  118693. /**
  118694. * Renormalize the mesh and patch it up if there are no weights
  118695. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  118696. * However in the case of zero weights then we set just a single influence to 1.
  118697. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  118698. */
  118699. cleanMatrixWeights(): void;
  118700. private normalizeSkinFourWeights;
  118701. private normalizeSkinWeightsAndExtra;
  118702. /**
  118703. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  118704. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  118705. * the user know there was an issue with importing the mesh
  118706. * @returns a validation object with skinned, valid and report string
  118707. */
  118708. validateSkinning(): {
  118709. skinned: boolean;
  118710. valid: boolean;
  118711. report: string;
  118712. };
  118713. /** @hidden */
  118714. _checkDelayState(): Mesh;
  118715. private _queueLoad;
  118716. /**
  118717. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  118718. * A mesh is in the frustum if its bounding box intersects the frustum
  118719. * @param frustumPlanes defines the frustum to test
  118720. * @returns true if the mesh is in the frustum planes
  118721. */
  118722. isInFrustum(frustumPlanes: Plane[]): boolean;
  118723. /**
  118724. * Sets the mesh material by the material or multiMaterial `id` property
  118725. * @param id is a string identifying the material or the multiMaterial
  118726. * @returns the current mesh
  118727. */
  118728. setMaterialByID(id: string): Mesh;
  118729. /**
  118730. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  118731. * @returns an array of IAnimatable
  118732. */
  118733. getAnimatables(): IAnimatable[];
  118734. /**
  118735. * Modifies the mesh geometry according to the passed transformation matrix.
  118736. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  118737. * The mesh normals are modified using the same transformation.
  118738. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118739. * @param transform defines the transform matrix to use
  118740. * @see https://doc.babylonjs.com/resources/baking_transformations
  118741. * @returns the current mesh
  118742. */
  118743. bakeTransformIntoVertices(transform: Matrix): Mesh;
  118744. /**
  118745. * Modifies the mesh geometry according to its own current World Matrix.
  118746. * The mesh World Matrix is then reset.
  118747. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  118748. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118749. * @see https://doc.babylonjs.com/resources/baking_transformations
  118750. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  118751. * @returns the current mesh
  118752. */
  118753. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  118754. /** @hidden */
  118755. get _positions(): Nullable<Vector3[]>;
  118756. /** @hidden */
  118757. _resetPointsArrayCache(): Mesh;
  118758. /** @hidden */
  118759. _generatePointsArray(): boolean;
  118760. /**
  118761. * Returns a new Mesh object generated from the current mesh properties.
  118762. * This method must not get confused with createInstance()
  118763. * @param name is a string, the name given to the new mesh
  118764. * @param newParent can be any Node object (default `null`)
  118765. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  118766. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  118767. * @returns a new mesh
  118768. */
  118769. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  118770. /**
  118771. * Releases resources associated with this mesh.
  118772. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118773. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118774. */
  118775. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118776. /** @hidden */
  118777. _disposeInstanceSpecificData(): void;
  118778. /** @hidden */
  118779. _disposeThinInstanceSpecificData(): void;
  118780. /**
  118781. * Modifies the mesh geometry according to a displacement map.
  118782. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  118783. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118784. * @param url is a string, the URL from the image file is to be downloaded.
  118785. * @param minHeight is the lower limit of the displacement.
  118786. * @param maxHeight is the upper limit of the displacement.
  118787. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  118788. * @param uvOffset is an optional vector2 used to offset UV.
  118789. * @param uvScale is an optional vector2 used to scale UV.
  118790. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  118791. * @returns the Mesh.
  118792. */
  118793. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118794. /**
  118795. * Modifies the mesh geometry according to a displacementMap buffer.
  118796. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  118797. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118798. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  118799. * @param heightMapWidth is the width of the buffer image.
  118800. * @param heightMapHeight is the height of the buffer image.
  118801. * @param minHeight is the lower limit of the displacement.
  118802. * @param maxHeight is the upper limit of the displacement.
  118803. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  118804. * @param uvOffset is an optional vector2 used to offset UV.
  118805. * @param uvScale is an optional vector2 used to scale UV.
  118806. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  118807. * @returns the Mesh.
  118808. */
  118809. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118810. /**
  118811. * Modify the mesh to get a flat shading rendering.
  118812. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  118813. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  118814. * @returns current mesh
  118815. */
  118816. convertToFlatShadedMesh(): Mesh;
  118817. /**
  118818. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  118819. * In other words, more vertices, no more indices and a single bigger VBO.
  118820. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  118821. * @returns current mesh
  118822. */
  118823. convertToUnIndexedMesh(): Mesh;
  118824. /**
  118825. * Inverses facet orientations.
  118826. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118827. * @param flipNormals will also inverts the normals
  118828. * @returns current mesh
  118829. */
  118830. flipFaces(flipNormals?: boolean): Mesh;
  118831. /**
  118832. * Increase the number of facets and hence vertices in a mesh
  118833. * Vertex normals are interpolated from existing vertex normals
  118834. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118835. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  118836. */
  118837. increaseVertices(numberPerEdge: number): void;
  118838. /**
  118839. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  118840. * This will undo any application of covertToFlatShadedMesh
  118841. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118842. */
  118843. forceSharedVertices(): void;
  118844. /** @hidden */
  118845. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  118846. /** @hidden */
  118847. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  118848. /**
  118849. * Creates a new InstancedMesh object from the mesh model.
  118850. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118851. * @param name defines the name of the new instance
  118852. * @returns a new InstancedMesh
  118853. */
  118854. createInstance(name: string): InstancedMesh;
  118855. /**
  118856. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  118857. * After this call, all the mesh instances have the same submeshes than the current mesh.
  118858. * @returns the current mesh
  118859. */
  118860. synchronizeInstances(): Mesh;
  118861. /**
  118862. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  118863. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  118864. * This should be used together with the simplification to avoid disappearing triangles.
  118865. * @param successCallback an optional success callback to be called after the optimization finished.
  118866. * @returns the current mesh
  118867. */
  118868. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  118869. /**
  118870. * Serialize current mesh
  118871. * @param serializationObject defines the object which will receive the serialization data
  118872. */
  118873. serialize(serializationObject: any): void;
  118874. /** @hidden */
  118875. _syncGeometryWithMorphTargetManager(): void;
  118876. /** @hidden */
  118877. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  118878. /**
  118879. * Returns a new Mesh object parsed from the source provided.
  118880. * @param parsedMesh is the source
  118881. * @param scene defines the hosting scene
  118882. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  118883. * @returns a new Mesh
  118884. */
  118885. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  118886. /**
  118887. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  118888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118889. * @param name defines the name of the mesh to create
  118890. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  118891. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  118892. * @param closePath creates a seam between the first and the last points of each path of the path array
  118893. * @param offset is taken in account only if the `pathArray` is containing a single path
  118894. * @param scene defines the hosting scene
  118895. * @param updatable defines if the mesh must be flagged as updatable
  118896. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118897. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  118898. * @returns a new Mesh
  118899. */
  118900. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118901. /**
  118902. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  118903. * @param name defines the name of the mesh to create
  118904. * @param radius sets the radius size (float) of the polygon (default 0.5)
  118905. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  118906. * @param scene defines the hosting scene
  118907. * @param updatable defines if the mesh must be flagged as updatable
  118908. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118909. * @returns a new Mesh
  118910. */
  118911. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118912. /**
  118913. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  118914. * @param name defines the name of the mesh to create
  118915. * @param size sets the size (float) of each box side (default 1)
  118916. * @param scene defines the hosting scene
  118917. * @param updatable defines if the mesh must be flagged as updatable
  118918. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118919. * @returns a new Mesh
  118920. */
  118921. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118922. /**
  118923. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  118924. * @param name defines the name of the mesh to create
  118925. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118926. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118927. * @param scene defines the hosting scene
  118928. * @param updatable defines if the mesh must be flagged as updatable
  118929. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118930. * @returns a new Mesh
  118931. */
  118932. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118933. /**
  118934. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  118935. * @param name defines the name of the mesh to create
  118936. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118937. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118938. * @param scene defines the hosting scene
  118939. * @returns a new Mesh
  118940. */
  118941. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  118942. /**
  118943. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  118944. * @param name defines the name of the mesh to create
  118945. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  118946. * @param diameterTop set the top cap diameter (floats, default 1)
  118947. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  118948. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  118949. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  118950. * @param scene defines the hosting scene
  118951. * @param updatable defines if the mesh must be flagged as updatable
  118952. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118953. * @returns a new Mesh
  118954. */
  118955. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  118956. /**
  118957. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  118958. * @param name defines the name of the mesh to create
  118959. * @param diameter sets the diameter size (float) of the torus (default 1)
  118960. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  118961. * @param tessellation sets the number of torus sides (postive integer, default 16)
  118962. * @param scene defines the hosting scene
  118963. * @param updatable defines if the mesh must be flagged as updatable
  118964. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118965. * @returns a new Mesh
  118966. */
  118967. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118968. /**
  118969. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  118970. * @param name defines the name of the mesh to create
  118971. * @param radius sets the global radius size (float) of the torus knot (default 2)
  118972. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  118973. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  118974. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  118975. * @param p the number of windings on X axis (positive integers, default 2)
  118976. * @param q the number of windings on Y axis (positive integers, default 3)
  118977. * @param scene defines the hosting scene
  118978. * @param updatable defines if the mesh must be flagged as updatable
  118979. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118980. * @returns a new Mesh
  118981. */
  118982. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118983. /**
  118984. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  118985. * @param name defines the name of the mesh to create
  118986. * @param points is an array successive Vector3
  118987. * @param scene defines the hosting scene
  118988. * @param updatable defines if the mesh must be flagged as updatable
  118989. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  118990. * @returns a new Mesh
  118991. */
  118992. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  118993. /**
  118994. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  118995. * @param name defines the name of the mesh to create
  118996. * @param points is an array successive Vector3
  118997. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  118998. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118999. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  119000. * @param scene defines the hosting scene
  119001. * @param updatable defines if the mesh must be flagged as updatable
  119002. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  119003. * @returns a new Mesh
  119004. */
  119005. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  119006. /**
  119007. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  119008. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  119009. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  119010. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119011. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119012. * Remember you can only change the shape positions, not their number when updating a polygon.
  119013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  119014. * @param name defines the name of the mesh to create
  119015. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  119016. * @param scene defines the hosting scene
  119017. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  119018. * @param updatable defines if the mesh must be flagged as updatable
  119019. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119020. * @param earcutInjection can be used to inject your own earcut reference
  119021. * @returns a new Mesh
  119022. */
  119023. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  119024. /**
  119025. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  119026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  119027. * @param name defines the name of the mesh to create
  119028. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  119029. * @param depth defines the height of extrusion
  119030. * @param scene defines the hosting scene
  119031. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  119032. * @param updatable defines if the mesh must be flagged as updatable
  119033. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119034. * @param earcutInjection can be used to inject your own earcut reference
  119035. * @returns a new Mesh
  119036. */
  119037. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  119038. /**
  119039. * Creates an extruded shape mesh.
  119040. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  119041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119043. * @param name defines the name of the mesh to create
  119044. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  119045. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  119046. * @param scale is the value to scale the shape
  119047. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  119048. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  119049. * @param scene defines the hosting scene
  119050. * @param updatable defines if the mesh must be flagged as updatable
  119051. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119052. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  119053. * @returns a new Mesh
  119054. */
  119055. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  119056. /**
  119057. * Creates an custom extruded shape mesh.
  119058. * The custom extrusion is a parametric shape.
  119059. * It has no predefined shape. Its final shape will depend on the input parameters.
  119060. * Please consider using the same method from the MeshBuilder class instead
  119061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119062. * @param name defines the name of the mesh to create
  119063. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  119064. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  119065. * @param scaleFunction is a custom Javascript function called on each path point
  119066. * @param rotationFunction is a custom Javascript function called on each path point
  119067. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119068. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  119069. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  119070. * @param scene defines the hosting scene
  119071. * @param updatable defines if the mesh must be flagged as updatable
  119072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119073. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  119074. * @returns a new Mesh
  119075. */
  119076. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  119077. /**
  119078. * Creates lathe mesh.
  119079. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  119080. * Please consider using the same method from the MeshBuilder class instead
  119081. * @param name defines the name of the mesh to create
  119082. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  119083. * @param radius is the radius value of the lathe
  119084. * @param tessellation is the side number of the lathe.
  119085. * @param scene defines the hosting scene
  119086. * @param updatable defines if the mesh must be flagged as updatable
  119087. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119088. * @returns a new Mesh
  119089. */
  119090. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  119091. /**
  119092. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  119093. * @param name defines the name of the mesh to create
  119094. * @param size sets the size (float) of both sides of the plane at once (default 1)
  119095. * @param scene defines the hosting scene
  119096. * @param updatable defines if the mesh must be flagged as updatable
  119097. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119098. * @returns a new Mesh
  119099. */
  119100. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  119101. /**
  119102. * Creates a ground mesh.
  119103. * Please consider using the same method from the MeshBuilder class instead
  119104. * @param name defines the name of the mesh to create
  119105. * @param width set the width of the ground
  119106. * @param height set the height of the ground
  119107. * @param subdivisions sets the number of subdivisions per side
  119108. * @param scene defines the hosting scene
  119109. * @param updatable defines if the mesh must be flagged as updatable
  119110. * @returns a new Mesh
  119111. */
  119112. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  119113. /**
  119114. * Creates a tiled ground mesh.
  119115. * Please consider using the same method from the MeshBuilder class instead
  119116. * @param name defines the name of the mesh to create
  119117. * @param xmin set the ground minimum X coordinate
  119118. * @param zmin set the ground minimum Y coordinate
  119119. * @param xmax set the ground maximum X coordinate
  119120. * @param zmax set the ground maximum Z coordinate
  119121. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  119122. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  119123. * @param scene defines the hosting scene
  119124. * @param updatable defines if the mesh must be flagged as updatable
  119125. * @returns a new Mesh
  119126. */
  119127. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  119128. w: number;
  119129. h: number;
  119130. }, precision: {
  119131. w: number;
  119132. h: number;
  119133. }, scene: Scene, updatable?: boolean): Mesh;
  119134. /**
  119135. * Creates a ground mesh from a height map.
  119136. * Please consider using the same method from the MeshBuilder class instead
  119137. * @see https://doc.babylonjs.com/babylon101/height_map
  119138. * @param name defines the name of the mesh to create
  119139. * @param url sets the URL of the height map image resource
  119140. * @param width set the ground width size
  119141. * @param height set the ground height size
  119142. * @param subdivisions sets the number of subdivision per side
  119143. * @param minHeight is the minimum altitude on the ground
  119144. * @param maxHeight is the maximum altitude on the ground
  119145. * @param scene defines the hosting scene
  119146. * @param updatable defines if the mesh must be flagged as updatable
  119147. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  119148. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  119149. * @returns a new Mesh
  119150. */
  119151. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  119152. /**
  119153. * Creates a tube mesh.
  119154. * The tube is a parametric shape.
  119155. * It has no predefined shape. Its final shape will depend on the input parameters.
  119156. * Please consider using the same method from the MeshBuilder class instead
  119157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119158. * @param name defines the name of the mesh to create
  119159. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  119160. * @param radius sets the tube radius size
  119161. * @param tessellation is the number of sides on the tubular surface
  119162. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  119163. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  119164. * @param scene defines the hosting scene
  119165. * @param updatable defines if the mesh must be flagged as updatable
  119166. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119167. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  119168. * @returns a new Mesh
  119169. */
  119170. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  119171. (i: number, distance: number): number;
  119172. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  119173. /**
  119174. * Creates a polyhedron mesh.
  119175. * Please consider using the same method from the MeshBuilder class instead.
  119176. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  119177. * * The parameter `size` (positive float, default 1) sets the polygon size
  119178. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119179. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  119180. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  119181. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  119182. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119183. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  119184. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119187. * @param name defines the name of the mesh to create
  119188. * @param options defines the options used to create the mesh
  119189. * @param scene defines the hosting scene
  119190. * @returns a new Mesh
  119191. */
  119192. static CreatePolyhedron(name: string, options: {
  119193. type?: number;
  119194. size?: number;
  119195. sizeX?: number;
  119196. sizeY?: number;
  119197. sizeZ?: number;
  119198. custom?: any;
  119199. faceUV?: Vector4[];
  119200. faceColors?: Color4[];
  119201. updatable?: boolean;
  119202. sideOrientation?: number;
  119203. }, scene: Scene): Mesh;
  119204. /**
  119205. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119206. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119207. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  119208. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119209. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  119210. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119213. * @param name defines the name of the mesh
  119214. * @param options defines the options used to create the mesh
  119215. * @param scene defines the hosting scene
  119216. * @returns a new Mesh
  119217. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119218. */
  119219. static CreateIcoSphere(name: string, options: {
  119220. radius?: number;
  119221. flat?: boolean;
  119222. subdivisions?: number;
  119223. sideOrientation?: number;
  119224. updatable?: boolean;
  119225. }, scene: Scene): Mesh;
  119226. /**
  119227. * Creates a decal mesh.
  119228. * Please consider using the same method from the MeshBuilder class instead.
  119229. * A decal is a mesh usually applied as a model onto the surface of another mesh
  119230. * @param name defines the name of the mesh
  119231. * @param sourceMesh defines the mesh receiving the decal
  119232. * @param position sets the position of the decal in world coordinates
  119233. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  119234. * @param size sets the decal scaling
  119235. * @param angle sets the angle to rotate the decal
  119236. * @returns a new Mesh
  119237. */
  119238. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  119239. /** Creates a Capsule Mesh
  119240. * @param name defines the name of the mesh.
  119241. * @param options the constructors options used to shape the mesh.
  119242. * @param scene defines the scene the mesh is scoped to.
  119243. * @returns the capsule mesh
  119244. * @see https://doc.babylonjs.com/how_to/capsule_shape
  119245. */
  119246. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  119247. /**
  119248. * Prepare internal position array for software CPU skinning
  119249. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  119250. */
  119251. setPositionsForCPUSkinning(): Float32Array;
  119252. /**
  119253. * Prepare internal normal array for software CPU skinning
  119254. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  119255. */
  119256. setNormalsForCPUSkinning(): Float32Array;
  119257. /**
  119258. * Updates the vertex buffer by applying transformation from the bones
  119259. * @param skeleton defines the skeleton to apply to current mesh
  119260. * @returns the current mesh
  119261. */
  119262. applySkeleton(skeleton: Skeleton): Mesh;
  119263. /**
  119264. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  119265. * @param meshes defines the list of meshes to scan
  119266. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  119267. */
  119268. static MinMax(meshes: AbstractMesh[]): {
  119269. min: Vector3;
  119270. max: Vector3;
  119271. };
  119272. /**
  119273. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  119274. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  119275. * @returns a vector3
  119276. */
  119277. static Center(meshesOrMinMaxVector: {
  119278. min: Vector3;
  119279. max: Vector3;
  119280. } | AbstractMesh[]): Vector3;
  119281. /**
  119282. * Merge the array of meshes into a single mesh for performance reasons.
  119283. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  119284. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  119285. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  119286. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  119287. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  119288. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  119289. * @returns a new mesh
  119290. */
  119291. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  119292. /** @hidden */
  119293. addInstance(instance: InstancedMesh): void;
  119294. /** @hidden */
  119295. removeInstance(instance: InstancedMesh): void;
  119296. }
  119297. }
  119298. declare module BABYLON {
  119299. /**
  119300. * The options Interface for creating a Capsule Mesh
  119301. */
  119302. export interface ICreateCapsuleOptions {
  119303. /** The Orientation of the capsule. Default : Vector3.Up() */
  119304. orientation?: Vector3;
  119305. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  119306. subdivisions: number;
  119307. /** Number of cylindrical segments on the capsule. */
  119308. tessellation: number;
  119309. /** Height or Length of the capsule. */
  119310. height: number;
  119311. /** Radius of the capsule. */
  119312. radius: number;
  119313. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  119314. capSubdivisions: number;
  119315. /** Overwrite for the top radius. */
  119316. radiusTop?: number;
  119317. /** Overwrite for the bottom radius. */
  119318. radiusBottom?: number;
  119319. /** Overwrite for the top capSubdivisions. */
  119320. topCapSubdivisions?: number;
  119321. /** Overwrite for the bottom capSubdivisions. */
  119322. bottomCapSubdivisions?: number;
  119323. }
  119324. /**
  119325. * Class containing static functions to help procedurally build meshes
  119326. */
  119327. export class CapsuleBuilder {
  119328. /**
  119329. * Creates a capsule or a pill mesh
  119330. * @param name defines the name of the mesh
  119331. * @param options The constructors options.
  119332. * @param scene The scene the mesh is scoped to.
  119333. * @returns Capsule Mesh
  119334. */
  119335. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  119336. }
  119337. }
  119338. declare module BABYLON {
  119339. /**
  119340. * Define an interface for all classes that will get and set the data on vertices
  119341. */
  119342. export interface IGetSetVerticesData {
  119343. /**
  119344. * Gets a boolean indicating if specific vertex data is present
  119345. * @param kind defines the vertex data kind to use
  119346. * @returns true is data kind is present
  119347. */
  119348. isVerticesDataPresent(kind: string): boolean;
  119349. /**
  119350. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  119351. * @param kind defines the data kind (Position, normal, etc...)
  119352. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  119353. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  119354. * @returns a float array containing vertex data
  119355. */
  119356. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  119357. /**
  119358. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  119359. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  119360. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  119361. * @returns the indices array or an empty array if the mesh has no geometry
  119362. */
  119363. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  119364. /**
  119365. * Set specific vertex data
  119366. * @param kind defines the data kind (Position, normal, etc...)
  119367. * @param data defines the vertex data to use
  119368. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  119369. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  119370. */
  119371. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  119372. /**
  119373. * Update a specific associated vertex buffer
  119374. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  119375. * - VertexBuffer.PositionKind
  119376. * - VertexBuffer.UVKind
  119377. * - VertexBuffer.UV2Kind
  119378. * - VertexBuffer.UV3Kind
  119379. * - VertexBuffer.UV4Kind
  119380. * - VertexBuffer.UV5Kind
  119381. * - VertexBuffer.UV6Kind
  119382. * - VertexBuffer.ColorKind
  119383. * - VertexBuffer.MatricesIndicesKind
  119384. * - VertexBuffer.MatricesIndicesExtraKind
  119385. * - VertexBuffer.MatricesWeightsKind
  119386. * - VertexBuffer.MatricesWeightsExtraKind
  119387. * @param data defines the data source
  119388. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  119389. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  119390. */
  119391. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  119392. /**
  119393. * Creates a new index buffer
  119394. * @param indices defines the indices to store in the index buffer
  119395. * @param totalVertices defines the total number of vertices (could be null)
  119396. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  119397. */
  119398. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  119399. }
  119400. /**
  119401. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  119402. */
  119403. export class VertexData {
  119404. /**
  119405. * Mesh side orientation : usually the external or front surface
  119406. */
  119407. static readonly FRONTSIDE: number;
  119408. /**
  119409. * Mesh side orientation : usually the internal or back surface
  119410. */
  119411. static readonly BACKSIDE: number;
  119412. /**
  119413. * Mesh side orientation : both internal and external or front and back surfaces
  119414. */
  119415. static readonly DOUBLESIDE: number;
  119416. /**
  119417. * Mesh side orientation : by default, `FRONTSIDE`
  119418. */
  119419. static readonly DEFAULTSIDE: number;
  119420. /**
  119421. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  119422. */
  119423. positions: Nullable<FloatArray>;
  119424. /**
  119425. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  119426. */
  119427. normals: Nullable<FloatArray>;
  119428. /**
  119429. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  119430. */
  119431. tangents: Nullable<FloatArray>;
  119432. /**
  119433. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119434. */
  119435. uvs: Nullable<FloatArray>;
  119436. /**
  119437. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119438. */
  119439. uvs2: Nullable<FloatArray>;
  119440. /**
  119441. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119442. */
  119443. uvs3: Nullable<FloatArray>;
  119444. /**
  119445. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119446. */
  119447. uvs4: Nullable<FloatArray>;
  119448. /**
  119449. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119450. */
  119451. uvs5: Nullable<FloatArray>;
  119452. /**
  119453. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119454. */
  119455. uvs6: Nullable<FloatArray>;
  119456. /**
  119457. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  119458. */
  119459. colors: Nullable<FloatArray>;
  119460. /**
  119461. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  119462. */
  119463. matricesIndices: Nullable<FloatArray>;
  119464. /**
  119465. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  119466. */
  119467. matricesWeights: Nullable<FloatArray>;
  119468. /**
  119469. * An array extending the number of possible indices
  119470. */
  119471. matricesIndicesExtra: Nullable<FloatArray>;
  119472. /**
  119473. * An array extending the number of possible weights when the number of indices is extended
  119474. */
  119475. matricesWeightsExtra: Nullable<FloatArray>;
  119476. /**
  119477. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  119478. */
  119479. indices: Nullable<IndicesArray>;
  119480. /**
  119481. * Uses the passed data array to set the set the values for the specified kind of data
  119482. * @param data a linear array of floating numbers
  119483. * @param kind the type of data that is being set, eg positions, colors etc
  119484. */
  119485. set(data: FloatArray, kind: string): void;
  119486. /**
  119487. * Associates the vertexData to the passed Mesh.
  119488. * Sets it as updatable or not (default `false`)
  119489. * @param mesh the mesh the vertexData is applied to
  119490. * @param updatable when used and having the value true allows new data to update the vertexData
  119491. * @returns the VertexData
  119492. */
  119493. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  119494. /**
  119495. * Associates the vertexData to the passed Geometry.
  119496. * Sets it as updatable or not (default `false`)
  119497. * @param geometry the geometry the vertexData is applied to
  119498. * @param updatable when used and having the value true allows new data to update the vertexData
  119499. * @returns VertexData
  119500. */
  119501. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  119502. /**
  119503. * Updates the associated mesh
  119504. * @param mesh the mesh to be updated
  119505. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  119506. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  119507. * @returns VertexData
  119508. */
  119509. updateMesh(mesh: Mesh): VertexData;
  119510. /**
  119511. * Updates the associated geometry
  119512. * @param geometry the geometry to be updated
  119513. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  119514. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  119515. * @returns VertexData.
  119516. */
  119517. updateGeometry(geometry: Geometry): VertexData;
  119518. private _applyTo;
  119519. private _update;
  119520. /**
  119521. * Transforms each position and each normal of the vertexData according to the passed Matrix
  119522. * @param matrix the transforming matrix
  119523. * @returns the VertexData
  119524. */
  119525. transform(matrix: Matrix): VertexData;
  119526. /**
  119527. * Merges the passed VertexData into the current one
  119528. * @param other the VertexData to be merged into the current one
  119529. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  119530. * @returns the modified VertexData
  119531. */
  119532. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  119533. private _mergeElement;
  119534. private _validate;
  119535. /**
  119536. * Serializes the VertexData
  119537. * @returns a serialized object
  119538. */
  119539. serialize(): any;
  119540. /**
  119541. * Extracts the vertexData from a mesh
  119542. * @param mesh the mesh from which to extract the VertexData
  119543. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  119544. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  119545. * @returns the object VertexData associated to the passed mesh
  119546. */
  119547. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  119548. /**
  119549. * Extracts the vertexData from the geometry
  119550. * @param geometry the geometry from which to extract the VertexData
  119551. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  119552. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  119553. * @returns the object VertexData associated to the passed mesh
  119554. */
  119555. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  119556. private static _ExtractFrom;
  119557. /**
  119558. * Creates the VertexData for a Ribbon
  119559. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  119560. * * pathArray array of paths, each of which an array of successive Vector3
  119561. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  119562. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  119563. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  119564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119565. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119566. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119567. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  119568. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  119569. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  119570. * @returns the VertexData of the ribbon
  119571. */
  119572. static CreateRibbon(options: {
  119573. pathArray: Vector3[][];
  119574. closeArray?: boolean;
  119575. closePath?: boolean;
  119576. offset?: number;
  119577. sideOrientation?: number;
  119578. frontUVs?: Vector4;
  119579. backUVs?: Vector4;
  119580. invertUV?: boolean;
  119581. uvs?: Vector2[];
  119582. colors?: Color4[];
  119583. }): VertexData;
  119584. /**
  119585. * Creates the VertexData for a box
  119586. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119587. * * size sets the width, height and depth of the box to the value of size, optional default 1
  119588. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  119589. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  119590. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  119591. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  119592. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  119593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119594. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119595. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119596. * @returns the VertexData of the box
  119597. */
  119598. static CreateBox(options: {
  119599. size?: number;
  119600. width?: number;
  119601. height?: number;
  119602. depth?: number;
  119603. faceUV?: Vector4[];
  119604. faceColors?: Color4[];
  119605. sideOrientation?: number;
  119606. frontUVs?: Vector4;
  119607. backUVs?: Vector4;
  119608. }): VertexData;
  119609. /**
  119610. * Creates the VertexData for a tiled box
  119611. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119612. * * faceTiles sets the pattern, tile size and number of tiles for a face
  119613. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  119614. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  119615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119616. * @returns the VertexData of the box
  119617. */
  119618. static CreateTiledBox(options: {
  119619. pattern?: number;
  119620. width?: number;
  119621. height?: number;
  119622. depth?: number;
  119623. tileSize?: number;
  119624. tileWidth?: number;
  119625. tileHeight?: number;
  119626. alignHorizontal?: number;
  119627. alignVertical?: number;
  119628. faceUV?: Vector4[];
  119629. faceColors?: Color4[];
  119630. sideOrientation?: number;
  119631. }): VertexData;
  119632. /**
  119633. * Creates the VertexData for a tiled plane
  119634. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119635. * * pattern a limited pattern arrangement depending on the number
  119636. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  119637. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  119638. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  119639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119640. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119641. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119642. * @returns the VertexData of the tiled plane
  119643. */
  119644. static CreateTiledPlane(options: {
  119645. pattern?: number;
  119646. tileSize?: number;
  119647. tileWidth?: number;
  119648. tileHeight?: number;
  119649. size?: number;
  119650. width?: number;
  119651. height?: number;
  119652. alignHorizontal?: number;
  119653. alignVertical?: number;
  119654. sideOrientation?: number;
  119655. frontUVs?: Vector4;
  119656. backUVs?: Vector4;
  119657. }): VertexData;
  119658. /**
  119659. * Creates the VertexData for an ellipsoid, defaults to a sphere
  119660. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119661. * * segments sets the number of horizontal strips optional, default 32
  119662. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  119663. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  119664. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  119665. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  119666. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  119667. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  119668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119669. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119670. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119671. * @returns the VertexData of the ellipsoid
  119672. */
  119673. static CreateSphere(options: {
  119674. segments?: number;
  119675. diameter?: number;
  119676. diameterX?: number;
  119677. diameterY?: number;
  119678. diameterZ?: number;
  119679. arc?: number;
  119680. slice?: number;
  119681. sideOrientation?: number;
  119682. frontUVs?: Vector4;
  119683. backUVs?: Vector4;
  119684. }): VertexData;
  119685. /**
  119686. * Creates the VertexData for a cylinder, cone or prism
  119687. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119688. * * height sets the height (y direction) of the cylinder, optional, default 2
  119689. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  119690. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  119691. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  119692. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119693. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  119694. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  119695. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119696. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119697. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  119698. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  119699. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119700. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119701. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119702. * @returns the VertexData of the cylinder, cone or prism
  119703. */
  119704. static CreateCylinder(options: {
  119705. height?: number;
  119706. diameterTop?: number;
  119707. diameterBottom?: number;
  119708. diameter?: number;
  119709. tessellation?: number;
  119710. subdivisions?: number;
  119711. arc?: number;
  119712. faceColors?: Color4[];
  119713. faceUV?: Vector4[];
  119714. hasRings?: boolean;
  119715. enclose?: boolean;
  119716. sideOrientation?: number;
  119717. frontUVs?: Vector4;
  119718. backUVs?: Vector4;
  119719. }): VertexData;
  119720. /**
  119721. * Creates the VertexData for a torus
  119722. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119723. * * diameter the diameter of the torus, optional default 1
  119724. * * thickness the diameter of the tube forming the torus, optional default 0.5
  119725. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119727. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119728. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119729. * @returns the VertexData of the torus
  119730. */
  119731. static CreateTorus(options: {
  119732. diameter?: number;
  119733. thickness?: number;
  119734. tessellation?: number;
  119735. sideOrientation?: number;
  119736. frontUVs?: Vector4;
  119737. backUVs?: Vector4;
  119738. }): VertexData;
  119739. /**
  119740. * Creates the VertexData of the LineSystem
  119741. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  119742. * - lines an array of lines, each line being an array of successive Vector3
  119743. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  119744. * @returns the VertexData of the LineSystem
  119745. */
  119746. static CreateLineSystem(options: {
  119747. lines: Vector3[][];
  119748. colors?: Nullable<Color4[][]>;
  119749. }): VertexData;
  119750. /**
  119751. * Create the VertexData for a DashedLines
  119752. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  119753. * - points an array successive Vector3
  119754. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  119755. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  119756. * - dashNb the intended total number of dashes, optional, default 200
  119757. * @returns the VertexData for the DashedLines
  119758. */
  119759. static CreateDashedLines(options: {
  119760. points: Vector3[];
  119761. dashSize?: number;
  119762. gapSize?: number;
  119763. dashNb?: number;
  119764. }): VertexData;
  119765. /**
  119766. * Creates the VertexData for a Ground
  119767. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119768. * - width the width (x direction) of the ground, optional, default 1
  119769. * - height the height (z direction) of the ground, optional, default 1
  119770. * - subdivisions the number of subdivisions per side, optional, default 1
  119771. * @returns the VertexData of the Ground
  119772. */
  119773. static CreateGround(options: {
  119774. width?: number;
  119775. height?: number;
  119776. subdivisions?: number;
  119777. subdivisionsX?: number;
  119778. subdivisionsY?: number;
  119779. }): VertexData;
  119780. /**
  119781. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  119782. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119783. * * xmin the ground minimum X coordinate, optional, default -1
  119784. * * zmin the ground minimum Z coordinate, optional, default -1
  119785. * * xmax the ground maximum X coordinate, optional, default 1
  119786. * * zmax the ground maximum Z coordinate, optional, default 1
  119787. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  119788. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  119789. * @returns the VertexData of the TiledGround
  119790. */
  119791. static CreateTiledGround(options: {
  119792. xmin: number;
  119793. zmin: number;
  119794. xmax: number;
  119795. zmax: number;
  119796. subdivisions?: {
  119797. w: number;
  119798. h: number;
  119799. };
  119800. precision?: {
  119801. w: number;
  119802. h: number;
  119803. };
  119804. }): VertexData;
  119805. /**
  119806. * Creates the VertexData of the Ground designed from a heightmap
  119807. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  119808. * * width the width (x direction) of the ground
  119809. * * height the height (z direction) of the ground
  119810. * * subdivisions the number of subdivisions per side
  119811. * * minHeight the minimum altitude on the ground, optional, default 0
  119812. * * maxHeight the maximum altitude on the ground, optional default 1
  119813. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  119814. * * buffer the array holding the image color data
  119815. * * bufferWidth the width of image
  119816. * * bufferHeight the height of image
  119817. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  119818. * @returns the VertexData of the Ground designed from a heightmap
  119819. */
  119820. static CreateGroundFromHeightMap(options: {
  119821. width: number;
  119822. height: number;
  119823. subdivisions: number;
  119824. minHeight: number;
  119825. maxHeight: number;
  119826. colorFilter: Color3;
  119827. buffer: Uint8Array;
  119828. bufferWidth: number;
  119829. bufferHeight: number;
  119830. alphaFilter: number;
  119831. }): VertexData;
  119832. /**
  119833. * Creates the VertexData for a Plane
  119834. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  119835. * * size sets the width and height of the plane to the value of size, optional default 1
  119836. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  119837. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  119838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119839. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119840. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119841. * @returns the VertexData of the box
  119842. */
  119843. static CreatePlane(options: {
  119844. size?: number;
  119845. width?: number;
  119846. height?: number;
  119847. sideOrientation?: number;
  119848. frontUVs?: Vector4;
  119849. backUVs?: Vector4;
  119850. }): VertexData;
  119851. /**
  119852. * Creates the VertexData of the Disc or regular Polygon
  119853. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  119854. * * radius the radius of the disc, optional default 0.5
  119855. * * tessellation the number of polygon sides, optional, default 64
  119856. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  119857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119858. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119859. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119860. * @returns the VertexData of the box
  119861. */
  119862. static CreateDisc(options: {
  119863. radius?: number;
  119864. tessellation?: number;
  119865. arc?: number;
  119866. sideOrientation?: number;
  119867. frontUVs?: Vector4;
  119868. backUVs?: Vector4;
  119869. }): VertexData;
  119870. /**
  119871. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  119872. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  119873. * @param polygon a mesh built from polygonTriangulation.build()
  119874. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119875. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119876. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119877. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119878. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119879. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  119880. * @returns the VertexData of the Polygon
  119881. */
  119882. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  119883. /**
  119884. * Creates the VertexData of the IcoSphere
  119885. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  119886. * * radius the radius of the IcoSphere, optional default 1
  119887. * * radiusX allows stretching in the x direction, optional, default radius
  119888. * * radiusY allows stretching in the y direction, optional, default radius
  119889. * * radiusZ allows stretching in the z direction, optional, default radius
  119890. * * flat when true creates a flat shaded mesh, optional, default true
  119891. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119893. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119894. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119895. * @returns the VertexData of the IcoSphere
  119896. */
  119897. static CreateIcoSphere(options: {
  119898. radius?: number;
  119899. radiusX?: number;
  119900. radiusY?: number;
  119901. radiusZ?: number;
  119902. flat?: boolean;
  119903. subdivisions?: number;
  119904. sideOrientation?: number;
  119905. frontUVs?: Vector4;
  119906. backUVs?: Vector4;
  119907. }): VertexData;
  119908. /**
  119909. * Creates the VertexData for a Polyhedron
  119910. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  119911. * * type provided types are:
  119912. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  119913. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  119914. * * size the size of the IcoSphere, optional default 1
  119915. * * sizeX allows stretching in the x direction, optional, default size
  119916. * * sizeY allows stretching in the y direction, optional, default size
  119917. * * sizeZ allows stretching in the z direction, optional, default size
  119918. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  119919. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119920. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119921. * * flat when true creates a flat shaded mesh, optional, default true
  119922. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119923. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119924. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119925. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119926. * @returns the VertexData of the Polyhedron
  119927. */
  119928. static CreatePolyhedron(options: {
  119929. type?: number;
  119930. size?: number;
  119931. sizeX?: number;
  119932. sizeY?: number;
  119933. sizeZ?: number;
  119934. custom?: any;
  119935. faceUV?: Vector4[];
  119936. faceColors?: Color4[];
  119937. flat?: boolean;
  119938. sideOrientation?: number;
  119939. frontUVs?: Vector4;
  119940. backUVs?: Vector4;
  119941. }): VertexData;
  119942. /**
  119943. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  119944. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  119945. * @returns the VertexData of the Capsule
  119946. */
  119947. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  119948. /**
  119949. * Creates the VertexData for a TorusKnot
  119950. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  119951. * * radius the radius of the torus knot, optional, default 2
  119952. * * tube the thickness of the tube, optional, default 0.5
  119953. * * radialSegments the number of sides on each tube segments, optional, default 32
  119954. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  119955. * * p the number of windings around the z axis, optional, default 2
  119956. * * q the number of windings around the x axis, optional, default 3
  119957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119958. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  119959. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  119960. * @returns the VertexData of the Torus Knot
  119961. */
  119962. static CreateTorusKnot(options: {
  119963. radius?: number;
  119964. tube?: number;
  119965. radialSegments?: number;
  119966. tubularSegments?: number;
  119967. p?: number;
  119968. q?: number;
  119969. sideOrientation?: number;
  119970. frontUVs?: Vector4;
  119971. backUVs?: Vector4;
  119972. }): VertexData;
  119973. /**
  119974. * Compute normals for given positions and indices
  119975. * @param positions an array of vertex positions, [...., x, y, z, ......]
  119976. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  119977. * @param normals an array of vertex normals, [...., x, y, z, ......]
  119978. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  119979. * * facetNormals : optional array of facet normals (vector3)
  119980. * * facetPositions : optional array of facet positions (vector3)
  119981. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  119982. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  119983. * * bInfo : optional bounding info, required for facetPartitioning computation
  119984. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  119985. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  119986. * * useRightHandedSystem: optional boolean to for right handed system computation
  119987. * * depthSort : optional boolean to enable the facet depth sort computation
  119988. * * distanceTo : optional Vector3 to compute the facet depth from this location
  119989. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  119990. */
  119991. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  119992. facetNormals?: any;
  119993. facetPositions?: any;
  119994. facetPartitioning?: any;
  119995. ratio?: number;
  119996. bInfo?: any;
  119997. bbSize?: Vector3;
  119998. subDiv?: any;
  119999. useRightHandedSystem?: boolean;
  120000. depthSort?: boolean;
  120001. distanceTo?: Vector3;
  120002. depthSortedFacets?: any;
  120003. }): void;
  120004. /** @hidden */
  120005. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  120006. /**
  120007. * Applies VertexData created from the imported parameters to the geometry
  120008. * @param parsedVertexData the parsed data from an imported file
  120009. * @param geometry the geometry to apply the VertexData to
  120010. */
  120011. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  120012. }
  120013. }
  120014. declare module BABYLON {
  120015. /**
  120016. * Class containing static functions to help procedurally build meshes
  120017. */
  120018. export class DiscBuilder {
  120019. /**
  120020. * Creates a plane polygonal mesh. By default, this is a disc
  120021. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  120022. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  120023. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  120024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120027. * @param name defines the name of the mesh
  120028. * @param options defines the options used to create the mesh
  120029. * @param scene defines the hosting scene
  120030. * @returns the plane polygonal mesh
  120031. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  120032. */
  120033. static CreateDisc(name: string, options: {
  120034. radius?: number;
  120035. tessellation?: number;
  120036. arc?: number;
  120037. updatable?: boolean;
  120038. sideOrientation?: number;
  120039. frontUVs?: Vector4;
  120040. backUVs?: Vector4;
  120041. }, scene?: Nullable<Scene>): Mesh;
  120042. }
  120043. }
  120044. declare module BABYLON {
  120045. /**
  120046. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  120047. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  120048. * The SPS is also a particle system. It provides some methods to manage the particles.
  120049. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  120050. *
  120051. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  120052. */
  120053. export class SolidParticleSystem implements IDisposable {
  120054. /**
  120055. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  120056. * Example : var p = SPS.particles[i];
  120057. */
  120058. particles: SolidParticle[];
  120059. /**
  120060. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  120061. */
  120062. nbParticles: number;
  120063. /**
  120064. * If the particles must ever face the camera (default false). Useful for planar particles.
  120065. */
  120066. billboard: boolean;
  120067. /**
  120068. * Recompute normals when adding a shape
  120069. */
  120070. recomputeNormals: boolean;
  120071. /**
  120072. * This a counter ofr your own usage. It's not set by any SPS functions.
  120073. */
  120074. counter: number;
  120075. /**
  120076. * The SPS name. This name is also given to the underlying mesh.
  120077. */
  120078. name: string;
  120079. /**
  120080. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  120081. */
  120082. mesh: Mesh;
  120083. /**
  120084. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  120085. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  120086. */
  120087. vars: any;
  120088. /**
  120089. * This array is populated when the SPS is set as 'pickable'.
  120090. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  120091. * Each element of this array is an object `{idx: int, faceId: int}`.
  120092. * `idx` is the picked particle index in the `SPS.particles` array
  120093. * `faceId` is the picked face index counted within this particle.
  120094. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  120095. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  120096. * Use the method SPS.pickedParticle(pickingInfo) instead.
  120097. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  120098. */
  120099. pickedParticles: {
  120100. idx: number;
  120101. faceId: number;
  120102. }[];
  120103. /**
  120104. * This array is populated when the SPS is set as 'pickable'
  120105. * Each key of this array is a submesh index.
  120106. * Each element of this array is a second array defined like this :
  120107. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  120108. * Each element of this second array is an object `{idx: int, faceId: int}`.
  120109. * `idx` is the picked particle index in the `SPS.particles` array
  120110. * `faceId` is the picked face index counted within this particle.
  120111. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  120112. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  120113. */
  120114. pickedBySubMesh: {
  120115. idx: number;
  120116. faceId: number;
  120117. }[][];
  120118. /**
  120119. * This array is populated when `enableDepthSort` is set to true.
  120120. * Each element of this array is an instance of the class DepthSortedParticle.
  120121. */
  120122. depthSortedParticles: DepthSortedParticle[];
  120123. /**
  120124. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  120125. * @hidden
  120126. */
  120127. _bSphereOnly: boolean;
  120128. /**
  120129. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  120130. * @hidden
  120131. */
  120132. _bSphereRadiusFactor: number;
  120133. private _scene;
  120134. private _positions;
  120135. private _indices;
  120136. private _normals;
  120137. private _colors;
  120138. private _uvs;
  120139. private _indices32;
  120140. private _positions32;
  120141. private _normals32;
  120142. private _fixedNormal32;
  120143. private _colors32;
  120144. private _uvs32;
  120145. private _index;
  120146. private _updatable;
  120147. private _pickable;
  120148. private _isVisibilityBoxLocked;
  120149. private _alwaysVisible;
  120150. private _depthSort;
  120151. private _expandable;
  120152. private _shapeCounter;
  120153. private _copy;
  120154. private _color;
  120155. private _computeParticleColor;
  120156. private _computeParticleTexture;
  120157. private _computeParticleRotation;
  120158. private _computeParticleVertex;
  120159. private _computeBoundingBox;
  120160. private _depthSortParticles;
  120161. private _camera;
  120162. private _mustUnrotateFixedNormals;
  120163. private _particlesIntersect;
  120164. private _needs32Bits;
  120165. private _isNotBuilt;
  120166. private _lastParticleId;
  120167. private _idxOfId;
  120168. private _multimaterialEnabled;
  120169. private _useModelMaterial;
  120170. private _indicesByMaterial;
  120171. private _materialIndexes;
  120172. private _depthSortFunction;
  120173. private _materialSortFunction;
  120174. private _materials;
  120175. private _multimaterial;
  120176. private _materialIndexesById;
  120177. private _defaultMaterial;
  120178. private _autoUpdateSubMeshes;
  120179. private _tmpVertex;
  120180. /**
  120181. * Creates a SPS (Solid Particle System) object.
  120182. * @param name (String) is the SPS name, this will be the underlying mesh name.
  120183. * @param scene (Scene) is the scene in which the SPS is added.
  120184. * @param options defines the options of the sps e.g.
  120185. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  120186. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  120187. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  120188. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  120189. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  120190. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  120191. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  120192. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  120193. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  120194. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  120195. */
  120196. constructor(name: string, scene: Scene, options?: {
  120197. updatable?: boolean;
  120198. isPickable?: boolean;
  120199. enableDepthSort?: boolean;
  120200. particleIntersection?: boolean;
  120201. boundingSphereOnly?: boolean;
  120202. bSphereRadiusFactor?: number;
  120203. expandable?: boolean;
  120204. useModelMaterial?: boolean;
  120205. enableMultiMaterial?: boolean;
  120206. });
  120207. /**
  120208. * Builds the SPS underlying mesh. Returns a standard Mesh.
  120209. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  120210. * @returns the created mesh
  120211. */
  120212. buildMesh(): Mesh;
  120213. /**
  120214. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  120215. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  120216. * Thus the particles generated from `digest()` have their property `position` set yet.
  120217. * @param mesh ( Mesh ) is the mesh to be digested
  120218. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  120219. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  120220. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  120221. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  120222. * @returns the current SPS
  120223. */
  120224. digest(mesh: Mesh, options?: {
  120225. facetNb?: number;
  120226. number?: number;
  120227. delta?: number;
  120228. storage?: [];
  120229. }): SolidParticleSystem;
  120230. /**
  120231. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  120232. * @hidden
  120233. */
  120234. private _unrotateFixedNormals;
  120235. /**
  120236. * Resets the temporary working copy particle
  120237. * @hidden
  120238. */
  120239. private _resetCopy;
  120240. /**
  120241. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  120242. * @param p the current index in the positions array to be updated
  120243. * @param ind the current index in the indices array
  120244. * @param shape a Vector3 array, the shape geometry
  120245. * @param positions the positions array to be updated
  120246. * @param meshInd the shape indices array
  120247. * @param indices the indices array to be updated
  120248. * @param meshUV the shape uv array
  120249. * @param uvs the uv array to be updated
  120250. * @param meshCol the shape color array
  120251. * @param colors the color array to be updated
  120252. * @param meshNor the shape normals array
  120253. * @param normals the normals array to be updated
  120254. * @param idx the particle index
  120255. * @param idxInShape the particle index in its shape
  120256. * @param options the addShape() method passed options
  120257. * @model the particle model
  120258. * @hidden
  120259. */
  120260. private _meshBuilder;
  120261. /**
  120262. * Returns a shape Vector3 array from positions float array
  120263. * @param positions float array
  120264. * @returns a vector3 array
  120265. * @hidden
  120266. */
  120267. private _posToShape;
  120268. /**
  120269. * Returns a shapeUV array from a float uvs (array deep copy)
  120270. * @param uvs as a float array
  120271. * @returns a shapeUV array
  120272. * @hidden
  120273. */
  120274. private _uvsToShapeUV;
  120275. /**
  120276. * Adds a new particle object in the particles array
  120277. * @param idx particle index in particles array
  120278. * @param id particle id
  120279. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  120280. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  120281. * @param model particle ModelShape object
  120282. * @param shapeId model shape identifier
  120283. * @param idxInShape index of the particle in the current model
  120284. * @param bInfo model bounding info object
  120285. * @param storage target storage array, if any
  120286. * @hidden
  120287. */
  120288. private _addParticle;
  120289. /**
  120290. * Adds some particles to the SPS from the model shape. Returns the shape id.
  120291. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  120292. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  120293. * @param nb (positive integer) the number of particles to be created from this model
  120294. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  120295. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  120296. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  120297. * @returns the number of shapes in the system
  120298. */
  120299. addShape(mesh: Mesh, nb: number, options?: {
  120300. positionFunction?: any;
  120301. vertexFunction?: any;
  120302. storage?: [];
  120303. }): number;
  120304. /**
  120305. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  120306. * @hidden
  120307. */
  120308. private _rebuildParticle;
  120309. /**
  120310. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  120311. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  120312. * @returns the SPS.
  120313. */
  120314. rebuildMesh(reset?: boolean): SolidParticleSystem;
  120315. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  120316. * Returns an array with the removed particles.
  120317. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  120318. * The SPS can't be empty so at least one particle needs to remain in place.
  120319. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  120320. * @param start index of the first particle to remove
  120321. * @param end index of the last particle to remove (included)
  120322. * @returns an array populated with the removed particles
  120323. */
  120324. removeParticles(start: number, end: number): SolidParticle[];
  120325. /**
  120326. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  120327. * @param solidParticleArray an array populated with Solid Particles objects
  120328. * @returns the SPS
  120329. */
  120330. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  120331. /**
  120332. * Creates a new particle and modifies the SPS mesh geometry :
  120333. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  120334. * - calls _addParticle() to populate the particle array
  120335. * factorized code from addShape() and insertParticlesFromArray()
  120336. * @param idx particle index in the particles array
  120337. * @param i particle index in its shape
  120338. * @param modelShape particle ModelShape object
  120339. * @param shape shape vertex array
  120340. * @param meshInd shape indices array
  120341. * @param meshUV shape uv array
  120342. * @param meshCol shape color array
  120343. * @param meshNor shape normals array
  120344. * @param bbInfo shape bounding info
  120345. * @param storage target particle storage
  120346. * @options addShape() passed options
  120347. * @hidden
  120348. */
  120349. private _insertNewParticle;
  120350. /**
  120351. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  120352. * This method calls `updateParticle()` for each particle of the SPS.
  120353. * For an animated SPS, it is usually called within the render loop.
  120354. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  120355. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  120356. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  120357. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  120358. * @returns the SPS.
  120359. */
  120360. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  120361. /**
  120362. * Disposes the SPS.
  120363. */
  120364. dispose(): void;
  120365. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  120366. * idx is the particle index in the SPS
  120367. * faceId is the picked face index counted within this particle.
  120368. * Returns null if the pickInfo can't identify a picked particle.
  120369. * @param pickingInfo (PickingInfo object)
  120370. * @returns {idx: number, faceId: number} or null
  120371. */
  120372. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  120373. idx: number;
  120374. faceId: number;
  120375. }>;
  120376. /**
  120377. * Returns a SolidParticle object from its identifier : particle.id
  120378. * @param id (integer) the particle Id
  120379. * @returns the searched particle or null if not found in the SPS.
  120380. */
  120381. getParticleById(id: number): Nullable<SolidParticle>;
  120382. /**
  120383. * Returns a new array populated with the particles having the passed shapeId.
  120384. * @param shapeId (integer) the shape identifier
  120385. * @returns a new solid particle array
  120386. */
  120387. getParticlesByShapeId(shapeId: number): SolidParticle[];
  120388. /**
  120389. * Populates the passed array "ref" with the particles having the passed shapeId.
  120390. * @param shapeId the shape identifier
  120391. * @returns the SPS
  120392. * @param ref
  120393. */
  120394. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  120395. /**
  120396. * Computes the required SubMeshes according the materials assigned to the particles.
  120397. * @returns the solid particle system.
  120398. * Does nothing if called before the SPS mesh is built.
  120399. */
  120400. computeSubMeshes(): SolidParticleSystem;
  120401. /**
  120402. * Sorts the solid particles by material when MultiMaterial is enabled.
  120403. * Updates the indices32 array.
  120404. * Updates the indicesByMaterial array.
  120405. * Updates the mesh indices array.
  120406. * @returns the SPS
  120407. * @hidden
  120408. */
  120409. private _sortParticlesByMaterial;
  120410. /**
  120411. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  120412. * @hidden
  120413. */
  120414. private _setMaterialIndexesById;
  120415. /**
  120416. * Returns an array with unique values of Materials from the passed array
  120417. * @param array the material array to be checked and filtered
  120418. * @hidden
  120419. */
  120420. private _filterUniqueMaterialId;
  120421. /**
  120422. * Sets a new Standard Material as _defaultMaterial if not already set.
  120423. * @hidden
  120424. */
  120425. private _setDefaultMaterial;
  120426. /**
  120427. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  120428. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120429. * @returns the SPS.
  120430. */
  120431. refreshVisibleSize(): SolidParticleSystem;
  120432. /**
  120433. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  120434. * @param size the size (float) of the visibility box
  120435. * note : this doesn't lock the SPS mesh bounding box.
  120436. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120437. */
  120438. setVisibilityBox(size: number): void;
  120439. /**
  120440. * Gets whether the SPS as always visible or not
  120441. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120442. */
  120443. get isAlwaysVisible(): boolean;
  120444. /**
  120445. * Sets the SPS as always visible or not
  120446. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120447. */
  120448. set isAlwaysVisible(val: boolean);
  120449. /**
  120450. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  120451. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120452. */
  120453. set isVisibilityBoxLocked(val: boolean);
  120454. /**
  120455. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  120456. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  120457. */
  120458. get isVisibilityBoxLocked(): boolean;
  120459. /**
  120460. * Tells to `setParticles()` to compute the particle rotations or not.
  120461. * Default value : true. The SPS is faster when it's set to false.
  120462. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  120463. */
  120464. set computeParticleRotation(val: boolean);
  120465. /**
  120466. * Tells to `setParticles()` to compute the particle colors or not.
  120467. * Default value : true. The SPS is faster when it's set to false.
  120468. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  120469. */
  120470. set computeParticleColor(val: boolean);
  120471. set computeParticleTexture(val: boolean);
  120472. /**
  120473. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  120474. * Default value : false. The SPS is faster when it's set to false.
  120475. * Note : the particle custom vertex positions aren't stored values.
  120476. */
  120477. set computeParticleVertex(val: boolean);
  120478. /**
  120479. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  120480. */
  120481. set computeBoundingBox(val: boolean);
  120482. /**
  120483. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  120484. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  120485. * Default : `true`
  120486. */
  120487. set depthSortParticles(val: boolean);
  120488. /**
  120489. * Gets if `setParticles()` computes the particle rotations or not.
  120490. * Default value : true. The SPS is faster when it's set to false.
  120491. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  120492. */
  120493. get computeParticleRotation(): boolean;
  120494. /**
  120495. * Gets if `setParticles()` computes the particle colors or not.
  120496. * Default value : true. The SPS is faster when it's set to false.
  120497. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  120498. */
  120499. get computeParticleColor(): boolean;
  120500. /**
  120501. * Gets if `setParticles()` computes the particle textures or not.
  120502. * Default value : true. The SPS is faster when it's set to false.
  120503. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  120504. */
  120505. get computeParticleTexture(): boolean;
  120506. /**
  120507. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  120508. * Default value : false. The SPS is faster when it's set to false.
  120509. * Note : the particle custom vertex positions aren't stored values.
  120510. */
  120511. get computeParticleVertex(): boolean;
  120512. /**
  120513. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  120514. */
  120515. get computeBoundingBox(): boolean;
  120516. /**
  120517. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  120518. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  120519. * Default : `true`
  120520. */
  120521. get depthSortParticles(): boolean;
  120522. /**
  120523. * Gets if the SPS is created as expandable at construction time.
  120524. * Default : `false`
  120525. */
  120526. get expandable(): boolean;
  120527. /**
  120528. * Gets if the SPS supports the Multi Materials
  120529. */
  120530. get multimaterialEnabled(): boolean;
  120531. /**
  120532. * Gets if the SPS uses the model materials for its own multimaterial.
  120533. */
  120534. get useModelMaterial(): boolean;
  120535. /**
  120536. * The SPS used material array.
  120537. */
  120538. get materials(): Material[];
  120539. /**
  120540. * Sets the SPS MultiMaterial from the passed materials.
  120541. * Note : the passed array is internally copied and not used then by reference.
  120542. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  120543. */
  120544. setMultiMaterial(materials: Material[]): void;
  120545. /**
  120546. * The SPS computed multimaterial object
  120547. */
  120548. get multimaterial(): MultiMaterial;
  120549. set multimaterial(mm: MultiMaterial);
  120550. /**
  120551. * If the subMeshes must be updated on the next call to setParticles()
  120552. */
  120553. get autoUpdateSubMeshes(): boolean;
  120554. set autoUpdateSubMeshes(val: boolean);
  120555. /**
  120556. * This function does nothing. It may be overwritten to set all the particle first values.
  120557. * The SPS doesn't call this function, you may have to call it by your own.
  120558. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  120559. */
  120560. initParticles(): void;
  120561. /**
  120562. * This function does nothing. It may be overwritten to recycle a particle.
  120563. * The SPS doesn't call this function, you may have to call it by your own.
  120564. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  120565. * @param particle The particle to recycle
  120566. * @returns the recycled particle
  120567. */
  120568. recycleParticle(particle: SolidParticle): SolidParticle;
  120569. /**
  120570. * Updates a particle : this function should be overwritten by the user.
  120571. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  120572. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  120573. * @example : just set a particle position or velocity and recycle conditions
  120574. * @param particle The particle to update
  120575. * @returns the updated particle
  120576. */
  120577. updateParticle(particle: SolidParticle): SolidParticle;
  120578. /**
  120579. * Updates a vertex of a particle : it can be overwritten by the user.
  120580. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  120581. * @param particle the current particle
  120582. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  120583. * @param pt the index of the current vertex in the particle shape
  120584. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  120585. * @example : just set a vertex particle position or color
  120586. * @returns the sps
  120587. */
  120588. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  120589. /**
  120590. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  120591. * This does nothing and may be overwritten by the user.
  120592. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120593. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120594. * @param update the boolean update value actually passed to setParticles()
  120595. */
  120596. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  120597. /**
  120598. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  120599. * This will be passed three parameters.
  120600. * This does nothing and may be overwritten by the user.
  120601. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120602. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  120603. * @param update the boolean update value actually passed to setParticles()
  120604. */
  120605. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  120606. }
  120607. }
  120608. declare module BABYLON {
  120609. /**
  120610. * Represents one particle of a solid particle system.
  120611. */
  120612. export class SolidParticle {
  120613. /**
  120614. * particle global index
  120615. */
  120616. idx: number;
  120617. /**
  120618. * particle identifier
  120619. */
  120620. id: number;
  120621. /**
  120622. * The color of the particle
  120623. */
  120624. color: Nullable<Color4>;
  120625. /**
  120626. * The world space position of the particle.
  120627. */
  120628. position: Vector3;
  120629. /**
  120630. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  120631. */
  120632. rotation: Vector3;
  120633. /**
  120634. * The world space rotation quaternion of the particle.
  120635. */
  120636. rotationQuaternion: Nullable<Quaternion>;
  120637. /**
  120638. * The scaling of the particle.
  120639. */
  120640. scaling: Vector3;
  120641. /**
  120642. * The uvs of the particle.
  120643. */
  120644. uvs: Vector4;
  120645. /**
  120646. * The current speed of the particle.
  120647. */
  120648. velocity: Vector3;
  120649. /**
  120650. * The pivot point in the particle local space.
  120651. */
  120652. pivot: Vector3;
  120653. /**
  120654. * Must the particle be translated from its pivot point in its local space ?
  120655. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  120656. * Default : false
  120657. */
  120658. translateFromPivot: boolean;
  120659. /**
  120660. * Is the particle active or not ?
  120661. */
  120662. alive: boolean;
  120663. /**
  120664. * Is the particle visible or not ?
  120665. */
  120666. isVisible: boolean;
  120667. /**
  120668. * Index of this particle in the global "positions" array (Internal use)
  120669. * @hidden
  120670. */
  120671. _pos: number;
  120672. /**
  120673. * @hidden Index of this particle in the global "indices" array (Internal use)
  120674. */
  120675. _ind: number;
  120676. /**
  120677. * @hidden ModelShape of this particle (Internal use)
  120678. */
  120679. _model: ModelShape;
  120680. /**
  120681. * ModelShape id of this particle
  120682. */
  120683. shapeId: number;
  120684. /**
  120685. * Index of the particle in its shape id
  120686. */
  120687. idxInShape: number;
  120688. /**
  120689. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  120690. */
  120691. _modelBoundingInfo: BoundingInfo;
  120692. /**
  120693. * @hidden Particle BoundingInfo object (Internal use)
  120694. */
  120695. _boundingInfo: BoundingInfo;
  120696. /**
  120697. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  120698. */
  120699. _sps: SolidParticleSystem;
  120700. /**
  120701. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  120702. */
  120703. _stillInvisible: boolean;
  120704. /**
  120705. * @hidden Last computed particle rotation matrix
  120706. */
  120707. _rotationMatrix: number[];
  120708. /**
  120709. * Parent particle Id, if any.
  120710. * Default null.
  120711. */
  120712. parentId: Nullable<number>;
  120713. /**
  120714. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  120715. */
  120716. materialIndex: Nullable<number>;
  120717. /**
  120718. * Custom object or properties.
  120719. */
  120720. props: Nullable<any>;
  120721. /**
  120722. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  120723. * The possible values are :
  120724. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  120725. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120726. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  120727. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  120728. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120729. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  120730. * */
  120731. cullingStrategy: number;
  120732. /**
  120733. * @hidden Internal global position in the SPS.
  120734. */
  120735. _globalPosition: Vector3;
  120736. /**
  120737. * Creates a Solid Particle object.
  120738. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  120739. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  120740. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  120741. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  120742. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  120743. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  120744. * @param shapeId (integer) is the model shape identifier in the SPS.
  120745. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  120746. * @param sps defines the sps it is associated to
  120747. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  120748. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  120749. */
  120750. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  120751. /**
  120752. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  120753. * @param target the particle target
  120754. * @returns the current particle
  120755. */
  120756. copyToRef(target: SolidParticle): SolidParticle;
  120757. /**
  120758. * Legacy support, changed scale to scaling
  120759. */
  120760. get scale(): Vector3;
  120761. /**
  120762. * Legacy support, changed scale to scaling
  120763. */
  120764. set scale(scale: Vector3);
  120765. /**
  120766. * Legacy support, changed quaternion to rotationQuaternion
  120767. */
  120768. get quaternion(): Nullable<Quaternion>;
  120769. /**
  120770. * Legacy support, changed quaternion to rotationQuaternion
  120771. */
  120772. set quaternion(q: Nullable<Quaternion>);
  120773. /**
  120774. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  120775. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  120776. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  120777. * @returns true if it intersects
  120778. */
  120779. intersectsMesh(target: Mesh | SolidParticle): boolean;
  120780. /**
  120781. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  120782. * A particle is in the frustum if its bounding box intersects the frustum
  120783. * @param frustumPlanes defines the frustum to test
  120784. * @returns true if the particle is in the frustum planes
  120785. */
  120786. isInFrustum(frustumPlanes: Plane[]): boolean;
  120787. /**
  120788. * get the rotation matrix of the particle
  120789. * @hidden
  120790. */
  120791. getRotationMatrix(m: Matrix): void;
  120792. }
  120793. /**
  120794. * Represents the shape of the model used by one particle of a solid particle system.
  120795. * SPS internal tool, don't use it manually.
  120796. */
  120797. export class ModelShape {
  120798. /**
  120799. * The shape id
  120800. * @hidden
  120801. */
  120802. shapeID: number;
  120803. /**
  120804. * flat array of model positions (internal use)
  120805. * @hidden
  120806. */
  120807. _shape: Vector3[];
  120808. /**
  120809. * flat array of model UVs (internal use)
  120810. * @hidden
  120811. */
  120812. _shapeUV: number[];
  120813. /**
  120814. * color array of the model
  120815. * @hidden
  120816. */
  120817. _shapeColors: number[];
  120818. /**
  120819. * indices array of the model
  120820. * @hidden
  120821. */
  120822. _indices: number[];
  120823. /**
  120824. * normals array of the model
  120825. * @hidden
  120826. */
  120827. _normals: number[];
  120828. /**
  120829. * length of the shape in the model indices array (internal use)
  120830. * @hidden
  120831. */
  120832. _indicesLength: number;
  120833. /**
  120834. * Custom position function (internal use)
  120835. * @hidden
  120836. */
  120837. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  120838. /**
  120839. * Custom vertex function (internal use)
  120840. * @hidden
  120841. */
  120842. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  120843. /**
  120844. * Model material (internal use)
  120845. * @hidden
  120846. */
  120847. _material: Nullable<Material>;
  120848. /**
  120849. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  120850. * SPS internal tool, don't use it manually.
  120851. * @hidden
  120852. */
  120853. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  120854. }
  120855. /**
  120856. * Represents a Depth Sorted Particle in the solid particle system.
  120857. * @hidden
  120858. */
  120859. export class DepthSortedParticle {
  120860. /**
  120861. * Particle index
  120862. */
  120863. idx: number;
  120864. /**
  120865. * Index of the particle in the "indices" array
  120866. */
  120867. ind: number;
  120868. /**
  120869. * Length of the particle shape in the "indices" array
  120870. */
  120871. indicesLength: number;
  120872. /**
  120873. * Squared distance from the particle to the camera
  120874. */
  120875. sqDistance: number;
  120876. /**
  120877. * Material index when used with MultiMaterials
  120878. */
  120879. materialIndex: number;
  120880. /**
  120881. * Creates a new sorted particle
  120882. * @param materialIndex
  120883. */
  120884. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  120885. }
  120886. /**
  120887. * Represents a solid particle vertex
  120888. */
  120889. export class SolidParticleVertex {
  120890. /**
  120891. * Vertex position
  120892. */
  120893. position: Vector3;
  120894. /**
  120895. * Vertex color
  120896. */
  120897. color: Color4;
  120898. /**
  120899. * Vertex UV
  120900. */
  120901. uv: Vector2;
  120902. /**
  120903. * Creates a new solid particle vertex
  120904. */
  120905. constructor();
  120906. /** Vertex x coordinate */
  120907. get x(): number;
  120908. set x(val: number);
  120909. /** Vertex y coordinate */
  120910. get y(): number;
  120911. set y(val: number);
  120912. /** Vertex z coordinate */
  120913. get z(): number;
  120914. set z(val: number);
  120915. }
  120916. }
  120917. declare module BABYLON {
  120918. /**
  120919. * @hidden
  120920. */
  120921. export class _MeshCollisionData {
  120922. _checkCollisions: boolean;
  120923. _collisionMask: number;
  120924. _collisionGroup: number;
  120925. _surroundingMeshes: Nullable<AbstractMesh[]>;
  120926. _collider: Nullable<Collider>;
  120927. _oldPositionForCollisions: Vector3;
  120928. _diffPositionForCollisions: Vector3;
  120929. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  120930. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  120931. _collisionResponse: boolean;
  120932. }
  120933. }
  120934. declare module BABYLON {
  120935. /** @hidden */
  120936. class _FacetDataStorage {
  120937. facetPositions: Vector3[];
  120938. facetNormals: Vector3[];
  120939. facetPartitioning: number[][];
  120940. facetNb: number;
  120941. partitioningSubdivisions: number;
  120942. partitioningBBoxRatio: number;
  120943. facetDataEnabled: boolean;
  120944. facetParameters: any;
  120945. bbSize: Vector3;
  120946. subDiv: {
  120947. max: number;
  120948. X: number;
  120949. Y: number;
  120950. Z: number;
  120951. };
  120952. facetDepthSort: boolean;
  120953. facetDepthSortEnabled: boolean;
  120954. depthSortedIndices: IndicesArray;
  120955. depthSortedFacets: {
  120956. ind: number;
  120957. sqDistance: number;
  120958. }[];
  120959. facetDepthSortFunction: (f1: {
  120960. ind: number;
  120961. sqDistance: number;
  120962. }, f2: {
  120963. ind: number;
  120964. sqDistance: number;
  120965. }) => number;
  120966. facetDepthSortFrom: Vector3;
  120967. facetDepthSortOrigin: Vector3;
  120968. invertedMatrix: Matrix;
  120969. }
  120970. /**
  120971. * @hidden
  120972. **/
  120973. class _InternalAbstractMeshDataInfo {
  120974. _hasVertexAlpha: boolean;
  120975. _useVertexColors: boolean;
  120976. _numBoneInfluencers: number;
  120977. _applyFog: boolean;
  120978. _receiveShadows: boolean;
  120979. _facetData: _FacetDataStorage;
  120980. _visibility: number;
  120981. _skeleton: Nullable<Skeleton>;
  120982. _layerMask: number;
  120983. _computeBonesUsingShaders: boolean;
  120984. _isActive: boolean;
  120985. _onlyForInstances: boolean;
  120986. _isActiveIntermediate: boolean;
  120987. _onlyForInstancesIntermediate: boolean;
  120988. _actAsRegularMesh: boolean;
  120989. _currentLOD: Nullable<AbstractMesh>;
  120990. _currentLODIsUpToDate: boolean;
  120991. }
  120992. /**
  120993. * Class used to store all common mesh properties
  120994. */
  120995. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  120996. /** No occlusion */
  120997. static OCCLUSION_TYPE_NONE: number;
  120998. /** Occlusion set to optimisitic */
  120999. static OCCLUSION_TYPE_OPTIMISTIC: number;
  121000. /** Occlusion set to strict */
  121001. static OCCLUSION_TYPE_STRICT: number;
  121002. /** Use an accurante occlusion algorithm */
  121003. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  121004. /** Use a conservative occlusion algorithm */
  121005. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  121006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  121007. * Test order :
  121008. * Is the bounding sphere outside the frustum ?
  121009. * If not, are the bounding box vertices outside the frustum ?
  121010. * It not, then the cullable object is in the frustum.
  121011. */
  121012. static readonly CULLINGSTRATEGY_STANDARD: number;
  121013. /** Culling strategy : Bounding Sphere Only.
  121014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  121015. * It's also less accurate than the standard because some not visible objects can still be selected.
  121016. * Test : is the bounding sphere outside the frustum ?
  121017. * If not, then the cullable object is in the frustum.
  121018. */
  121019. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  121020. /** Culling strategy : Optimistic Inclusion.
  121021. * This in an inclusion test first, then the standard exclusion test.
  121022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  121023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  121024. * Anyway, it's as accurate as the standard strategy.
  121025. * Test :
  121026. * Is the cullable object bounding sphere center in the frustum ?
  121027. * If not, apply the default culling strategy.
  121028. */
  121029. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  121030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  121031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  121032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  121033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  121034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  121035. * Test :
  121036. * Is the cullable object bounding sphere center in the frustum ?
  121037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  121038. */
  121039. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  121040. /**
  121041. * No billboard
  121042. */
  121043. static get BILLBOARDMODE_NONE(): number;
  121044. /** Billboard on X axis */
  121045. static get BILLBOARDMODE_X(): number;
  121046. /** Billboard on Y axis */
  121047. static get BILLBOARDMODE_Y(): number;
  121048. /** Billboard on Z axis */
  121049. static get BILLBOARDMODE_Z(): number;
  121050. /** Billboard on all axes */
  121051. static get BILLBOARDMODE_ALL(): number;
  121052. /** Billboard on using position instead of orientation */
  121053. static get BILLBOARDMODE_USE_POSITION(): number;
  121054. /** @hidden */
  121055. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  121056. /**
  121057. * The culling strategy to use to check whether the mesh must be rendered or not.
  121058. * This value can be changed at any time and will be used on the next render mesh selection.
  121059. * The possible values are :
  121060. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  121061. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  121062. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  121063. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  121064. * Please read each static variable documentation to get details about the culling process.
  121065. * */
  121066. cullingStrategy: number;
  121067. /**
  121068. * Gets the number of facets in the mesh
  121069. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  121070. */
  121071. get facetNb(): number;
  121072. /**
  121073. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  121074. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  121075. */
  121076. get partitioningSubdivisions(): number;
  121077. set partitioningSubdivisions(nb: number);
  121078. /**
  121079. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  121080. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  121081. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  121082. */
  121083. get partitioningBBoxRatio(): number;
  121084. set partitioningBBoxRatio(ratio: number);
  121085. /**
  121086. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  121087. * Works only for updatable meshes.
  121088. * Doesn't work with multi-materials
  121089. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  121090. */
  121091. get mustDepthSortFacets(): boolean;
  121092. set mustDepthSortFacets(sort: boolean);
  121093. /**
  121094. * The location (Vector3) where the facet depth sort must be computed from.
  121095. * By default, the active camera position.
  121096. * Used only when facet depth sort is enabled
  121097. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  121098. */
  121099. get facetDepthSortFrom(): Vector3;
  121100. set facetDepthSortFrom(location: Vector3);
  121101. /**
  121102. * gets a boolean indicating if facetData is enabled
  121103. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  121104. */
  121105. get isFacetDataEnabled(): boolean;
  121106. /** @hidden */
  121107. _updateNonUniformScalingState(value: boolean): boolean;
  121108. /**
  121109. * An event triggered when this mesh collides with another one
  121110. */
  121111. onCollideObservable: Observable<AbstractMesh>;
  121112. /** Set a function to call when this mesh collides with another one */
  121113. set onCollide(callback: () => void);
  121114. /**
  121115. * An event triggered when the collision's position changes
  121116. */
  121117. onCollisionPositionChangeObservable: Observable<Vector3>;
  121118. /** Set a function to call when the collision's position changes */
  121119. set onCollisionPositionChange(callback: () => void);
  121120. /**
  121121. * An event triggered when material is changed
  121122. */
  121123. onMaterialChangedObservable: Observable<AbstractMesh>;
  121124. /**
  121125. * Gets or sets the orientation for POV movement & rotation
  121126. */
  121127. definedFacingForward: boolean;
  121128. /** @hidden */
  121129. _occlusionQuery: Nullable<WebGLQuery>;
  121130. /** @hidden */
  121131. _renderingGroup: Nullable<RenderingGroup>;
  121132. /**
  121133. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  121134. */
  121135. get visibility(): number;
  121136. /**
  121137. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  121138. */
  121139. set visibility(value: number);
  121140. /** Gets or sets the alpha index used to sort transparent meshes
  121141. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  121142. */
  121143. alphaIndex: number;
  121144. /**
  121145. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  121146. */
  121147. isVisible: boolean;
  121148. /**
  121149. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  121150. */
  121151. isPickable: boolean;
  121152. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  121153. showSubMeshesBoundingBox: boolean;
  121154. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  121155. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121156. */
  121157. isBlocker: boolean;
  121158. /**
  121159. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  121160. */
  121161. enablePointerMoveEvents: boolean;
  121162. private _renderingGroupId;
  121163. /**
  121164. * Specifies the rendering group id for this mesh (0 by default)
  121165. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  121166. */
  121167. get renderingGroupId(): number;
  121168. set renderingGroupId(value: number);
  121169. private _material;
  121170. /** Gets or sets current material */
  121171. get material(): Nullable<Material>;
  121172. set material(value: Nullable<Material>);
  121173. /**
  121174. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  121175. * @see https://doc.babylonjs.com/babylon101/shadows
  121176. */
  121177. get receiveShadows(): boolean;
  121178. set receiveShadows(value: boolean);
  121179. /** Defines color to use when rendering outline */
  121180. outlineColor: Color3;
  121181. /** Define width to use when rendering outline */
  121182. outlineWidth: number;
  121183. /** Defines color to use when rendering overlay */
  121184. overlayColor: Color3;
  121185. /** Defines alpha to use when rendering overlay */
  121186. overlayAlpha: number;
  121187. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  121188. get hasVertexAlpha(): boolean;
  121189. set hasVertexAlpha(value: boolean);
  121190. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  121191. get useVertexColors(): boolean;
  121192. set useVertexColors(value: boolean);
  121193. /**
  121194. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  121195. */
  121196. get computeBonesUsingShaders(): boolean;
  121197. set computeBonesUsingShaders(value: boolean);
  121198. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  121199. get numBoneInfluencers(): number;
  121200. set numBoneInfluencers(value: number);
  121201. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  121202. get applyFog(): boolean;
  121203. set applyFog(value: boolean);
  121204. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  121205. useOctreeForRenderingSelection: boolean;
  121206. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  121207. useOctreeForPicking: boolean;
  121208. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  121209. useOctreeForCollisions: boolean;
  121210. /**
  121211. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  121212. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  121213. */
  121214. get layerMask(): number;
  121215. set layerMask(value: number);
  121216. /**
  121217. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  121218. */
  121219. alwaysSelectAsActiveMesh: boolean;
  121220. /**
  121221. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  121222. */
  121223. doNotSyncBoundingInfo: boolean;
  121224. /**
  121225. * Gets or sets the current action manager
  121226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121227. */
  121228. actionManager: Nullable<AbstractActionManager>;
  121229. private _meshCollisionData;
  121230. /**
  121231. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  121232. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121233. */
  121234. ellipsoid: Vector3;
  121235. /**
  121236. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  121237. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121238. */
  121239. ellipsoidOffset: Vector3;
  121240. /**
  121241. * Gets or sets a collision mask used to mask collisions (default is -1).
  121242. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  121243. */
  121244. get collisionMask(): number;
  121245. set collisionMask(mask: number);
  121246. /**
  121247. * Gets or sets a collision response flag (default is true).
  121248. * when collisionResponse is false, events are still triggered but colliding entity has no response
  121249. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  121250. * to respond to the collision.
  121251. */
  121252. get collisionResponse(): boolean;
  121253. set collisionResponse(response: boolean);
  121254. /**
  121255. * Gets or sets the current collision group mask (-1 by default).
  121256. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  121257. */
  121258. get collisionGroup(): number;
  121259. set collisionGroup(mask: number);
  121260. /**
  121261. * Gets or sets current surrounding meshes (null by default).
  121262. *
  121263. * By default collision detection is tested against every mesh in the scene.
  121264. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  121265. * meshes will be tested for the collision.
  121266. *
  121267. * Note: if set to an empty array no collision will happen when this mesh is moved.
  121268. */
  121269. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  121270. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  121271. /**
  121272. * Defines edge width used when edgesRenderer is enabled
  121273. * @see https://www.babylonjs-playground.com/#10OJSG#13
  121274. */
  121275. edgesWidth: number;
  121276. /**
  121277. * Defines edge color used when edgesRenderer is enabled
  121278. * @see https://www.babylonjs-playground.com/#10OJSG#13
  121279. */
  121280. edgesColor: Color4;
  121281. /** @hidden */
  121282. _edgesRenderer: Nullable<IEdgesRenderer>;
  121283. /** @hidden */
  121284. _masterMesh: Nullable<AbstractMesh>;
  121285. /** @hidden */
  121286. _boundingInfo: Nullable<BoundingInfo>;
  121287. /** @hidden */
  121288. _renderId: number;
  121289. /**
  121290. * Gets or sets the list of subMeshes
  121291. * @see https://doc.babylonjs.com/how_to/multi_materials
  121292. */
  121293. subMeshes: SubMesh[];
  121294. /** @hidden */
  121295. _intersectionsInProgress: AbstractMesh[];
  121296. /** @hidden */
  121297. _unIndexed: boolean;
  121298. /** @hidden */
  121299. _lightSources: Light[];
  121300. /** Gets the list of lights affecting that mesh */
  121301. get lightSources(): Light[];
  121302. /** @hidden */
  121303. get _positions(): Nullable<Vector3[]>;
  121304. /** @hidden */
  121305. _waitingData: {
  121306. lods: Nullable<any>;
  121307. actions: Nullable<any>;
  121308. freezeWorldMatrix: Nullable<boolean>;
  121309. };
  121310. /** @hidden */
  121311. _bonesTransformMatrices: Nullable<Float32Array>;
  121312. /** @hidden */
  121313. _transformMatrixTexture: Nullable<RawTexture>;
  121314. /**
  121315. * Gets or sets a skeleton to apply skining transformations
  121316. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121317. */
  121318. set skeleton(value: Nullable<Skeleton>);
  121319. get skeleton(): Nullable<Skeleton>;
  121320. /**
  121321. * An event triggered when the mesh is rebuilt.
  121322. */
  121323. onRebuildObservable: Observable<AbstractMesh>;
  121324. /**
  121325. * The current mesh unifom buffer.
  121326. * @hidden Internal use only.
  121327. */
  121328. _uniformBuffer: UniformBuffer;
  121329. /**
  121330. * Creates a new AbstractMesh
  121331. * @param name defines the name of the mesh
  121332. * @param scene defines the hosting scene
  121333. */
  121334. constructor(name: string, scene?: Nullable<Scene>);
  121335. protected _buildUniformLayout(): void;
  121336. /**
  121337. * Transfer the mesh values to its UBO.
  121338. * @param world The world matrix associated with the mesh
  121339. */
  121340. transferToEffect(world: Matrix): void;
  121341. /**
  121342. * Gets the mesh uniform buffer.
  121343. * @return the uniform buffer of the mesh.
  121344. */
  121345. getMeshUniformBuffer(): UniformBuffer;
  121346. /**
  121347. * Returns the string "AbstractMesh"
  121348. * @returns "AbstractMesh"
  121349. */
  121350. getClassName(): string;
  121351. /**
  121352. * Gets a string representation of the current mesh
  121353. * @param fullDetails defines a boolean indicating if full details must be included
  121354. * @returns a string representation of the current mesh
  121355. */
  121356. toString(fullDetails?: boolean): string;
  121357. /**
  121358. * @hidden
  121359. */
  121360. protected _getEffectiveParent(): Nullable<Node>;
  121361. /** @hidden */
  121362. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  121363. /** @hidden */
  121364. _rebuild(): void;
  121365. /** @hidden */
  121366. _resyncLightSources(): void;
  121367. /** @hidden */
  121368. _resyncLightSource(light: Light): void;
  121369. /** @hidden */
  121370. _unBindEffect(): void;
  121371. /** @hidden */
  121372. _removeLightSource(light: Light, dispose: boolean): void;
  121373. private _markSubMeshesAsDirty;
  121374. /** @hidden */
  121375. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  121376. /** @hidden */
  121377. _markSubMeshesAsAttributesDirty(): void;
  121378. /** @hidden */
  121379. _markSubMeshesAsMiscDirty(): void;
  121380. /**
  121381. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  121382. */
  121383. get scaling(): Vector3;
  121384. set scaling(newScaling: Vector3);
  121385. /**
  121386. * Returns true if the mesh is blocked. Implemented by child classes
  121387. */
  121388. get isBlocked(): boolean;
  121389. /**
  121390. * Returns the mesh itself by default. Implemented by child classes
  121391. * @param camera defines the camera to use to pick the right LOD level
  121392. * @returns the currentAbstractMesh
  121393. */
  121394. getLOD(camera: Camera): Nullable<AbstractMesh>;
  121395. /**
  121396. * Returns 0 by default. Implemented by child classes
  121397. * @returns an integer
  121398. */
  121399. getTotalVertices(): number;
  121400. /**
  121401. * Returns a positive integer : the total number of indices in this mesh geometry.
  121402. * @returns the numner of indices or zero if the mesh has no geometry.
  121403. */
  121404. getTotalIndices(): number;
  121405. /**
  121406. * Returns null by default. Implemented by child classes
  121407. * @returns null
  121408. */
  121409. getIndices(): Nullable<IndicesArray>;
  121410. /**
  121411. * Returns the array of the requested vertex data kind. Implemented by child classes
  121412. * @param kind defines the vertex data kind to use
  121413. * @returns null
  121414. */
  121415. getVerticesData(kind: string): Nullable<FloatArray>;
  121416. /**
  121417. * Sets the vertex data of the mesh geometry for the requested `kind`.
  121418. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  121419. * Note that a new underlying VertexBuffer object is created each call.
  121420. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  121421. * @param kind defines vertex data kind:
  121422. * * VertexBuffer.PositionKind
  121423. * * VertexBuffer.UVKind
  121424. * * VertexBuffer.UV2Kind
  121425. * * VertexBuffer.UV3Kind
  121426. * * VertexBuffer.UV4Kind
  121427. * * VertexBuffer.UV5Kind
  121428. * * VertexBuffer.UV6Kind
  121429. * * VertexBuffer.ColorKind
  121430. * * VertexBuffer.MatricesIndicesKind
  121431. * * VertexBuffer.MatricesIndicesExtraKind
  121432. * * VertexBuffer.MatricesWeightsKind
  121433. * * VertexBuffer.MatricesWeightsExtraKind
  121434. * @param data defines the data source
  121435. * @param updatable defines if the data must be flagged as updatable (or static)
  121436. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  121437. * @returns the current mesh
  121438. */
  121439. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  121440. /**
  121441. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  121442. * If the mesh has no geometry, it is simply returned as it is.
  121443. * @param kind defines vertex data kind:
  121444. * * VertexBuffer.PositionKind
  121445. * * VertexBuffer.UVKind
  121446. * * VertexBuffer.UV2Kind
  121447. * * VertexBuffer.UV3Kind
  121448. * * VertexBuffer.UV4Kind
  121449. * * VertexBuffer.UV5Kind
  121450. * * VertexBuffer.UV6Kind
  121451. * * VertexBuffer.ColorKind
  121452. * * VertexBuffer.MatricesIndicesKind
  121453. * * VertexBuffer.MatricesIndicesExtraKind
  121454. * * VertexBuffer.MatricesWeightsKind
  121455. * * VertexBuffer.MatricesWeightsExtraKind
  121456. * @param data defines the data source
  121457. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  121458. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  121459. * @returns the current mesh
  121460. */
  121461. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  121462. /**
  121463. * Sets the mesh indices,
  121464. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  121465. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  121466. * @param totalVertices Defines the total number of vertices
  121467. * @returns the current mesh
  121468. */
  121469. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  121470. /**
  121471. * Gets a boolean indicating if specific vertex data is present
  121472. * @param kind defines the vertex data kind to use
  121473. * @returns true is data kind is present
  121474. */
  121475. isVerticesDataPresent(kind: string): boolean;
  121476. /**
  121477. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  121478. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  121479. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  121480. * @returns a BoundingInfo
  121481. */
  121482. getBoundingInfo(): BoundingInfo;
  121483. /**
  121484. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  121485. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  121486. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  121487. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  121488. * @returns the current mesh
  121489. */
  121490. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  121491. /**
  121492. * Overwrite the current bounding info
  121493. * @param boundingInfo defines the new bounding info
  121494. * @returns the current mesh
  121495. */
  121496. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  121497. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  121498. get useBones(): boolean;
  121499. /** @hidden */
  121500. _preActivate(): void;
  121501. /** @hidden */
  121502. _preActivateForIntermediateRendering(renderId: number): void;
  121503. /** @hidden */
  121504. _activate(renderId: number, intermediateRendering: boolean): boolean;
  121505. /** @hidden */
  121506. _postActivate(): void;
  121507. /** @hidden */
  121508. _freeze(): void;
  121509. /** @hidden */
  121510. _unFreeze(): void;
  121511. /**
  121512. * Gets the current world matrix
  121513. * @returns a Matrix
  121514. */
  121515. getWorldMatrix(): Matrix;
  121516. /** @hidden */
  121517. _getWorldMatrixDeterminant(): number;
  121518. /**
  121519. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  121520. */
  121521. get isAnInstance(): boolean;
  121522. /**
  121523. * Gets a boolean indicating if this mesh has instances
  121524. */
  121525. get hasInstances(): boolean;
  121526. /**
  121527. * Gets a boolean indicating if this mesh has thin instances
  121528. */
  121529. get hasThinInstances(): boolean;
  121530. /**
  121531. * Perform relative position change from the point of view of behind the front of the mesh.
  121532. * This is performed taking into account the meshes current rotation, so you do not have to care.
  121533. * Supports definition of mesh facing forward or backward
  121534. * @param amountRight defines the distance on the right axis
  121535. * @param amountUp defines the distance on the up axis
  121536. * @param amountForward defines the distance on the forward axis
  121537. * @returns the current mesh
  121538. */
  121539. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  121540. /**
  121541. * Calculate relative position change from the point of view of behind the front of the mesh.
  121542. * This is performed taking into account the meshes current rotation, so you do not have to care.
  121543. * Supports definition of mesh facing forward or backward
  121544. * @param amountRight defines the distance on the right axis
  121545. * @param amountUp defines the distance on the up axis
  121546. * @param amountForward defines the distance on the forward axis
  121547. * @returns the new displacement vector
  121548. */
  121549. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  121550. /**
  121551. * Perform relative rotation change from the point of view of behind the front of the mesh.
  121552. * Supports definition of mesh facing forward or backward
  121553. * @param flipBack defines the flip
  121554. * @param twirlClockwise defines the twirl
  121555. * @param tiltRight defines the tilt
  121556. * @returns the current mesh
  121557. */
  121558. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  121559. /**
  121560. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  121561. * Supports definition of mesh facing forward or backward.
  121562. * @param flipBack defines the flip
  121563. * @param twirlClockwise defines the twirl
  121564. * @param tiltRight defines the tilt
  121565. * @returns the new rotation vector
  121566. */
  121567. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  121568. /**
  121569. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  121570. * This means the mesh underlying bounding box and sphere are recomputed.
  121571. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  121572. * @returns the current mesh
  121573. */
  121574. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  121575. /** @hidden */
  121576. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  121577. /** @hidden */
  121578. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  121579. /** @hidden */
  121580. _updateBoundingInfo(): AbstractMesh;
  121581. /** @hidden */
  121582. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  121583. /** @hidden */
  121584. protected _afterComputeWorldMatrix(): void;
  121585. /** @hidden */
  121586. get _effectiveMesh(): AbstractMesh;
  121587. /**
  121588. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  121589. * A mesh is in the frustum if its bounding box intersects the frustum
  121590. * @param frustumPlanes defines the frustum to test
  121591. * @returns true if the mesh is in the frustum planes
  121592. */
  121593. isInFrustum(frustumPlanes: Plane[]): boolean;
  121594. /**
  121595. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  121596. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  121597. * @param frustumPlanes defines the frustum to test
  121598. * @returns true if the mesh is completely in the frustum planes
  121599. */
  121600. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  121601. /**
  121602. * True if the mesh intersects another mesh or a SolidParticle object
  121603. * @param mesh defines a target mesh or SolidParticle to test
  121604. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  121605. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  121606. * @returns true if there is an intersection
  121607. */
  121608. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  121609. /**
  121610. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  121611. * @param point defines the point to test
  121612. * @returns true if there is an intersection
  121613. */
  121614. intersectsPoint(point: Vector3): boolean;
  121615. /**
  121616. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  121617. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121618. */
  121619. get checkCollisions(): boolean;
  121620. set checkCollisions(collisionEnabled: boolean);
  121621. /**
  121622. * Gets Collider object used to compute collisions (not physics)
  121623. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121624. */
  121625. get collider(): Nullable<Collider>;
  121626. /**
  121627. * Move the mesh using collision engine
  121628. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121629. * @param displacement defines the requested displacement vector
  121630. * @returns the current mesh
  121631. */
  121632. moveWithCollisions(displacement: Vector3): AbstractMesh;
  121633. private _onCollisionPositionChange;
  121634. /** @hidden */
  121635. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  121636. /** @hidden */
  121637. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  121638. /** @hidden */
  121639. _checkCollision(collider: Collider): AbstractMesh;
  121640. /** @hidden */
  121641. _generatePointsArray(): boolean;
  121642. /**
  121643. * Checks if the passed Ray intersects with the mesh
  121644. * @param ray defines the ray to use
  121645. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  121646. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121647. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  121648. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  121649. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  121650. * @returns the picking info
  121651. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  121652. */
  121653. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  121654. /**
  121655. * Clones the current mesh
  121656. * @param name defines the mesh name
  121657. * @param newParent defines the new mesh parent
  121658. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  121659. * @returns the new mesh
  121660. */
  121661. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  121662. /**
  121663. * Disposes all the submeshes of the current meshnp
  121664. * @returns the current mesh
  121665. */
  121666. releaseSubMeshes(): AbstractMesh;
  121667. /**
  121668. * Releases resources associated with this abstract mesh.
  121669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121671. */
  121672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121673. /**
  121674. * Adds the passed mesh as a child to the current mesh
  121675. * @param mesh defines the child mesh
  121676. * @returns the current mesh
  121677. */
  121678. addChild(mesh: AbstractMesh): AbstractMesh;
  121679. /**
  121680. * Removes the passed mesh from the current mesh children list
  121681. * @param mesh defines the child mesh
  121682. * @returns the current mesh
  121683. */
  121684. removeChild(mesh: AbstractMesh): AbstractMesh;
  121685. /** @hidden */
  121686. private _initFacetData;
  121687. /**
  121688. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  121689. * This method can be called within the render loop.
  121690. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  121691. * @returns the current mesh
  121692. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121693. */
  121694. updateFacetData(): AbstractMesh;
  121695. /**
  121696. * Returns the facetLocalNormals array.
  121697. * The normals are expressed in the mesh local spac
  121698. * @returns an array of Vector3
  121699. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121700. */
  121701. getFacetLocalNormals(): Vector3[];
  121702. /**
  121703. * Returns the facetLocalPositions array.
  121704. * The facet positions are expressed in the mesh local space
  121705. * @returns an array of Vector3
  121706. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121707. */
  121708. getFacetLocalPositions(): Vector3[];
  121709. /**
  121710. * Returns the facetLocalPartioning array
  121711. * @returns an array of array of numbers
  121712. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121713. */
  121714. getFacetLocalPartitioning(): number[][];
  121715. /**
  121716. * Returns the i-th facet position in the world system.
  121717. * This method allocates a new Vector3 per call
  121718. * @param i defines the facet index
  121719. * @returns a new Vector3
  121720. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121721. */
  121722. getFacetPosition(i: number): Vector3;
  121723. /**
  121724. * Sets the reference Vector3 with the i-th facet position in the world system
  121725. * @param i defines the facet index
  121726. * @param ref defines the target vector
  121727. * @returns the current mesh
  121728. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121729. */
  121730. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  121731. /**
  121732. * Returns the i-th facet normal in the world system.
  121733. * This method allocates a new Vector3 per call
  121734. * @param i defines the facet index
  121735. * @returns a new Vector3
  121736. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121737. */
  121738. getFacetNormal(i: number): Vector3;
  121739. /**
  121740. * Sets the reference Vector3 with the i-th facet normal in the world system
  121741. * @param i defines the facet index
  121742. * @param ref defines the target vector
  121743. * @returns the current mesh
  121744. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121745. */
  121746. getFacetNormalToRef(i: number, ref: Vector3): this;
  121747. /**
  121748. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  121749. * @param x defines x coordinate
  121750. * @param y defines y coordinate
  121751. * @param z defines z coordinate
  121752. * @returns the array of facet indexes
  121753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121754. */
  121755. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  121756. /**
  121757. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  121758. * @param projected sets as the (x,y,z) world projection on the facet
  121759. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  121760. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  121761. * @param x defines x coordinate
  121762. * @param y defines y coordinate
  121763. * @param z defines z coordinate
  121764. * @returns the face index if found (or null instead)
  121765. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121766. */
  121767. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121768. /**
  121769. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  121770. * @param projected sets as the (x,y,z) local projection on the facet
  121771. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  121772. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  121773. * @param x defines x coordinate
  121774. * @param y defines y coordinate
  121775. * @param z defines z coordinate
  121776. * @returns the face index if found (or null instead)
  121777. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121778. */
  121779. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121780. /**
  121781. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  121782. * @returns the parameters
  121783. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121784. */
  121785. getFacetDataParameters(): any;
  121786. /**
  121787. * Disables the feature FacetData and frees the related memory
  121788. * @returns the current mesh
  121789. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121790. */
  121791. disableFacetData(): AbstractMesh;
  121792. /**
  121793. * Updates the AbstractMesh indices array
  121794. * @param indices defines the data source
  121795. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  121796. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  121797. * @returns the current mesh
  121798. */
  121799. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  121800. /**
  121801. * Creates new normals data for the mesh
  121802. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  121803. * @returns the current mesh
  121804. */
  121805. createNormals(updatable: boolean): AbstractMesh;
  121806. /**
  121807. * Align the mesh with a normal
  121808. * @param normal defines the normal to use
  121809. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  121810. * @returns the current mesh
  121811. */
  121812. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  121813. /** @hidden */
  121814. _checkOcclusionQuery(): boolean;
  121815. /**
  121816. * Disables the mesh edge rendering mode
  121817. * @returns the currentAbstractMesh
  121818. */
  121819. disableEdgesRendering(): AbstractMesh;
  121820. /**
  121821. * Enables the edge rendering mode on the mesh.
  121822. * This mode makes the mesh edges visible
  121823. * @param epsilon defines the maximal distance between two angles to detect a face
  121824. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  121825. * @param options options to the edge renderer
  121826. * @returns the currentAbstractMesh
  121827. * @see https://www.babylonjs-playground.com/#19O9TU#0
  121828. */
  121829. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  121830. /**
  121831. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  121832. * @returns an array of particle systems in the scene that use the mesh as an emitter
  121833. */
  121834. getConnectedParticleSystems(): IParticleSystem[];
  121835. }
  121836. }
  121837. declare module BABYLON {
  121838. /**
  121839. * Interface used to define ActionEvent
  121840. */
  121841. export interface IActionEvent {
  121842. /** The mesh or sprite that triggered the action */
  121843. source: any;
  121844. /** The X mouse cursor position at the time of the event */
  121845. pointerX: number;
  121846. /** The Y mouse cursor position at the time of the event */
  121847. pointerY: number;
  121848. /** The mesh that is currently pointed at (can be null) */
  121849. meshUnderPointer: Nullable<AbstractMesh>;
  121850. /** the original (browser) event that triggered the ActionEvent */
  121851. sourceEvent?: any;
  121852. /** additional data for the event */
  121853. additionalData?: any;
  121854. }
  121855. /**
  121856. * ActionEvent is the event being sent when an action is triggered.
  121857. */
  121858. export class ActionEvent implements IActionEvent {
  121859. /** The mesh or sprite that triggered the action */
  121860. source: any;
  121861. /** The X mouse cursor position at the time of the event */
  121862. pointerX: number;
  121863. /** The Y mouse cursor position at the time of the event */
  121864. pointerY: number;
  121865. /** The mesh that is currently pointed at (can be null) */
  121866. meshUnderPointer: Nullable<AbstractMesh>;
  121867. /** the original (browser) event that triggered the ActionEvent */
  121868. sourceEvent?: any;
  121869. /** additional data for the event */
  121870. additionalData?: any;
  121871. /**
  121872. * Creates a new ActionEvent
  121873. * @param source The mesh or sprite that triggered the action
  121874. * @param pointerX The X mouse cursor position at the time of the event
  121875. * @param pointerY The Y mouse cursor position at the time of the event
  121876. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  121877. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  121878. * @param additionalData additional data for the event
  121879. */
  121880. constructor(
  121881. /** The mesh or sprite that triggered the action */
  121882. source: any,
  121883. /** The X mouse cursor position at the time of the event */
  121884. pointerX: number,
  121885. /** The Y mouse cursor position at the time of the event */
  121886. pointerY: number,
  121887. /** The mesh that is currently pointed at (can be null) */
  121888. meshUnderPointer: Nullable<AbstractMesh>,
  121889. /** the original (browser) event that triggered the ActionEvent */
  121890. sourceEvent?: any,
  121891. /** additional data for the event */
  121892. additionalData?: any);
  121893. /**
  121894. * Helper function to auto-create an ActionEvent from a source mesh.
  121895. * @param source The source mesh that triggered the event
  121896. * @param evt The original (browser) event
  121897. * @param additionalData additional data for the event
  121898. * @returns the new ActionEvent
  121899. */
  121900. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  121901. /**
  121902. * Helper function to auto-create an ActionEvent from a source sprite
  121903. * @param source The source sprite that triggered the event
  121904. * @param scene Scene associated with the sprite
  121905. * @param evt The original (browser) event
  121906. * @param additionalData additional data for the event
  121907. * @returns the new ActionEvent
  121908. */
  121909. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  121910. /**
  121911. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  121912. * @param scene the scene where the event occurred
  121913. * @param evt The original (browser) event
  121914. * @returns the new ActionEvent
  121915. */
  121916. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  121917. /**
  121918. * Helper function to auto-create an ActionEvent from a primitive
  121919. * @param prim defines the target primitive
  121920. * @param pointerPos defines the pointer position
  121921. * @param evt The original (browser) event
  121922. * @param additionalData additional data for the event
  121923. * @returns the new ActionEvent
  121924. */
  121925. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  121926. }
  121927. }
  121928. declare module BABYLON {
  121929. /**
  121930. * Abstract class used to decouple action Manager from scene and meshes.
  121931. * Do not instantiate.
  121932. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121933. */
  121934. export abstract class AbstractActionManager implements IDisposable {
  121935. /** Gets the list of active triggers */
  121936. static Triggers: {
  121937. [key: string]: number;
  121938. };
  121939. /** Gets the cursor to use when hovering items */
  121940. hoverCursor: string;
  121941. /** Gets the list of actions */
  121942. actions: IAction[];
  121943. /**
  121944. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  121945. */
  121946. isRecursive: boolean;
  121947. /**
  121948. * Releases all associated resources
  121949. */
  121950. abstract dispose(): void;
  121951. /**
  121952. * Does this action manager has pointer triggers
  121953. */
  121954. abstract get hasPointerTriggers(): boolean;
  121955. /**
  121956. * Does this action manager has pick triggers
  121957. */
  121958. abstract get hasPickTriggers(): boolean;
  121959. /**
  121960. * Process a specific trigger
  121961. * @param trigger defines the trigger to process
  121962. * @param evt defines the event details to be processed
  121963. */
  121964. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  121965. /**
  121966. * Does this action manager handles actions of any of the given triggers
  121967. * @param triggers defines the triggers to be tested
  121968. * @return a boolean indicating whether one (or more) of the triggers is handled
  121969. */
  121970. abstract hasSpecificTriggers(triggers: number[]): boolean;
  121971. /**
  121972. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  121973. * speed.
  121974. * @param triggerA defines the trigger to be tested
  121975. * @param triggerB defines the trigger to be tested
  121976. * @return a boolean indicating whether one (or more) of the triggers is handled
  121977. */
  121978. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  121979. /**
  121980. * Does this action manager handles actions of a given trigger
  121981. * @param trigger defines the trigger to be tested
  121982. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  121983. * @return whether the trigger is handled
  121984. */
  121985. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  121986. /**
  121987. * Serialize this manager to a JSON object
  121988. * @param name defines the property name to store this manager
  121989. * @returns a JSON representation of this manager
  121990. */
  121991. abstract serialize(name: string): any;
  121992. /**
  121993. * Registers an action to this action manager
  121994. * @param action defines the action to be registered
  121995. * @return the action amended (prepared) after registration
  121996. */
  121997. abstract registerAction(action: IAction): Nullable<IAction>;
  121998. /**
  121999. * Unregisters an action to this action manager
  122000. * @param action defines the action to be unregistered
  122001. * @return a boolean indicating whether the action has been unregistered
  122002. */
  122003. abstract unregisterAction(action: IAction): Boolean;
  122004. /**
  122005. * Does exist one action manager with at least one trigger
  122006. **/
  122007. static get HasTriggers(): boolean;
  122008. /**
  122009. * Does exist one action manager with at least one pick trigger
  122010. **/
  122011. static get HasPickTriggers(): boolean;
  122012. /**
  122013. * Does exist one action manager that handles actions of a given trigger
  122014. * @param trigger defines the trigger to be tested
  122015. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  122016. **/
  122017. static HasSpecificTrigger(trigger: number): boolean;
  122018. }
  122019. }
  122020. declare module BABYLON {
  122021. /**
  122022. * Defines how a node can be built from a string name.
  122023. */
  122024. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  122025. /**
  122026. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  122027. */
  122028. export class Node implements IBehaviorAware<Node> {
  122029. /** @hidden */
  122030. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  122031. private static _NodeConstructors;
  122032. /**
  122033. * Add a new node constructor
  122034. * @param type defines the type name of the node to construct
  122035. * @param constructorFunc defines the constructor function
  122036. */
  122037. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  122038. /**
  122039. * Returns a node constructor based on type name
  122040. * @param type defines the type name
  122041. * @param name defines the new node name
  122042. * @param scene defines the hosting scene
  122043. * @param options defines optional options to transmit to constructors
  122044. * @returns the new constructor or null
  122045. */
  122046. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  122047. /**
  122048. * Gets or sets the name of the node
  122049. */
  122050. name: string;
  122051. /**
  122052. * Gets or sets the id of the node
  122053. */
  122054. id: string;
  122055. /**
  122056. * Gets or sets the unique id of the node
  122057. */
  122058. uniqueId: number;
  122059. /**
  122060. * Gets or sets a string used to store user defined state for the node
  122061. */
  122062. state: string;
  122063. /**
  122064. * Gets or sets an object used to store user defined information for the node
  122065. */
  122066. metadata: any;
  122067. /**
  122068. * For internal use only. Please do not use.
  122069. */
  122070. reservedDataStore: any;
  122071. /**
  122072. * List of inspectable custom properties (used by the Inspector)
  122073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  122074. */
  122075. inspectableCustomProperties: IInspectable[];
  122076. private _doNotSerialize;
  122077. /**
  122078. * Gets or sets a boolean used to define if the node must be serialized
  122079. */
  122080. get doNotSerialize(): boolean;
  122081. set doNotSerialize(value: boolean);
  122082. /** @hidden */
  122083. _isDisposed: boolean;
  122084. /**
  122085. * Gets a list of Animations associated with the node
  122086. */
  122087. animations: Animation[];
  122088. protected _ranges: {
  122089. [name: string]: Nullable<AnimationRange>;
  122090. };
  122091. /**
  122092. * Callback raised when the node is ready to be used
  122093. */
  122094. onReady: Nullable<(node: Node) => void>;
  122095. private _isEnabled;
  122096. private _isParentEnabled;
  122097. private _isReady;
  122098. /** @hidden */
  122099. _currentRenderId: number;
  122100. private _parentUpdateId;
  122101. /** @hidden */
  122102. _childUpdateId: number;
  122103. /** @hidden */
  122104. _waitingParentId: Nullable<string>;
  122105. /** @hidden */
  122106. _scene: Scene;
  122107. /** @hidden */
  122108. _cache: any;
  122109. private _parentNode;
  122110. private _children;
  122111. /** @hidden */
  122112. _worldMatrix: Matrix;
  122113. /** @hidden */
  122114. _worldMatrixDeterminant: number;
  122115. /** @hidden */
  122116. _worldMatrixDeterminantIsDirty: boolean;
  122117. /** @hidden */
  122118. private _sceneRootNodesIndex;
  122119. /**
  122120. * Gets a boolean indicating if the node has been disposed
  122121. * @returns true if the node was disposed
  122122. */
  122123. isDisposed(): boolean;
  122124. /**
  122125. * Gets or sets the parent of the node (without keeping the current position in the scene)
  122126. * @see https://doc.babylonjs.com/how_to/parenting
  122127. */
  122128. set parent(parent: Nullable<Node>);
  122129. get parent(): Nullable<Node>;
  122130. /** @hidden */
  122131. _addToSceneRootNodes(): void;
  122132. /** @hidden */
  122133. _removeFromSceneRootNodes(): void;
  122134. private _animationPropertiesOverride;
  122135. /**
  122136. * Gets or sets the animation properties override
  122137. */
  122138. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  122139. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  122140. /**
  122141. * Gets a string identifying the name of the class
  122142. * @returns "Node" string
  122143. */
  122144. getClassName(): string;
  122145. /** @hidden */
  122146. readonly _isNode: boolean;
  122147. /**
  122148. * An event triggered when the mesh is disposed
  122149. */
  122150. onDisposeObservable: Observable<Node>;
  122151. private _onDisposeObserver;
  122152. /**
  122153. * Sets a callback that will be raised when the node will be disposed
  122154. */
  122155. set onDispose(callback: () => void);
  122156. /**
  122157. * Creates a new Node
  122158. * @param name the name and id to be given to this node
  122159. * @param scene the scene this node will be added to
  122160. */
  122161. constructor(name: string, scene?: Nullable<Scene>);
  122162. /**
  122163. * Gets the scene of the node
  122164. * @returns a scene
  122165. */
  122166. getScene(): Scene;
  122167. /**
  122168. * Gets the engine of the node
  122169. * @returns a Engine
  122170. */
  122171. getEngine(): Engine;
  122172. private _behaviors;
  122173. /**
  122174. * Attach a behavior to the node
  122175. * @see https://doc.babylonjs.com/features/behaviour
  122176. * @param behavior defines the behavior to attach
  122177. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  122178. * @returns the current Node
  122179. */
  122180. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  122181. /**
  122182. * Remove an attached behavior
  122183. * @see https://doc.babylonjs.com/features/behaviour
  122184. * @param behavior defines the behavior to attach
  122185. * @returns the current Node
  122186. */
  122187. removeBehavior(behavior: Behavior<Node>): Node;
  122188. /**
  122189. * Gets the list of attached behaviors
  122190. * @see https://doc.babylonjs.com/features/behaviour
  122191. */
  122192. get behaviors(): Behavior<Node>[];
  122193. /**
  122194. * Gets an attached behavior by name
  122195. * @param name defines the name of the behavior to look for
  122196. * @see https://doc.babylonjs.com/features/behaviour
  122197. * @returns null if behavior was not found else the requested behavior
  122198. */
  122199. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  122200. /**
  122201. * Returns the latest update of the World matrix
  122202. * @returns a Matrix
  122203. */
  122204. getWorldMatrix(): Matrix;
  122205. /** @hidden */
  122206. _getWorldMatrixDeterminant(): number;
  122207. /**
  122208. * Returns directly the latest state of the mesh World matrix.
  122209. * A Matrix is returned.
  122210. */
  122211. get worldMatrixFromCache(): Matrix;
  122212. /** @hidden */
  122213. _initCache(): void;
  122214. /** @hidden */
  122215. updateCache(force?: boolean): void;
  122216. /** @hidden */
  122217. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  122218. /** @hidden */
  122219. _updateCache(ignoreParentClass?: boolean): void;
  122220. /** @hidden */
  122221. _isSynchronized(): boolean;
  122222. /** @hidden */
  122223. _markSyncedWithParent(): void;
  122224. /** @hidden */
  122225. isSynchronizedWithParent(): boolean;
  122226. /** @hidden */
  122227. isSynchronized(): boolean;
  122228. /**
  122229. * Is this node ready to be used/rendered
  122230. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  122231. * @return true if the node is ready
  122232. */
  122233. isReady(completeCheck?: boolean): boolean;
  122234. /**
  122235. * Is this node enabled?
  122236. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  122237. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  122238. * @return whether this node (and its parent) is enabled
  122239. */
  122240. isEnabled(checkAncestors?: boolean): boolean;
  122241. /** @hidden */
  122242. protected _syncParentEnabledState(): void;
  122243. /**
  122244. * Set the enabled state of this node
  122245. * @param value defines the new enabled state
  122246. */
  122247. setEnabled(value: boolean): void;
  122248. /**
  122249. * Is this node a descendant of the given node?
  122250. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  122251. * @param ancestor defines the parent node to inspect
  122252. * @returns a boolean indicating if this node is a descendant of the given node
  122253. */
  122254. isDescendantOf(ancestor: Node): boolean;
  122255. /** @hidden */
  122256. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  122257. /**
  122258. * Will return all nodes that have this node as ascendant
  122259. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  122260. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  122261. * @return all children nodes of all types
  122262. */
  122263. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  122264. /**
  122265. * Get all child-meshes of this node
  122266. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  122267. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  122268. * @returns an array of AbstractMesh
  122269. */
  122270. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  122271. /**
  122272. * Get all direct children of this node
  122273. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  122274. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  122275. * @returns an array of Node
  122276. */
  122277. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  122278. /** @hidden */
  122279. _setReady(state: boolean): void;
  122280. /**
  122281. * Get an animation by name
  122282. * @param name defines the name of the animation to look for
  122283. * @returns null if not found else the requested animation
  122284. */
  122285. getAnimationByName(name: string): Nullable<Animation>;
  122286. /**
  122287. * Creates an animation range for this node
  122288. * @param name defines the name of the range
  122289. * @param from defines the starting key
  122290. * @param to defines the end key
  122291. */
  122292. createAnimationRange(name: string, from: number, to: number): void;
  122293. /**
  122294. * Delete a specific animation range
  122295. * @param name defines the name of the range to delete
  122296. * @param deleteFrames defines if animation frames from the range must be deleted as well
  122297. */
  122298. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  122299. /**
  122300. * Get an animation range by name
  122301. * @param name defines the name of the animation range to look for
  122302. * @returns null if not found else the requested animation range
  122303. */
  122304. getAnimationRange(name: string): Nullable<AnimationRange>;
  122305. /**
  122306. * Gets the list of all animation ranges defined on this node
  122307. * @returns an array
  122308. */
  122309. getAnimationRanges(): Nullable<AnimationRange>[];
  122310. /**
  122311. * Will start the animation sequence
  122312. * @param name defines the range frames for animation sequence
  122313. * @param loop defines if the animation should loop (false by default)
  122314. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  122315. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  122316. * @returns the object created for this animation. If range does not exist, it will return null
  122317. */
  122318. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  122319. /**
  122320. * Serialize animation ranges into a JSON compatible object
  122321. * @returns serialization object
  122322. */
  122323. serializeAnimationRanges(): any;
  122324. /**
  122325. * Computes the world matrix of the node
  122326. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  122327. * @returns the world matrix
  122328. */
  122329. computeWorldMatrix(force?: boolean): Matrix;
  122330. /**
  122331. * Releases resources associated with this node.
  122332. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122333. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122334. */
  122335. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122336. /**
  122337. * Parse animation range data from a serialization object and store them into a given node
  122338. * @param node defines where to store the animation ranges
  122339. * @param parsedNode defines the serialization object to read data from
  122340. * @param scene defines the hosting scene
  122341. */
  122342. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  122343. /**
  122344. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  122345. * @param includeDescendants Include bounding info from descendants as well (true by default)
  122346. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  122347. * @returns the new bounding vectors
  122348. */
  122349. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  122350. min: Vector3;
  122351. max: Vector3;
  122352. };
  122353. }
  122354. }
  122355. declare module BABYLON {
  122356. /**
  122357. * @hidden
  122358. */
  122359. export class _IAnimationState {
  122360. key: number;
  122361. repeatCount: number;
  122362. workValue?: any;
  122363. loopMode?: number;
  122364. offsetValue?: any;
  122365. highLimitValue?: any;
  122366. }
  122367. /**
  122368. * Class used to store any kind of animation
  122369. */
  122370. export class Animation {
  122371. /**Name of the animation */
  122372. name: string;
  122373. /**Property to animate */
  122374. targetProperty: string;
  122375. /**The frames per second of the animation */
  122376. framePerSecond: number;
  122377. /**The data type of the animation */
  122378. dataType: number;
  122379. /**The loop mode of the animation */
  122380. loopMode?: number | undefined;
  122381. /**Specifies if blending should be enabled */
  122382. enableBlending?: boolean | undefined;
  122383. /**
  122384. * Use matrix interpolation instead of using direct key value when animating matrices
  122385. */
  122386. static AllowMatricesInterpolation: boolean;
  122387. /**
  122388. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  122389. */
  122390. static AllowMatrixDecomposeForInterpolation: boolean;
  122391. /** Define the Url to load snippets */
  122392. static SnippetUrl: string;
  122393. /** Snippet ID if the animation was created from the snippet server */
  122394. snippetId: string;
  122395. /**
  122396. * Stores the key frames of the animation
  122397. */
  122398. private _keys;
  122399. /**
  122400. * Stores the easing function of the animation
  122401. */
  122402. private _easingFunction;
  122403. /**
  122404. * @hidden Internal use only
  122405. */
  122406. _runtimeAnimations: RuntimeAnimation[];
  122407. /**
  122408. * The set of event that will be linked to this animation
  122409. */
  122410. private _events;
  122411. /**
  122412. * Stores an array of target property paths
  122413. */
  122414. targetPropertyPath: string[];
  122415. /**
  122416. * Stores the blending speed of the animation
  122417. */
  122418. blendingSpeed: number;
  122419. /**
  122420. * Stores the animation ranges for the animation
  122421. */
  122422. private _ranges;
  122423. /**
  122424. * @hidden Internal use
  122425. */
  122426. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  122427. /**
  122428. * Sets up an animation
  122429. * @param property The property to animate
  122430. * @param animationType The animation type to apply
  122431. * @param framePerSecond The frames per second of the animation
  122432. * @param easingFunction The easing function used in the animation
  122433. * @returns The created animation
  122434. */
  122435. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  122436. /**
  122437. * Create and start an animation on a node
  122438. * @param name defines the name of the global animation that will be run on all nodes
  122439. * @param node defines the root node where the animation will take place
  122440. * @param targetProperty defines property to animate
  122441. * @param framePerSecond defines the number of frame per second yo use
  122442. * @param totalFrame defines the number of frames in total
  122443. * @param from defines the initial value
  122444. * @param to defines the final value
  122445. * @param loopMode defines which loop mode you want to use (off by default)
  122446. * @param easingFunction defines the easing function to use (linear by default)
  122447. * @param onAnimationEnd defines the callback to call when animation end
  122448. * @returns the animatable created for this animation
  122449. */
  122450. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  122451. /**
  122452. * Create and start an animation on a node and its descendants
  122453. * @param name defines the name of the global animation that will be run on all nodes
  122454. * @param node defines the root node where the animation will take place
  122455. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  122456. * @param targetProperty defines property to animate
  122457. * @param framePerSecond defines the number of frame per second to use
  122458. * @param totalFrame defines the number of frames in total
  122459. * @param from defines the initial value
  122460. * @param to defines the final value
  122461. * @param loopMode defines which loop mode you want to use (off by default)
  122462. * @param easingFunction defines the easing function to use (linear by default)
  122463. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  122464. * @returns the list of animatables created for all nodes
  122465. * @example https://www.babylonjs-playground.com/#MH0VLI
  122466. */
  122467. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  122468. /**
  122469. * Creates a new animation, merges it with the existing animations and starts it
  122470. * @param name Name of the animation
  122471. * @param node Node which contains the scene that begins the animations
  122472. * @param targetProperty Specifies which property to animate
  122473. * @param framePerSecond The frames per second of the animation
  122474. * @param totalFrame The total number of frames
  122475. * @param from The frame at the beginning of the animation
  122476. * @param to The frame at the end of the animation
  122477. * @param loopMode Specifies the loop mode of the animation
  122478. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  122479. * @param onAnimationEnd Callback to run once the animation is complete
  122480. * @returns Nullable animation
  122481. */
  122482. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  122483. /**
  122484. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  122485. * @param sourceAnimation defines the Animation containing keyframes to convert
  122486. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  122487. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  122488. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  122489. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  122490. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  122491. */
  122492. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  122493. /**
  122494. * Transition property of an host to the target Value
  122495. * @param property The property to transition
  122496. * @param targetValue The target Value of the property
  122497. * @param host The object where the property to animate belongs
  122498. * @param scene Scene used to run the animation
  122499. * @param frameRate Framerate (in frame/s) to use
  122500. * @param transition The transition type we want to use
  122501. * @param duration The duration of the animation, in milliseconds
  122502. * @param onAnimationEnd Callback trigger at the end of the animation
  122503. * @returns Nullable animation
  122504. */
  122505. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  122506. /**
  122507. * Return the array of runtime animations currently using this animation
  122508. */
  122509. get runtimeAnimations(): RuntimeAnimation[];
  122510. /**
  122511. * Specifies if any of the runtime animations are currently running
  122512. */
  122513. get hasRunningRuntimeAnimations(): boolean;
  122514. /**
  122515. * Initializes the animation
  122516. * @param name Name of the animation
  122517. * @param targetProperty Property to animate
  122518. * @param framePerSecond The frames per second of the animation
  122519. * @param dataType The data type of the animation
  122520. * @param loopMode The loop mode of the animation
  122521. * @param enableBlending Specifies if blending should be enabled
  122522. */
  122523. constructor(
  122524. /**Name of the animation */
  122525. name: string,
  122526. /**Property to animate */
  122527. targetProperty: string,
  122528. /**The frames per second of the animation */
  122529. framePerSecond: number,
  122530. /**The data type of the animation */
  122531. dataType: number,
  122532. /**The loop mode of the animation */
  122533. loopMode?: number | undefined,
  122534. /**Specifies if blending should be enabled */
  122535. enableBlending?: boolean | undefined);
  122536. /**
  122537. * Converts the animation to a string
  122538. * @param fullDetails support for multiple levels of logging within scene loading
  122539. * @returns String form of the animation
  122540. */
  122541. toString(fullDetails?: boolean): string;
  122542. /**
  122543. * Add an event to this animation
  122544. * @param event Event to add
  122545. */
  122546. addEvent(event: AnimationEvent): void;
  122547. /**
  122548. * Remove all events found at the given frame
  122549. * @param frame The frame to remove events from
  122550. */
  122551. removeEvents(frame: number): void;
  122552. /**
  122553. * Retrieves all the events from the animation
  122554. * @returns Events from the animation
  122555. */
  122556. getEvents(): AnimationEvent[];
  122557. /**
  122558. * Creates an animation range
  122559. * @param name Name of the animation range
  122560. * @param from Starting frame of the animation range
  122561. * @param to Ending frame of the animation
  122562. */
  122563. createRange(name: string, from: number, to: number): void;
  122564. /**
  122565. * Deletes an animation range by name
  122566. * @param name Name of the animation range to delete
  122567. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  122568. */
  122569. deleteRange(name: string, deleteFrames?: boolean): void;
  122570. /**
  122571. * Gets the animation range by name, or null if not defined
  122572. * @param name Name of the animation range
  122573. * @returns Nullable animation range
  122574. */
  122575. getRange(name: string): Nullable<AnimationRange>;
  122576. /**
  122577. * Gets the key frames from the animation
  122578. * @returns The key frames of the animation
  122579. */
  122580. getKeys(): Array<IAnimationKey>;
  122581. /**
  122582. * Gets the highest frame rate of the animation
  122583. * @returns Highest frame rate of the animation
  122584. */
  122585. getHighestFrame(): number;
  122586. /**
  122587. * Gets the easing function of the animation
  122588. * @returns Easing function of the animation
  122589. */
  122590. getEasingFunction(): IEasingFunction;
  122591. /**
  122592. * Sets the easing function of the animation
  122593. * @param easingFunction A custom mathematical formula for animation
  122594. */
  122595. setEasingFunction(easingFunction: EasingFunction): void;
  122596. /**
  122597. * Interpolates a scalar linearly
  122598. * @param startValue Start value of the animation curve
  122599. * @param endValue End value of the animation curve
  122600. * @param gradient Scalar amount to interpolate
  122601. * @returns Interpolated scalar value
  122602. */
  122603. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  122604. /**
  122605. * Interpolates a scalar cubically
  122606. * @param startValue Start value of the animation curve
  122607. * @param outTangent End tangent of the animation
  122608. * @param endValue End value of the animation curve
  122609. * @param inTangent Start tangent of the animation curve
  122610. * @param gradient Scalar amount to interpolate
  122611. * @returns Interpolated scalar value
  122612. */
  122613. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  122614. /**
  122615. * Interpolates a quaternion using a spherical linear interpolation
  122616. * @param startValue Start value of the animation curve
  122617. * @param endValue End value of the animation curve
  122618. * @param gradient Scalar amount to interpolate
  122619. * @returns Interpolated quaternion value
  122620. */
  122621. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  122622. /**
  122623. * Interpolates a quaternion cubically
  122624. * @param startValue Start value of the animation curve
  122625. * @param outTangent End tangent of the animation curve
  122626. * @param endValue End value of the animation curve
  122627. * @param inTangent Start tangent of the animation curve
  122628. * @param gradient Scalar amount to interpolate
  122629. * @returns Interpolated quaternion value
  122630. */
  122631. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  122632. /**
  122633. * Interpolates a Vector3 linearl
  122634. * @param startValue Start value of the animation curve
  122635. * @param endValue End value of the animation curve
  122636. * @param gradient Scalar amount to interpolate
  122637. * @returns Interpolated scalar value
  122638. */
  122639. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  122640. /**
  122641. * Interpolates a Vector3 cubically
  122642. * @param startValue Start value of the animation curve
  122643. * @param outTangent End tangent of the animation
  122644. * @param endValue End value of the animation curve
  122645. * @param inTangent Start tangent of the animation curve
  122646. * @param gradient Scalar amount to interpolate
  122647. * @returns InterpolatedVector3 value
  122648. */
  122649. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  122650. /**
  122651. * Interpolates a Vector2 linearly
  122652. * @param startValue Start value of the animation curve
  122653. * @param endValue End value of the animation curve
  122654. * @param gradient Scalar amount to interpolate
  122655. * @returns Interpolated Vector2 value
  122656. */
  122657. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  122658. /**
  122659. * Interpolates a Vector2 cubically
  122660. * @param startValue Start value of the animation curve
  122661. * @param outTangent End tangent of the animation
  122662. * @param endValue End value of the animation curve
  122663. * @param inTangent Start tangent of the animation curve
  122664. * @param gradient Scalar amount to interpolate
  122665. * @returns Interpolated Vector2 value
  122666. */
  122667. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  122668. /**
  122669. * Interpolates a size linearly
  122670. * @param startValue Start value of the animation curve
  122671. * @param endValue End value of the animation curve
  122672. * @param gradient Scalar amount to interpolate
  122673. * @returns Interpolated Size value
  122674. */
  122675. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  122676. /**
  122677. * Interpolates a Color3 linearly
  122678. * @param startValue Start value of the animation curve
  122679. * @param endValue End value of the animation curve
  122680. * @param gradient Scalar amount to interpolate
  122681. * @returns Interpolated Color3 value
  122682. */
  122683. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  122684. /**
  122685. * Interpolates a Color4 linearly
  122686. * @param startValue Start value of the animation curve
  122687. * @param endValue End value of the animation curve
  122688. * @param gradient Scalar amount to interpolate
  122689. * @returns Interpolated Color3 value
  122690. */
  122691. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  122692. /**
  122693. * @hidden Internal use only
  122694. */
  122695. _getKeyValue(value: any): any;
  122696. /**
  122697. * @hidden Internal use only
  122698. */
  122699. _interpolate(currentFrame: number, state: _IAnimationState): any;
  122700. /**
  122701. * Defines the function to use to interpolate matrices
  122702. * @param startValue defines the start matrix
  122703. * @param endValue defines the end matrix
  122704. * @param gradient defines the gradient between both matrices
  122705. * @param result defines an optional target matrix where to store the interpolation
  122706. * @returns the interpolated matrix
  122707. */
  122708. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  122709. /**
  122710. * Makes a copy of the animation
  122711. * @returns Cloned animation
  122712. */
  122713. clone(): Animation;
  122714. /**
  122715. * Sets the key frames of the animation
  122716. * @param values The animation key frames to set
  122717. */
  122718. setKeys(values: Array<IAnimationKey>): void;
  122719. /**
  122720. * Serializes the animation to an object
  122721. * @returns Serialized object
  122722. */
  122723. serialize(): any;
  122724. /**
  122725. * Float animation type
  122726. */
  122727. static readonly ANIMATIONTYPE_FLOAT: number;
  122728. /**
  122729. * Vector3 animation type
  122730. */
  122731. static readonly ANIMATIONTYPE_VECTOR3: number;
  122732. /**
  122733. * Quaternion animation type
  122734. */
  122735. static readonly ANIMATIONTYPE_QUATERNION: number;
  122736. /**
  122737. * Matrix animation type
  122738. */
  122739. static readonly ANIMATIONTYPE_MATRIX: number;
  122740. /**
  122741. * Color3 animation type
  122742. */
  122743. static readonly ANIMATIONTYPE_COLOR3: number;
  122744. /**
  122745. * Color3 animation type
  122746. */
  122747. static readonly ANIMATIONTYPE_COLOR4: number;
  122748. /**
  122749. * Vector2 animation type
  122750. */
  122751. static readonly ANIMATIONTYPE_VECTOR2: number;
  122752. /**
  122753. * Size animation type
  122754. */
  122755. static readonly ANIMATIONTYPE_SIZE: number;
  122756. /**
  122757. * Relative Loop Mode
  122758. */
  122759. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  122760. /**
  122761. * Cycle Loop Mode
  122762. */
  122763. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  122764. /**
  122765. * Constant Loop Mode
  122766. */
  122767. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  122768. /** @hidden */
  122769. static _UniversalLerp(left: any, right: any, amount: number): any;
  122770. /**
  122771. * Parses an animation object and creates an animation
  122772. * @param parsedAnimation Parsed animation object
  122773. * @returns Animation object
  122774. */
  122775. static Parse(parsedAnimation: any): Animation;
  122776. /**
  122777. * Appends the serialized animations from the source animations
  122778. * @param source Source containing the animations
  122779. * @param destination Target to store the animations
  122780. */
  122781. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122782. /**
  122783. * Creates a new animation or an array of animations from a snippet saved in a remote file
  122784. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  122785. * @param url defines the url to load from
  122786. * @returns a promise that will resolve to the new animation or an array of animations
  122787. */
  122788. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  122789. /**
  122790. * Creates an animation or an array of animations from a snippet saved by the Inspector
  122791. * @param snippetId defines the snippet to load
  122792. * @returns a promise that will resolve to the new animation or a new array of animations
  122793. */
  122794. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  122795. }
  122796. }
  122797. declare module BABYLON {
  122798. /**
  122799. * Interface containing an array of animations
  122800. */
  122801. export interface IAnimatable {
  122802. /**
  122803. * Array of animations
  122804. */
  122805. animations: Nullable<Array<Animation>>;
  122806. }
  122807. }
  122808. declare module BABYLON {
  122809. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  122810. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122811. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122812. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122813. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122814. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122815. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122816. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122817. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122818. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122819. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122820. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122821. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122822. /**
  122823. * Decorator used to define property that can be serialized as reference to a camera
  122824. * @param sourceName defines the name of the property to decorate
  122825. */
  122826. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122827. /**
  122828. * Class used to help serialization objects
  122829. */
  122830. export class SerializationHelper {
  122831. /** @hidden */
  122832. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  122833. /** @hidden */
  122834. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  122835. /** @hidden */
  122836. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  122837. /** @hidden */
  122838. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  122839. /**
  122840. * Appends the serialized animations from the source animations
  122841. * @param source Source containing the animations
  122842. * @param destination Target to store the animations
  122843. */
  122844. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122845. /**
  122846. * Static function used to serialized a specific entity
  122847. * @param entity defines the entity to serialize
  122848. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  122849. * @returns a JSON compatible object representing the serialization of the entity
  122850. */
  122851. static Serialize<T>(entity: T, serializationObject?: any): any;
  122852. /**
  122853. * Creates a new entity from a serialization data object
  122854. * @param creationFunction defines a function used to instanciated the new entity
  122855. * @param source defines the source serialization data
  122856. * @param scene defines the hosting scene
  122857. * @param rootUrl defines the root url for resources
  122858. * @returns a new entity
  122859. */
  122860. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  122861. /**
  122862. * Clones an object
  122863. * @param creationFunction defines the function used to instanciate the new object
  122864. * @param source defines the source object
  122865. * @returns the cloned object
  122866. */
  122867. static Clone<T>(creationFunction: () => T, source: T): T;
  122868. /**
  122869. * Instanciates a new object based on a source one (some data will be shared between both object)
  122870. * @param creationFunction defines the function used to instanciate the new object
  122871. * @param source defines the source object
  122872. * @returns the new object
  122873. */
  122874. static Instanciate<T>(creationFunction: () => T, source: T): T;
  122875. }
  122876. }
  122877. declare module BABYLON {
  122878. /**
  122879. * This is the base class of all the camera used in the application.
  122880. * @see https://doc.babylonjs.com/features/cameras
  122881. */
  122882. export class Camera extends Node {
  122883. /** @hidden */
  122884. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  122885. /**
  122886. * This is the default projection mode used by the cameras.
  122887. * It helps recreating a feeling of perspective and better appreciate depth.
  122888. * This is the best way to simulate real life cameras.
  122889. */
  122890. static readonly PERSPECTIVE_CAMERA: number;
  122891. /**
  122892. * This helps creating camera with an orthographic mode.
  122893. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  122894. */
  122895. static readonly ORTHOGRAPHIC_CAMERA: number;
  122896. /**
  122897. * This is the default FOV mode for perspective cameras.
  122898. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  122899. */
  122900. static readonly FOVMODE_VERTICAL_FIXED: number;
  122901. /**
  122902. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  122903. */
  122904. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  122905. /**
  122906. * This specifies ther is no need for a camera rig.
  122907. * Basically only one eye is rendered corresponding to the camera.
  122908. */
  122909. static readonly RIG_MODE_NONE: number;
  122910. /**
  122911. * Simulates a camera Rig with one blue eye and one red eye.
  122912. * This can be use with 3d blue and red glasses.
  122913. */
  122914. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  122915. /**
  122916. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  122917. */
  122918. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  122919. /**
  122920. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  122921. */
  122922. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  122923. /**
  122924. * Defines that both eyes of the camera will be rendered over under each other.
  122925. */
  122926. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  122927. /**
  122928. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  122929. */
  122930. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  122931. /**
  122932. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  122933. */
  122934. static readonly RIG_MODE_VR: number;
  122935. /**
  122936. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  122937. */
  122938. static readonly RIG_MODE_WEBVR: number;
  122939. /**
  122940. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  122941. */
  122942. static readonly RIG_MODE_CUSTOM: number;
  122943. /**
  122944. * Defines if by default attaching controls should prevent the default javascript event to continue.
  122945. */
  122946. static ForceAttachControlToAlwaysPreventDefault: boolean;
  122947. /**
  122948. * Define the input manager associated with the camera.
  122949. */
  122950. inputs: CameraInputsManager<Camera>;
  122951. /** @hidden */
  122952. _position: Vector3;
  122953. /**
  122954. * Define the current local position of the camera in the scene
  122955. */
  122956. get position(): Vector3;
  122957. set position(newPosition: Vector3);
  122958. protected _upVector: Vector3;
  122959. /**
  122960. * The vector the camera should consider as up.
  122961. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  122962. */
  122963. set upVector(vec: Vector3);
  122964. get upVector(): Vector3;
  122965. /**
  122966. * Define the current limit on the left side for an orthographic camera
  122967. * In scene unit
  122968. */
  122969. orthoLeft: Nullable<number>;
  122970. /**
  122971. * Define the current limit on the right side for an orthographic camera
  122972. * In scene unit
  122973. */
  122974. orthoRight: Nullable<number>;
  122975. /**
  122976. * Define the current limit on the bottom side for an orthographic camera
  122977. * In scene unit
  122978. */
  122979. orthoBottom: Nullable<number>;
  122980. /**
  122981. * Define the current limit on the top side for an orthographic camera
  122982. * In scene unit
  122983. */
  122984. orthoTop: Nullable<number>;
  122985. /**
  122986. * Field Of View is set in Radians. (default is 0.8)
  122987. */
  122988. fov: number;
  122989. /**
  122990. * Define the minimum distance the camera can see from.
  122991. * This is important to note that the depth buffer are not infinite and the closer it starts
  122992. * the more your scene might encounter depth fighting issue.
  122993. */
  122994. minZ: number;
  122995. /**
  122996. * Define the maximum distance the camera can see to.
  122997. * This is important to note that the depth buffer are not infinite and the further it end
  122998. * the more your scene might encounter depth fighting issue.
  122999. */
  123000. maxZ: number;
  123001. /**
  123002. * Define the default inertia of the camera.
  123003. * This helps giving a smooth feeling to the camera movement.
  123004. */
  123005. inertia: number;
  123006. /**
  123007. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  123008. */
  123009. mode: number;
  123010. /**
  123011. * Define whether the camera is intermediate.
  123012. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  123013. */
  123014. isIntermediate: boolean;
  123015. /**
  123016. * Define the viewport of the camera.
  123017. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  123018. */
  123019. viewport: Viewport;
  123020. /**
  123021. * Restricts the camera to viewing objects with the same layerMask.
  123022. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  123023. */
  123024. layerMask: number;
  123025. /**
  123026. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  123027. */
  123028. fovMode: number;
  123029. /**
  123030. * Rig mode of the camera.
  123031. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  123032. * This is normally controlled byt the camera themselves as internal use.
  123033. */
  123034. cameraRigMode: number;
  123035. /**
  123036. * Defines the distance between both "eyes" in case of a RIG
  123037. */
  123038. interaxialDistance: number;
  123039. /**
  123040. * Defines if stereoscopic rendering is done side by side or over under.
  123041. */
  123042. isStereoscopicSideBySide: boolean;
  123043. /**
  123044. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  123045. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  123046. * else in the scene. (Eg. security camera)
  123047. *
  123048. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  123049. */
  123050. customRenderTargets: RenderTargetTexture[];
  123051. /**
  123052. * When set, the camera will render to this render target instead of the default canvas
  123053. *
  123054. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  123055. */
  123056. outputRenderTarget: Nullable<RenderTargetTexture>;
  123057. /**
  123058. * Observable triggered when the camera view matrix has changed.
  123059. */
  123060. onViewMatrixChangedObservable: Observable<Camera>;
  123061. /**
  123062. * Observable triggered when the camera Projection matrix has changed.
  123063. */
  123064. onProjectionMatrixChangedObservable: Observable<Camera>;
  123065. /**
  123066. * Observable triggered when the inputs have been processed.
  123067. */
  123068. onAfterCheckInputsObservable: Observable<Camera>;
  123069. /**
  123070. * Observable triggered when reset has been called and applied to the camera.
  123071. */
  123072. onRestoreStateObservable: Observable<Camera>;
  123073. /**
  123074. * Is this camera a part of a rig system?
  123075. */
  123076. isRigCamera: boolean;
  123077. /**
  123078. * If isRigCamera set to true this will be set with the parent camera.
  123079. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  123080. */
  123081. rigParent?: Camera;
  123082. /** @hidden */
  123083. _cameraRigParams: any;
  123084. /** @hidden */
  123085. _rigCameras: Camera[];
  123086. /** @hidden */
  123087. _rigPostProcess: Nullable<PostProcess>;
  123088. protected _webvrViewMatrix: Matrix;
  123089. /** @hidden */
  123090. _skipRendering: boolean;
  123091. /** @hidden */
  123092. _projectionMatrix: Matrix;
  123093. /** @hidden */
  123094. _postProcesses: Nullable<PostProcess>[];
  123095. /** @hidden */
  123096. _activeMeshes: SmartArray<AbstractMesh>;
  123097. protected _globalPosition: Vector3;
  123098. /** @hidden */
  123099. _computedViewMatrix: Matrix;
  123100. private _doNotComputeProjectionMatrix;
  123101. private _transformMatrix;
  123102. private _frustumPlanes;
  123103. private _refreshFrustumPlanes;
  123104. private _storedFov;
  123105. private _stateStored;
  123106. /**
  123107. * Instantiates a new camera object.
  123108. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  123109. * @see https://doc.babylonjs.com/features/cameras
  123110. * @param name Defines the name of the camera in the scene
  123111. * @param position Defines the position of the camera
  123112. * @param scene Defines the scene the camera belongs too
  123113. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  123114. */
  123115. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123116. /**
  123117. * Store current camera state (fov, position, etc..)
  123118. * @returns the camera
  123119. */
  123120. storeState(): Camera;
  123121. /**
  123122. * Restores the camera state values if it has been stored. You must call storeState() first
  123123. */
  123124. protected _restoreStateValues(): boolean;
  123125. /**
  123126. * Restored camera state. You must call storeState() first.
  123127. * @returns true if restored and false otherwise
  123128. */
  123129. restoreState(): boolean;
  123130. /**
  123131. * Gets the class name of the camera.
  123132. * @returns the class name
  123133. */
  123134. getClassName(): string;
  123135. /** @hidden */
  123136. readonly _isCamera: boolean;
  123137. /**
  123138. * Gets a string representation of the camera useful for debug purpose.
  123139. * @param fullDetails Defines that a more verboe level of logging is required
  123140. * @returns the string representation
  123141. */
  123142. toString(fullDetails?: boolean): string;
  123143. /**
  123144. * Gets the current world space position of the camera.
  123145. */
  123146. get globalPosition(): Vector3;
  123147. /**
  123148. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  123149. * @returns the active meshe list
  123150. */
  123151. getActiveMeshes(): SmartArray<AbstractMesh>;
  123152. /**
  123153. * Check whether a mesh is part of the current active mesh list of the camera
  123154. * @param mesh Defines the mesh to check
  123155. * @returns true if active, false otherwise
  123156. */
  123157. isActiveMesh(mesh: Mesh): boolean;
  123158. /**
  123159. * Is this camera ready to be used/rendered
  123160. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  123161. * @return true if the camera is ready
  123162. */
  123163. isReady(completeCheck?: boolean): boolean;
  123164. /** @hidden */
  123165. _initCache(): void;
  123166. /** @hidden */
  123167. _updateCache(ignoreParentClass?: boolean): void;
  123168. /** @hidden */
  123169. _isSynchronized(): boolean;
  123170. /** @hidden */
  123171. _isSynchronizedViewMatrix(): boolean;
  123172. /** @hidden */
  123173. _isSynchronizedProjectionMatrix(): boolean;
  123174. /**
  123175. * Attach the input controls to a specific dom element to get the input from.
  123176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123177. */
  123178. attachControl(noPreventDefault?: boolean): void;
  123179. /**
  123180. * Attach the input controls to a specific dom element to get the input from.
  123181. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  123182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123183. * BACK COMPAT SIGNATURE ONLY.
  123184. */
  123185. attachControl(ignored: any, noPreventDefault?: boolean): void;
  123186. /**
  123187. * Detach the current controls from the specified dom element.
  123188. */
  123189. detachControl(): void;
  123190. /**
  123191. * Detach the current controls from the specified dom element.
  123192. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  123193. */
  123194. detachControl(ignored: any): void;
  123195. /**
  123196. * Update the camera state according to the different inputs gathered during the frame.
  123197. */
  123198. update(): void;
  123199. /** @hidden */
  123200. _checkInputs(): void;
  123201. /** @hidden */
  123202. get rigCameras(): Camera[];
  123203. /**
  123204. * Gets the post process used by the rig cameras
  123205. */
  123206. get rigPostProcess(): Nullable<PostProcess>;
  123207. /**
  123208. * Internal, gets the first post proces.
  123209. * @returns the first post process to be run on this camera.
  123210. */
  123211. _getFirstPostProcess(): Nullable<PostProcess>;
  123212. private _cascadePostProcessesToRigCams;
  123213. /**
  123214. * Attach a post process to the camera.
  123215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  123216. * @param postProcess The post process to attach to the camera
  123217. * @param insertAt The position of the post process in case several of them are in use in the scene
  123218. * @returns the position the post process has been inserted at
  123219. */
  123220. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  123221. /**
  123222. * Detach a post process to the camera.
  123223. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  123224. * @param postProcess The post process to detach from the camera
  123225. */
  123226. detachPostProcess(postProcess: PostProcess): void;
  123227. /**
  123228. * Gets the current world matrix of the camera
  123229. */
  123230. getWorldMatrix(): Matrix;
  123231. /** @hidden */
  123232. _getViewMatrix(): Matrix;
  123233. /**
  123234. * Gets the current view matrix of the camera.
  123235. * @param force forces the camera to recompute the matrix without looking at the cached state
  123236. * @returns the view matrix
  123237. */
  123238. getViewMatrix(force?: boolean): Matrix;
  123239. /**
  123240. * Freeze the projection matrix.
  123241. * It will prevent the cache check of the camera projection compute and can speed up perf
  123242. * if no parameter of the camera are meant to change
  123243. * @param projection Defines manually a projection if necessary
  123244. */
  123245. freezeProjectionMatrix(projection?: Matrix): void;
  123246. /**
  123247. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  123248. */
  123249. unfreezeProjectionMatrix(): void;
  123250. /**
  123251. * Gets the current projection matrix of the camera.
  123252. * @param force forces the camera to recompute the matrix without looking at the cached state
  123253. * @returns the projection matrix
  123254. */
  123255. getProjectionMatrix(force?: boolean): Matrix;
  123256. /**
  123257. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  123258. * @returns a Matrix
  123259. */
  123260. getTransformationMatrix(): Matrix;
  123261. private _updateFrustumPlanes;
  123262. /**
  123263. * Checks if a cullable object (mesh...) is in the camera frustum
  123264. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  123265. * @param target The object to check
  123266. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  123267. * @returns true if the object is in frustum otherwise false
  123268. */
  123269. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  123270. /**
  123271. * Checks if a cullable object (mesh...) is in the camera frustum
  123272. * Unlike isInFrustum this cheks the full bounding box
  123273. * @param target The object to check
  123274. * @returns true if the object is in frustum otherwise false
  123275. */
  123276. isCompletelyInFrustum(target: ICullable): boolean;
  123277. /**
  123278. * Gets a ray in the forward direction from the camera.
  123279. * @param length Defines the length of the ray to create
  123280. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  123281. * @param origin Defines the start point of the ray which defaults to the camera position
  123282. * @returns the forward ray
  123283. */
  123284. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  123285. /**
  123286. * Gets a ray in the forward direction from the camera.
  123287. * @param refRay the ray to (re)use when setting the values
  123288. * @param length Defines the length of the ray to create
  123289. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  123290. * @param origin Defines the start point of the ray which defaults to the camera position
  123291. * @returns the forward ray
  123292. */
  123293. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  123294. /**
  123295. * Releases resources associated with this node.
  123296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123298. */
  123299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123300. /** @hidden */
  123301. _isLeftCamera: boolean;
  123302. /**
  123303. * Gets the left camera of a rig setup in case of Rigged Camera
  123304. */
  123305. get isLeftCamera(): boolean;
  123306. /** @hidden */
  123307. _isRightCamera: boolean;
  123308. /**
  123309. * Gets the right camera of a rig setup in case of Rigged Camera
  123310. */
  123311. get isRightCamera(): boolean;
  123312. /**
  123313. * Gets the left camera of a rig setup in case of Rigged Camera
  123314. */
  123315. get leftCamera(): Nullable<FreeCamera>;
  123316. /**
  123317. * Gets the right camera of a rig setup in case of Rigged Camera
  123318. */
  123319. get rightCamera(): Nullable<FreeCamera>;
  123320. /**
  123321. * Gets the left camera target of a rig setup in case of Rigged Camera
  123322. * @returns the target position
  123323. */
  123324. getLeftTarget(): Nullable<Vector3>;
  123325. /**
  123326. * Gets the right camera target of a rig setup in case of Rigged Camera
  123327. * @returns the target position
  123328. */
  123329. getRightTarget(): Nullable<Vector3>;
  123330. /**
  123331. * @hidden
  123332. */
  123333. setCameraRigMode(mode: number, rigParams: any): void;
  123334. /** @hidden */
  123335. static _setStereoscopicRigMode(camera: Camera): void;
  123336. /** @hidden */
  123337. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  123338. /** @hidden */
  123339. static _setVRRigMode(camera: Camera, rigParams: any): void;
  123340. /** @hidden */
  123341. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  123342. /** @hidden */
  123343. _getVRProjectionMatrix(): Matrix;
  123344. protected _updateCameraRotationMatrix(): void;
  123345. protected _updateWebVRCameraRotationMatrix(): void;
  123346. /**
  123347. * This function MUST be overwritten by the different WebVR cameras available.
  123348. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  123349. * @hidden
  123350. */
  123351. _getWebVRProjectionMatrix(): Matrix;
  123352. /**
  123353. * This function MUST be overwritten by the different WebVR cameras available.
  123354. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  123355. * @hidden
  123356. */
  123357. _getWebVRViewMatrix(): Matrix;
  123358. /** @hidden */
  123359. setCameraRigParameter(name: string, value: any): void;
  123360. /**
  123361. * needs to be overridden by children so sub has required properties to be copied
  123362. * @hidden
  123363. */
  123364. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  123365. /**
  123366. * May need to be overridden by children
  123367. * @hidden
  123368. */
  123369. _updateRigCameras(): void;
  123370. /** @hidden */
  123371. _setupInputs(): void;
  123372. /**
  123373. * Serialiaze the camera setup to a json represention
  123374. * @returns the JSON representation
  123375. */
  123376. serialize(): any;
  123377. /**
  123378. * Clones the current camera.
  123379. * @param name The cloned camera name
  123380. * @returns the cloned camera
  123381. */
  123382. clone(name: string): Camera;
  123383. /**
  123384. * Gets the direction of the camera relative to a given local axis.
  123385. * @param localAxis Defines the reference axis to provide a relative direction.
  123386. * @return the direction
  123387. */
  123388. getDirection(localAxis: Vector3): Vector3;
  123389. /**
  123390. * Returns the current camera absolute rotation
  123391. */
  123392. get absoluteRotation(): Quaternion;
  123393. /**
  123394. * Gets the direction of the camera relative to a given local axis into a passed vector.
  123395. * @param localAxis Defines the reference axis to provide a relative direction.
  123396. * @param result Defines the vector to store the result in
  123397. */
  123398. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  123399. /**
  123400. * Gets a camera constructor for a given camera type
  123401. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  123402. * @param name The name of the camera the result will be able to instantiate
  123403. * @param scene The scene the result will construct the camera in
  123404. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  123405. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  123406. * @returns a factory method to construc the camera
  123407. */
  123408. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  123409. /**
  123410. * Compute the world matrix of the camera.
  123411. * @returns the camera world matrix
  123412. */
  123413. computeWorldMatrix(): Matrix;
  123414. /**
  123415. * Parse a JSON and creates the camera from the parsed information
  123416. * @param parsedCamera The JSON to parse
  123417. * @param scene The scene to instantiate the camera in
  123418. * @returns the newly constructed camera
  123419. */
  123420. static Parse(parsedCamera: any, scene: Scene): Camera;
  123421. }
  123422. }
  123423. declare module BABYLON {
  123424. /**
  123425. * PostProcessManager is used to manage one or more post processes or post process pipelines
  123426. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123427. */
  123428. export class PostProcessManager {
  123429. private _scene;
  123430. private _indexBuffer;
  123431. private _vertexBuffers;
  123432. /**
  123433. * Creates a new instance PostProcess
  123434. * @param scene The scene that the post process is associated with.
  123435. */
  123436. constructor(scene: Scene);
  123437. private _prepareBuffers;
  123438. private _buildIndexBuffer;
  123439. /**
  123440. * Rebuilds the vertex buffers of the manager.
  123441. * @hidden
  123442. */
  123443. _rebuild(): void;
  123444. /**
  123445. * Prepares a frame to be run through a post process.
  123446. * @param sourceTexture The input texture to the post procesess. (default: null)
  123447. * @param postProcesses An array of post processes to be run. (default: null)
  123448. * @returns True if the post processes were able to be run.
  123449. * @hidden
  123450. */
  123451. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  123452. /**
  123453. * Manually render a set of post processes to a texture.
  123454. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  123455. * @param postProcesses An array of post processes to be run.
  123456. * @param targetTexture The target texture to render to.
  123457. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  123458. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  123459. * @param lodLevel defines which lod of the texture to render to
  123460. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  123461. */
  123462. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  123463. /**
  123464. * Finalize the result of the output of the postprocesses.
  123465. * @param doNotPresent If true the result will not be displayed to the screen.
  123466. * @param targetTexture The target texture to render to.
  123467. * @param faceIndex The index of the face to bind the target texture to.
  123468. * @param postProcesses The array of post processes to render.
  123469. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  123470. * @hidden
  123471. */
  123472. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  123473. /**
  123474. * Disposes of the post process manager.
  123475. */
  123476. dispose(): void;
  123477. }
  123478. }
  123479. declare module BABYLON {
  123480. /**
  123481. * This Helps creating a texture that will be created from a camera in your scene.
  123482. * It is basically a dynamic texture that could be used to create special effects for instance.
  123483. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  123484. */
  123485. export class RenderTargetTexture extends Texture {
  123486. /**
  123487. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  123488. */
  123489. static readonly REFRESHRATE_RENDER_ONCE: number;
  123490. /**
  123491. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  123492. */
  123493. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  123494. /**
  123495. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  123496. * the central point of your effect and can save a lot of performances.
  123497. */
  123498. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  123499. /**
  123500. * Use this predicate to dynamically define the list of mesh you want to render.
  123501. * If set, the renderList property will be overwritten.
  123502. */
  123503. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  123504. private _renderList;
  123505. /**
  123506. * Use this list to define the list of mesh you want to render.
  123507. */
  123508. get renderList(): Nullable<Array<AbstractMesh>>;
  123509. set renderList(value: Nullable<Array<AbstractMesh>>);
  123510. /**
  123511. * Use this function to overload the renderList array at rendering time.
  123512. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  123513. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  123514. * the cube (if the RTT is a cube, else layerOrFace=0).
  123515. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  123516. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  123517. * hold dummy elements!
  123518. */
  123519. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  123520. private _hookArray;
  123521. /**
  123522. * Define if particles should be rendered in your texture.
  123523. */
  123524. renderParticles: boolean;
  123525. /**
  123526. * Define if sprites should be rendered in your texture.
  123527. */
  123528. renderSprites: boolean;
  123529. /**
  123530. * Define the camera used to render the texture.
  123531. */
  123532. activeCamera: Nullable<Camera>;
  123533. /**
  123534. * Override the mesh isReady function with your own one.
  123535. */
  123536. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  123537. /**
  123538. * Override the render function of the texture with your own one.
  123539. */
  123540. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  123541. /**
  123542. * Define if camera post processes should be use while rendering the texture.
  123543. */
  123544. useCameraPostProcesses: boolean;
  123545. /**
  123546. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  123547. */
  123548. ignoreCameraViewport: boolean;
  123549. private _postProcessManager;
  123550. private _postProcesses;
  123551. private _resizeObserver;
  123552. /**
  123553. * An event triggered when the texture is unbind.
  123554. */
  123555. onBeforeBindObservable: Observable<RenderTargetTexture>;
  123556. /**
  123557. * An event triggered when the texture is unbind.
  123558. */
  123559. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  123560. private _onAfterUnbindObserver;
  123561. /**
  123562. * Set a after unbind callback in the texture.
  123563. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  123564. */
  123565. set onAfterUnbind(callback: () => void);
  123566. /**
  123567. * An event triggered before rendering the texture
  123568. */
  123569. onBeforeRenderObservable: Observable<number>;
  123570. private _onBeforeRenderObserver;
  123571. /**
  123572. * Set a before render callback in the texture.
  123573. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  123574. */
  123575. set onBeforeRender(callback: (faceIndex: number) => void);
  123576. /**
  123577. * An event triggered after rendering the texture
  123578. */
  123579. onAfterRenderObservable: Observable<number>;
  123580. private _onAfterRenderObserver;
  123581. /**
  123582. * Set a after render callback in the texture.
  123583. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  123584. */
  123585. set onAfterRender(callback: (faceIndex: number) => void);
  123586. /**
  123587. * An event triggered after the texture clear
  123588. */
  123589. onClearObservable: Observable<Engine>;
  123590. private _onClearObserver;
  123591. /**
  123592. * Set a clear callback in the texture.
  123593. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  123594. */
  123595. set onClear(callback: (Engine: Engine) => void);
  123596. /**
  123597. * An event triggered when the texture is resized.
  123598. */
  123599. onResizeObservable: Observable<RenderTargetTexture>;
  123600. /**
  123601. * Define the clear color of the Render Target if it should be different from the scene.
  123602. */
  123603. clearColor: Color4;
  123604. protected _size: number | {
  123605. width: number;
  123606. height: number;
  123607. layers?: number;
  123608. };
  123609. protected _initialSizeParameter: number | {
  123610. width: number;
  123611. height: number;
  123612. } | {
  123613. ratio: number;
  123614. };
  123615. protected _sizeRatio: Nullable<number>;
  123616. /** @hidden */
  123617. _generateMipMaps: boolean;
  123618. protected _renderingManager: RenderingManager;
  123619. /** @hidden */
  123620. _waitingRenderList?: string[];
  123621. protected _doNotChangeAspectRatio: boolean;
  123622. protected _currentRefreshId: number;
  123623. protected _refreshRate: number;
  123624. protected _textureMatrix: Matrix;
  123625. protected _samples: number;
  123626. protected _renderTargetOptions: RenderTargetCreationOptions;
  123627. /**
  123628. * Gets render target creation options that were used.
  123629. */
  123630. get renderTargetOptions(): RenderTargetCreationOptions;
  123631. protected _onRatioRescale(): void;
  123632. /**
  123633. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  123634. * It must define where the camera used to render the texture is set
  123635. */
  123636. boundingBoxPosition: Vector3;
  123637. private _boundingBoxSize;
  123638. /**
  123639. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  123640. * When defined, the cubemap will switch to local mode
  123641. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123642. * @example https://www.babylonjs-playground.com/#RNASML
  123643. */
  123644. set boundingBoxSize(value: Vector3);
  123645. get boundingBoxSize(): Vector3;
  123646. /**
  123647. * In case the RTT has been created with a depth texture, get the associated
  123648. * depth texture.
  123649. * Otherwise, return null.
  123650. */
  123651. get depthStencilTexture(): Nullable<InternalTexture>;
  123652. /**
  123653. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  123654. * or used a shadow, depth texture...
  123655. * @param name The friendly name of the texture
  123656. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  123657. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  123658. * @param generateMipMaps True if mip maps need to be generated after render.
  123659. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  123660. * @param type The type of the buffer in the RTT (int, half float, float...)
  123661. * @param isCube True if a cube texture needs to be created
  123662. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  123663. * @param generateDepthBuffer True to generate a depth buffer
  123664. * @param generateStencilBuffer True to generate a stencil buffer
  123665. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  123666. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  123667. * @param delayAllocation if the texture allocation should be delayed (default: false)
  123668. * @param samples sample count to use when creating the RTT
  123669. */
  123670. constructor(name: string, size: number | {
  123671. width: number;
  123672. height: number;
  123673. layers?: number;
  123674. } | {
  123675. ratio: number;
  123676. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  123677. /**
  123678. * Creates a depth stencil texture.
  123679. * This is only available in WebGL 2 or with the depth texture extension available.
  123680. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  123681. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  123682. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  123683. * @param samples sample count of the depth/stencil texture
  123684. */
  123685. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  123686. private _processSizeParameter;
  123687. /**
  123688. * Define the number of samples to use in case of MSAA.
  123689. * It defaults to one meaning no MSAA has been enabled.
  123690. */
  123691. get samples(): number;
  123692. set samples(value: number);
  123693. /**
  123694. * Resets the refresh counter of the texture and start bak from scratch.
  123695. * Could be useful to regenerate the texture if it is setup to render only once.
  123696. */
  123697. resetRefreshCounter(): void;
  123698. /**
  123699. * Define the refresh rate of the texture or the rendering frequency.
  123700. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  123701. */
  123702. get refreshRate(): number;
  123703. set refreshRate(value: number);
  123704. /**
  123705. * Adds a post process to the render target rendering passes.
  123706. * @param postProcess define the post process to add
  123707. */
  123708. addPostProcess(postProcess: PostProcess): void;
  123709. /**
  123710. * Clear all the post processes attached to the render target
  123711. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  123712. */
  123713. clearPostProcesses(dispose?: boolean): void;
  123714. /**
  123715. * Remove one of the post process from the list of attached post processes to the texture
  123716. * @param postProcess define the post process to remove from the list
  123717. */
  123718. removePostProcess(postProcess: PostProcess): void;
  123719. /** @hidden */
  123720. _shouldRender(): boolean;
  123721. /**
  123722. * Gets the actual render size of the texture.
  123723. * @returns the width of the render size
  123724. */
  123725. getRenderSize(): number;
  123726. /**
  123727. * Gets the actual render width of the texture.
  123728. * @returns the width of the render size
  123729. */
  123730. getRenderWidth(): number;
  123731. /**
  123732. * Gets the actual render height of the texture.
  123733. * @returns the height of the render size
  123734. */
  123735. getRenderHeight(): number;
  123736. /**
  123737. * Gets the actual number of layers of the texture.
  123738. * @returns the number of layers
  123739. */
  123740. getRenderLayers(): number;
  123741. /**
  123742. * Get if the texture can be rescaled or not.
  123743. */
  123744. get canRescale(): boolean;
  123745. /**
  123746. * Resize the texture using a ratio.
  123747. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  123748. */
  123749. scale(ratio: number): void;
  123750. /**
  123751. * Get the texture reflection matrix used to rotate/transform the reflection.
  123752. * @returns the reflection matrix
  123753. */
  123754. getReflectionTextureMatrix(): Matrix;
  123755. /**
  123756. * Resize the texture to a new desired size.
  123757. * Be carrefull as it will recreate all the data in the new texture.
  123758. * @param size Define the new size. It can be:
  123759. * - a number for squared texture,
  123760. * - an object containing { width: number, height: number }
  123761. * - or an object containing a ratio { ratio: number }
  123762. */
  123763. resize(size: number | {
  123764. width: number;
  123765. height: number;
  123766. } | {
  123767. ratio: number;
  123768. }): void;
  123769. private _defaultRenderListPrepared;
  123770. /**
  123771. * Renders all the objects from the render list into the texture.
  123772. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  123773. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  123774. */
  123775. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  123776. private _bestReflectionRenderTargetDimension;
  123777. private _prepareRenderingManager;
  123778. /**
  123779. * @hidden
  123780. * @param faceIndex face index to bind to if this is a cubetexture
  123781. * @param layer defines the index of the texture to bind in the array
  123782. */
  123783. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  123784. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123785. private renderToTarget;
  123786. /**
  123787. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  123788. * This allowed control for front to back rendering or reversly depending of the special needs.
  123789. *
  123790. * @param renderingGroupId The rendering group id corresponding to its index
  123791. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  123792. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  123793. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  123794. */
  123795. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  123796. /**
  123797. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  123798. *
  123799. * @param renderingGroupId The rendering group id corresponding to its index
  123800. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  123801. */
  123802. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  123803. /**
  123804. * Clones the texture.
  123805. * @returns the cloned texture
  123806. */
  123807. clone(): RenderTargetTexture;
  123808. /**
  123809. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  123810. * @returns The JSON representation of the texture
  123811. */
  123812. serialize(): any;
  123813. /**
  123814. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  123815. */
  123816. disposeFramebufferObjects(): void;
  123817. /**
  123818. * Dispose the texture and release its associated resources.
  123819. */
  123820. dispose(): void;
  123821. /** @hidden */
  123822. _rebuild(): void;
  123823. /**
  123824. * Clear the info related to rendering groups preventing retention point in material dispose.
  123825. */
  123826. freeRenderingGroups(): void;
  123827. /**
  123828. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  123829. * @returns the view count
  123830. */
  123831. getViewCount(): number;
  123832. }
  123833. }
  123834. declare module BABYLON {
  123835. /**
  123836. * Options to be used when creating an effect.
  123837. */
  123838. export interface IEffectCreationOptions {
  123839. /**
  123840. * Atrributes that will be used in the shader.
  123841. */
  123842. attributes: string[];
  123843. /**
  123844. * Uniform varible names that will be set in the shader.
  123845. */
  123846. uniformsNames: string[];
  123847. /**
  123848. * Uniform buffer variable names that will be set in the shader.
  123849. */
  123850. uniformBuffersNames: string[];
  123851. /**
  123852. * Sampler texture variable names that will be set in the shader.
  123853. */
  123854. samplers: string[];
  123855. /**
  123856. * Define statements that will be set in the shader.
  123857. */
  123858. defines: any;
  123859. /**
  123860. * Possible fallbacks for this effect to improve performance when needed.
  123861. */
  123862. fallbacks: Nullable<IEffectFallbacks>;
  123863. /**
  123864. * Callback that will be called when the shader is compiled.
  123865. */
  123866. onCompiled: Nullable<(effect: Effect) => void>;
  123867. /**
  123868. * Callback that will be called if an error occurs during shader compilation.
  123869. */
  123870. onError: Nullable<(effect: Effect, errors: string) => void>;
  123871. /**
  123872. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  123873. */
  123874. indexParameters?: any;
  123875. /**
  123876. * Max number of lights that can be used in the shader.
  123877. */
  123878. maxSimultaneousLights?: number;
  123879. /**
  123880. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  123881. */
  123882. transformFeedbackVaryings?: Nullable<string[]>;
  123883. /**
  123884. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  123885. */
  123886. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  123887. /**
  123888. * Is this effect rendering to several color attachments ?
  123889. */
  123890. multiTarget?: boolean;
  123891. }
  123892. /**
  123893. * Effect containing vertex and fragment shader that can be executed on an object.
  123894. */
  123895. export class Effect implements IDisposable {
  123896. /**
  123897. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  123898. */
  123899. static ShadersRepository: string;
  123900. /**
  123901. * Enable logging of the shader code when a compilation error occurs
  123902. */
  123903. static LogShaderCodeOnCompilationError: boolean;
  123904. /**
  123905. * Name of the effect.
  123906. */
  123907. name: any;
  123908. /**
  123909. * String container all the define statements that should be set on the shader.
  123910. */
  123911. defines: string;
  123912. /**
  123913. * Callback that will be called when the shader is compiled.
  123914. */
  123915. onCompiled: Nullable<(effect: Effect) => void>;
  123916. /**
  123917. * Callback that will be called if an error occurs during shader compilation.
  123918. */
  123919. onError: Nullable<(effect: Effect, errors: string) => void>;
  123920. /**
  123921. * Callback that will be called when effect is bound.
  123922. */
  123923. onBind: Nullable<(effect: Effect) => void>;
  123924. /**
  123925. * Unique ID of the effect.
  123926. */
  123927. uniqueId: number;
  123928. /**
  123929. * Observable that will be called when the shader is compiled.
  123930. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  123931. */
  123932. onCompileObservable: Observable<Effect>;
  123933. /**
  123934. * Observable that will be called if an error occurs during shader compilation.
  123935. */
  123936. onErrorObservable: Observable<Effect>;
  123937. /** @hidden */
  123938. _onBindObservable: Nullable<Observable<Effect>>;
  123939. /**
  123940. * @hidden
  123941. * Specifies if the effect was previously ready
  123942. */
  123943. _wasPreviouslyReady: boolean;
  123944. /**
  123945. * Observable that will be called when effect is bound.
  123946. */
  123947. get onBindObservable(): Observable<Effect>;
  123948. /** @hidden */
  123949. _bonesComputationForcedToCPU: boolean;
  123950. /** @hidden */
  123951. _uniformBuffersNames: {
  123952. [key: string]: number;
  123953. };
  123954. /** @hidden */
  123955. _samplerList: string[];
  123956. /** @hidden */
  123957. _multiTarget: boolean;
  123958. private static _uniqueIdSeed;
  123959. private _engine;
  123960. private _uniformBuffersNamesList;
  123961. private _uniformsNames;
  123962. private _samplers;
  123963. private _isReady;
  123964. private _compilationError;
  123965. private _allFallbacksProcessed;
  123966. private _attributesNames;
  123967. private _attributes;
  123968. private _attributeLocationByName;
  123969. private _uniforms;
  123970. /**
  123971. * Key for the effect.
  123972. * @hidden
  123973. */
  123974. _key: string;
  123975. private _indexParameters;
  123976. private _fallbacks;
  123977. private _vertexSourceCodeOverride;
  123978. private _fragmentSourceCodeOverride;
  123979. private _transformFeedbackVaryings;
  123980. /**
  123981. * Compiled shader to webGL program.
  123982. * @hidden
  123983. */
  123984. _pipelineContext: Nullable<IPipelineContext>;
  123985. /** @hidden */
  123986. _vertexSourceCode: string;
  123987. /** @hidden */
  123988. _fragmentSourceCode: string;
  123989. /** @hidden */
  123990. private _rawVertexSourceCode;
  123991. /** @hidden */
  123992. private _rawFragmentSourceCode;
  123993. private static _baseCache;
  123994. private _processingContext;
  123995. /**
  123996. * Instantiates an effect.
  123997. * An effect can be used to create/manage/execute vertex and fragment shaders.
  123998. * @param baseName Name of the effect.
  123999. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  124000. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  124001. * @param samplers List of sampler variables that will be passed to the shader.
  124002. * @param engine Engine to be used to render the effect
  124003. * @param defines Define statements to be added to the shader.
  124004. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  124005. * @param onCompiled Callback that will be called when the shader is compiled.
  124006. * @param onError Callback that will be called if an error occurs during shader compilation.
  124007. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  124008. * @param key Effect Key identifying uniquely compiled shader variants
  124009. */
  124010. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, key?: string);
  124011. private _useFinalCode;
  124012. /**
  124013. * Unique key for this effect
  124014. */
  124015. get key(): string;
  124016. /**
  124017. * If the effect has been compiled and prepared.
  124018. * @returns if the effect is compiled and prepared.
  124019. */
  124020. isReady(): boolean;
  124021. private _isReadyInternal;
  124022. /**
  124023. * The engine the effect was initialized with.
  124024. * @returns the engine.
  124025. */
  124026. getEngine(): Engine;
  124027. /**
  124028. * The pipeline context for this effect
  124029. * @returns the associated pipeline context
  124030. */
  124031. getPipelineContext(): Nullable<IPipelineContext>;
  124032. /**
  124033. * The set of names of attribute variables for the shader.
  124034. * @returns An array of attribute names.
  124035. */
  124036. getAttributesNames(): string[];
  124037. /**
  124038. * Returns the attribute at the given index.
  124039. * @param index The index of the attribute.
  124040. * @returns The location of the attribute.
  124041. */
  124042. getAttributeLocation(index: number): number;
  124043. /**
  124044. * Returns the attribute based on the name of the variable.
  124045. * @param name of the attribute to look up.
  124046. * @returns the attribute location.
  124047. */
  124048. getAttributeLocationByName(name: string): number;
  124049. /**
  124050. * The number of attributes.
  124051. * @returns the numnber of attributes.
  124052. */
  124053. getAttributesCount(): number;
  124054. /**
  124055. * Gets the index of a uniform variable.
  124056. * @param uniformName of the uniform to look up.
  124057. * @returns the index.
  124058. */
  124059. getUniformIndex(uniformName: string): number;
  124060. /**
  124061. * Returns the attribute based on the name of the variable.
  124062. * @param uniformName of the uniform to look up.
  124063. * @returns the location of the uniform.
  124064. */
  124065. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  124066. /**
  124067. * Returns an array of sampler variable names
  124068. * @returns The array of sampler variable names.
  124069. */
  124070. getSamplers(): string[];
  124071. /**
  124072. * Returns an array of uniform variable names
  124073. * @returns The array of uniform variable names.
  124074. */
  124075. getUniformNames(): string[];
  124076. /**
  124077. * Returns an array of uniform buffer variable names
  124078. * @returns The array of uniform buffer variable names.
  124079. */
  124080. getUniformBuffersNames(): string[];
  124081. /**
  124082. * Returns the index parameters used to create the effect
  124083. * @returns The index parameters object
  124084. */
  124085. getIndexParameters(): any;
  124086. /**
  124087. * The error from the last compilation.
  124088. * @returns the error string.
  124089. */
  124090. getCompilationError(): string;
  124091. /**
  124092. * Gets a boolean indicating that all fallbacks were used during compilation
  124093. * @returns true if all fallbacks were used
  124094. */
  124095. allFallbacksProcessed(): boolean;
  124096. /**
  124097. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  124098. * @param func The callback to be used.
  124099. */
  124100. executeWhenCompiled(func: (effect: Effect) => void): void;
  124101. private _checkIsReady;
  124102. private _loadShader;
  124103. /**
  124104. * Gets the vertex shader source code of this effect
  124105. */
  124106. get vertexSourceCode(): string;
  124107. /**
  124108. * Gets the fragment shader source code of this effect
  124109. */
  124110. get fragmentSourceCode(): string;
  124111. /**
  124112. * Gets the vertex shader source code before it has been processed by the preprocessor
  124113. */
  124114. get rawVertexSourceCode(): string;
  124115. /**
  124116. * Gets the fragment shader source code before it has been processed by the preprocessor
  124117. */
  124118. get rawFragmentSourceCode(): string;
  124119. /**
  124120. * Recompiles the webGL program
  124121. * @param vertexSourceCode The source code for the vertex shader.
  124122. * @param fragmentSourceCode The source code for the fragment shader.
  124123. * @param onCompiled Callback called when completed.
  124124. * @param onError Callback called on error.
  124125. * @hidden
  124126. */
  124127. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  124128. /**
  124129. * Prepares the effect
  124130. * @hidden
  124131. */
  124132. _prepareEffect(): void;
  124133. private _getShaderCodeAndErrorLine;
  124134. private _processCompilationErrors;
  124135. /**
  124136. * Checks if the effect is supported. (Must be called after compilation)
  124137. */
  124138. get isSupported(): boolean;
  124139. /**
  124140. * Binds a texture to the engine to be used as output of the shader.
  124141. * @param channel Name of the output variable.
  124142. * @param texture Texture to bind.
  124143. * @hidden
  124144. */
  124145. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  124146. /**
  124147. * Sets a texture on the engine to be used in the shader.
  124148. * @param channel Name of the sampler variable.
  124149. * @param texture Texture to set.
  124150. */
  124151. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  124152. /**
  124153. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  124154. * @param channel Name of the sampler variable.
  124155. * @param texture Texture to set.
  124156. */
  124157. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  124158. /**
  124159. * Sets an array of textures on the engine to be used in the shader.
  124160. * @param channel Name of the variable.
  124161. * @param textures Textures to set.
  124162. */
  124163. setTextureArray(channel: string, textures: ThinTexture[]): void;
  124164. /**
  124165. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  124166. * @param channel Name of the sampler variable.
  124167. * @param postProcess Post process to get the input texture from.
  124168. */
  124169. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  124170. /**
  124171. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  124172. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  124173. * @param channel Name of the sampler variable.
  124174. * @param postProcess Post process to get the output texture from.
  124175. */
  124176. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  124177. /**
  124178. * Binds a buffer to a uniform.
  124179. * @param buffer Buffer to bind.
  124180. * @param name Name of the uniform variable to bind to.
  124181. */
  124182. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  124183. /**
  124184. * Binds block to a uniform.
  124185. * @param blockName Name of the block to bind.
  124186. * @param index Index to bind.
  124187. */
  124188. bindUniformBlock(blockName: string, index: number): void;
  124189. /**
  124190. * Sets an interger value on a uniform variable.
  124191. * @param uniformName Name of the variable.
  124192. * @param value Value to be set.
  124193. * @returns this effect.
  124194. */
  124195. setInt(uniformName: string, value: number): Effect;
  124196. /**
  124197. * Sets an int2 value on a uniform variable.
  124198. * @param uniformName Name of the variable.
  124199. * @param x First int in int2.
  124200. * @param y Second int in int2.
  124201. * @returns this effect.
  124202. */
  124203. setInt2(uniformName: string, x: number, y: number): Effect;
  124204. /**
  124205. * Sets an int3 value on a uniform variable.
  124206. * @param uniformName Name of the variable.
  124207. * @param x First int in int3.
  124208. * @param y Second int in int3.
  124209. * @param z Third int in int3.
  124210. * @returns this effect.
  124211. */
  124212. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  124213. /**
  124214. * Sets an int4 value on a uniform variable.
  124215. * @param uniformName Name of the variable.
  124216. * @param x First int in int4.
  124217. * @param y Second int in int4.
  124218. * @param z Third int in int4.
  124219. * @param w Fourth int in int4.
  124220. * @returns this effect.
  124221. */
  124222. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  124223. /**
  124224. * Sets an int array on a uniform variable.
  124225. * @param uniformName Name of the variable.
  124226. * @param array array to be set.
  124227. * @returns this effect.
  124228. */
  124229. setIntArray(uniformName: string, array: Int32Array): Effect;
  124230. /**
  124231. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  124232. * @param uniformName Name of the variable.
  124233. * @param array array to be set.
  124234. * @returns this effect.
  124235. */
  124236. setIntArray2(uniformName: string, array: Int32Array): Effect;
  124237. /**
  124238. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  124239. * @param uniformName Name of the variable.
  124240. * @param array array to be set.
  124241. * @returns this effect.
  124242. */
  124243. setIntArray3(uniformName: string, array: Int32Array): Effect;
  124244. /**
  124245. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  124246. * @param uniformName Name of the variable.
  124247. * @param array array to be set.
  124248. * @returns this effect.
  124249. */
  124250. setIntArray4(uniformName: string, array: Int32Array): Effect;
  124251. /**
  124252. * Sets an float array on a uniform variable.
  124253. * @param uniformName Name of the variable.
  124254. * @param array array to be set.
  124255. * @returns this effect.
  124256. */
  124257. setFloatArray(uniformName: string, array: FloatArray): Effect;
  124258. /**
  124259. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  124260. * @param uniformName Name of the variable.
  124261. * @param array array to be set.
  124262. * @returns this effect.
  124263. */
  124264. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  124265. /**
  124266. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  124267. * @param uniformName Name of the variable.
  124268. * @param array array to be set.
  124269. * @returns this effect.
  124270. */
  124271. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  124272. /**
  124273. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  124274. * @param uniformName Name of the variable.
  124275. * @param array array to be set.
  124276. * @returns this effect.
  124277. */
  124278. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  124279. /**
  124280. * Sets an array on a uniform variable.
  124281. * @param uniformName Name of the variable.
  124282. * @param array array to be set.
  124283. * @returns this effect.
  124284. */
  124285. setArray(uniformName: string, array: number[]): Effect;
  124286. /**
  124287. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  124288. * @param uniformName Name of the variable.
  124289. * @param array array to be set.
  124290. * @returns this effect.
  124291. */
  124292. setArray2(uniformName: string, array: number[]): Effect;
  124293. /**
  124294. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  124295. * @param uniformName Name of the variable.
  124296. * @param array array to be set.
  124297. * @returns this effect.
  124298. */
  124299. setArray3(uniformName: string, array: number[]): Effect;
  124300. /**
  124301. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  124302. * @param uniformName Name of the variable.
  124303. * @param array array to be set.
  124304. * @returns this effect.
  124305. */
  124306. setArray4(uniformName: string, array: number[]): Effect;
  124307. /**
  124308. * Sets matrices on a uniform variable.
  124309. * @param uniformName Name of the variable.
  124310. * @param matrices matrices to be set.
  124311. * @returns this effect.
  124312. */
  124313. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  124314. /**
  124315. * Sets matrix on a uniform variable.
  124316. * @param uniformName Name of the variable.
  124317. * @param matrix matrix to be set.
  124318. * @returns this effect.
  124319. */
  124320. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  124321. /**
  124322. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  124323. * @param uniformName Name of the variable.
  124324. * @param matrix matrix to be set.
  124325. * @returns this effect.
  124326. */
  124327. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  124328. /**
  124329. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  124330. * @param uniformName Name of the variable.
  124331. * @param matrix matrix to be set.
  124332. * @returns this effect.
  124333. */
  124334. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  124335. /**
  124336. * Sets a float on a uniform variable.
  124337. * @param uniformName Name of the variable.
  124338. * @param value value to be set.
  124339. * @returns this effect.
  124340. */
  124341. setFloat(uniformName: string, value: number): Effect;
  124342. /**
  124343. * Sets a boolean on a uniform variable.
  124344. * @param uniformName Name of the variable.
  124345. * @param bool value to be set.
  124346. * @returns this effect.
  124347. */
  124348. setBool(uniformName: string, bool: boolean): Effect;
  124349. /**
  124350. * Sets a Vector2 on a uniform variable.
  124351. * @param uniformName Name of the variable.
  124352. * @param vector2 vector2 to be set.
  124353. * @returns this effect.
  124354. */
  124355. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  124356. /**
  124357. * Sets a float2 on a uniform variable.
  124358. * @param uniformName Name of the variable.
  124359. * @param x First float in float2.
  124360. * @param y Second float in float2.
  124361. * @returns this effect.
  124362. */
  124363. setFloat2(uniformName: string, x: number, y: number): Effect;
  124364. /**
  124365. * Sets a Vector3 on a uniform variable.
  124366. * @param uniformName Name of the variable.
  124367. * @param vector3 Value to be set.
  124368. * @returns this effect.
  124369. */
  124370. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  124371. /**
  124372. * Sets a float3 on a uniform variable.
  124373. * @param uniformName Name of the variable.
  124374. * @param x First float in float3.
  124375. * @param y Second float in float3.
  124376. * @param z Third float in float3.
  124377. * @returns this effect.
  124378. */
  124379. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  124380. /**
  124381. * Sets a Vector4 on a uniform variable.
  124382. * @param uniformName Name of the variable.
  124383. * @param vector4 Value to be set.
  124384. * @returns this effect.
  124385. */
  124386. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  124387. /**
  124388. * Sets a float4 on a uniform variable.
  124389. * @param uniformName Name of the variable.
  124390. * @param x First float in float4.
  124391. * @param y Second float in float4.
  124392. * @param z Third float in float4.
  124393. * @param w Fourth float in float4.
  124394. * @returns this effect.
  124395. */
  124396. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  124397. /**
  124398. * Sets a Color3 on a uniform variable.
  124399. * @param uniformName Name of the variable.
  124400. * @param color3 Value to be set.
  124401. * @returns this effect.
  124402. */
  124403. setColor3(uniformName: string, color3: IColor3Like): Effect;
  124404. /**
  124405. * Sets a Color4 on a uniform variable.
  124406. * @param uniformName Name of the variable.
  124407. * @param color3 Value to be set.
  124408. * @param alpha Alpha value to be set.
  124409. * @returns this effect.
  124410. */
  124411. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  124412. /**
  124413. * Sets a Color4 on a uniform variable
  124414. * @param uniformName defines the name of the variable
  124415. * @param color4 defines the value to be set
  124416. * @returns this effect.
  124417. */
  124418. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  124419. /**
  124420. * Release all associated resources.
  124421. **/
  124422. dispose(): void;
  124423. /**
  124424. * This function will add a new shader to the shader store
  124425. * @param name the name of the shader
  124426. * @param pixelShader optional pixel shader content
  124427. * @param vertexShader optional vertex shader content
  124428. */
  124429. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  124430. /**
  124431. * Store of each shader (The can be looked up using effect.key)
  124432. */
  124433. static ShadersStore: {
  124434. [key: string]: string;
  124435. };
  124436. /**
  124437. * Store of each included file for a shader (The can be looked up using effect.key)
  124438. */
  124439. static IncludesShadersStore: {
  124440. [key: string]: string;
  124441. };
  124442. /**
  124443. * Resets the cache of effects.
  124444. */
  124445. static ResetCache(): void;
  124446. }
  124447. }
  124448. declare module BABYLON {
  124449. /**
  124450. * Interface used to describe the capabilities of the engine relatively to the current browser
  124451. */
  124452. export interface EngineCapabilities {
  124453. /** Maximum textures units per fragment shader */
  124454. maxTexturesImageUnits: number;
  124455. /** Maximum texture units per vertex shader */
  124456. maxVertexTextureImageUnits: number;
  124457. /** Maximum textures units in the entire pipeline */
  124458. maxCombinedTexturesImageUnits: number;
  124459. /** Maximum texture size */
  124460. maxTextureSize: number;
  124461. /** Maximum texture samples */
  124462. maxSamples?: number;
  124463. /** Maximum cube texture size */
  124464. maxCubemapTextureSize: number;
  124465. /** Maximum render texture size */
  124466. maxRenderTextureSize: number;
  124467. /** Maximum number of vertex attributes */
  124468. maxVertexAttribs: number;
  124469. /** Maximum number of varyings */
  124470. maxVaryingVectors: number;
  124471. /** Maximum number of uniforms per vertex shader */
  124472. maxVertexUniformVectors: number;
  124473. /** Maximum number of uniforms per fragment shader */
  124474. maxFragmentUniformVectors: number;
  124475. /** Defines if standard derivates (dx/dy) are supported */
  124476. standardDerivatives: boolean;
  124477. /** Defines if s3tc texture compression is supported */
  124478. s3tc?: WEBGL_compressed_texture_s3tc;
  124479. /** Defines if pvrtc texture compression is supported */
  124480. pvrtc: any;
  124481. /** Defines if etc1 texture compression is supported */
  124482. etc1: any;
  124483. /** Defines if etc2 texture compression is supported */
  124484. etc2: any;
  124485. /** Defines if astc texture compression is supported */
  124486. astc: any;
  124487. /** Defines if bptc texture compression is supported */
  124488. bptc: any;
  124489. /** Defines if float textures are supported */
  124490. textureFloat: boolean;
  124491. /** Defines if vertex array objects are supported */
  124492. vertexArrayObject: boolean;
  124493. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  124494. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  124495. /** Gets the maximum level of anisotropy supported */
  124496. maxAnisotropy: number;
  124497. /** Defines if instancing is supported */
  124498. instancedArrays: boolean;
  124499. /** Defines if 32 bits indices are supported */
  124500. uintIndices: boolean;
  124501. /** Defines if high precision shaders are supported */
  124502. highPrecisionShaderSupported: boolean;
  124503. /** Defines if depth reading in the fragment shader is supported */
  124504. fragmentDepthSupported: boolean;
  124505. /** Defines if float texture linear filtering is supported*/
  124506. textureFloatLinearFiltering: boolean;
  124507. /** Defines if rendering to float textures is supported */
  124508. textureFloatRender: boolean;
  124509. /** Defines if half float textures are supported*/
  124510. textureHalfFloat: boolean;
  124511. /** Defines if half float texture linear filtering is supported*/
  124512. textureHalfFloatLinearFiltering: boolean;
  124513. /** Defines if rendering to half float textures is supported */
  124514. textureHalfFloatRender: boolean;
  124515. /** Defines if textureLOD shader command is supported */
  124516. textureLOD: boolean;
  124517. /** Defines if draw buffers extension is supported */
  124518. drawBuffersExtension: boolean;
  124519. /** Defines if depth textures are supported */
  124520. depthTextureExtension: boolean;
  124521. /** Defines if float color buffer are supported */
  124522. colorBufferFloat: boolean;
  124523. /** Gets disjoint timer query extension (null if not supported) */
  124524. timerQuery?: EXT_disjoint_timer_query;
  124525. /** Defines if timestamp can be used with timer query */
  124526. canUseTimestampForTimerQuery: boolean;
  124527. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  124528. multiview?: any;
  124529. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  124530. oculusMultiview?: any;
  124531. /** Function used to let the system compiles shaders in background */
  124532. parallelShaderCompile?: {
  124533. COMPLETION_STATUS_KHR: number;
  124534. };
  124535. /** Max number of texture samples for MSAA */
  124536. maxMSAASamples: number;
  124537. /** Defines if the blend min max extension is supported */
  124538. blendMinMax: boolean;
  124539. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  124540. canUseGLInstanceID: boolean;
  124541. }
  124542. }
  124543. declare module BABYLON {
  124544. /**
  124545. * @hidden
  124546. **/
  124547. export class DepthCullingState {
  124548. private _isDepthTestDirty;
  124549. private _isDepthMaskDirty;
  124550. private _isDepthFuncDirty;
  124551. private _isCullFaceDirty;
  124552. private _isCullDirty;
  124553. private _isZOffsetDirty;
  124554. private _isFrontFaceDirty;
  124555. private _depthTest;
  124556. private _depthMask;
  124557. private _depthFunc;
  124558. private _cull;
  124559. private _cullFace;
  124560. private _zOffset;
  124561. private _frontFace;
  124562. /**
  124563. * Initializes the state.
  124564. */
  124565. constructor();
  124566. get isDirty(): boolean;
  124567. get zOffset(): number;
  124568. set zOffset(value: number);
  124569. get cullFace(): Nullable<number>;
  124570. set cullFace(value: Nullable<number>);
  124571. get cull(): Nullable<boolean>;
  124572. set cull(value: Nullable<boolean>);
  124573. get depthFunc(): Nullable<number>;
  124574. set depthFunc(value: Nullable<number>);
  124575. get depthMask(): boolean;
  124576. set depthMask(value: boolean);
  124577. get depthTest(): boolean;
  124578. set depthTest(value: boolean);
  124579. get frontFace(): Nullable<number>;
  124580. set frontFace(value: Nullable<number>);
  124581. reset(): void;
  124582. apply(gl: WebGLRenderingContext): void;
  124583. }
  124584. }
  124585. declare module BABYLON {
  124586. /**
  124587. * @hidden
  124588. **/
  124589. export class StencilState {
  124590. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  124591. static readonly ALWAYS: number;
  124592. /** Passed to stencilOperation to specify that stencil value must be kept */
  124593. static readonly KEEP: number;
  124594. /** Passed to stencilOperation to specify that stencil value must be replaced */
  124595. static readonly REPLACE: number;
  124596. private _isStencilTestDirty;
  124597. private _isStencilMaskDirty;
  124598. private _isStencilFuncDirty;
  124599. private _isStencilOpDirty;
  124600. private _stencilTest;
  124601. private _stencilMask;
  124602. private _stencilFunc;
  124603. private _stencilFuncRef;
  124604. private _stencilFuncMask;
  124605. private _stencilOpStencilFail;
  124606. private _stencilOpDepthFail;
  124607. private _stencilOpStencilDepthPass;
  124608. get isDirty(): boolean;
  124609. get stencilFunc(): number;
  124610. set stencilFunc(value: number);
  124611. get stencilFuncRef(): number;
  124612. set stencilFuncRef(value: number);
  124613. get stencilFuncMask(): number;
  124614. set stencilFuncMask(value: number);
  124615. get stencilOpStencilFail(): number;
  124616. set stencilOpStencilFail(value: number);
  124617. get stencilOpDepthFail(): number;
  124618. set stencilOpDepthFail(value: number);
  124619. get stencilOpStencilDepthPass(): number;
  124620. set stencilOpStencilDepthPass(value: number);
  124621. get stencilMask(): number;
  124622. set stencilMask(value: number);
  124623. get stencilTest(): boolean;
  124624. set stencilTest(value: boolean);
  124625. constructor();
  124626. reset(): void;
  124627. apply(gl: WebGLRenderingContext): void;
  124628. }
  124629. }
  124630. declare module BABYLON {
  124631. /**
  124632. * @hidden
  124633. **/
  124634. export class AlphaState {
  124635. _blendFunctionParameters: Nullable<number>[];
  124636. _blendEquationParameters: Nullable<number>[];
  124637. _blendConstants: Nullable<number>[];
  124638. _isBlendConstantsDirty: boolean;
  124639. private _alphaBlend;
  124640. private _isAlphaBlendDirty;
  124641. private _isBlendFunctionParametersDirty;
  124642. private _isBlendEquationParametersDirty;
  124643. /**
  124644. * Initializes the state.
  124645. */
  124646. constructor();
  124647. get isDirty(): boolean;
  124648. get alphaBlend(): boolean;
  124649. set alphaBlend(value: boolean);
  124650. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  124651. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  124652. setAlphaEquationParameters(rgb: number, alpha: number): void;
  124653. reset(): void;
  124654. apply(gl: WebGLRenderingContext): void;
  124655. }
  124656. }
  124657. declare module BABYLON {
  124658. /** @hidden */
  124659. export class WebGLShaderProcessor implements IShaderProcessor {
  124660. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124661. }
  124662. }
  124663. declare module BABYLON {
  124664. /** @hidden */
  124665. export class WebGL2ShaderProcessor implements IShaderProcessor {
  124666. attributeProcessor(attribute: string): string;
  124667. varyingProcessor(varying: string, isFragment: boolean): string;
  124668. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124669. }
  124670. }
  124671. declare module BABYLON {
  124672. /**
  124673. * Interface for attribute information associated with buffer instanciation
  124674. */
  124675. export interface InstancingAttributeInfo {
  124676. /**
  124677. * Name of the GLSL attribute
  124678. * if attribute index is not specified, this is used to retrieve the index from the effect
  124679. */
  124680. attributeName: string;
  124681. /**
  124682. * Index/offset of the attribute in the vertex shader
  124683. * if not specified, this will be computes from the name.
  124684. */
  124685. index?: number;
  124686. /**
  124687. * size of the attribute, 1, 2, 3 or 4
  124688. */
  124689. attributeSize: number;
  124690. /**
  124691. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  124692. */
  124693. offset: number;
  124694. /**
  124695. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  124696. * default to 1
  124697. */
  124698. divisor?: number;
  124699. /**
  124700. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  124701. * default is FLOAT
  124702. */
  124703. attributeType?: number;
  124704. /**
  124705. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  124706. */
  124707. normalized?: boolean;
  124708. }
  124709. }
  124710. declare module BABYLON {
  124711. /** @hidden */
  124712. export interface EngineFeatures {
  124713. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  124714. forceBitmapOverHTMLImageElement: boolean;
  124715. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  124716. supportRenderAndCopyToLodForFloatTextures: boolean;
  124717. /** Indicates that the engine support handling depth/stencil textures */
  124718. supportDepthStencilTexture: boolean;
  124719. /** Indicates that the engine support shadow samplers */
  124720. supportShadowSamplers: boolean;
  124721. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  124722. uniformBufferHardCheckMatrix: boolean;
  124723. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  124724. allowTexturePrefiltering: boolean;
  124725. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  124726. trackUbosInFrame: boolean;
  124727. /** Indicates that the Cascaded Shadow Map technic is supported */
  124728. supportCSM: boolean;
  124729. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  124730. basisNeedsPOT: boolean;
  124731. /** Indicates that the engine supports 3D textures */
  124732. support3DTextures: boolean;
  124733. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  124734. needTypeSuffixInShaderConstants: boolean;
  124735. /** Indicates that MSAA is supported */
  124736. supportMSAA: boolean;
  124737. /** Indicates that SSAO2 is supported */
  124738. supportSSAO2: boolean;
  124739. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  124740. supportExtendedTextureFormats: boolean;
  124741. /** Indicates that the switch/case construct is supported in shaders */
  124742. supportSwitchCaseInShader: boolean;
  124743. /** Indicates that synchronous texture reading is supported */
  124744. supportSyncTextureRead: boolean;
  124745. /** @hidden */
  124746. _collectUbosUpdatedInFrame: boolean;
  124747. }
  124748. }
  124749. declare module BABYLON {
  124750. /** @hidden */
  124751. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  124752. private _webGLTexture;
  124753. private _context;
  124754. get underlyingResource(): Nullable<WebGLTexture>;
  124755. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  124756. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  124757. set(hardwareTexture: WebGLTexture): void;
  124758. reset(): void;
  124759. release(): void;
  124760. }
  124761. }
  124762. declare module BABYLON {
  124763. interface ThinEngine {
  124764. /**
  124765. * Update a video texture
  124766. * @param texture defines the texture to update
  124767. * @param video defines the video element to use
  124768. * @param invertY defines if data must be stored with Y axis inverted
  124769. */
  124770. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  124771. }
  124772. }
  124773. declare module BABYLON {
  124774. interface ThinEngine {
  124775. /**
  124776. * Creates a dynamic texture
  124777. * @param width defines the width of the texture
  124778. * @param height defines the height of the texture
  124779. * @param generateMipMaps defines if the engine should generate the mip levels
  124780. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  124781. * @returns the dynamic texture inside an InternalTexture
  124782. */
  124783. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  124784. /**
  124785. * Update the content of a dynamic texture
  124786. * @param texture defines the texture to update
  124787. * @param source defines the source containing the data
  124788. * @param invertY defines if data must be stored with Y axis inverted
  124789. * @param premulAlpha defines if alpha is stored as premultiplied
  124790. * @param format defines the format of the data
  124791. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  124792. */
  124793. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  124794. }
  124795. }
  124796. declare module BABYLON {
  124797. /**
  124798. * Settings for finer control over video usage
  124799. */
  124800. export interface VideoTextureSettings {
  124801. /**
  124802. * Applies `autoplay` to video, if specified
  124803. */
  124804. autoPlay?: boolean;
  124805. /**
  124806. * Applies `muted` to video, if specified
  124807. */
  124808. muted?: boolean;
  124809. /**
  124810. * Applies `loop` to video, if specified
  124811. */
  124812. loop?: boolean;
  124813. /**
  124814. * Automatically updates internal texture from video at every frame in the render loop
  124815. */
  124816. autoUpdateTexture: boolean;
  124817. /**
  124818. * Image src displayed during the video loading or until the user interacts with the video.
  124819. */
  124820. poster?: string;
  124821. }
  124822. /**
  124823. * If you want to display a video in your scene, this is the special texture for that.
  124824. * This special texture works similar to other textures, with the exception of a few parameters.
  124825. * @see https://doc.babylonjs.com/how_to/video_texture
  124826. */
  124827. export class VideoTexture extends Texture {
  124828. /**
  124829. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  124830. */
  124831. readonly autoUpdateTexture: boolean;
  124832. /**
  124833. * The video instance used by the texture internally
  124834. */
  124835. readonly video: HTMLVideoElement;
  124836. private _onUserActionRequestedObservable;
  124837. /**
  124838. * Event triggerd when a dom action is required by the user to play the video.
  124839. * This happens due to recent changes in browser policies preventing video to auto start.
  124840. */
  124841. get onUserActionRequestedObservable(): Observable<Texture>;
  124842. private _generateMipMaps;
  124843. private _stillImageCaptured;
  124844. private _displayingPosterTexture;
  124845. private _settings;
  124846. private _createInternalTextureOnEvent;
  124847. private _frameId;
  124848. private _currentSrc;
  124849. /**
  124850. * Creates a video texture.
  124851. * If you want to display a video in your scene, this is the special texture for that.
  124852. * This special texture works similar to other textures, with the exception of a few parameters.
  124853. * @see https://doc.babylonjs.com/how_to/video_texture
  124854. * @param name optional name, will detect from video source, if not defined
  124855. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  124856. * @param scene is obviously the current scene.
  124857. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  124858. * @param invertY is false by default but can be used to invert video on Y axis
  124859. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  124860. * @param settings allows finer control over video usage
  124861. */
  124862. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  124863. private _getName;
  124864. private _getVideo;
  124865. private _createInternalTexture;
  124866. private reset;
  124867. /**
  124868. * @hidden Internal method to initiate `update`.
  124869. */
  124870. _rebuild(): void;
  124871. /**
  124872. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  124873. */
  124874. update(): void;
  124875. /**
  124876. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  124877. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  124878. */
  124879. updateTexture(isVisible: boolean): void;
  124880. protected _updateInternalTexture: () => void;
  124881. /**
  124882. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  124883. * @param url New url.
  124884. */
  124885. updateURL(url: string): void;
  124886. /**
  124887. * Clones the texture.
  124888. * @returns the cloned texture
  124889. */
  124890. clone(): VideoTexture;
  124891. /**
  124892. * Dispose the texture and release its associated resources.
  124893. */
  124894. dispose(): void;
  124895. /**
  124896. * Creates a video texture straight from a stream.
  124897. * @param scene Define the scene the texture should be created in
  124898. * @param stream Define the stream the texture should be created from
  124899. * @returns The created video texture as a promise
  124900. */
  124901. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  124902. /**
  124903. * Creates a video texture straight from your WebCam video feed.
  124904. * @param scene Define the scene the texture should be created in
  124905. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124906. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124907. * @returns The created video texture as a promise
  124908. */
  124909. static CreateFromWebCamAsync(scene: Scene, constraints: {
  124910. minWidth: number;
  124911. maxWidth: number;
  124912. minHeight: number;
  124913. maxHeight: number;
  124914. deviceId: string;
  124915. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  124916. /**
  124917. * Creates a video texture straight from your WebCam video feed.
  124918. * @param scene Define the scene the texture should be created in
  124919. * @param onReady Define a callback to triggered once the texture will be ready
  124920. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124921. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124922. */
  124923. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  124924. minWidth: number;
  124925. maxWidth: number;
  124926. minHeight: number;
  124927. maxHeight: number;
  124928. deviceId: string;
  124929. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  124930. }
  124931. }
  124932. declare module BABYLON {
  124933. /**
  124934. * Defines the interface used by objects working like Scene
  124935. * @hidden
  124936. */
  124937. export interface ISceneLike {
  124938. _addPendingData(data: any): void;
  124939. _removePendingData(data: any): void;
  124940. offlineProvider: IOfflineProvider;
  124941. }
  124942. /**
  124943. * Information about the current host
  124944. */
  124945. export interface HostInformation {
  124946. /**
  124947. * Defines if the current host is a mobile
  124948. */
  124949. isMobile: boolean;
  124950. }
  124951. /** Interface defining initialization parameters for Engine class */
  124952. export interface EngineOptions extends WebGLContextAttributes {
  124953. /**
  124954. * Defines if the engine should no exceed a specified device ratio
  124955. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  124956. */
  124957. limitDeviceRatio?: number;
  124958. /**
  124959. * Defines if webvr should be enabled automatically
  124960. * @see https://doc.babylonjs.com/how_to/webvr_camera
  124961. */
  124962. autoEnableWebVR?: boolean;
  124963. /**
  124964. * Defines if webgl2 should be turned off even if supported
  124965. * @see https://doc.babylonjs.com/features/webgl2
  124966. */
  124967. disableWebGL2Support?: boolean;
  124968. /**
  124969. * Defines if webaudio should be initialized as well
  124970. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  124971. */
  124972. audioEngine?: boolean;
  124973. /**
  124974. * Defines if animations should run using a deterministic lock step
  124975. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124976. */
  124977. deterministicLockstep?: boolean;
  124978. /** Defines the maximum steps to use with deterministic lock step mode */
  124979. lockstepMaxSteps?: number;
  124980. /** Defines the seconds between each deterministic lock step */
  124981. timeStep?: number;
  124982. /**
  124983. * Defines that engine should ignore context lost events
  124984. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  124985. */
  124986. doNotHandleContextLost?: boolean;
  124987. /**
  124988. * Defines that engine should ignore modifying touch action attribute and style
  124989. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  124990. */
  124991. doNotHandleTouchAction?: boolean;
  124992. /**
  124993. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  124994. */
  124995. useHighPrecisionFloats?: boolean;
  124996. /**
  124997. * Make the canvas XR Compatible for XR sessions
  124998. */
  124999. xrCompatible?: boolean;
  125000. /**
  125001. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  125002. */
  125003. useHighPrecisionMatrix?: boolean;
  125004. /**
  125005. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  125006. */
  125007. failIfMajorPerformanceCaveat?: boolean;
  125008. /**
  125009. * Defines whether to adapt to the device's viewport characteristics (default: false)
  125010. */
  125011. adaptToDeviceRatio?: boolean;
  125012. }
  125013. /**
  125014. * The base engine class (root of all engines)
  125015. */
  125016. export class ThinEngine {
  125017. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  125018. static ExceptionList: ({
  125019. key: string;
  125020. capture: string;
  125021. captureConstraint: number;
  125022. targets: string[];
  125023. } | {
  125024. key: string;
  125025. capture: null;
  125026. captureConstraint: null;
  125027. targets: string[];
  125028. })[];
  125029. /** @hidden */
  125030. static _TextureLoaders: IInternalTextureLoader[];
  125031. /**
  125032. * Returns the current npm package of the sdk
  125033. */
  125034. static get NpmPackage(): string;
  125035. /**
  125036. * Returns the current version of the framework
  125037. */
  125038. static get Version(): string;
  125039. /**
  125040. * Returns a string describing the current engine
  125041. */
  125042. get description(): string;
  125043. /**
  125044. * Returns the name of the engine
  125045. */
  125046. get name(): string;
  125047. /**
  125048. * Returns the version of the engine
  125049. */
  125050. get version(): number;
  125051. /**
  125052. * Gets or sets the epsilon value used by collision engine
  125053. */
  125054. static CollisionsEpsilon: number;
  125055. /**
  125056. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  125057. */
  125058. static get ShadersRepository(): string;
  125059. static set ShadersRepository(value: string);
  125060. /** @hidden */
  125061. _shaderProcessor: Nullable<IShaderProcessor>;
  125062. /**
  125063. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  125064. */
  125065. forcePOTTextures: boolean;
  125066. /**
  125067. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  125068. */
  125069. isFullscreen: boolean;
  125070. /**
  125071. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  125072. */
  125073. cullBackFaces: boolean;
  125074. /**
  125075. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  125076. */
  125077. renderEvenInBackground: boolean;
  125078. /**
  125079. * Gets or sets a boolean indicating that cache can be kept between frames
  125080. */
  125081. preventCacheWipeBetweenFrames: boolean;
  125082. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  125083. validateShaderPrograms: boolean;
  125084. /**
  125085. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  125086. * This can provide greater z depth for distant objects.
  125087. */
  125088. useReverseDepthBuffer: boolean;
  125089. /**
  125090. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  125091. */
  125092. disableUniformBuffers: boolean;
  125093. private _frameId;
  125094. /**
  125095. * Gets the current frame id
  125096. */
  125097. get frameId(): number;
  125098. /** @hidden */
  125099. _uniformBuffers: UniformBuffer[];
  125100. /**
  125101. * Gets a boolean indicating that the engine supports uniform buffers
  125102. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  125103. */
  125104. get supportsUniformBuffers(): boolean;
  125105. /** @hidden */
  125106. _gl: WebGLRenderingContext;
  125107. /** @hidden */
  125108. _webGLVersion: number;
  125109. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  125110. protected _windowIsBackground: boolean;
  125111. protected _creationOptions: EngineOptions;
  125112. protected _highPrecisionShadersAllowed: boolean;
  125113. /** @hidden */
  125114. get _shouldUseHighPrecisionShader(): boolean;
  125115. /**
  125116. * Gets a boolean indicating that only power of 2 textures are supported
  125117. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  125118. */
  125119. get needPOTTextures(): boolean;
  125120. /** @hidden */
  125121. _badOS: boolean;
  125122. /** @hidden */
  125123. _badDesktopOS: boolean;
  125124. protected _hardwareScalingLevel: number;
  125125. /** @hidden */
  125126. _caps: EngineCapabilities;
  125127. /** @hidden */
  125128. _features: EngineFeatures;
  125129. protected _isStencilEnable: boolean;
  125130. private _glVersion;
  125131. private _glRenderer;
  125132. private _glVendor;
  125133. /** @hidden */
  125134. _videoTextureSupported: boolean;
  125135. protected _renderingQueueLaunched: boolean;
  125136. protected _activeRenderLoops: (() => void)[];
  125137. /**
  125138. * Observable signaled when a context lost event is raised
  125139. */
  125140. onContextLostObservable: Observable<ThinEngine>;
  125141. /**
  125142. * Observable signaled when a context restored event is raised
  125143. */
  125144. onContextRestoredObservable: Observable<ThinEngine>;
  125145. private _onContextLost;
  125146. private _onContextRestored;
  125147. protected _contextWasLost: boolean;
  125148. /** @hidden */
  125149. _doNotHandleContextLost: boolean;
  125150. /**
  125151. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  125152. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  125153. */
  125154. get doNotHandleContextLost(): boolean;
  125155. set doNotHandleContextLost(value: boolean);
  125156. /**
  125157. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  125158. */
  125159. disableVertexArrayObjects: boolean;
  125160. /** @hidden */
  125161. protected _colorWrite: boolean;
  125162. /** @hidden */
  125163. protected _colorWriteChanged: boolean;
  125164. /** @hidden */
  125165. protected _depthCullingState: DepthCullingState;
  125166. /** @hidden */
  125167. protected _stencilState: StencilState;
  125168. /** @hidden */
  125169. _alphaState: AlphaState;
  125170. /** @hidden */
  125171. _alphaMode: number;
  125172. /** @hidden */
  125173. _alphaEquation: number;
  125174. /** @hidden */
  125175. _internalTexturesCache: InternalTexture[];
  125176. /** @hidden */
  125177. protected _activeChannel: number;
  125178. private _currentTextureChannel;
  125179. /** @hidden */
  125180. protected _boundTexturesCache: {
  125181. [key: string]: Nullable<InternalTexture>;
  125182. };
  125183. /** @hidden */
  125184. protected _currentEffect: Nullable<Effect>;
  125185. /** @hidden */
  125186. protected _currentProgram: Nullable<WebGLProgram>;
  125187. protected _compiledEffects: {
  125188. [key: string]: Effect;
  125189. };
  125190. private _vertexAttribArraysEnabled;
  125191. /** @hidden */
  125192. protected _cachedViewport: Nullable<IViewportLike>;
  125193. private _cachedVertexArrayObject;
  125194. /** @hidden */
  125195. protected _cachedVertexBuffers: any;
  125196. /** @hidden */
  125197. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  125198. /** @hidden */
  125199. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  125200. /** @hidden */
  125201. _currentRenderTarget: Nullable<InternalTexture>;
  125202. private _uintIndicesCurrentlySet;
  125203. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  125204. /** @hidden */
  125205. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  125206. /** @hidden */
  125207. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  125208. private _currentBufferPointers;
  125209. private _currentInstanceLocations;
  125210. private _currentInstanceBuffers;
  125211. private _textureUnits;
  125212. /** @hidden */
  125213. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  125214. /** @hidden */
  125215. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  125216. /** @hidden */
  125217. _boundRenderFunction: any;
  125218. private _vaoRecordInProgress;
  125219. private _mustWipeVertexAttributes;
  125220. private _emptyTexture;
  125221. private _emptyCubeTexture;
  125222. private _emptyTexture3D;
  125223. private _emptyTexture2DArray;
  125224. /** @hidden */
  125225. _frameHandler: number;
  125226. private _nextFreeTextureSlots;
  125227. private _maxSimultaneousTextures;
  125228. private _activeRequests;
  125229. /** @hidden */
  125230. _transformTextureUrl: Nullable<(url: string) => string>;
  125231. /**
  125232. * Gets information about the current host
  125233. */
  125234. hostInformation: HostInformation;
  125235. protected get _supportsHardwareTextureRescaling(): boolean;
  125236. private _framebufferDimensionsObject;
  125237. /**
  125238. * sets the object from which width and height will be taken from when getting render width and height
  125239. * Will fallback to the gl object
  125240. * @param dimensions the framebuffer width and height that will be used.
  125241. */
  125242. set framebufferDimensionsObject(dimensions: Nullable<{
  125243. framebufferWidth: number;
  125244. framebufferHeight: number;
  125245. }>);
  125246. /**
  125247. * Gets the current viewport
  125248. */
  125249. get currentViewport(): Nullable<IViewportLike>;
  125250. /**
  125251. * Gets the default empty texture
  125252. */
  125253. get emptyTexture(): InternalTexture;
  125254. /**
  125255. * Gets the default empty 3D texture
  125256. */
  125257. get emptyTexture3D(): InternalTexture;
  125258. /**
  125259. * Gets the default empty 2D array texture
  125260. */
  125261. get emptyTexture2DArray(): InternalTexture;
  125262. /**
  125263. * Gets the default empty cube texture
  125264. */
  125265. get emptyCubeTexture(): InternalTexture;
  125266. /**
  125267. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  125268. */
  125269. premultipliedAlpha: boolean;
  125270. /**
  125271. * Observable event triggered before each texture is initialized
  125272. */
  125273. onBeforeTextureInitObservable: Observable<Texture>;
  125274. /** @hidden */
  125275. protected _isWebGPU: boolean;
  125276. /**
  125277. * Gets a boolean indicating if the engine runs in WebGPU or not.
  125278. */
  125279. get isWebGPU(): boolean;
  125280. /** @hidden */
  125281. protected _shaderPlatformName: string;
  125282. /**
  125283. * Gets the shader platfrom name used by the effects.
  125284. */
  125285. get shaderPlatformName(): string;
  125286. /**
  125287. * Creates a new engine
  125288. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  125289. * @param antialias defines enable antialiasing (default: false)
  125290. * @param options defines further options to be sent to the getContext() function
  125291. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  125292. */
  125293. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  125294. /**
  125295. * @hidden
  125296. */
  125297. _debugPushGroup(groupName: string, targetObject?: number): void;
  125298. /**
  125299. * @hidden
  125300. */
  125301. _debugPopGroup(targetObject?: number): void;
  125302. /**
  125303. * @hidden
  125304. */
  125305. _debugInsertMarker(text: string, targetObject?: number): void;
  125306. /**
  125307. * Shared initialization across engines types.
  125308. * @param canvas The canvas associated with this instance of the engine.
  125309. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  125310. * @param audioEngine Defines if an audio engine should be created by default
  125311. */
  125312. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  125313. /**
  125314. * Gets a shader processor implementation fitting with the current engine type.
  125315. * @returns The shader processor implementation.
  125316. */
  125317. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  125318. /** @hidden */
  125319. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  125320. private _rebuildInternalTextures;
  125321. private _rebuildEffects;
  125322. /**
  125323. * Gets a boolean indicating if all created effects are ready
  125324. * @returns true if all effects are ready
  125325. */
  125326. areAllEffectsReady(): boolean;
  125327. protected _rebuildBuffers(): void;
  125328. protected _initGLContext(): void;
  125329. protected _initFeatures(): void;
  125330. /**
  125331. * Gets version of the current webGL context
  125332. * Keep it for back compat - use version instead
  125333. */
  125334. get webGLVersion(): number;
  125335. /**
  125336. * Gets a string identifying the name of the class
  125337. * @returns "Engine" string
  125338. */
  125339. getClassName(): string;
  125340. /**
  125341. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  125342. */
  125343. get isStencilEnable(): boolean;
  125344. /** @hidden */
  125345. _prepareWorkingCanvas(): void;
  125346. /**
  125347. * Reset the texture cache to empty state
  125348. */
  125349. resetTextureCache(): void;
  125350. /**
  125351. * Gets an object containing information about the current webGL context
  125352. * @returns an object containing the vender, the renderer and the version of the current webGL context
  125353. */
  125354. getGlInfo(): {
  125355. vendor: string;
  125356. renderer: string;
  125357. version: string;
  125358. };
  125359. /**
  125360. * Defines the hardware scaling level.
  125361. * By default the hardware scaling level is computed from the window device ratio.
  125362. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  125363. * @param level defines the level to use
  125364. */
  125365. setHardwareScalingLevel(level: number): void;
  125366. /**
  125367. * Gets the current hardware scaling level.
  125368. * By default the hardware scaling level is computed from the window device ratio.
  125369. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  125370. * @returns a number indicating the current hardware scaling level
  125371. */
  125372. getHardwareScalingLevel(): number;
  125373. /**
  125374. * Gets the list of loaded textures
  125375. * @returns an array containing all loaded textures
  125376. */
  125377. getLoadedTexturesCache(): InternalTexture[];
  125378. /**
  125379. * Gets the object containing all engine capabilities
  125380. * @returns the EngineCapabilities object
  125381. */
  125382. getCaps(): EngineCapabilities;
  125383. /**
  125384. * stop executing a render loop function and remove it from the execution array
  125385. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  125386. */
  125387. stopRenderLoop(renderFunction?: () => void): void;
  125388. /** @hidden */
  125389. _renderLoop(): void;
  125390. /**
  125391. * Gets the HTML canvas attached with the current webGL context
  125392. * @returns a HTML canvas
  125393. */
  125394. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  125395. /**
  125396. * Gets host window
  125397. * @returns the host window object
  125398. */
  125399. getHostWindow(): Nullable<Window>;
  125400. /**
  125401. * Gets the current render width
  125402. * @param useScreen defines if screen size must be used (or the current render target if any)
  125403. * @returns a number defining the current render width
  125404. */
  125405. getRenderWidth(useScreen?: boolean): number;
  125406. /**
  125407. * Gets the current render height
  125408. * @param useScreen defines if screen size must be used (or the current render target if any)
  125409. * @returns a number defining the current render height
  125410. */
  125411. getRenderHeight(useScreen?: boolean): number;
  125412. /**
  125413. * Can be used to override the current requestAnimationFrame requester.
  125414. * @hidden
  125415. */
  125416. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  125417. /**
  125418. * Register and execute a render loop. The engine can have more than one render function
  125419. * @param renderFunction defines the function to continuously execute
  125420. */
  125421. runRenderLoop(renderFunction: () => void): void;
  125422. /**
  125423. * Clear the current render buffer or the current render target (if any is set up)
  125424. * @param color defines the color to use
  125425. * @param backBuffer defines if the back buffer must be cleared
  125426. * @param depth defines if the depth buffer must be cleared
  125427. * @param stencil defines if the stencil buffer must be cleared
  125428. */
  125429. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  125430. protected _viewportCached: {
  125431. x: number;
  125432. y: number;
  125433. z: number;
  125434. w: number;
  125435. };
  125436. /** @hidden */
  125437. _viewport(x: number, y: number, width: number, height: number): void;
  125438. /**
  125439. * Set the WebGL's viewport
  125440. * @param viewport defines the viewport element to be used
  125441. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  125442. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  125443. */
  125444. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  125445. /**
  125446. * Begin a new frame
  125447. */
  125448. beginFrame(): void;
  125449. /**
  125450. * Enf the current frame
  125451. */
  125452. endFrame(): void;
  125453. /**
  125454. * Resize the view according to the canvas' size
  125455. * @param forceSetSize true to force setting the sizes of the underlying canvas
  125456. */
  125457. resize(forceSetSize?: boolean): void;
  125458. /**
  125459. * Force a specific size of the canvas
  125460. * @param width defines the new canvas' width
  125461. * @param height defines the new canvas' height
  125462. * @param forceSetSize true to force setting the sizes of the underlying canvas
  125463. * @returns true if the size was changed
  125464. */
  125465. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  125466. /**
  125467. * Binds the frame buffer to the specified texture.
  125468. * @param texture The texture to render to or null for the default canvas
  125469. * @param faceIndex The face of the texture to render to in case of cube texture
  125470. * @param requiredWidth The width of the target to render to
  125471. * @param requiredHeight The height of the target to render to
  125472. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  125473. * @param lodLevel defines the lod level to bind to the frame buffer
  125474. * @param layer defines the 2d array index to bind to frame buffer to
  125475. */
  125476. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  125477. /** @hidden */
  125478. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  125479. /**
  125480. * Unbind the current render target texture from the webGL context
  125481. * @param texture defines the render target texture to unbind
  125482. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  125483. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  125484. */
  125485. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  125486. /**
  125487. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  125488. */
  125489. flushFramebuffer(): void;
  125490. /**
  125491. * Unbind the current render target and bind the default framebuffer
  125492. */
  125493. restoreDefaultFramebuffer(): void;
  125494. /** @hidden */
  125495. protected _resetVertexBufferBinding(): void;
  125496. /**
  125497. * Creates a vertex buffer
  125498. * @param data the data for the vertex buffer
  125499. * @returns the new WebGL static buffer
  125500. */
  125501. createVertexBuffer(data: DataArray): DataBuffer;
  125502. private _createVertexBuffer;
  125503. /**
  125504. * Creates a dynamic vertex buffer
  125505. * @param data the data for the dynamic vertex buffer
  125506. * @returns the new WebGL dynamic buffer
  125507. */
  125508. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  125509. protected _resetIndexBufferBinding(): void;
  125510. /**
  125511. * Creates a new index buffer
  125512. * @param indices defines the content of the index buffer
  125513. * @param updatable defines if the index buffer must be updatable
  125514. * @returns a new webGL buffer
  125515. */
  125516. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  125517. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  125518. /**
  125519. * Bind a webGL buffer to the webGL context
  125520. * @param buffer defines the buffer to bind
  125521. */
  125522. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  125523. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  125524. private bindBuffer;
  125525. /**
  125526. * update the bound buffer with the given data
  125527. * @param data defines the data to update
  125528. */
  125529. updateArrayBuffer(data: Float32Array): void;
  125530. private _vertexAttribPointer;
  125531. /** @hidden */
  125532. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  125533. private _bindVertexBuffersAttributes;
  125534. /**
  125535. * Records a vertex array object
  125536. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  125537. * @param vertexBuffers defines the list of vertex buffers to store
  125538. * @param indexBuffer defines the index buffer to store
  125539. * @param effect defines the effect to store
  125540. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  125541. * @returns the new vertex array object
  125542. */
  125543. recordVertexArrayObject(vertexBuffers: {
  125544. [key: string]: VertexBuffer;
  125545. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  125546. [kind: string]: Nullable<VertexBuffer>;
  125547. }): WebGLVertexArrayObject;
  125548. /**
  125549. * Bind a specific vertex array object
  125550. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  125551. * @param vertexArrayObject defines the vertex array object to bind
  125552. * @param indexBuffer defines the index buffer to bind
  125553. */
  125554. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  125555. /**
  125556. * Bind webGl buffers directly to the webGL context
  125557. * @param vertexBuffer defines the vertex buffer to bind
  125558. * @param indexBuffer defines the index buffer to bind
  125559. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  125560. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  125561. * @param effect defines the effect associated with the vertex buffer
  125562. */
  125563. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  125564. private _unbindVertexArrayObject;
  125565. /**
  125566. * Bind a list of vertex buffers to the webGL context
  125567. * @param vertexBuffers defines the list of vertex buffers to bind
  125568. * @param indexBuffer defines the index buffer to bind
  125569. * @param effect defines the effect associated with the vertex buffers
  125570. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  125571. */
  125572. bindBuffers(vertexBuffers: {
  125573. [key: string]: Nullable<VertexBuffer>;
  125574. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  125575. [kind: string]: Nullable<VertexBuffer>;
  125576. }): void;
  125577. /**
  125578. * Unbind all instance attributes
  125579. */
  125580. unbindInstanceAttributes(): void;
  125581. /**
  125582. * Release and free the memory of a vertex array object
  125583. * @param vao defines the vertex array object to delete
  125584. */
  125585. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  125586. /** @hidden */
  125587. _releaseBuffer(buffer: DataBuffer): boolean;
  125588. protected _deleteBuffer(buffer: DataBuffer): void;
  125589. /**
  125590. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  125591. * @param instancesBuffer defines the webGL buffer to update and bind
  125592. * @param data defines the data to store in the buffer
  125593. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  125594. */
  125595. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  125596. /**
  125597. * Bind the content of a webGL buffer used with instantiation
  125598. * @param instancesBuffer defines the webGL buffer to bind
  125599. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  125600. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  125601. */
  125602. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  125603. /**
  125604. * Disable the instance attribute corresponding to the name in parameter
  125605. * @param name defines the name of the attribute to disable
  125606. */
  125607. disableInstanceAttributeByName(name: string): void;
  125608. /**
  125609. * Disable the instance attribute corresponding to the location in parameter
  125610. * @param attributeLocation defines the attribute location of the attribute to disable
  125611. */
  125612. disableInstanceAttribute(attributeLocation: number): void;
  125613. /**
  125614. * Disable the attribute corresponding to the location in parameter
  125615. * @param attributeLocation defines the attribute location of the attribute to disable
  125616. */
  125617. disableAttributeByIndex(attributeLocation: number): void;
  125618. /**
  125619. * Send a draw order
  125620. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  125621. * @param indexStart defines the starting index
  125622. * @param indexCount defines the number of index to draw
  125623. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125624. */
  125625. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  125626. /**
  125627. * Draw a list of points
  125628. * @param verticesStart defines the index of first vertex to draw
  125629. * @param verticesCount defines the count of vertices to draw
  125630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125631. */
  125632. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125633. /**
  125634. * Draw a list of unindexed primitives
  125635. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  125636. * @param verticesStart defines the index of first vertex to draw
  125637. * @param verticesCount defines the count of vertices to draw
  125638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125639. */
  125640. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125641. /**
  125642. * Draw a list of indexed primitives
  125643. * @param fillMode defines the primitive to use
  125644. * @param indexStart defines the starting index
  125645. * @param indexCount defines the number of index to draw
  125646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125647. */
  125648. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  125649. /**
  125650. * Draw a list of unindexed primitives
  125651. * @param fillMode defines the primitive to use
  125652. * @param verticesStart defines the index of first vertex to draw
  125653. * @param verticesCount defines the count of vertices to draw
  125654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125655. */
  125656. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125657. private _drawMode;
  125658. /** @hidden */
  125659. protected _reportDrawCall(): void;
  125660. /** @hidden */
  125661. _releaseEffect(effect: Effect): void;
  125662. /** @hidden */
  125663. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  125664. /**
  125665. * Create a new effect (used to store vertex/fragment shaders)
  125666. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  125667. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  125668. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  125669. * @param samplers defines an array of string used to represent textures
  125670. * @param defines defines the string containing the defines to use to compile the shaders
  125671. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125672. * @param onCompiled defines a function to call when the effect creation is successful
  125673. * @param onError defines a function to call when the effect creation has failed
  125674. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  125675. * @returns the new Effect
  125676. */
  125677. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  125678. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  125679. private _compileShader;
  125680. private _compileRawShader;
  125681. /** @hidden */
  125682. _getShaderSource(shader: WebGLShader): Nullable<string>;
  125683. /**
  125684. * Directly creates a webGL program
  125685. * @param pipelineContext defines the pipeline context to attach to
  125686. * @param vertexCode defines the vertex shader code to use
  125687. * @param fragmentCode defines the fragment shader code to use
  125688. * @param context defines the webGL context to use (if not set, the current one will be used)
  125689. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125690. * @returns the new webGL program
  125691. */
  125692. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125693. /**
  125694. * Creates a webGL program
  125695. * @param pipelineContext defines the pipeline context to attach to
  125696. * @param vertexCode defines the vertex shader code to use
  125697. * @param fragmentCode defines the fragment shader code to use
  125698. * @param defines defines the string containing the defines to use to compile the shaders
  125699. * @param context defines the webGL context to use (if not set, the current one will be used)
  125700. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125701. * @returns the new webGL program
  125702. */
  125703. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125704. /**
  125705. * Creates a new pipeline context
  125706. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  125707. * @returns the new pipeline
  125708. */
  125709. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  125710. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125711. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  125712. /** @hidden */
  125713. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  125714. /** @hidden */
  125715. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  125716. /** @hidden */
  125717. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  125718. /**
  125719. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  125720. * @param pipelineContext defines the pipeline context to use
  125721. * @param uniformsNames defines the list of uniform names
  125722. * @returns an array of webGL uniform locations
  125723. */
  125724. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  125725. /**
  125726. * Gets the list of active attributes for a given webGL program
  125727. * @param pipelineContext defines the pipeline context to use
  125728. * @param attributesNames defines the list of attribute names to get
  125729. * @returns an array of indices indicating the offset of each attribute
  125730. */
  125731. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  125732. /**
  125733. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  125734. * @param effect defines the effect to activate
  125735. */
  125736. enableEffect(effect: Nullable<Effect>): void;
  125737. /**
  125738. * Set the value of an uniform to a number (int)
  125739. * @param uniform defines the webGL uniform location where to store the value
  125740. * @param value defines the int number to store
  125741. * @returns true if the value was set
  125742. */
  125743. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125744. /**
  125745. * Set the value of an uniform to a int2
  125746. * @param uniform defines the webGL uniform location where to store the value
  125747. * @param x defines the 1st component of the value
  125748. * @param y defines the 2nd component of the value
  125749. * @returns true if the value was set
  125750. */
  125751. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125752. /**
  125753. * Set the value of an uniform to a int3
  125754. * @param uniform defines the webGL uniform location where to store the value
  125755. * @param x defines the 1st component of the value
  125756. * @param y defines the 2nd component of the value
  125757. * @param z defines the 3rd component of the value
  125758. * @returns true if the value was set
  125759. */
  125760. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125761. /**
  125762. * Set the value of an uniform to a int4
  125763. * @param uniform defines the webGL uniform location where to store the value
  125764. * @param x defines the 1st component of the value
  125765. * @param y defines the 2nd component of the value
  125766. * @param z defines the 3rd component of the value
  125767. * @param w defines the 4th component of the value
  125768. * @returns true if the value was set
  125769. */
  125770. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125771. /**
  125772. * Set the value of an uniform to an array of int32
  125773. * @param uniform defines the webGL uniform location where to store the value
  125774. * @param array defines the array of int32 to store
  125775. * @returns true if the value was set
  125776. */
  125777. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125778. /**
  125779. * Set the value of an uniform to an array of int32 (stored as vec2)
  125780. * @param uniform defines the webGL uniform location where to store the value
  125781. * @param array defines the array of int32 to store
  125782. * @returns true if the value was set
  125783. */
  125784. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125785. /**
  125786. * Set the value of an uniform to an array of int32 (stored as vec3)
  125787. * @param uniform defines the webGL uniform location where to store the value
  125788. * @param array defines the array of int32 to store
  125789. * @returns true if the value was set
  125790. */
  125791. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125792. /**
  125793. * Set the value of an uniform to an array of int32 (stored as vec4)
  125794. * @param uniform defines the webGL uniform location where to store the value
  125795. * @param array defines the array of int32 to store
  125796. * @returns true if the value was set
  125797. */
  125798. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125799. /**
  125800. * Set the value of an uniform to an array of number
  125801. * @param uniform defines the webGL uniform location where to store the value
  125802. * @param array defines the array of number to store
  125803. * @returns true if the value was set
  125804. */
  125805. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125806. /**
  125807. * Set the value of an uniform to an array of number (stored as vec2)
  125808. * @param uniform defines the webGL uniform location where to store the value
  125809. * @param array defines the array of number to store
  125810. * @returns true if the value was set
  125811. */
  125812. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125813. /**
  125814. * Set the value of an uniform to an array of number (stored as vec3)
  125815. * @param uniform defines the webGL uniform location where to store the value
  125816. * @param array defines the array of number to store
  125817. * @returns true if the value was set
  125818. */
  125819. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125820. /**
  125821. * Set the value of an uniform to an array of number (stored as vec4)
  125822. * @param uniform defines the webGL uniform location where to store the value
  125823. * @param array defines the array of number to store
  125824. * @returns true if the value was set
  125825. */
  125826. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125827. /**
  125828. * Set the value of an uniform to an array of float32 (stored as matrices)
  125829. * @param uniform defines the webGL uniform location where to store the value
  125830. * @param matrices defines the array of float32 to store
  125831. * @returns true if the value was set
  125832. */
  125833. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  125834. /**
  125835. * Set the value of an uniform to a matrix (3x3)
  125836. * @param uniform defines the webGL uniform location where to store the value
  125837. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  125838. * @returns true if the value was set
  125839. */
  125840. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125841. /**
  125842. * Set the value of an uniform to a matrix (2x2)
  125843. * @param uniform defines the webGL uniform location where to store the value
  125844. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  125845. * @returns true if the value was set
  125846. */
  125847. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125848. /**
  125849. * Set the value of an uniform to a number (float)
  125850. * @param uniform defines the webGL uniform location where to store the value
  125851. * @param value defines the float number to store
  125852. * @returns true if the value was transfered
  125853. */
  125854. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125855. /**
  125856. * Set the value of an uniform to a vec2
  125857. * @param uniform defines the webGL uniform location where to store the value
  125858. * @param x defines the 1st component of the value
  125859. * @param y defines the 2nd component of the value
  125860. * @returns true if the value was set
  125861. */
  125862. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125863. /**
  125864. * Set the value of an uniform to a vec3
  125865. * @param uniform defines the webGL uniform location where to store the value
  125866. * @param x defines the 1st component of the value
  125867. * @param y defines the 2nd component of the value
  125868. * @param z defines the 3rd component of the value
  125869. * @returns true if the value was set
  125870. */
  125871. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125872. /**
  125873. * Set the value of an uniform to a vec4
  125874. * @param uniform defines the webGL uniform location where to store the value
  125875. * @param x defines the 1st component of the value
  125876. * @param y defines the 2nd component of the value
  125877. * @param z defines the 3rd component of the value
  125878. * @param w defines the 4th component of the value
  125879. * @returns true if the value was set
  125880. */
  125881. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125882. /**
  125883. * Apply all cached states (depth, culling, stencil and alpha)
  125884. */
  125885. applyStates(): void;
  125886. /**
  125887. * Enable or disable color writing
  125888. * @param enable defines the state to set
  125889. */
  125890. setColorWrite(enable: boolean): void;
  125891. /**
  125892. * Gets a boolean indicating if color writing is enabled
  125893. * @returns the current color writing state
  125894. */
  125895. getColorWrite(): boolean;
  125896. /**
  125897. * Gets the depth culling state manager
  125898. */
  125899. get depthCullingState(): DepthCullingState;
  125900. /**
  125901. * Gets the alpha state manager
  125902. */
  125903. get alphaState(): AlphaState;
  125904. /**
  125905. * Gets the stencil state manager
  125906. */
  125907. get stencilState(): StencilState;
  125908. /**
  125909. * Clears the list of texture accessible through engine.
  125910. * This can help preventing texture load conflict due to name collision.
  125911. */
  125912. clearInternalTexturesCache(): void;
  125913. /**
  125914. * Force the entire cache to be cleared
  125915. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  125916. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  125917. */
  125918. wipeCaches(bruteForce?: boolean): void;
  125919. /** @hidden */
  125920. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  125921. min: number;
  125922. mag: number;
  125923. };
  125924. /** @hidden */
  125925. protected _createTexture(): WebGLTexture;
  125926. /** @hidden */
  125927. _createHardwareTexture(): HardwareTextureWrapper;
  125928. protected _createTextureBase(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode: number | undefined, onLoad: (() => void) | null | undefined, onError: ((message: string, exception: any) => void) | null | undefined, prepareTexture: (texture: InternalTexture, extension: string, scene: Nullable<ISceneLike>, img: HTMLImageElement | ImageBitmap | {
  125929. width: number;
  125930. height: number;
  125931. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125932. width: number;
  125933. height: number;
  125934. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125935. width: number;
  125936. height: number;
  125937. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  125938. /**
  125939. * Usually called from Texture.ts.
  125940. * Passed information to create a WebGLTexture
  125941. * @param url defines a value which contains one of the following:
  125942. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  125943. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  125944. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  125945. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  125946. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  125947. * @param scene needed for loading to the correct scene
  125948. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  125949. * @param onLoad optional callback to be called upon successful completion
  125950. * @param onError optional callback to be called upon failure
  125951. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  125952. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  125953. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  125954. * @param forcedExtension defines the extension to use to pick the right loader
  125955. * @param mimeType defines an optional mime type
  125956. * @param loaderOptions options to be passed to the loader
  125957. * @returns a InternalTexture for assignment back into BABYLON.Texture
  125958. */
  125959. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  125960. /**
  125961. * Loads an image as an HTMLImageElement.
  125962. * @param input url string, ArrayBuffer, or Blob to load
  125963. * @param onLoad callback called when the image successfully loads
  125964. * @param onError callback called when the image fails to load
  125965. * @param offlineProvider offline provider for caching
  125966. * @param mimeType optional mime type
  125967. * @returns the HTMLImageElement of the loaded image
  125968. * @hidden
  125969. */
  125970. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  125971. /**
  125972. * @hidden
  125973. */
  125974. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  125975. private _unpackFlipYCached;
  125976. /**
  125977. * In case you are sharing the context with other applications, it might
  125978. * be interested to not cache the unpack flip y state to ensure a consistent
  125979. * value would be set.
  125980. */
  125981. enableUnpackFlipYCached: boolean;
  125982. /** @hidden */
  125983. _unpackFlipY(value: boolean): void;
  125984. /** @hidden */
  125985. _getUnpackAlignement(): number;
  125986. private _getTextureTarget;
  125987. /**
  125988. * Update the sampling mode of a given texture
  125989. * @param samplingMode defines the required sampling mode
  125990. * @param texture defines the texture to update
  125991. * @param generateMipMaps defines whether to generate mipmaps for the texture
  125992. */
  125993. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  125994. /**
  125995. * Update the dimensions of a texture
  125996. * @param texture texture to update
  125997. * @param width new width of the texture
  125998. * @param height new height of the texture
  125999. * @param depth new depth of the texture
  126000. */
  126001. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  126002. /**
  126003. * Update the sampling mode of a given texture
  126004. * @param texture defines the texture to update
  126005. * @param wrapU defines the texture wrap mode of the u coordinates
  126006. * @param wrapV defines the texture wrap mode of the v coordinates
  126007. * @param wrapR defines the texture wrap mode of the r coordinates
  126008. */
  126009. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  126010. /** @hidden */
  126011. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  126012. width: number;
  126013. height: number;
  126014. layers?: number;
  126015. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  126016. /** @hidden */
  126017. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  126018. /** @hidden */
  126019. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  126020. /**
  126021. * Update a portion of an internal texture
  126022. * @param texture defines the texture to update
  126023. * @param imageData defines the data to store into the texture
  126024. * @param xOffset defines the x coordinates of the update rectangle
  126025. * @param yOffset defines the y coordinates of the update rectangle
  126026. * @param width defines the width of the update rectangle
  126027. * @param height defines the height of the update rectangle
  126028. * @param faceIndex defines the face index if texture is a cube (0 by default)
  126029. * @param lod defines the lod level to update (0 by default)
  126030. */
  126031. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  126032. /** @hidden */
  126033. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  126034. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  126035. private _prepareWebGLTexture;
  126036. /** @hidden */
  126037. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  126038. private _getDepthStencilBuffer;
  126039. /** @hidden */
  126040. _releaseFramebufferObjects(texture: InternalTexture): void;
  126041. /** @hidden */
  126042. _releaseTexture(texture: InternalTexture): void;
  126043. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  126044. protected _setProgram(program: WebGLProgram): void;
  126045. protected _boundUniforms: {
  126046. [key: number]: WebGLUniformLocation;
  126047. };
  126048. /**
  126049. * Binds an effect to the webGL context
  126050. * @param effect defines the effect to bind
  126051. */
  126052. bindSamplers(effect: Effect): void;
  126053. private _activateCurrentTexture;
  126054. /** @hidden */
  126055. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  126056. /** @hidden */
  126057. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  126058. /**
  126059. * Unbind all textures from the webGL context
  126060. */
  126061. unbindAllTextures(): void;
  126062. /**
  126063. * Sets a texture to the according uniform.
  126064. * @param channel The texture channel
  126065. * @param uniform The uniform to set
  126066. * @param texture The texture to apply
  126067. * @param name The name of the uniform in the effect
  126068. */
  126069. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  126070. private _bindSamplerUniformToChannel;
  126071. private _getTextureWrapMode;
  126072. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  126073. /**
  126074. * Sets an array of texture to the webGL context
  126075. * @param channel defines the channel where the texture array must be set
  126076. * @param uniform defines the associated uniform location
  126077. * @param textures defines the array of textures to bind
  126078. * @param name name of the channel
  126079. */
  126080. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  126081. /** @hidden */
  126082. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  126083. private _setTextureParameterFloat;
  126084. private _setTextureParameterInteger;
  126085. /**
  126086. * Unbind all vertex attributes from the webGL context
  126087. */
  126088. unbindAllAttributes(): void;
  126089. /**
  126090. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  126091. */
  126092. releaseEffects(): void;
  126093. /**
  126094. * Dispose and release all associated resources
  126095. */
  126096. dispose(): void;
  126097. /**
  126098. * Attach a new callback raised when context lost event is fired
  126099. * @param callback defines the callback to call
  126100. */
  126101. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  126102. /**
  126103. * Attach a new callback raised when context restored event is fired
  126104. * @param callback defines the callback to call
  126105. */
  126106. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  126107. /**
  126108. * Get the current error code of the webGL context
  126109. * @returns the error code
  126110. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  126111. */
  126112. getError(): number;
  126113. private _canRenderToFloatFramebuffer;
  126114. private _canRenderToHalfFloatFramebuffer;
  126115. private _canRenderToFramebuffer;
  126116. /** @hidden */
  126117. _getWebGLTextureType(type: number): number;
  126118. /** @hidden */
  126119. _getInternalFormat(format: number): number;
  126120. /** @hidden */
  126121. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  126122. /** @hidden */
  126123. _getRGBAMultiSampleBufferFormat(type: number): number;
  126124. /** @hidden */
  126125. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  126126. /**
  126127. * Loads a file from a url
  126128. * @param url url to load
  126129. * @param onSuccess callback called when the file successfully loads
  126130. * @param onProgress callback called while file is loading (if the server supports this mode)
  126131. * @param offlineProvider defines the offline provider for caching
  126132. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126133. * @param onError callback called when the file fails to load
  126134. * @returns a file request object
  126135. * @hidden
  126136. */
  126137. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  126138. /**
  126139. * Reads pixels from the current frame buffer. Please note that this function can be slow
  126140. * @param x defines the x coordinate of the rectangle where pixels must be read
  126141. * @param y defines the y coordinate of the rectangle where pixels must be read
  126142. * @param width defines the width of the rectangle where pixels must be read
  126143. * @param height defines the height of the rectangle where pixels must be read
  126144. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  126145. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  126146. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  126147. */
  126148. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  126149. private static _IsSupported;
  126150. private static _HasMajorPerformanceCaveat;
  126151. /**
  126152. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  126153. */
  126154. static get IsSupported(): boolean;
  126155. /**
  126156. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  126157. * @returns true if the engine can be created
  126158. * @ignorenaming
  126159. */
  126160. static isSupported(): boolean;
  126161. /**
  126162. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  126163. */
  126164. static get HasMajorPerformanceCaveat(): boolean;
  126165. /**
  126166. * Find the next highest power of two.
  126167. * @param x Number to start search from.
  126168. * @return Next highest power of two.
  126169. */
  126170. static CeilingPOT(x: number): number;
  126171. /**
  126172. * Find the next lowest power of two.
  126173. * @param x Number to start search from.
  126174. * @return Next lowest power of two.
  126175. */
  126176. static FloorPOT(x: number): number;
  126177. /**
  126178. * Find the nearest power of two.
  126179. * @param x Number to start search from.
  126180. * @return Next nearest power of two.
  126181. */
  126182. static NearestPOT(x: number): number;
  126183. /**
  126184. * Get the closest exponent of two
  126185. * @param value defines the value to approximate
  126186. * @param max defines the maximum value to return
  126187. * @param mode defines how to define the closest value
  126188. * @returns closest exponent of two of the given value
  126189. */
  126190. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  126191. /**
  126192. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  126193. * @param func - the function to be called
  126194. * @param requester - the object that will request the next frame. Falls back to window.
  126195. * @returns frame number
  126196. */
  126197. static QueueNewFrame(func: () => void, requester?: any): number;
  126198. /**
  126199. * Gets host document
  126200. * @returns the host document object
  126201. */
  126202. getHostDocument(): Nullable<Document>;
  126203. }
  126204. }
  126205. declare module BABYLON {
  126206. /**
  126207. * Defines the source of the internal texture
  126208. */
  126209. export enum InternalTextureSource {
  126210. /**
  126211. * The source of the texture data is unknown
  126212. */
  126213. Unknown = 0,
  126214. /**
  126215. * Texture data comes from an URL
  126216. */
  126217. Url = 1,
  126218. /**
  126219. * Texture data is only used for temporary storage
  126220. */
  126221. Temp = 2,
  126222. /**
  126223. * Texture data comes from raw data (ArrayBuffer)
  126224. */
  126225. Raw = 3,
  126226. /**
  126227. * Texture content is dynamic (video or dynamic texture)
  126228. */
  126229. Dynamic = 4,
  126230. /**
  126231. * Texture content is generated by rendering to it
  126232. */
  126233. RenderTarget = 5,
  126234. /**
  126235. * Texture content is part of a multi render target process
  126236. */
  126237. MultiRenderTarget = 6,
  126238. /**
  126239. * Texture data comes from a cube data file
  126240. */
  126241. Cube = 7,
  126242. /**
  126243. * Texture data comes from a raw cube data
  126244. */
  126245. CubeRaw = 8,
  126246. /**
  126247. * Texture data come from a prefiltered cube data file
  126248. */
  126249. CubePrefiltered = 9,
  126250. /**
  126251. * Texture content is raw 3D data
  126252. */
  126253. Raw3D = 10,
  126254. /**
  126255. * Texture content is raw 2D array data
  126256. */
  126257. Raw2DArray = 11,
  126258. /**
  126259. * Texture content is a depth texture
  126260. */
  126261. Depth = 12,
  126262. /**
  126263. * Texture data comes from a raw cube data encoded with RGBD
  126264. */
  126265. CubeRawRGBD = 13
  126266. }
  126267. /**
  126268. * Class used to store data associated with WebGL texture data for the engine
  126269. * This class should not be used directly
  126270. */
  126271. export class InternalTexture {
  126272. /** @hidden */
  126273. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  126274. /**
  126275. * Defines if the texture is ready
  126276. */
  126277. isReady: boolean;
  126278. /**
  126279. * Defines if the texture is a cube texture
  126280. */
  126281. isCube: boolean;
  126282. /**
  126283. * Defines if the texture contains 3D data
  126284. */
  126285. is3D: boolean;
  126286. /**
  126287. * Defines if the texture contains 2D array data
  126288. */
  126289. is2DArray: boolean;
  126290. /**
  126291. * Defines if the texture contains multiview data
  126292. */
  126293. isMultiview: boolean;
  126294. /**
  126295. * Gets the URL used to load this texture
  126296. */
  126297. url: string;
  126298. /** @hidden */
  126299. _originalUrl: string;
  126300. /**
  126301. * Gets the sampling mode of the texture
  126302. */
  126303. samplingMode: number;
  126304. /**
  126305. * Gets a boolean indicating if the texture needs mipmaps generation
  126306. */
  126307. generateMipMaps: boolean;
  126308. /**
  126309. * Gets the number of samples used by the texture (WebGL2+ only)
  126310. */
  126311. samples: number;
  126312. /**
  126313. * Gets the type of the texture (int, float...)
  126314. */
  126315. type: number;
  126316. /**
  126317. * Gets the format of the texture (RGB, RGBA...)
  126318. */
  126319. format: number;
  126320. /**
  126321. * Observable called when the texture is loaded
  126322. */
  126323. onLoadedObservable: Observable<InternalTexture>;
  126324. /**
  126325. * Gets the width of the texture
  126326. */
  126327. width: number;
  126328. /**
  126329. * Gets the height of the texture
  126330. */
  126331. height: number;
  126332. /**
  126333. * Gets the depth of the texture
  126334. */
  126335. depth: number;
  126336. /**
  126337. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  126338. */
  126339. baseWidth: number;
  126340. /**
  126341. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  126342. */
  126343. baseHeight: number;
  126344. /**
  126345. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  126346. */
  126347. baseDepth: number;
  126348. /**
  126349. * Gets a boolean indicating if the texture is inverted on Y axis
  126350. */
  126351. invertY: boolean;
  126352. /** @hidden */
  126353. _invertVScale: boolean;
  126354. /** @hidden */
  126355. _associatedChannel: number;
  126356. /** @hidden */
  126357. _source: InternalTextureSource;
  126358. /** @hidden */
  126359. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  126360. /** @hidden */
  126361. _bufferView: Nullable<ArrayBufferView>;
  126362. /** @hidden */
  126363. _bufferViewArray: Nullable<ArrayBufferView[]>;
  126364. /** @hidden */
  126365. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  126366. /** @hidden */
  126367. _size: number;
  126368. /** @hidden */
  126369. _extension: string;
  126370. /** @hidden */
  126371. _files: Nullable<string[]>;
  126372. /** @hidden */
  126373. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  126374. /** @hidden */
  126375. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  126376. /** @hidden */
  126377. _framebuffer: Nullable<WebGLFramebuffer>;
  126378. /** @hidden */
  126379. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  126380. /** @hidden */
  126381. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  126382. /** @hidden */
  126383. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  126384. /** @hidden */
  126385. _attachments: Nullable<number[]>;
  126386. /** @hidden */
  126387. _textureArray: Nullable<InternalTexture[]>;
  126388. /** @hidden */
  126389. _cachedCoordinatesMode: Nullable<number>;
  126390. /** @hidden */
  126391. _cachedWrapU: Nullable<number>;
  126392. /** @hidden */
  126393. _cachedWrapV: Nullable<number>;
  126394. /** @hidden */
  126395. _cachedWrapR: Nullable<number>;
  126396. /** @hidden */
  126397. _cachedAnisotropicFilteringLevel: Nullable<number>;
  126398. /** @hidden */
  126399. _isDisabled: boolean;
  126400. /** @hidden */
  126401. _compression: Nullable<string>;
  126402. /** @hidden */
  126403. _generateStencilBuffer: boolean;
  126404. /** @hidden */
  126405. _generateDepthBuffer: boolean;
  126406. /** @hidden */
  126407. _comparisonFunction: number;
  126408. /** @hidden */
  126409. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  126410. /** @hidden */
  126411. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  126412. /** @hidden */
  126413. _sphericalPolynomialComputed: boolean;
  126414. /** @hidden */
  126415. _lodGenerationScale: number;
  126416. /** @hidden */
  126417. _lodGenerationOffset: number;
  126418. /** @hidden */
  126419. _depthStencilTexture: Nullable<InternalTexture>;
  126420. /** @hidden */
  126421. _colorTextureArray: Nullable<WebGLTexture>;
  126422. /** @hidden */
  126423. _depthStencilTextureArray: Nullable<WebGLTexture>;
  126424. /** @hidden */
  126425. _lodTextureHigh: Nullable<BaseTexture>;
  126426. /** @hidden */
  126427. _lodTextureMid: Nullable<BaseTexture>;
  126428. /** @hidden */
  126429. _lodTextureLow: Nullable<BaseTexture>;
  126430. /** @hidden */
  126431. _isRGBD: boolean;
  126432. /** @hidden */
  126433. _linearSpecularLOD: boolean;
  126434. /** @hidden */
  126435. _irradianceTexture: Nullable<BaseTexture>;
  126436. /** @hidden */
  126437. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  126438. /** @hidden */
  126439. _references: number;
  126440. /** @hidden */
  126441. _gammaSpace: Nullable<boolean>;
  126442. private _engine;
  126443. private _uniqueId;
  126444. private static _Counter;
  126445. /** Gets the unique id of the internal texture */
  126446. get uniqueId(): number;
  126447. /**
  126448. * Gets the Engine the texture belongs to.
  126449. * @returns The babylon engine
  126450. */
  126451. getEngine(): ThinEngine;
  126452. /**
  126453. * Gets the data source type of the texture
  126454. */
  126455. get source(): InternalTextureSource;
  126456. /**
  126457. * Creates a new InternalTexture
  126458. * @param engine defines the engine to use
  126459. * @param source defines the type of data that will be used
  126460. * @param delayAllocation if the texture allocation should be delayed (default: false)
  126461. */
  126462. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  126463. /**
  126464. * Increments the number of references (ie. the number of Texture that point to it)
  126465. */
  126466. incrementReferences(): void;
  126467. /**
  126468. * Change the size of the texture (not the size of the content)
  126469. * @param width defines the new width
  126470. * @param height defines the new height
  126471. * @param depth defines the new depth (1 by default)
  126472. */
  126473. updateSize(width: int, height: int, depth?: int): void;
  126474. /** @hidden */
  126475. _rebuild(): void;
  126476. /** @hidden */
  126477. _swapAndDie(target: InternalTexture): void;
  126478. /**
  126479. * Dispose the current allocated resources
  126480. */
  126481. dispose(): void;
  126482. }
  126483. }
  126484. declare module BABYLON {
  126485. /**
  126486. * Interface used to present a loading screen while loading a scene
  126487. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  126488. */
  126489. export interface ILoadingScreen {
  126490. /**
  126491. * Function called to display the loading screen
  126492. */
  126493. displayLoadingUI: () => void;
  126494. /**
  126495. * Function called to hide the loading screen
  126496. */
  126497. hideLoadingUI: () => void;
  126498. /**
  126499. * Gets or sets the color to use for the background
  126500. */
  126501. loadingUIBackgroundColor: string;
  126502. /**
  126503. * Gets or sets the text to display while loading
  126504. */
  126505. loadingUIText: string;
  126506. }
  126507. /**
  126508. * Class used for the default loading screen
  126509. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  126510. */
  126511. export class DefaultLoadingScreen implements ILoadingScreen {
  126512. private _renderingCanvas;
  126513. private _loadingText;
  126514. private _loadingDivBackgroundColor;
  126515. private _loadingDiv;
  126516. private _loadingTextDiv;
  126517. /** Gets or sets the logo url to use for the default loading screen */
  126518. static DefaultLogoUrl: string;
  126519. /** Gets or sets the spinner url to use for the default loading screen */
  126520. static DefaultSpinnerUrl: string;
  126521. /**
  126522. * Creates a new default loading screen
  126523. * @param _renderingCanvas defines the canvas used to render the scene
  126524. * @param _loadingText defines the default text to display
  126525. * @param _loadingDivBackgroundColor defines the default background color
  126526. */
  126527. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  126528. /**
  126529. * Function called to display the loading screen
  126530. */
  126531. displayLoadingUI(): void;
  126532. /**
  126533. * Function called to hide the loading screen
  126534. */
  126535. hideLoadingUI(): void;
  126536. /**
  126537. * Gets or sets the text to display while loading
  126538. */
  126539. set loadingUIText(text: string);
  126540. get loadingUIText(): string;
  126541. /**
  126542. * Gets or sets the color to use for the background
  126543. */
  126544. get loadingUIBackgroundColor(): string;
  126545. set loadingUIBackgroundColor(color: string);
  126546. private _resizeLoadingUI;
  126547. }
  126548. }
  126549. declare module BABYLON {
  126550. /**
  126551. * Interface for any object that can request an animation frame
  126552. */
  126553. export interface ICustomAnimationFrameRequester {
  126554. /**
  126555. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  126556. */
  126557. renderFunction?: Function;
  126558. /**
  126559. * Called to request the next frame to render to
  126560. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  126561. */
  126562. requestAnimationFrame: Function;
  126563. /**
  126564. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  126565. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  126566. */
  126567. requestID?: number;
  126568. }
  126569. }
  126570. declare module BABYLON {
  126571. /**
  126572. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  126573. */
  126574. export class PerformanceMonitor {
  126575. private _enabled;
  126576. private _rollingFrameTime;
  126577. private _lastFrameTimeMs;
  126578. /**
  126579. * constructor
  126580. * @param frameSampleSize The number of samples required to saturate the sliding window
  126581. */
  126582. constructor(frameSampleSize?: number);
  126583. /**
  126584. * Samples current frame
  126585. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  126586. */
  126587. sampleFrame(timeMs?: number): void;
  126588. /**
  126589. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  126590. */
  126591. get averageFrameTime(): number;
  126592. /**
  126593. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  126594. */
  126595. get averageFrameTimeVariance(): number;
  126596. /**
  126597. * Returns the frame time of the most recent frame
  126598. */
  126599. get instantaneousFrameTime(): number;
  126600. /**
  126601. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  126602. */
  126603. get averageFPS(): number;
  126604. /**
  126605. * Returns the average framerate in frames per second using the most recent frame time
  126606. */
  126607. get instantaneousFPS(): number;
  126608. /**
  126609. * Returns true if enough samples have been taken to completely fill the sliding window
  126610. */
  126611. get isSaturated(): boolean;
  126612. /**
  126613. * Enables contributions to the sliding window sample set
  126614. */
  126615. enable(): void;
  126616. /**
  126617. * Disables contributions to the sliding window sample set
  126618. * Samples will not be interpolated over the disabled period
  126619. */
  126620. disable(): void;
  126621. /**
  126622. * Returns true if sampling is enabled
  126623. */
  126624. get isEnabled(): boolean;
  126625. /**
  126626. * Resets performance monitor
  126627. */
  126628. reset(): void;
  126629. }
  126630. /**
  126631. * RollingAverage
  126632. *
  126633. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  126634. */
  126635. export class RollingAverage {
  126636. /**
  126637. * Current average
  126638. */
  126639. average: number;
  126640. /**
  126641. * Current variance
  126642. */
  126643. variance: number;
  126644. protected _samples: Array<number>;
  126645. protected _sampleCount: number;
  126646. protected _pos: number;
  126647. protected _m2: number;
  126648. /**
  126649. * constructor
  126650. * @param length The number of samples required to saturate the sliding window
  126651. */
  126652. constructor(length: number);
  126653. /**
  126654. * Adds a sample to the sample set
  126655. * @param v The sample value
  126656. */
  126657. add(v: number): void;
  126658. /**
  126659. * Returns previously added values or null if outside of history or outside the sliding window domain
  126660. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  126661. * @return Value previously recorded with add() or null if outside of range
  126662. */
  126663. history(i: number): number;
  126664. /**
  126665. * Returns true if enough samples have been taken to completely fill the sliding window
  126666. * @return true if sample-set saturated
  126667. */
  126668. isSaturated(): boolean;
  126669. /**
  126670. * Resets the rolling average (equivalent to 0 samples taken so far)
  126671. */
  126672. reset(): void;
  126673. /**
  126674. * Wraps a value around the sample range boundaries
  126675. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  126676. * @return Wrapped position in sample range
  126677. */
  126678. protected _wrapPosition(i: number): number;
  126679. }
  126680. }
  126681. declare module BABYLON {
  126682. /**
  126683. * This class is used to track a performance counter which is number based.
  126684. * The user has access to many properties which give statistics of different nature.
  126685. *
  126686. * The implementer can track two kinds of Performance Counter: time and count.
  126687. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  126688. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  126689. */
  126690. export class PerfCounter {
  126691. /**
  126692. * Gets or sets a global boolean to turn on and off all the counters
  126693. */
  126694. static Enabled: boolean;
  126695. /**
  126696. * Returns the smallest value ever
  126697. */
  126698. get min(): number;
  126699. /**
  126700. * Returns the biggest value ever
  126701. */
  126702. get max(): number;
  126703. /**
  126704. * Returns the average value since the performance counter is running
  126705. */
  126706. get average(): number;
  126707. /**
  126708. * Returns the average value of the last second the counter was monitored
  126709. */
  126710. get lastSecAverage(): number;
  126711. /**
  126712. * Returns the current value
  126713. */
  126714. get current(): number;
  126715. /**
  126716. * Gets the accumulated total
  126717. */
  126718. get total(): number;
  126719. /**
  126720. * Gets the total value count
  126721. */
  126722. get count(): number;
  126723. /**
  126724. * Creates a new counter
  126725. */
  126726. constructor();
  126727. /**
  126728. * Call this method to start monitoring a new frame.
  126729. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  126730. */
  126731. fetchNewFrame(): void;
  126732. /**
  126733. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  126734. * @param newCount the count value to add to the monitored count
  126735. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  126736. */
  126737. addCount(newCount: number, fetchResult: boolean): void;
  126738. /**
  126739. * Start monitoring this performance counter
  126740. */
  126741. beginMonitoring(): void;
  126742. /**
  126743. * Compute the time lapsed since the previous beginMonitoring() call.
  126744. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  126745. */
  126746. endMonitoring(newFrame?: boolean): void;
  126747. private _fetchResult;
  126748. private _startMonitoringTime;
  126749. private _min;
  126750. private _max;
  126751. private _average;
  126752. private _current;
  126753. private _totalValueCount;
  126754. private _totalAccumulated;
  126755. private _lastSecAverage;
  126756. private _lastSecAccumulated;
  126757. private _lastSecTime;
  126758. private _lastSecValueCount;
  126759. }
  126760. }
  126761. declare module BABYLON {
  126762. interface ThinEngine {
  126763. /** @hidden */
  126764. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  126765. /** @hidden */
  126766. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  126767. }
  126768. }
  126769. declare module BABYLON {
  126770. /**
  126771. * Class used to work with sound analyzer using fast fourier transform (FFT)
  126772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126773. */
  126774. export class Analyser {
  126775. /**
  126776. * Gets or sets the smoothing
  126777. * @ignorenaming
  126778. */
  126779. SMOOTHING: number;
  126780. /**
  126781. * Gets or sets the FFT table size
  126782. * @ignorenaming
  126783. */
  126784. FFT_SIZE: number;
  126785. /**
  126786. * Gets or sets the bar graph amplitude
  126787. * @ignorenaming
  126788. */
  126789. BARGRAPHAMPLITUDE: number;
  126790. /**
  126791. * Gets or sets the position of the debug canvas
  126792. * @ignorenaming
  126793. */
  126794. DEBUGCANVASPOS: {
  126795. x: number;
  126796. y: number;
  126797. };
  126798. /**
  126799. * Gets or sets the debug canvas size
  126800. * @ignorenaming
  126801. */
  126802. DEBUGCANVASSIZE: {
  126803. width: number;
  126804. height: number;
  126805. };
  126806. private _byteFreqs;
  126807. private _byteTime;
  126808. private _floatFreqs;
  126809. private _webAudioAnalyser;
  126810. private _debugCanvas;
  126811. private _debugCanvasContext;
  126812. private _scene;
  126813. private _registerFunc;
  126814. private _audioEngine;
  126815. /**
  126816. * Creates a new analyser
  126817. * @param scene defines hosting scene
  126818. */
  126819. constructor(scene: Scene);
  126820. /**
  126821. * Get the number of data values you will have to play with for the visualization
  126822. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  126823. * @returns a number
  126824. */
  126825. getFrequencyBinCount(): number;
  126826. /**
  126827. * Gets the current frequency data as a byte array
  126828. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126829. * @returns a Uint8Array
  126830. */
  126831. getByteFrequencyData(): Uint8Array;
  126832. /**
  126833. * Gets the current waveform as a byte array
  126834. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  126835. * @returns a Uint8Array
  126836. */
  126837. getByteTimeDomainData(): Uint8Array;
  126838. /**
  126839. * Gets the current frequency data as a float array
  126840. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126841. * @returns a Float32Array
  126842. */
  126843. getFloatFrequencyData(): Float32Array;
  126844. /**
  126845. * Renders the debug canvas
  126846. */
  126847. drawDebugCanvas(): void;
  126848. /**
  126849. * Stops rendering the debug canvas and removes it
  126850. */
  126851. stopDebugCanvas(): void;
  126852. /**
  126853. * Connects two audio nodes
  126854. * @param inputAudioNode defines first node to connect
  126855. * @param outputAudioNode defines second node to connect
  126856. */
  126857. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  126858. /**
  126859. * Releases all associated resources
  126860. */
  126861. dispose(): void;
  126862. }
  126863. }
  126864. declare module BABYLON {
  126865. /**
  126866. * This represents an audio engine and it is responsible
  126867. * to play, synchronize and analyse sounds throughout the application.
  126868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126869. */
  126870. export interface IAudioEngine extends IDisposable {
  126871. /**
  126872. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126873. */
  126874. readonly canUseWebAudio: boolean;
  126875. /**
  126876. * Gets the current AudioContext if available.
  126877. */
  126878. readonly audioContext: Nullable<AudioContext>;
  126879. /**
  126880. * The master gain node defines the global audio volume of your audio engine.
  126881. */
  126882. readonly masterGain: GainNode;
  126883. /**
  126884. * Gets whether or not mp3 are supported by your browser.
  126885. */
  126886. readonly isMP3supported: boolean;
  126887. /**
  126888. * Gets whether or not ogg are supported by your browser.
  126889. */
  126890. readonly isOGGsupported: boolean;
  126891. /**
  126892. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126893. * @ignoreNaming
  126894. */
  126895. WarnedWebAudioUnsupported: boolean;
  126896. /**
  126897. * Defines if the audio engine relies on a custom unlocked button.
  126898. * In this case, the embedded button will not be displayed.
  126899. */
  126900. useCustomUnlockedButton: boolean;
  126901. /**
  126902. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  126903. */
  126904. readonly unlocked: boolean;
  126905. /**
  126906. * Event raised when audio has been unlocked on the browser.
  126907. */
  126908. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126909. /**
  126910. * Event raised when audio has been locked on the browser.
  126911. */
  126912. onAudioLockedObservable: Observable<IAudioEngine>;
  126913. /**
  126914. * Flags the audio engine in Locked state.
  126915. * This happens due to new browser policies preventing audio to autoplay.
  126916. */
  126917. lock(): void;
  126918. /**
  126919. * Unlocks the audio engine once a user action has been done on the dom.
  126920. * This is helpful to resume play once browser policies have been satisfied.
  126921. */
  126922. unlock(): void;
  126923. /**
  126924. * Gets the global volume sets on the master gain.
  126925. * @returns the global volume if set or -1 otherwise
  126926. */
  126927. getGlobalVolume(): number;
  126928. /**
  126929. * Sets the global volume of your experience (sets on the master gain).
  126930. * @param newVolume Defines the new global volume of the application
  126931. */
  126932. setGlobalVolume(newVolume: number): void;
  126933. /**
  126934. * Connect the audio engine to an audio analyser allowing some amazing
  126935. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126936. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126937. * @param analyser The analyser to connect to the engine
  126938. */
  126939. connectToAnalyser(analyser: Analyser): void;
  126940. }
  126941. }
  126942. declare module BABYLON {
  126943. /**
  126944. * Defines the interface used by display changed events
  126945. */
  126946. export interface IDisplayChangedEventArgs {
  126947. /** Gets the vrDisplay object (if any) */
  126948. vrDisplay: Nullable<any>;
  126949. /** Gets a boolean indicating if webVR is supported */
  126950. vrSupported: boolean;
  126951. }
  126952. /**
  126953. * Defines the interface used by objects containing a viewport (like a camera)
  126954. */
  126955. interface IViewportOwnerLike {
  126956. /**
  126957. * Gets or sets the viewport
  126958. */
  126959. viewport: IViewportLike;
  126960. }
  126961. /**
  126962. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  126963. */
  126964. export class Engine extends ThinEngine {
  126965. /** Defines that alpha blending is disabled */
  126966. static readonly ALPHA_DISABLE: number;
  126967. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  126968. static readonly ALPHA_ADD: number;
  126969. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  126970. static readonly ALPHA_COMBINE: number;
  126971. /** Defines that alpha blending to DEST - SRC * DEST */
  126972. static readonly ALPHA_SUBTRACT: number;
  126973. /** Defines that alpha blending to SRC * DEST */
  126974. static readonly ALPHA_MULTIPLY: number;
  126975. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  126976. static readonly ALPHA_MAXIMIZED: number;
  126977. /** Defines that alpha blending to SRC + DEST */
  126978. static readonly ALPHA_ONEONE: number;
  126979. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  126980. static readonly ALPHA_PREMULTIPLIED: number;
  126981. /**
  126982. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  126983. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  126984. */
  126985. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  126986. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  126987. static readonly ALPHA_INTERPOLATE: number;
  126988. /**
  126989. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  126990. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  126991. */
  126992. static readonly ALPHA_SCREENMODE: number;
  126993. /** Defines that the ressource is not delayed*/
  126994. static readonly DELAYLOADSTATE_NONE: number;
  126995. /** Defines that the ressource was successfully delay loaded */
  126996. static readonly DELAYLOADSTATE_LOADED: number;
  126997. /** Defines that the ressource is currently delay loading */
  126998. static readonly DELAYLOADSTATE_LOADING: number;
  126999. /** Defines that the ressource is delayed and has not started loading */
  127000. static readonly DELAYLOADSTATE_NOTLOADED: number;
  127001. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  127002. static readonly NEVER: number;
  127003. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  127004. static readonly ALWAYS: number;
  127005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  127006. static readonly LESS: number;
  127007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  127008. static readonly EQUAL: number;
  127009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  127010. static readonly LEQUAL: number;
  127011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  127012. static readonly GREATER: number;
  127013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  127014. static readonly GEQUAL: number;
  127015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  127016. static readonly NOTEQUAL: number;
  127017. /** Passed to stencilOperation to specify that stencil value must be kept */
  127018. static readonly KEEP: number;
  127019. /** Passed to stencilOperation to specify that stencil value must be replaced */
  127020. static readonly REPLACE: number;
  127021. /** Passed to stencilOperation to specify that stencil value must be incremented */
  127022. static readonly INCR: number;
  127023. /** Passed to stencilOperation to specify that stencil value must be decremented */
  127024. static readonly DECR: number;
  127025. /** Passed to stencilOperation to specify that stencil value must be inverted */
  127026. static readonly INVERT: number;
  127027. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  127028. static readonly INCR_WRAP: number;
  127029. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  127030. static readonly DECR_WRAP: number;
  127031. /** Texture is not repeating outside of 0..1 UVs */
  127032. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  127033. /** Texture is repeating outside of 0..1 UVs */
  127034. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  127035. /** Texture is repeating and mirrored */
  127036. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  127037. /** ALPHA */
  127038. static readonly TEXTUREFORMAT_ALPHA: number;
  127039. /** LUMINANCE */
  127040. static readonly TEXTUREFORMAT_LUMINANCE: number;
  127041. /** LUMINANCE_ALPHA */
  127042. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  127043. /** RGB */
  127044. static readonly TEXTUREFORMAT_RGB: number;
  127045. /** RGBA */
  127046. static readonly TEXTUREFORMAT_RGBA: number;
  127047. /** RED */
  127048. static readonly TEXTUREFORMAT_RED: number;
  127049. /** RED (2nd reference) */
  127050. static readonly TEXTUREFORMAT_R: number;
  127051. /** RG */
  127052. static readonly TEXTUREFORMAT_RG: number;
  127053. /** RED_INTEGER */
  127054. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  127055. /** RED_INTEGER (2nd reference) */
  127056. static readonly TEXTUREFORMAT_R_INTEGER: number;
  127057. /** RG_INTEGER */
  127058. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  127059. /** RGB_INTEGER */
  127060. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  127061. /** RGBA_INTEGER */
  127062. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  127063. /** UNSIGNED_BYTE */
  127064. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  127065. /** UNSIGNED_BYTE (2nd reference) */
  127066. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  127067. /** FLOAT */
  127068. static readonly TEXTURETYPE_FLOAT: number;
  127069. /** HALF_FLOAT */
  127070. static readonly TEXTURETYPE_HALF_FLOAT: number;
  127071. /** BYTE */
  127072. static readonly TEXTURETYPE_BYTE: number;
  127073. /** SHORT */
  127074. static readonly TEXTURETYPE_SHORT: number;
  127075. /** UNSIGNED_SHORT */
  127076. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  127077. /** INT */
  127078. static readonly TEXTURETYPE_INT: number;
  127079. /** UNSIGNED_INT */
  127080. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  127081. /** UNSIGNED_SHORT_4_4_4_4 */
  127082. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  127083. /** UNSIGNED_SHORT_5_5_5_1 */
  127084. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  127085. /** UNSIGNED_SHORT_5_6_5 */
  127086. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  127087. /** UNSIGNED_INT_2_10_10_10_REV */
  127088. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  127089. /** UNSIGNED_INT_24_8 */
  127090. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  127091. /** UNSIGNED_INT_10F_11F_11F_REV */
  127092. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  127093. /** UNSIGNED_INT_5_9_9_9_REV */
  127094. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  127095. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  127096. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  127097. /** nearest is mag = nearest and min = nearest and mip = none */
  127098. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  127099. /** Bilinear is mag = linear and min = linear and mip = nearest */
  127100. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  127101. /** Trilinear is mag = linear and min = linear and mip = linear */
  127102. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  127103. /** nearest is mag = nearest and min = nearest and mip = linear */
  127104. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  127105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  127106. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  127107. /** Trilinear is mag = linear and min = linear and mip = linear */
  127108. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  127109. /** mag = nearest and min = nearest and mip = nearest */
  127110. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  127111. /** mag = nearest and min = linear and mip = nearest */
  127112. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  127113. /** mag = nearest and min = linear and mip = linear */
  127114. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  127115. /** mag = nearest and min = linear and mip = none */
  127116. static readonly TEXTURE_NEAREST_LINEAR: number;
  127117. /** mag = nearest and min = nearest and mip = none */
  127118. static readonly TEXTURE_NEAREST_NEAREST: number;
  127119. /** mag = linear and min = nearest and mip = nearest */
  127120. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  127121. /** mag = linear and min = nearest and mip = linear */
  127122. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  127123. /** mag = linear and min = linear and mip = none */
  127124. static readonly TEXTURE_LINEAR_LINEAR: number;
  127125. /** mag = linear and min = nearest and mip = none */
  127126. static readonly TEXTURE_LINEAR_NEAREST: number;
  127127. /** Explicit coordinates mode */
  127128. static readonly TEXTURE_EXPLICIT_MODE: number;
  127129. /** Spherical coordinates mode */
  127130. static readonly TEXTURE_SPHERICAL_MODE: number;
  127131. /** Planar coordinates mode */
  127132. static readonly TEXTURE_PLANAR_MODE: number;
  127133. /** Cubic coordinates mode */
  127134. static readonly TEXTURE_CUBIC_MODE: number;
  127135. /** Projection coordinates mode */
  127136. static readonly TEXTURE_PROJECTION_MODE: number;
  127137. /** Skybox coordinates mode */
  127138. static readonly TEXTURE_SKYBOX_MODE: number;
  127139. /** Inverse Cubic coordinates mode */
  127140. static readonly TEXTURE_INVCUBIC_MODE: number;
  127141. /** Equirectangular coordinates mode */
  127142. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  127143. /** Equirectangular Fixed coordinates mode */
  127144. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  127145. /** Equirectangular Fixed Mirrored coordinates mode */
  127146. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  127147. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  127148. static readonly SCALEMODE_FLOOR: number;
  127149. /** Defines that texture rescaling will look for the nearest power of 2 size */
  127150. static readonly SCALEMODE_NEAREST: number;
  127151. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  127152. static readonly SCALEMODE_CEILING: number;
  127153. /**
  127154. * Returns the current npm package of the sdk
  127155. */
  127156. static get NpmPackage(): string;
  127157. /**
  127158. * Returns the current version of the framework
  127159. */
  127160. static get Version(): string;
  127161. /** Gets the list of created engines */
  127162. static get Instances(): Engine[];
  127163. /**
  127164. * Gets the latest created engine
  127165. */
  127166. static get LastCreatedEngine(): Nullable<Engine>;
  127167. /**
  127168. * Gets the latest created scene
  127169. */
  127170. static get LastCreatedScene(): Nullable<Scene>;
  127171. /**
  127172. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  127173. * @param flag defines which part of the materials must be marked as dirty
  127174. * @param predicate defines a predicate used to filter which materials should be affected
  127175. */
  127176. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  127177. /**
  127178. * Method called to create the default loading screen.
  127179. * This can be overriden in your own app.
  127180. * @param canvas The rendering canvas element
  127181. * @returns The loading screen
  127182. */
  127183. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  127184. /**
  127185. * Method called to create the default rescale post process on each engine.
  127186. */
  127187. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  127188. /**
  127189. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  127190. **/
  127191. enableOfflineSupport: boolean;
  127192. /**
  127193. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  127194. **/
  127195. disableManifestCheck: boolean;
  127196. /**
  127197. * Gets the list of created scenes
  127198. */
  127199. scenes: Scene[];
  127200. /**
  127201. * Event raised when a new scene is created
  127202. */
  127203. onNewSceneAddedObservable: Observable<Scene>;
  127204. /**
  127205. * Gets the list of created postprocesses
  127206. */
  127207. postProcesses: PostProcess[];
  127208. /**
  127209. * Gets a boolean indicating if the pointer is currently locked
  127210. */
  127211. isPointerLock: boolean;
  127212. /**
  127213. * Observable event triggered each time the rendering canvas is resized
  127214. */
  127215. onResizeObservable: Observable<Engine>;
  127216. /**
  127217. * Observable event triggered each time the canvas loses focus
  127218. */
  127219. onCanvasBlurObservable: Observable<Engine>;
  127220. /**
  127221. * Observable event triggered each time the canvas gains focus
  127222. */
  127223. onCanvasFocusObservable: Observable<Engine>;
  127224. /**
  127225. * Observable event triggered each time the canvas receives pointerout event
  127226. */
  127227. onCanvasPointerOutObservable: Observable<PointerEvent>;
  127228. /**
  127229. * Observable raised when the engine begins a new frame
  127230. */
  127231. onBeginFrameObservable: Observable<Engine>;
  127232. /**
  127233. * If set, will be used to request the next animation frame for the render loop
  127234. */
  127235. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  127236. /**
  127237. * Observable raised when the engine ends the current frame
  127238. */
  127239. onEndFrameObservable: Observable<Engine>;
  127240. /**
  127241. * Observable raised when the engine is about to compile a shader
  127242. */
  127243. onBeforeShaderCompilationObservable: Observable<Engine>;
  127244. /**
  127245. * Observable raised when the engine has jsut compiled a shader
  127246. */
  127247. onAfterShaderCompilationObservable: Observable<Engine>;
  127248. /**
  127249. * Gets the audio engine
  127250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127251. * @ignorenaming
  127252. */
  127253. static audioEngine: IAudioEngine;
  127254. /**
  127255. * Default AudioEngine factory responsible of creating the Audio Engine.
  127256. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  127257. */
  127258. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  127259. /**
  127260. * Default offline support factory responsible of creating a tool used to store data locally.
  127261. * By default, this will create a Database object if the workload has been embedded.
  127262. */
  127263. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  127264. private _loadingScreen;
  127265. private _pointerLockRequested;
  127266. private _rescalePostProcess;
  127267. protected _deterministicLockstep: boolean;
  127268. protected _lockstepMaxSteps: number;
  127269. protected _timeStep: number;
  127270. protected get _supportsHardwareTextureRescaling(): boolean;
  127271. private _fps;
  127272. private _deltaTime;
  127273. /** @hidden */
  127274. _drawCalls: PerfCounter;
  127275. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  127276. canvasTabIndex: number;
  127277. /**
  127278. * Turn this value on if you want to pause FPS computation when in background
  127279. */
  127280. disablePerformanceMonitorInBackground: boolean;
  127281. private _performanceMonitor;
  127282. /**
  127283. * Gets the performance monitor attached to this engine
  127284. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127285. */
  127286. get performanceMonitor(): PerformanceMonitor;
  127287. private _onFocus;
  127288. private _onBlur;
  127289. private _onCanvasPointerOut;
  127290. private _onCanvasBlur;
  127291. private _onCanvasFocus;
  127292. private _onFullscreenChange;
  127293. private _onPointerLockChange;
  127294. /**
  127295. * Gets the HTML element used to attach event listeners
  127296. * @returns a HTML element
  127297. */
  127298. getInputElement(): Nullable<HTMLElement>;
  127299. /**
  127300. * Creates a new engine
  127301. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  127302. * @param antialias defines enable antialiasing (default: false)
  127303. * @param options defines further options to be sent to the getContext() function
  127304. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  127305. */
  127306. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  127307. /**
  127308. * Shared initialization across engines types.
  127309. * @param canvas The canvas associated with this instance of the engine.
  127310. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  127311. * @param audioEngine Defines if an audio engine should be created by default
  127312. */
  127313. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  127314. /**
  127315. * Gets current aspect ratio
  127316. * @param viewportOwner defines the camera to use to get the aspect ratio
  127317. * @param useScreen defines if screen size must be used (or the current render target if any)
  127318. * @returns a number defining the aspect ratio
  127319. */
  127320. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  127321. /**
  127322. * Gets current screen aspect ratio
  127323. * @returns a number defining the aspect ratio
  127324. */
  127325. getScreenAspectRatio(): number;
  127326. /**
  127327. * Gets the client rect of the HTML canvas attached with the current webGL context
  127328. * @returns a client rectanglee
  127329. */
  127330. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  127331. /**
  127332. * Gets the client rect of the HTML element used for events
  127333. * @returns a client rectanglee
  127334. */
  127335. getInputElementClientRect(): Nullable<ClientRect>;
  127336. /**
  127337. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  127338. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127339. * @returns true if engine is in deterministic lock step mode
  127340. */
  127341. isDeterministicLockStep(): boolean;
  127342. /**
  127343. * Gets the max steps when engine is running in deterministic lock step
  127344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127345. * @returns the max steps
  127346. */
  127347. getLockstepMaxSteps(): number;
  127348. /**
  127349. * Returns the time in ms between steps when using deterministic lock step.
  127350. * @returns time step in (ms)
  127351. */
  127352. getTimeStep(): number;
  127353. /**
  127354. * Force the mipmap generation for the given render target texture
  127355. * @param texture defines the render target texture to use
  127356. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  127357. */
  127358. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  127359. /** States */
  127360. /**
  127361. * Set various states to the webGL context
  127362. * @param culling defines backface culling state
  127363. * @param zOffset defines the value to apply to zOffset (0 by default)
  127364. * @param force defines if states must be applied even if cache is up to date
  127365. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127366. */
  127367. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127368. /**
  127369. * Set the z offset to apply to current rendering
  127370. * @param value defines the offset to apply
  127371. */
  127372. setZOffset(value: number): void;
  127373. /**
  127374. * Gets the current value of the zOffset
  127375. * @returns the current zOffset state
  127376. */
  127377. getZOffset(): number;
  127378. /**
  127379. * Gets a boolean indicating if depth testing is enabled
  127380. * @returns the current state
  127381. */
  127382. getDepthBuffer(): boolean;
  127383. /**
  127384. * Enable or disable depth buffering
  127385. * @param enable defines the state to set
  127386. */
  127387. setDepthBuffer(enable: boolean): void;
  127388. /**
  127389. * Gets a boolean indicating if depth writing is enabled
  127390. * @returns the current depth writing state
  127391. */
  127392. getDepthWrite(): boolean;
  127393. /**
  127394. * Enable or disable depth writing
  127395. * @param enable defines the state to set
  127396. */
  127397. setDepthWrite(enable: boolean): void;
  127398. /**
  127399. * Gets a boolean indicating if stencil buffer is enabled
  127400. * @returns the current stencil buffer state
  127401. */
  127402. getStencilBuffer(): boolean;
  127403. /**
  127404. * Enable or disable the stencil buffer
  127405. * @param enable defines if the stencil buffer must be enabled or disabled
  127406. */
  127407. setStencilBuffer(enable: boolean): void;
  127408. /**
  127409. * Gets the current stencil mask
  127410. * @returns a number defining the new stencil mask to use
  127411. */
  127412. getStencilMask(): number;
  127413. /**
  127414. * Sets the current stencil mask
  127415. * @param mask defines the new stencil mask to use
  127416. */
  127417. setStencilMask(mask: number): void;
  127418. /**
  127419. * Gets the current stencil function
  127420. * @returns a number defining the stencil function to use
  127421. */
  127422. getStencilFunction(): number;
  127423. /**
  127424. * Gets the current stencil reference value
  127425. * @returns a number defining the stencil reference value to use
  127426. */
  127427. getStencilFunctionReference(): number;
  127428. /**
  127429. * Gets the current stencil mask
  127430. * @returns a number defining the stencil mask to use
  127431. */
  127432. getStencilFunctionMask(): number;
  127433. /**
  127434. * Sets the current stencil function
  127435. * @param stencilFunc defines the new stencil function to use
  127436. */
  127437. setStencilFunction(stencilFunc: number): void;
  127438. /**
  127439. * Sets the current stencil reference
  127440. * @param reference defines the new stencil reference to use
  127441. */
  127442. setStencilFunctionReference(reference: number): void;
  127443. /**
  127444. * Sets the current stencil mask
  127445. * @param mask defines the new stencil mask to use
  127446. */
  127447. setStencilFunctionMask(mask: number): void;
  127448. /**
  127449. * Gets the current stencil operation when stencil fails
  127450. * @returns a number defining stencil operation to use when stencil fails
  127451. */
  127452. getStencilOperationFail(): number;
  127453. /**
  127454. * Gets the current stencil operation when depth fails
  127455. * @returns a number defining stencil operation to use when depth fails
  127456. */
  127457. getStencilOperationDepthFail(): number;
  127458. /**
  127459. * Gets the current stencil operation when stencil passes
  127460. * @returns a number defining stencil operation to use when stencil passes
  127461. */
  127462. getStencilOperationPass(): number;
  127463. /**
  127464. * Sets the stencil operation to use when stencil fails
  127465. * @param operation defines the stencil operation to use when stencil fails
  127466. */
  127467. setStencilOperationFail(operation: number): void;
  127468. /**
  127469. * Sets the stencil operation to use when depth fails
  127470. * @param operation defines the stencil operation to use when depth fails
  127471. */
  127472. setStencilOperationDepthFail(operation: number): void;
  127473. /**
  127474. * Sets the stencil operation to use when stencil passes
  127475. * @param operation defines the stencil operation to use when stencil passes
  127476. */
  127477. setStencilOperationPass(operation: number): void;
  127478. /**
  127479. * Sets a boolean indicating if the dithering state is enabled or disabled
  127480. * @param value defines the dithering state
  127481. */
  127482. setDitheringState(value: boolean): void;
  127483. /**
  127484. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  127485. * @param value defines the rasterizer state
  127486. */
  127487. setRasterizerState(value: boolean): void;
  127488. /**
  127489. * Gets the current depth function
  127490. * @returns a number defining the depth function
  127491. */
  127492. getDepthFunction(): Nullable<number>;
  127493. /**
  127494. * Sets the current depth function
  127495. * @param depthFunc defines the function to use
  127496. */
  127497. setDepthFunction(depthFunc: number): void;
  127498. /**
  127499. * Sets the current depth function to GREATER
  127500. */
  127501. setDepthFunctionToGreater(): void;
  127502. /**
  127503. * Sets the current depth function to GEQUAL
  127504. */
  127505. setDepthFunctionToGreaterOrEqual(): void;
  127506. /**
  127507. * Sets the current depth function to LESS
  127508. */
  127509. setDepthFunctionToLess(): void;
  127510. /**
  127511. * Sets the current depth function to LEQUAL
  127512. */
  127513. setDepthFunctionToLessOrEqual(): void;
  127514. private _cachedStencilBuffer;
  127515. private _cachedStencilFunction;
  127516. private _cachedStencilMask;
  127517. private _cachedStencilOperationPass;
  127518. private _cachedStencilOperationFail;
  127519. private _cachedStencilOperationDepthFail;
  127520. private _cachedStencilReference;
  127521. /**
  127522. * Caches the the state of the stencil buffer
  127523. */
  127524. cacheStencilState(): void;
  127525. /**
  127526. * Restores the state of the stencil buffer
  127527. */
  127528. restoreStencilState(): void;
  127529. /**
  127530. * Directly set the WebGL Viewport
  127531. * @param x defines the x coordinate of the viewport (in screen space)
  127532. * @param y defines the y coordinate of the viewport (in screen space)
  127533. * @param width defines the width of the viewport (in screen space)
  127534. * @param height defines the height of the viewport (in screen space)
  127535. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  127536. */
  127537. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  127538. /**
  127539. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  127540. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  127541. * @param y defines the y-coordinate of the corner of the clear rectangle
  127542. * @param width defines the width of the clear rectangle
  127543. * @param height defines the height of the clear rectangle
  127544. * @param clearColor defines the clear color
  127545. */
  127546. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  127547. /**
  127548. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  127549. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  127550. * @param y defines the y-coordinate of the corner of the clear rectangle
  127551. * @param width defines the width of the clear rectangle
  127552. * @param height defines the height of the clear rectangle
  127553. */
  127554. enableScissor(x: number, y: number, width: number, height: number): void;
  127555. /**
  127556. * Disable previously set scissor test rectangle
  127557. */
  127558. disableScissor(): void;
  127559. protected _reportDrawCall(): void;
  127560. /**
  127561. * Initializes a webVR display and starts listening to display change events
  127562. * The onVRDisplayChangedObservable will be notified upon these changes
  127563. * @returns The onVRDisplayChangedObservable
  127564. */
  127565. initWebVR(): Observable<IDisplayChangedEventArgs>;
  127566. /** @hidden */
  127567. _prepareVRComponent(): void;
  127568. /** @hidden */
  127569. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  127570. /** @hidden */
  127571. _submitVRFrame(): void;
  127572. /**
  127573. * Call this function to leave webVR mode
  127574. * Will do nothing if webVR is not supported or if there is no webVR device
  127575. * @see https://doc.babylonjs.com/how_to/webvr_camera
  127576. */
  127577. disableVR(): void;
  127578. /**
  127579. * Gets a boolean indicating that the system is in VR mode and is presenting
  127580. * @returns true if VR mode is engaged
  127581. */
  127582. isVRPresenting(): boolean;
  127583. /** @hidden */
  127584. _requestVRFrame(): void;
  127585. /** @hidden */
  127586. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  127587. /**
  127588. * Gets the source code of the vertex shader associated with a specific webGL program
  127589. * @param program defines the program to use
  127590. * @returns a string containing the source code of the vertex shader associated with the program
  127591. */
  127592. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  127593. /**
  127594. * Gets the source code of the fragment shader associated with a specific webGL program
  127595. * @param program defines the program to use
  127596. * @returns a string containing the source code of the fragment shader associated with the program
  127597. */
  127598. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  127599. /**
  127600. * Sets a depth stencil texture from a render target to the according uniform.
  127601. * @param channel The texture channel
  127602. * @param uniform The uniform to set
  127603. * @param texture The render target texture containing the depth stencil texture to apply
  127604. * @param name The texture name
  127605. */
  127606. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  127607. /**
  127608. * Sets a texture to the webGL context from a postprocess
  127609. * @param channel defines the channel to use
  127610. * @param postProcess defines the source postprocess
  127611. * @param name name of the channel
  127612. */
  127613. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  127614. /**
  127615. * Binds the output of the passed in post process to the texture channel specified
  127616. * @param channel The channel the texture should be bound to
  127617. * @param postProcess The post process which's output should be bound
  127618. * @param name name of the channel
  127619. */
  127620. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  127621. protected _rebuildBuffers(): void;
  127622. /** @hidden */
  127623. _renderFrame(): void;
  127624. _renderLoop(): void;
  127625. /** @hidden */
  127626. _renderViews(): boolean;
  127627. /**
  127628. * Toggle full screen mode
  127629. * @param requestPointerLock defines if a pointer lock should be requested from the user
  127630. */
  127631. switchFullscreen(requestPointerLock: boolean): void;
  127632. /**
  127633. * Enters full screen mode
  127634. * @param requestPointerLock defines if a pointer lock should be requested from the user
  127635. */
  127636. enterFullscreen(requestPointerLock: boolean): void;
  127637. /**
  127638. * Exits full screen mode
  127639. */
  127640. exitFullscreen(): void;
  127641. /**
  127642. * Enters Pointerlock mode
  127643. */
  127644. enterPointerlock(): void;
  127645. /**
  127646. * Exits Pointerlock mode
  127647. */
  127648. exitPointerlock(): void;
  127649. /**
  127650. * Begin a new frame
  127651. */
  127652. beginFrame(): void;
  127653. /**
  127654. * End the current frame
  127655. */
  127656. endFrame(): void;
  127657. /**
  127658. * Resize the view according to the canvas' size
  127659. * @param forceSetSize true to force setting the sizes of the underlying canvas
  127660. */
  127661. resize(forceSetSize?: boolean): void;
  127662. /**
  127663. * Force a specific size of the canvas
  127664. * @param width defines the new canvas' width
  127665. * @param height defines the new canvas' height
  127666. * @param forceSetSize true to force setting the sizes of the underlying canvas
  127667. * @returns true if the size was changed
  127668. */
  127669. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  127670. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  127671. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127672. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127673. _releaseTexture(texture: InternalTexture): void;
  127674. /**
  127675. * @hidden
  127676. * Rescales a texture
  127677. * @param source input texutre
  127678. * @param destination destination texture
  127679. * @param scene scene to use to render the resize
  127680. * @param internalFormat format to use when resizing
  127681. * @param onComplete callback to be called when resize has completed
  127682. */
  127683. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  127684. /**
  127685. * Gets the current framerate
  127686. * @returns a number representing the framerate
  127687. */
  127688. getFps(): number;
  127689. /**
  127690. * Gets the time spent between current and previous frame
  127691. * @returns a number representing the delta time in ms
  127692. */
  127693. getDeltaTime(): number;
  127694. private _measureFps;
  127695. /** @hidden */
  127696. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  127697. /**
  127698. * Updates the sample count of a render target texture
  127699. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127700. * @param texture defines the texture to update
  127701. * @param samples defines the sample count to set
  127702. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127703. */
  127704. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  127705. /**
  127706. * Updates a depth texture Comparison Mode and Function.
  127707. * If the comparison Function is equal to 0, the mode will be set to none.
  127708. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  127709. * @param texture The texture to set the comparison function for
  127710. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  127711. */
  127712. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  127713. /**
  127714. * Creates a webGL buffer to use with instanciation
  127715. * @param capacity defines the size of the buffer
  127716. * @returns the webGL buffer
  127717. */
  127718. createInstancesBuffer(capacity: number): DataBuffer;
  127719. /**
  127720. * Delete a webGL buffer used with instanciation
  127721. * @param buffer defines the webGL buffer to delete
  127722. */
  127723. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  127724. private _clientWaitAsync;
  127725. /** @hidden */
  127726. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  127727. dispose(): void;
  127728. private _disableTouchAction;
  127729. /**
  127730. * Display the loading screen
  127731. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127732. */
  127733. displayLoadingUI(): void;
  127734. /**
  127735. * Hide the loading screen
  127736. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127737. */
  127738. hideLoadingUI(): void;
  127739. /**
  127740. * Gets the current loading screen object
  127741. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127742. */
  127743. get loadingScreen(): ILoadingScreen;
  127744. /**
  127745. * Sets the current loading screen object
  127746. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127747. */
  127748. set loadingScreen(loadingScreen: ILoadingScreen);
  127749. /**
  127750. * Sets the current loading screen text
  127751. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127752. */
  127753. set loadingUIText(text: string);
  127754. /**
  127755. * Sets the current loading screen background color
  127756. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127757. */
  127758. set loadingUIBackgroundColor(color: string);
  127759. /** Pointerlock and fullscreen */
  127760. /**
  127761. * Ask the browser to promote the current element to pointerlock mode
  127762. * @param element defines the DOM element to promote
  127763. */
  127764. static _RequestPointerlock(element: HTMLElement): void;
  127765. /**
  127766. * Asks the browser to exit pointerlock mode
  127767. */
  127768. static _ExitPointerlock(): void;
  127769. /**
  127770. * Ask the browser to promote the current element to fullscreen rendering mode
  127771. * @param element defines the DOM element to promote
  127772. */
  127773. static _RequestFullscreen(element: HTMLElement): void;
  127774. /**
  127775. * Asks the browser to exit fullscreen mode
  127776. */
  127777. static _ExitFullscreen(): void;
  127778. }
  127779. }
  127780. declare module BABYLON {
  127781. /**
  127782. * The engine store class is responsible to hold all the instances of Engine and Scene created
  127783. * during the life time of the application.
  127784. */
  127785. export class EngineStore {
  127786. /** Gets the list of created engines */
  127787. static Instances: Engine[];
  127788. /** @hidden */
  127789. static _LastCreatedScene: Nullable<Scene>;
  127790. /**
  127791. * Gets the latest created engine
  127792. */
  127793. static get LastCreatedEngine(): Nullable<Engine>;
  127794. /**
  127795. * Gets the latest created scene
  127796. */
  127797. static get LastCreatedScene(): Nullable<Scene>;
  127798. /**
  127799. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127800. * @ignorenaming
  127801. */
  127802. static UseFallbackTexture: boolean;
  127803. /**
  127804. * Texture content used if a texture cannot loaded
  127805. * @ignorenaming
  127806. */
  127807. static FallbackTexture: string;
  127808. }
  127809. }
  127810. declare module BABYLON {
  127811. /**
  127812. * Helper class that provides a small promise polyfill
  127813. */
  127814. export class PromisePolyfill {
  127815. /**
  127816. * Static function used to check if the polyfill is required
  127817. * If this is the case then the function will inject the polyfill to window.Promise
  127818. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  127819. */
  127820. static Apply(force?: boolean): void;
  127821. }
  127822. }
  127823. declare module BABYLON {
  127824. /**
  127825. * Interface for screenshot methods with describe argument called `size` as object with options
  127826. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  127827. */
  127828. export interface IScreenshotSize {
  127829. /**
  127830. * number in pixels for canvas height
  127831. */
  127832. height?: number;
  127833. /**
  127834. * multiplier allowing render at a higher or lower resolution
  127835. * If value is defined then height and width will be ignored and taken from camera
  127836. */
  127837. precision?: number;
  127838. /**
  127839. * number in pixels for canvas width
  127840. */
  127841. width?: number;
  127842. }
  127843. }
  127844. declare module BABYLON {
  127845. interface IColor4Like {
  127846. r: float;
  127847. g: float;
  127848. b: float;
  127849. a: float;
  127850. }
  127851. /**
  127852. * Class containing a set of static utilities functions
  127853. */
  127854. export class Tools {
  127855. /**
  127856. * Gets or sets the base URL to use to load assets
  127857. */
  127858. static get BaseUrl(): string;
  127859. static set BaseUrl(value: string);
  127860. /**
  127861. * Enable/Disable Custom HTTP Request Headers globally.
  127862. * default = false
  127863. * @see CustomRequestHeaders
  127864. */
  127865. static UseCustomRequestHeaders: boolean;
  127866. /**
  127867. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  127868. * i.e. when loading files, where the server/service expects an Authorization header
  127869. */
  127870. static CustomRequestHeaders: {
  127871. [key: string]: string;
  127872. };
  127873. /**
  127874. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  127875. */
  127876. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  127877. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  127878. /**
  127879. * Default behaviour for cors in the application.
  127880. * It can be a string if the expected behavior is identical in the entire app.
  127881. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  127882. */
  127883. static get CorsBehavior(): string | ((url: string | string[]) => string);
  127884. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  127885. /**
  127886. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127887. * @ignorenaming
  127888. */
  127889. static get UseFallbackTexture(): boolean;
  127890. static set UseFallbackTexture(value: boolean);
  127891. /**
  127892. * Use this object to register external classes like custom textures or material
  127893. * to allow the laoders to instantiate them
  127894. */
  127895. static get RegisteredExternalClasses(): {
  127896. [key: string]: Object;
  127897. };
  127898. static set RegisteredExternalClasses(classes: {
  127899. [key: string]: Object;
  127900. });
  127901. /**
  127902. * Texture content used if a texture cannot loaded
  127903. * @ignorenaming
  127904. */
  127905. static get fallbackTexture(): string;
  127906. static set fallbackTexture(value: string);
  127907. /**
  127908. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  127909. * @param u defines the coordinate on X axis
  127910. * @param v defines the coordinate on Y axis
  127911. * @param width defines the width of the source data
  127912. * @param height defines the height of the source data
  127913. * @param pixels defines the source byte array
  127914. * @param color defines the output color
  127915. */
  127916. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  127917. /**
  127918. * Interpolates between a and b via alpha
  127919. * @param a The lower value (returned when alpha = 0)
  127920. * @param b The upper value (returned when alpha = 1)
  127921. * @param alpha The interpolation-factor
  127922. * @return The mixed value
  127923. */
  127924. static Mix(a: number, b: number, alpha: number): number;
  127925. /**
  127926. * Tries to instantiate a new object from a given class name
  127927. * @param className defines the class name to instantiate
  127928. * @returns the new object or null if the system was not able to do the instantiation
  127929. */
  127930. static Instantiate(className: string): any;
  127931. /**
  127932. * Provides a slice function that will work even on IE
  127933. * @param data defines the array to slice
  127934. * @param start defines the start of the data (optional)
  127935. * @param end defines the end of the data (optional)
  127936. * @returns the new sliced array
  127937. */
  127938. static Slice<T>(data: T, start?: number, end?: number): T;
  127939. /**
  127940. * Provides a slice function that will work even on IE
  127941. * The difference between this and Slice is that this will force-convert to array
  127942. * @param data defines the array to slice
  127943. * @param start defines the start of the data (optional)
  127944. * @param end defines the end of the data (optional)
  127945. * @returns the new sliced array
  127946. */
  127947. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  127948. /**
  127949. * Polyfill for setImmediate
  127950. * @param action defines the action to execute after the current execution block
  127951. */
  127952. static SetImmediate(action: () => void): void;
  127953. /**
  127954. * Function indicating if a number is an exponent of 2
  127955. * @param value defines the value to test
  127956. * @returns true if the value is an exponent of 2
  127957. */
  127958. static IsExponentOfTwo(value: number): boolean;
  127959. private static _tmpFloatArray;
  127960. /**
  127961. * Returns the nearest 32-bit single precision float representation of a Number
  127962. * @param value A Number. If the parameter is of a different type, it will get converted
  127963. * to a number or to NaN if it cannot be converted
  127964. * @returns number
  127965. */
  127966. static FloatRound(value: number): number;
  127967. /**
  127968. * Extracts the filename from a path
  127969. * @param path defines the path to use
  127970. * @returns the filename
  127971. */
  127972. static GetFilename(path: string): string;
  127973. /**
  127974. * Extracts the "folder" part of a path (everything before the filename).
  127975. * @param uri The URI to extract the info from
  127976. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  127977. * @returns The "folder" part of the path
  127978. */
  127979. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  127980. /**
  127981. * Extracts text content from a DOM element hierarchy
  127982. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  127983. */
  127984. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  127985. /**
  127986. * Convert an angle in radians to degrees
  127987. * @param angle defines the angle to convert
  127988. * @returns the angle in degrees
  127989. */
  127990. static ToDegrees(angle: number): number;
  127991. /**
  127992. * Convert an angle in degrees to radians
  127993. * @param angle defines the angle to convert
  127994. * @returns the angle in radians
  127995. */
  127996. static ToRadians(angle: number): number;
  127997. /**
  127998. * Returns an array if obj is not an array
  127999. * @param obj defines the object to evaluate as an array
  128000. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  128001. * @returns either obj directly if obj is an array or a new array containing obj
  128002. */
  128003. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  128004. /**
  128005. * Gets the pointer prefix to use
  128006. * @param engine defines the engine we are finding the prefix for
  128007. * @returns "pointer" if touch is enabled. Else returns "mouse"
  128008. */
  128009. static GetPointerPrefix(engine: Engine): string;
  128010. /**
  128011. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  128012. * @param url define the url we are trying
  128013. * @param element define the dom element where to configure the cors policy
  128014. */
  128015. static SetCorsBehavior(url: string | string[], element: {
  128016. crossOrigin: string | null;
  128017. }): void;
  128018. /**
  128019. * Removes unwanted characters from an url
  128020. * @param url defines the url to clean
  128021. * @returns the cleaned url
  128022. */
  128023. static CleanUrl(url: string): string;
  128024. /**
  128025. * Gets or sets a function used to pre-process url before using them to load assets
  128026. */
  128027. static get PreprocessUrl(): (url: string) => string;
  128028. static set PreprocessUrl(processor: (url: string) => string);
  128029. /**
  128030. * Loads an image as an HTMLImageElement.
  128031. * @param input url string, ArrayBuffer, or Blob to load
  128032. * @param onLoad callback called when the image successfully loads
  128033. * @param onError callback called when the image fails to load
  128034. * @param offlineProvider offline provider for caching
  128035. * @param mimeType optional mime type
  128036. * @returns the HTMLImageElement of the loaded image
  128037. */
  128038. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  128039. /**
  128040. * Loads a file from a url
  128041. * @param url url string, ArrayBuffer, or Blob to load
  128042. * @param onSuccess callback called when the file successfully loads
  128043. * @param onProgress callback called while file is loading (if the server supports this mode)
  128044. * @param offlineProvider defines the offline provider for caching
  128045. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128046. * @param onError callback called when the file fails to load
  128047. * @returns a file request object
  128048. */
  128049. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  128050. /**
  128051. * Loads a file from a url
  128052. * @param url the file url to load
  128053. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128054. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  128055. */
  128056. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  128057. /**
  128058. * Load a script (identified by an url). When the url returns, the
  128059. * content of this file is added into a new script element, attached to the DOM (body element)
  128060. * @param scriptUrl defines the url of the script to laod
  128061. * @param onSuccess defines the callback called when the script is loaded
  128062. * @param onError defines the callback to call if an error occurs
  128063. * @param scriptId defines the id of the script element
  128064. */
  128065. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  128066. /**
  128067. * Load an asynchronous script (identified by an url). When the url returns, the
  128068. * content of this file is added into a new script element, attached to the DOM (body element)
  128069. * @param scriptUrl defines the url of the script to laod
  128070. * @param scriptId defines the id of the script element
  128071. * @returns a promise request object
  128072. */
  128073. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  128074. /**
  128075. * Loads a file from a blob
  128076. * @param fileToLoad defines the blob to use
  128077. * @param callback defines the callback to call when data is loaded
  128078. * @param progressCallback defines the callback to call during loading process
  128079. * @returns a file request object
  128080. */
  128081. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  128082. /**
  128083. * Reads a file from a File object
  128084. * @param file defines the file to load
  128085. * @param onSuccess defines the callback to call when data is loaded
  128086. * @param onProgress defines the callback to call during loading process
  128087. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128088. * @param onError defines the callback to call when an error occurs
  128089. * @returns a file request object
  128090. */
  128091. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  128092. /**
  128093. * Creates a data url from a given string content
  128094. * @param content defines the content to convert
  128095. * @returns the new data url link
  128096. */
  128097. static FileAsURL(content: string): string;
  128098. /**
  128099. * Format the given number to a specific decimal format
  128100. * @param value defines the number to format
  128101. * @param decimals defines the number of decimals to use
  128102. * @returns the formatted string
  128103. */
  128104. static Format(value: number, decimals?: number): string;
  128105. /**
  128106. * Tries to copy an object by duplicating every property
  128107. * @param source defines the source object
  128108. * @param destination defines the target object
  128109. * @param doNotCopyList defines a list of properties to avoid
  128110. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  128111. */
  128112. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  128113. /**
  128114. * Gets a boolean indicating if the given object has no own property
  128115. * @param obj defines the object to test
  128116. * @returns true if object has no own property
  128117. */
  128118. static IsEmpty(obj: any): boolean;
  128119. /**
  128120. * Function used to register events at window level
  128121. * @param windowElement defines the Window object to use
  128122. * @param events defines the events to register
  128123. */
  128124. static RegisterTopRootEvents(windowElement: Window, events: {
  128125. name: string;
  128126. handler: Nullable<(e: FocusEvent) => any>;
  128127. }[]): void;
  128128. /**
  128129. * Function used to unregister events from window level
  128130. * @param windowElement defines the Window object to use
  128131. * @param events defines the events to unregister
  128132. */
  128133. static UnregisterTopRootEvents(windowElement: Window, events: {
  128134. name: string;
  128135. handler: Nullable<(e: FocusEvent) => any>;
  128136. }[]): void;
  128137. /**
  128138. * @ignore
  128139. */
  128140. static _ScreenshotCanvas: HTMLCanvasElement;
  128141. /**
  128142. * Dumps the current bound framebuffer
  128143. * @param width defines the rendering width
  128144. * @param height defines the rendering height
  128145. * @param engine defines the hosting engine
  128146. * @param successCallback defines the callback triggered once the data are available
  128147. * @param mimeType defines the mime type of the result
  128148. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  128149. * @return a void promise
  128150. */
  128151. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  128152. /**
  128153. * Dumps an array buffer
  128154. * @param width defines the rendering width
  128155. * @param height defines the rendering height
  128156. * @param data the data array
  128157. * @param successCallback defines the callback triggered once the data are available
  128158. * @param mimeType defines the mime type of the result
  128159. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  128160. * @param invertY true to invert the picture in the Y dimension
  128161. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  128162. */
  128163. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  128164. /**
  128165. * Dumps an array buffer
  128166. * @param width defines the rendering width
  128167. * @param height defines the rendering height
  128168. * @param data the data array
  128169. * @param successCallback defines the callback triggered once the data are available
  128170. * @param mimeType defines the mime type of the result
  128171. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  128172. * @param invertY true to invert the picture in the Y dimension
  128173. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  128174. * @return a promise that resolve to the final data
  128175. */
  128176. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  128177. /**
  128178. * Converts the canvas data to blob.
  128179. * This acts as a polyfill for browsers not supporting the to blob function.
  128180. * @param canvas Defines the canvas to extract the data from
  128181. * @param successCallback Defines the callback triggered once the data are available
  128182. * @param mimeType Defines the mime type of the result
  128183. */
  128184. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  128185. /**
  128186. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  128187. * @param successCallback defines the callback triggered once the data are available
  128188. * @param mimeType defines the mime type of the result
  128189. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  128190. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  128191. */
  128192. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  128193. /**
  128194. * Downloads a blob in the browser
  128195. * @param blob defines the blob to download
  128196. * @param fileName defines the name of the downloaded file
  128197. */
  128198. static Download(blob: Blob, fileName: string): void;
  128199. /**
  128200. * Will return the right value of the noPreventDefault variable
  128201. * Needed to keep backwards compatibility to the old API.
  128202. *
  128203. * @param args arguments passed to the attachControl function
  128204. * @returns the correct value for noPreventDefault
  128205. */
  128206. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  128207. /**
  128208. * Captures a screenshot of the current rendering
  128209. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128210. * @param engine defines the rendering engine
  128211. * @param camera defines the source camera
  128212. * @param size This parameter can be set to a single number or to an object with the
  128213. * following (optional) properties: precision, width, height. If a single number is passed,
  128214. * it will be used for both width and height. If an object is passed, the screenshot size
  128215. * will be derived from the parameters. The precision property is a multiplier allowing
  128216. * rendering at a higher or lower resolution
  128217. * @param successCallback defines the callback receives a single parameter which contains the
  128218. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128219. * src parameter of an <img> to display it
  128220. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128221. * Check your browser for supported MIME types
  128222. */
  128223. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  128224. /**
  128225. * Captures a screenshot of the current rendering
  128226. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128227. * @param engine defines the rendering engine
  128228. * @param camera defines the source camera
  128229. * @param size This parameter can be set to a single number or to an object with the
  128230. * following (optional) properties: precision, width, height. If a single number is passed,
  128231. * it will be used for both width and height. If an object is passed, the screenshot size
  128232. * will be derived from the parameters. The precision property is a multiplier allowing
  128233. * rendering at a higher or lower resolution
  128234. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128235. * Check your browser for supported MIME types
  128236. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128237. * to the src parameter of an <img> to display it
  128238. */
  128239. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  128240. /**
  128241. * Generates an image screenshot from the specified camera.
  128242. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128243. * @param engine The engine to use for rendering
  128244. * @param camera The camera to use for rendering
  128245. * @param size This parameter can be set to a single number or to an object with the
  128246. * following (optional) properties: precision, width, height. If a single number is passed,
  128247. * it will be used for both width and height. If an object is passed, the screenshot size
  128248. * will be derived from the parameters. The precision property is a multiplier allowing
  128249. * rendering at a higher or lower resolution
  128250. * @param successCallback The callback receives a single parameter which contains the
  128251. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128252. * src parameter of an <img> to display it
  128253. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128254. * Check your browser for supported MIME types
  128255. * @param samples Texture samples (default: 1)
  128256. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128257. * @param fileName A name for for the downloaded file.
  128258. */
  128259. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128260. /**
  128261. * Generates an image screenshot from the specified camera.
  128262. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128263. * @param engine The engine to use for rendering
  128264. * @param camera The camera to use for rendering
  128265. * @param size This parameter can be set to a single number or to an object with the
  128266. * following (optional) properties: precision, width, height. If a single number is passed,
  128267. * it will be used for both width and height. If an object is passed, the screenshot size
  128268. * will be derived from the parameters. The precision property is a multiplier allowing
  128269. * rendering at a higher or lower resolution
  128270. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128271. * Check your browser for supported MIME types
  128272. * @param samples Texture samples (default: 1)
  128273. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128274. * @param fileName A name for for the downloaded file.
  128275. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128276. * to the src parameter of an <img> to display it
  128277. */
  128278. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128279. /**
  128280. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  128281. * Be aware Math.random() could cause collisions, but:
  128282. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  128283. * @returns a pseudo random id
  128284. */
  128285. static RandomId(): string;
  128286. /**
  128287. * Test if the given uri is a base64 string
  128288. * @param uri The uri to test
  128289. * @return True if the uri is a base64 string or false otherwise
  128290. */
  128291. static IsBase64(uri: string): boolean;
  128292. /**
  128293. * Decode the given base64 uri.
  128294. * @param uri The uri to decode
  128295. * @return The decoded base64 data.
  128296. */
  128297. static DecodeBase64(uri: string): ArrayBuffer;
  128298. /**
  128299. * Gets the absolute url.
  128300. * @param url the input url
  128301. * @return the absolute url
  128302. */
  128303. static GetAbsoluteUrl(url: string): string;
  128304. /**
  128305. * No log
  128306. */
  128307. static readonly NoneLogLevel: number;
  128308. /**
  128309. * Only message logs
  128310. */
  128311. static readonly MessageLogLevel: number;
  128312. /**
  128313. * Only warning logs
  128314. */
  128315. static readonly WarningLogLevel: number;
  128316. /**
  128317. * Only error logs
  128318. */
  128319. static readonly ErrorLogLevel: number;
  128320. /**
  128321. * All logs
  128322. */
  128323. static readonly AllLogLevel: number;
  128324. /**
  128325. * Gets a value indicating the number of loading errors
  128326. * @ignorenaming
  128327. */
  128328. static get errorsCount(): number;
  128329. /**
  128330. * Callback called when a new log is added
  128331. */
  128332. static OnNewCacheEntry: (entry: string) => void;
  128333. /**
  128334. * Log a message to the console
  128335. * @param message defines the message to log
  128336. */
  128337. static Log(message: string): void;
  128338. /**
  128339. * Write a warning message to the console
  128340. * @param message defines the message to log
  128341. */
  128342. static Warn(message: string): void;
  128343. /**
  128344. * Write an error message to the console
  128345. * @param message defines the message to log
  128346. */
  128347. static Error(message: string): void;
  128348. /**
  128349. * Gets current log cache (list of logs)
  128350. */
  128351. static get LogCache(): string;
  128352. /**
  128353. * Clears the log cache
  128354. */
  128355. static ClearLogCache(): void;
  128356. /**
  128357. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  128358. */
  128359. static set LogLevels(level: number);
  128360. /**
  128361. * Checks if the window object exists
  128362. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  128363. */
  128364. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  128365. /**
  128366. * No performance log
  128367. */
  128368. static readonly PerformanceNoneLogLevel: number;
  128369. /**
  128370. * Use user marks to log performance
  128371. */
  128372. static readonly PerformanceUserMarkLogLevel: number;
  128373. /**
  128374. * Log performance to the console
  128375. */
  128376. static readonly PerformanceConsoleLogLevel: number;
  128377. private static _performance;
  128378. /**
  128379. * Sets the current performance log level
  128380. */
  128381. static set PerformanceLogLevel(level: number);
  128382. private static _StartPerformanceCounterDisabled;
  128383. private static _EndPerformanceCounterDisabled;
  128384. private static _StartUserMark;
  128385. private static _EndUserMark;
  128386. private static _StartPerformanceConsole;
  128387. private static _EndPerformanceConsole;
  128388. /**
  128389. * Starts a performance counter
  128390. */
  128391. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  128392. /**
  128393. * Ends a specific performance coutner
  128394. */
  128395. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  128396. /**
  128397. * Gets either window.performance.now() if supported or Date.now() else
  128398. */
  128399. static get Now(): number;
  128400. /**
  128401. * This method will return the name of the class used to create the instance of the given object.
  128402. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  128403. * @param object the object to get the class name from
  128404. * @param isType defines if the object is actually a type
  128405. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  128406. */
  128407. static GetClassName(object: any, isType?: boolean): string;
  128408. /**
  128409. * Gets the first element of an array satisfying a given predicate
  128410. * @param array defines the array to browse
  128411. * @param predicate defines the predicate to use
  128412. * @returns null if not found or the element
  128413. */
  128414. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  128415. /**
  128416. * This method will return the name of the full name of the class, including its owning module (if any).
  128417. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  128418. * @param object the object to get the class name from
  128419. * @param isType defines if the object is actually a type
  128420. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  128421. * @ignorenaming
  128422. */
  128423. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  128424. /**
  128425. * Returns a promise that resolves after the given amount of time.
  128426. * @param delay Number of milliseconds to delay
  128427. * @returns Promise that resolves after the given amount of time
  128428. */
  128429. static DelayAsync(delay: number): Promise<void>;
  128430. /**
  128431. * Utility function to detect if the current user agent is Safari
  128432. * @returns whether or not the current user agent is safari
  128433. */
  128434. static IsSafari(): boolean;
  128435. }
  128436. /**
  128437. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  128438. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  128439. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  128440. * @param name The name of the class, case should be preserved
  128441. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  128442. */
  128443. export function className(name: string, module?: string): (target: Object) => void;
  128444. /**
  128445. * An implementation of a loop for asynchronous functions.
  128446. */
  128447. export class AsyncLoop {
  128448. /**
  128449. * Defines the number of iterations for the loop
  128450. */
  128451. iterations: number;
  128452. /**
  128453. * Defines the current index of the loop.
  128454. */
  128455. index: number;
  128456. private _done;
  128457. private _fn;
  128458. private _successCallback;
  128459. /**
  128460. * Constructor.
  128461. * @param iterations the number of iterations.
  128462. * @param func the function to run each iteration
  128463. * @param successCallback the callback that will be called upon succesful execution
  128464. * @param offset starting offset.
  128465. */
  128466. constructor(
  128467. /**
  128468. * Defines the number of iterations for the loop
  128469. */
  128470. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  128471. /**
  128472. * Execute the next iteration. Must be called after the last iteration was finished.
  128473. */
  128474. executeNext(): void;
  128475. /**
  128476. * Break the loop and run the success callback.
  128477. */
  128478. breakLoop(): void;
  128479. /**
  128480. * Create and run an async loop.
  128481. * @param iterations the number of iterations.
  128482. * @param fn the function to run each iteration
  128483. * @param successCallback the callback that will be called upon succesful execution
  128484. * @param offset starting offset.
  128485. * @returns the created async loop object
  128486. */
  128487. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  128488. /**
  128489. * A for-loop that will run a given number of iterations synchronous and the rest async.
  128490. * @param iterations total number of iterations
  128491. * @param syncedIterations number of synchronous iterations in each async iteration.
  128492. * @param fn the function to call each iteration.
  128493. * @param callback a success call back that will be called when iterating stops.
  128494. * @param breakFunction a break condition (optional)
  128495. * @param timeout timeout settings for the setTimeout function. default - 0.
  128496. * @returns the created async loop object
  128497. */
  128498. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  128499. }
  128500. }
  128501. declare module BABYLON {
  128502. /**
  128503. * This class implement a typical dictionary using a string as key and the generic type T as value.
  128504. * The underlying implementation relies on an associative array to ensure the best performances.
  128505. * The value can be anything including 'null' but except 'undefined'
  128506. */
  128507. export class StringDictionary<T> {
  128508. /**
  128509. * This will clear this dictionary and copy the content from the 'source' one.
  128510. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  128511. * @param source the dictionary to take the content from and copy to this dictionary
  128512. */
  128513. copyFrom(source: StringDictionary<T>): void;
  128514. /**
  128515. * Get a value based from its key
  128516. * @param key the given key to get the matching value from
  128517. * @return the value if found, otherwise undefined is returned
  128518. */
  128519. get(key: string): T | undefined;
  128520. /**
  128521. * Get a value from its key or add it if it doesn't exist.
  128522. * This method will ensure you that a given key/data will be present in the dictionary.
  128523. * @param key the given key to get the matching value from
  128524. * @param factory the factory that will create the value if the key is not present in the dictionary.
  128525. * The factory will only be invoked if there's no data for the given key.
  128526. * @return the value corresponding to the key.
  128527. */
  128528. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  128529. /**
  128530. * Get a value from its key if present in the dictionary otherwise add it
  128531. * @param key the key to get the value from
  128532. * @param val if there's no such key/value pair in the dictionary add it with this value
  128533. * @return the value corresponding to the key
  128534. */
  128535. getOrAdd(key: string, val: T): T;
  128536. /**
  128537. * Check if there's a given key in the dictionary
  128538. * @param key the key to check for
  128539. * @return true if the key is present, false otherwise
  128540. */
  128541. contains(key: string): boolean;
  128542. /**
  128543. * Add a new key and its corresponding value
  128544. * @param key the key to add
  128545. * @param value the value corresponding to the key
  128546. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  128547. */
  128548. add(key: string, value: T): boolean;
  128549. /**
  128550. * Update a specific value associated to a key
  128551. * @param key defines the key to use
  128552. * @param value defines the value to store
  128553. * @returns true if the value was updated (or false if the key was not found)
  128554. */
  128555. set(key: string, value: T): boolean;
  128556. /**
  128557. * Get the element of the given key and remove it from the dictionary
  128558. * @param key defines the key to search
  128559. * @returns the value associated with the key or null if not found
  128560. */
  128561. getAndRemove(key: string): Nullable<T>;
  128562. /**
  128563. * Remove a key/value from the dictionary.
  128564. * @param key the key to remove
  128565. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  128566. */
  128567. remove(key: string): boolean;
  128568. /**
  128569. * Clear the whole content of the dictionary
  128570. */
  128571. clear(): void;
  128572. /**
  128573. * Gets the current count
  128574. */
  128575. get count(): number;
  128576. /**
  128577. * Execute a callback on each key/val of the dictionary.
  128578. * Note that you can remove any element in this dictionary in the callback implementation
  128579. * @param callback the callback to execute on a given key/value pair
  128580. */
  128581. forEach(callback: (key: string, val: T) => void): void;
  128582. /**
  128583. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  128584. * If the callback returns null or undefined the method will iterate to the next key/value pair
  128585. * Note that you can remove any element in this dictionary in the callback implementation
  128586. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  128587. * @returns the first item
  128588. */
  128589. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  128590. private _count;
  128591. private _data;
  128592. }
  128593. }
  128594. declare module BABYLON {
  128595. /** @hidden */
  128596. export interface ICollisionCoordinator {
  128597. createCollider(): Collider;
  128598. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  128599. init(scene: Scene): void;
  128600. }
  128601. /** @hidden */
  128602. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  128603. private _scene;
  128604. private _scaledPosition;
  128605. private _scaledVelocity;
  128606. private _finalPosition;
  128607. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  128608. createCollider(): Collider;
  128609. init(scene: Scene): void;
  128610. private _collideWithWorld;
  128611. }
  128612. }
  128613. declare module BABYLON {
  128614. /**
  128615. * Class used to manage all inputs for the scene.
  128616. */
  128617. export class InputManager {
  128618. /** The distance in pixel that you have to move to prevent some events */
  128619. static DragMovementThreshold: number;
  128620. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  128621. static LongPressDelay: number;
  128622. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  128623. static DoubleClickDelay: number;
  128624. /** If you need to check double click without raising a single click at first click, enable this flag */
  128625. static ExclusiveDoubleClickMode: boolean;
  128626. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  128627. private _alreadyAttached;
  128628. private _alreadyAttachedTo;
  128629. private _wheelEventName;
  128630. private _onPointerMove;
  128631. private _onPointerDown;
  128632. private _onPointerUp;
  128633. private _initClickEvent;
  128634. private _initActionManager;
  128635. private _delayedSimpleClick;
  128636. private _delayedSimpleClickTimeout;
  128637. private _previousDelayedSimpleClickTimeout;
  128638. private _meshPickProceed;
  128639. private _previousButtonPressed;
  128640. private _currentPickResult;
  128641. private _previousPickResult;
  128642. private _totalPointersPressed;
  128643. private _doubleClickOccured;
  128644. private _pointerOverMesh;
  128645. private _pickedDownMesh;
  128646. private _pickedUpMesh;
  128647. private _pointerX;
  128648. private _pointerY;
  128649. private _unTranslatedPointerX;
  128650. private _unTranslatedPointerY;
  128651. private _startingPointerPosition;
  128652. private _previousStartingPointerPosition;
  128653. private _startingPointerTime;
  128654. private _previousStartingPointerTime;
  128655. private _pointerCaptures;
  128656. private _meshUnderPointerId;
  128657. private _onKeyDown;
  128658. private _onKeyUp;
  128659. private _keyboardIsAttached;
  128660. private _onCanvasFocusObserver;
  128661. private _onCanvasBlurObserver;
  128662. private _scene;
  128663. /**
  128664. * Creates a new InputManager
  128665. * @param scene defines the hosting scene
  128666. */
  128667. constructor(scene: Scene);
  128668. /**
  128669. * Gets the mesh that is currently under the pointer
  128670. */
  128671. get meshUnderPointer(): Nullable<AbstractMesh>;
  128672. /**
  128673. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  128674. * @param pointerId the pointer id to use
  128675. * @returns The mesh under this pointer id or null if not found
  128676. */
  128677. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  128678. /**
  128679. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  128680. */
  128681. get unTranslatedPointer(): Vector2;
  128682. /**
  128683. * Gets or sets the current on-screen X position of the pointer
  128684. */
  128685. get pointerX(): number;
  128686. set pointerX(value: number);
  128687. /**
  128688. * Gets or sets the current on-screen Y position of the pointer
  128689. */
  128690. get pointerY(): number;
  128691. set pointerY(value: number);
  128692. private _updatePointerPosition;
  128693. private _processPointerMove;
  128694. private _setRayOnPointerInfo;
  128695. private _checkPrePointerObservable;
  128696. /**
  128697. * Use this method to simulate a pointer move on a mesh
  128698. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128699. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128700. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128701. */
  128702. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128703. /**
  128704. * Use this method to simulate a pointer down on a mesh
  128705. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128706. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128707. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128708. */
  128709. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128710. private _processPointerDown;
  128711. /** @hidden */
  128712. _isPointerSwiping(): boolean;
  128713. /**
  128714. * Use this method to simulate a pointer up on a mesh
  128715. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128716. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128717. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128718. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  128719. */
  128720. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  128721. private _processPointerUp;
  128722. /**
  128723. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  128724. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  128725. * @returns true if the pointer was captured
  128726. */
  128727. isPointerCaptured(pointerId?: number): boolean;
  128728. /**
  128729. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  128730. * @param attachUp defines if you want to attach events to pointerup
  128731. * @param attachDown defines if you want to attach events to pointerdown
  128732. * @param attachMove defines if you want to attach events to pointermove
  128733. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  128734. */
  128735. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  128736. /**
  128737. * Detaches all event handlers
  128738. */
  128739. detachControl(): void;
  128740. /**
  128741. * Force the value of meshUnderPointer
  128742. * @param mesh defines the mesh to use
  128743. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  128744. */
  128745. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  128746. /**
  128747. * Gets the mesh under the pointer
  128748. * @returns a Mesh or null if no mesh is under the pointer
  128749. */
  128750. getPointerOverMesh(): Nullable<AbstractMesh>;
  128751. }
  128752. }
  128753. declare module BABYLON {
  128754. /**
  128755. * This class defines the direct association between an animation and a target
  128756. */
  128757. export class TargetedAnimation {
  128758. /**
  128759. * Animation to perform
  128760. */
  128761. animation: Animation;
  128762. /**
  128763. * Target to animate
  128764. */
  128765. target: any;
  128766. /**
  128767. * Returns the string "TargetedAnimation"
  128768. * @returns "TargetedAnimation"
  128769. */
  128770. getClassName(): string;
  128771. /**
  128772. * Serialize the object
  128773. * @returns the JSON object representing the current entity
  128774. */
  128775. serialize(): any;
  128776. }
  128777. /**
  128778. * Use this class to create coordinated animations on multiple targets
  128779. */
  128780. export class AnimationGroup implements IDisposable {
  128781. /** The name of the animation group */
  128782. name: string;
  128783. private _scene;
  128784. private _targetedAnimations;
  128785. private _animatables;
  128786. private _from;
  128787. private _to;
  128788. private _isStarted;
  128789. private _isPaused;
  128790. private _speedRatio;
  128791. private _loopAnimation;
  128792. private _isAdditive;
  128793. /**
  128794. * Gets or sets the unique id of the node
  128795. */
  128796. uniqueId: number;
  128797. /**
  128798. * This observable will notify when one animation have ended
  128799. */
  128800. onAnimationEndObservable: Observable<TargetedAnimation>;
  128801. /**
  128802. * Observer raised when one animation loops
  128803. */
  128804. onAnimationLoopObservable: Observable<TargetedAnimation>;
  128805. /**
  128806. * Observer raised when all animations have looped
  128807. */
  128808. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  128809. /**
  128810. * This observable will notify when all animations have ended.
  128811. */
  128812. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  128813. /**
  128814. * This observable will notify when all animations have paused.
  128815. */
  128816. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  128817. /**
  128818. * This observable will notify when all animations are playing.
  128819. */
  128820. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  128821. /**
  128822. * Gets the first frame
  128823. */
  128824. get from(): number;
  128825. /**
  128826. * Gets the last frame
  128827. */
  128828. get to(): number;
  128829. /**
  128830. * Define if the animations are started
  128831. */
  128832. get isStarted(): boolean;
  128833. /**
  128834. * Gets a value indicating that the current group is playing
  128835. */
  128836. get isPlaying(): boolean;
  128837. /**
  128838. * Gets or sets the speed ratio to use for all animations
  128839. */
  128840. get speedRatio(): number;
  128841. /**
  128842. * Gets or sets the speed ratio to use for all animations
  128843. */
  128844. set speedRatio(value: number);
  128845. /**
  128846. * Gets or sets if all animations should loop or not
  128847. */
  128848. get loopAnimation(): boolean;
  128849. set loopAnimation(value: boolean);
  128850. /**
  128851. * Gets or sets if all animations should be evaluated additively
  128852. */
  128853. get isAdditive(): boolean;
  128854. set isAdditive(value: boolean);
  128855. /**
  128856. * Gets the targeted animations for this animation group
  128857. */
  128858. get targetedAnimations(): Array<TargetedAnimation>;
  128859. /**
  128860. * returning the list of animatables controlled by this animation group.
  128861. */
  128862. get animatables(): Array<Animatable>;
  128863. /**
  128864. * Gets the list of target animations
  128865. */
  128866. get children(): TargetedAnimation[];
  128867. /**
  128868. * Instantiates a new Animation Group.
  128869. * This helps managing several animations at once.
  128870. * @see https://doc.babylonjs.com/how_to/group
  128871. * @param name Defines the name of the group
  128872. * @param scene Defines the scene the group belongs to
  128873. */
  128874. constructor(
  128875. /** The name of the animation group */
  128876. name: string, scene?: Nullable<Scene>);
  128877. /**
  128878. * Add an animation (with its target) in the group
  128879. * @param animation defines the animation we want to add
  128880. * @param target defines the target of the animation
  128881. * @returns the TargetedAnimation object
  128882. */
  128883. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  128884. /**
  128885. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  128886. * It can add constant keys at begin or end
  128887. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  128888. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  128889. * @returns the animation group
  128890. */
  128891. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  128892. private _animationLoopCount;
  128893. private _animationLoopFlags;
  128894. private _processLoop;
  128895. /**
  128896. * Start all animations on given targets
  128897. * @param loop defines if animations must loop
  128898. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  128899. * @param from defines the from key (optional)
  128900. * @param to defines the to key (optional)
  128901. * @param isAdditive defines the additive state for the resulting animatables (optional)
  128902. * @returns the current animation group
  128903. */
  128904. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  128905. /**
  128906. * Pause all animations
  128907. * @returns the animation group
  128908. */
  128909. pause(): AnimationGroup;
  128910. /**
  128911. * Play all animations to initial state
  128912. * This function will start() the animations if they were not started or will restart() them if they were paused
  128913. * @param loop defines if animations must loop
  128914. * @returns the animation group
  128915. */
  128916. play(loop?: boolean): AnimationGroup;
  128917. /**
  128918. * Reset all animations to initial state
  128919. * @returns the animation group
  128920. */
  128921. reset(): AnimationGroup;
  128922. /**
  128923. * Restart animations from key 0
  128924. * @returns the animation group
  128925. */
  128926. restart(): AnimationGroup;
  128927. /**
  128928. * Stop all animations
  128929. * @returns the animation group
  128930. */
  128931. stop(): AnimationGroup;
  128932. /**
  128933. * Set animation weight for all animatables
  128934. * @param weight defines the weight to use
  128935. * @return the animationGroup
  128936. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128937. */
  128938. setWeightForAllAnimatables(weight: number): AnimationGroup;
  128939. /**
  128940. * Synchronize and normalize all animatables with a source animatable
  128941. * @param root defines the root animatable to synchronize with
  128942. * @return the animationGroup
  128943. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128944. */
  128945. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  128946. /**
  128947. * Goes to a specific frame in this animation group
  128948. * @param frame the frame number to go to
  128949. * @return the animationGroup
  128950. */
  128951. goToFrame(frame: number): AnimationGroup;
  128952. /**
  128953. * Dispose all associated resources
  128954. */
  128955. dispose(): void;
  128956. private _checkAnimationGroupEnded;
  128957. /**
  128958. * Clone the current animation group and returns a copy
  128959. * @param newName defines the name of the new group
  128960. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  128961. * @returns the new aniamtion group
  128962. */
  128963. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  128964. /**
  128965. * Serializes the animationGroup to an object
  128966. * @returns Serialized object
  128967. */
  128968. serialize(): any;
  128969. /**
  128970. * Returns a new AnimationGroup object parsed from the source provided.
  128971. * @param parsedAnimationGroup defines the source
  128972. * @param scene defines the scene that will receive the animationGroup
  128973. * @returns a new AnimationGroup
  128974. */
  128975. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  128976. /**
  128977. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  128978. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  128979. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  128980. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  128981. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  128982. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  128983. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  128984. */
  128985. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  128986. /**
  128987. * Returns the string "AnimationGroup"
  128988. * @returns "AnimationGroup"
  128989. */
  128990. getClassName(): string;
  128991. /**
  128992. * Creates a detailled string about the object
  128993. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  128994. * @returns a string representing the object
  128995. */
  128996. toString(fullDetails?: boolean): string;
  128997. }
  128998. }
  128999. declare module BABYLON {
  129000. /**
  129001. * @hidden
  129002. **/
  129003. export class _TimeToken {
  129004. _startTimeQuery: Nullable<WebGLQuery>;
  129005. _endTimeQuery: Nullable<WebGLQuery>;
  129006. _timeElapsedQuery: Nullable<WebGLQuery>;
  129007. _timeElapsedQueryEnded: boolean;
  129008. }
  129009. }
  129010. declare module BABYLON {
  129011. /** @hidden */
  129012. export enum ExtensionName {
  129013. DepthClamping = "depth-clamping",
  129014. Depth24UnormStencil8 = "depth24unorm-stencil8",
  129015. Depth32FloatStencil8 = "depth32float-stencil8",
  129016. PipelineStatisticsQuery = "pipeline-statistics-query",
  129017. TextureCompressionBC = "texture-compression-bc",
  129018. TimestampQuery = "timestamp-query"
  129019. }
  129020. /** @hidden */
  129021. export enum AddressMode {
  129022. ClampToEdge = "clamp-to-edge",
  129023. Repeat = "repeat",
  129024. MirrorRepeat = "mirror-repeat"
  129025. }
  129026. /** @hidden */
  129027. export enum BindingType {
  129028. UniformBuffer = "uniform-buffer",
  129029. StorageBuffer = "storage-buffer",
  129030. ReadonlyStorageBuffer = "readonly-storage-buffer",
  129031. Sampler = "sampler",
  129032. ComparisonSampler = "comparison-sampler",
  129033. SampledTexture = "sampled-texture",
  129034. ReadonlyStorageTexture = "readonly-storage-texture",
  129035. WriteonlyStorageTexture = "writeonly-storage-texture"
  129036. }
  129037. /** @hidden */
  129038. export enum BlendFactor {
  129039. Zero = "zero",
  129040. One = "one",
  129041. SrcColor = "src-color",
  129042. OneMinusSrcColor = "one-minus-src-color",
  129043. SrcAlpha = "src-alpha",
  129044. OneMinusSrcAlpha = "one-minus-src-alpha",
  129045. DstColor = "dst-color",
  129046. OneMinusDstColor = "one-minus-dst-color",
  129047. DstAlpha = "dst-alpha",
  129048. OneMinusDstAlpha = "one-minus-dst-alpha",
  129049. SrcAlphaSaturated = "src-alpha-saturated",
  129050. BlendColor = "blend-color",
  129051. OneMinusBlendColor = "one-minus-blend-color"
  129052. }
  129053. /** @hidden */
  129054. export enum BlendOperation {
  129055. Add = "add",
  129056. Subtract = "subtract",
  129057. ReverseSubtract = "reverse-subtract",
  129058. Min = "min",
  129059. Max = "max"
  129060. }
  129061. /** @hidden */
  129062. export enum CompareFunction {
  129063. Never = "never",
  129064. Less = "less",
  129065. Equal = "equal",
  129066. LessEqual = "less-equal",
  129067. Greater = "greater",
  129068. NotEqual = "not-equal",
  129069. GreaterEqual = "greater-equal",
  129070. Always = "always"
  129071. }
  129072. /** @hidden */
  129073. export enum CullMode {
  129074. None = "none",
  129075. Front = "front",
  129076. Back = "back"
  129077. }
  129078. /** @hidden */
  129079. export enum FilterMode {
  129080. Nearest = "nearest",
  129081. Linear = "linear"
  129082. }
  129083. /** @hidden */
  129084. export enum FrontFace {
  129085. CCW = "ccw",
  129086. CW = "cw"
  129087. }
  129088. /** @hidden */
  129089. export enum IndexFormat {
  129090. Uint16 = "uint16",
  129091. Uint32 = "uint32"
  129092. }
  129093. /** @hidden */
  129094. export enum InputStepMode {
  129095. Vertex = "vertex",
  129096. Instance = "instance"
  129097. }
  129098. /** @hidden */
  129099. export enum LoadOp {
  129100. Load = "load"
  129101. }
  129102. /** @hidden */
  129103. export enum PrimitiveTopology {
  129104. PointList = "point-list",
  129105. LineList = "line-list",
  129106. LineStrip = "line-strip",
  129107. TriangleList = "triangle-list",
  129108. TriangleStrip = "triangle-strip"
  129109. }
  129110. /** @hidden */
  129111. export enum StencilOperation {
  129112. Keep = "keep",
  129113. Zero = "zero",
  129114. Replace = "replace",
  129115. Invert = "invert",
  129116. IncrementClamp = "increment-clamp",
  129117. DecrementClamp = "decrement-clamp",
  129118. IncrementWrap = "increment-wrap",
  129119. DecrementWrap = "decrement-wrap"
  129120. }
  129121. /** @hidden */
  129122. export enum StoreOp {
  129123. Store = "store",
  129124. Clear = "clear"
  129125. }
  129126. /** @hidden */
  129127. export enum TextureDimension {
  129128. E1d = "1d",
  129129. E2d = "2d",
  129130. E3d = "3d"
  129131. }
  129132. /** @hidden */
  129133. export enum TextureFormat {
  129134. R8Unorm = "r8unorm",
  129135. R8Snorm = "r8snorm",
  129136. R8Uint = "r8uint",
  129137. R8Sint = "r8sint",
  129138. R16Uint = "r16uint",
  129139. R16Sint = "r16sint",
  129140. R16Float = "r16float",
  129141. RG8Unorm = "rg8unorm",
  129142. RG8Snorm = "rg8snorm",
  129143. RG8Uint = "rg8uint",
  129144. RG8Sint = "rg8sint",
  129145. R32Uint = "r32uint",
  129146. R32Sint = "r32sint",
  129147. R32Float = "r32float",
  129148. RG16Uint = "rg16uint",
  129149. RG16Sint = "rg16sint",
  129150. RG16Float = "rg16float",
  129151. RGBA8Unorm = "rgba8unorm",
  129152. RGBA8UnormSRGB = "rgba8unorm-srgb",
  129153. RGBA8Snorm = "rgba8snorm",
  129154. RGBA8Uint = "rgba8uint",
  129155. RGBA8Sint = "rgba8sint",
  129156. BGRA8Unorm = "bgra8unorm",
  129157. BGRA8UnormSRGB = "bgra8unorm-srgb",
  129158. RGB9E5UFloat = "rgb9e5ufloat",
  129159. RGB10A2Unorm = "rgb10a2unorm",
  129160. RG11B10UFloat = "rg11b10ufloat",
  129161. RG32Uint = "rg32uint",
  129162. RG32Sint = "rg32sint",
  129163. RG32Float = "rg32float",
  129164. RGBA16Uint = "rgba16uint",
  129165. RGBA16Sint = "rgba16sint",
  129166. RGBA16Float = "rgba16float",
  129167. RGBA32Uint = "rgba32uint",
  129168. RGBA32Sint = "rgba32sint",
  129169. RGBA32Float = "rgba32float",
  129170. Stencil8 = "stencil8",
  129171. Depth16Unorm = "depth16unorm",
  129172. Depth24Plus = "depth24plus",
  129173. Depth24PlusStencil8 = "depth24plus-stencil8",
  129174. Depth32Float = "depth32float",
  129175. BC1RGBAUNorm = "bc1-rgba-unorm",
  129176. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  129177. BC2RGBAUnorm = "bc2-rgba-unorm",
  129178. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  129179. BC3RGBAUnorm = "bc3-rgba-unorm",
  129180. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  129181. BC4RUnorm = "bc4-r-unorm",
  129182. BC4RSnorm = "bc4-r-snorm",
  129183. BC5RGUnorm = "bc5-rg-unorm",
  129184. BC5RGSnorm = "bc5-rg-snorm",
  129185. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  129186. BC6HRGBFloat = "bc6h-rgb-float",
  129187. BC7RGBAUnorm = "bc7-rgba-unorm",
  129188. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  129189. Depth24UnormStencil8 = "depth24unorm-stencil8",
  129190. Depth32FloatStencil8 = "depth32float-stencil8"
  129191. }
  129192. /** @hidden */
  129193. export enum TextureComponentType {
  129194. Float = "float",
  129195. Sint = "sint",
  129196. Uint = "uint",
  129197. DepthComparison = "depth-comparison"
  129198. }
  129199. /** @hidden */
  129200. export enum TextureViewDimension {
  129201. E1d = "1d",
  129202. E2d = "2d",
  129203. E2dArray = "2d-array",
  129204. Cube = "cube",
  129205. CubeArray = "cube-array",
  129206. E3d = "3d"
  129207. }
  129208. /** @hidden */
  129209. export enum VertexFormat {
  129210. Uchar2 = "uchar2",
  129211. Uchar4 = "uchar4",
  129212. Char2 = "char2",
  129213. Char4 = "char4",
  129214. Uchar2Norm = "uchar2norm",
  129215. Uchar4Norm = "uchar4norm",
  129216. Char2Norm = "char2norm",
  129217. Char4Norm = "char4norm",
  129218. Ushort2 = "ushort2",
  129219. Ushort4 = "ushort4",
  129220. Short2 = "short2",
  129221. Short4 = "short4",
  129222. Ushort2Norm = "ushort2norm",
  129223. Ushort4Norm = "ushort4norm",
  129224. Short2Norm = "short2norm",
  129225. Short4Norm = "short4norm",
  129226. Half2 = "half2",
  129227. Half4 = "half4",
  129228. Float = "float",
  129229. Float2 = "float2",
  129230. Float3 = "float3",
  129231. Float4 = "float4",
  129232. Uint = "uint",
  129233. Uint2 = "uint2",
  129234. Uint3 = "uint3",
  129235. Uint4 = "uint4",
  129236. Int = "int",
  129237. Int2 = "int2",
  129238. Int3 = "int3",
  129239. Int4 = "int4"
  129240. }
  129241. /** @hidden */
  129242. export enum TextureAspect {
  129243. All = "all",
  129244. StencilOnly = "stencil-only",
  129245. DepthOnly = "depth-only"
  129246. }
  129247. /** @hidden */
  129248. export enum CompilationMessageType {
  129249. Error = "error",
  129250. Warning = "warning",
  129251. Info = "info"
  129252. }
  129253. /** @hidden */
  129254. export enum QueryType {
  129255. Occlusion = "occlusion"
  129256. }
  129257. /** @hidden */
  129258. export enum BufferUsage {
  129259. MapRead = 1,
  129260. MapWrite = 2,
  129261. CopySrc = 4,
  129262. CopyDst = 8,
  129263. Index = 16,
  129264. Vertex = 32,
  129265. Uniform = 64,
  129266. Storage = 128,
  129267. Indirect = 256,
  129268. QueryResolve = 512
  129269. }
  129270. /** @hidden */
  129271. export enum ColorWrite {
  129272. Red = 1,
  129273. Green = 2,
  129274. Blue = 4,
  129275. Alpha = 8,
  129276. All = 15
  129277. }
  129278. /** @hidden */
  129279. export enum ShaderStage {
  129280. Vertex = 1,
  129281. Fragment = 2,
  129282. Compute = 4
  129283. }
  129284. /** @hidden */
  129285. export enum TextureUsage {
  129286. CopySrc = 1,
  129287. CopyDst = 2,
  129288. Sampled = 4,
  129289. Storage = 8,
  129290. OutputAttachment = 16
  129291. }
  129292. /** @hidden */
  129293. export enum MapMode {
  129294. Read = 1,
  129295. Write = 2
  129296. }
  129297. }
  129298. declare module BABYLON {
  129299. /** @hidden */
  129300. export interface WebGPUBindingInfo {
  129301. setIndex: number;
  129302. bindingIndex: number;
  129303. }
  129304. /** @hidden */
  129305. export interface WebGPUTextureSamplerBindingDescription {
  129306. sampler: WebGPUBindingInfo;
  129307. isTextureArray: boolean;
  129308. textures: Array<WebGPUBindingInfo>;
  129309. }
  129310. /** @hidden
  129311. * If the binding is a UBO, isSampler=isTexture=false
  129312. */
  129313. export interface WebGPUBindingDescription {
  129314. name: string;
  129315. usedInVertex: boolean;
  129316. usedInFragment: boolean;
  129317. isSampler: boolean;
  129318. isComparisonSampler?: boolean;
  129319. isTexture: boolean;
  129320. componentType?: GPUTextureComponentType;
  129321. textureDimension?: GPUTextureViewDimension;
  129322. }
  129323. /**
  129324. * @hidden
  129325. */
  129326. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  129327. uboNextBindingIndex: number;
  129328. freeSetIndex: number;
  129329. freeBindingIndex: number;
  129330. availableVaryings: {
  129331. [key: string]: number;
  129332. };
  129333. availableAttributes: {
  129334. [key: string]: number;
  129335. };
  129336. availableUBOs: {
  129337. [key: string]: {
  129338. setIndex: number;
  129339. bindingIndex: number;
  129340. };
  129341. };
  129342. availableSamplers: {
  129343. [key: string]: WebGPUTextureSamplerBindingDescription;
  129344. };
  129345. leftOverUniforms: {
  129346. name: string;
  129347. type: string;
  129348. length: number;
  129349. }[];
  129350. orderedAttributes: string[];
  129351. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  129352. uniformBufferNames: string[];
  129353. private _attributeNextLocation;
  129354. private _varyingNextLocation;
  129355. constructor();
  129356. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  129357. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  129358. getNextFreeUBOBinding(): {
  129359. setIndex: number;
  129360. bindingIndex: number;
  129361. };
  129362. private _getNextFreeBinding;
  129363. }
  129364. }
  129365. declare module BABYLON {
  129366. /** @hidden */
  129367. export interface IWebGPUPipelineContextSamplerCache {
  129368. samplerBinding: number;
  129369. firstTextureName: string;
  129370. }
  129371. /** @hidden */
  129372. export interface IWebGPUPipelineContextTextureCache {
  129373. textureBinding: number;
  129374. texture: InternalTexture;
  129375. }
  129376. /** @hidden */
  129377. export interface IWebGPUPipelineContextVertexInputsCache {
  129378. indexBuffer: Nullable<GPUBuffer>;
  129379. indexOffset: number;
  129380. vertexStartSlot: number;
  129381. vertexBuffers: GPUBuffer[];
  129382. vertexOffsets: number[];
  129383. }
  129384. /** @hidden */
  129385. export interface IWebGPURenderPipelineStageDescriptor {
  129386. vertexStage: GPUProgrammableStageDescriptor;
  129387. fragmentStage?: GPUProgrammableStageDescriptor;
  129388. }
  129389. /** @hidden */
  129390. export class WebGPUPipelineContext implements IPipelineContext {
  129391. engine: WebGPUEngine;
  129392. shaderProcessingContext: WebGPUShaderProcessingContext;
  129393. leftOverUniformsByName: {
  129394. [name: string]: string;
  129395. };
  129396. sources: {
  129397. vertex: string;
  129398. fragment: string;
  129399. rawVertex: string;
  129400. rawFragment: string;
  129401. };
  129402. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  129403. samplers: {
  129404. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  129405. };
  129406. textures: {
  129407. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  129408. };
  129409. bindGroupLayouts: GPUBindGroupLayout[];
  129410. bindGroupsCache: {
  129411. [key: string]: GPUBindGroup[];
  129412. };
  129413. /**
  129414. * Stores the uniform buffer
  129415. */
  129416. uniformBuffer: Nullable<UniformBuffer>;
  129417. onCompiled?: () => void;
  129418. get isAsync(): boolean;
  129419. get isReady(): boolean;
  129420. /** @hidden */
  129421. _name: string;
  129422. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  129423. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  129424. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  129425. [key: string]: number;
  129426. }, uniformsNames: string[], uniforms: {
  129427. [key: string]: Nullable<WebGLUniformLocation>;
  129428. }, samplerList: string[], samplers: {
  129429. [key: string]: number;
  129430. }, attributesNames: string[], attributes: number[]): void;
  129431. /** @hidden */
  129432. /**
  129433. * Build the uniform buffer used in the material.
  129434. */
  129435. buildUniformLayout(): void;
  129436. /**
  129437. * Release all associated resources.
  129438. **/
  129439. dispose(): void;
  129440. /**
  129441. * Sets an integer value on a uniform variable.
  129442. * @param uniformName Name of the variable.
  129443. * @param value Value to be set.
  129444. */
  129445. setInt(uniformName: string, value: number): void;
  129446. /**
  129447. * Sets an int2 value on a uniform variable.
  129448. * @param uniformName Name of the variable.
  129449. * @param x First int in int2.
  129450. * @param y Second int in int2.
  129451. */
  129452. setInt2(uniformName: string, x: number, y: number): void;
  129453. /**
  129454. * Sets an int3 value on a uniform variable.
  129455. * @param uniformName Name of the variable.
  129456. * @param x First int in int3.
  129457. * @param y Second int in int3.
  129458. * @param z Third int in int3.
  129459. */
  129460. setInt3(uniformName: string, x: number, y: number, z: number): void;
  129461. /**
  129462. * Sets an int4 value on a uniform variable.
  129463. * @param uniformName Name of the variable.
  129464. * @param x First int in int4.
  129465. * @param y Second int in int4.
  129466. * @param z Third int in int4.
  129467. * @param w Fourth int in int4.
  129468. */
  129469. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  129470. /**
  129471. * Sets an int array on a uniform variable.
  129472. * @param uniformName Name of the variable.
  129473. * @param array array to be set.
  129474. */
  129475. setIntArray(uniformName: string, array: Int32Array): void;
  129476. /**
  129477. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  129478. * @param uniformName Name of the variable.
  129479. * @param array array to be set.
  129480. */
  129481. setIntArray2(uniformName: string, array: Int32Array): void;
  129482. /**
  129483. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  129484. * @param uniformName Name of the variable.
  129485. * @param array array to be set.
  129486. */
  129487. setIntArray3(uniformName: string, array: Int32Array): void;
  129488. /**
  129489. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  129490. * @param uniformName Name of the variable.
  129491. * @param array array to be set.
  129492. */
  129493. setIntArray4(uniformName: string, array: Int32Array): void;
  129494. /**
  129495. * Sets an array on a uniform variable.
  129496. * @param uniformName Name of the variable.
  129497. * @param array array to be set.
  129498. */
  129499. setArray(uniformName: string, array: number[]): void;
  129500. /**
  129501. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  129502. * @param uniformName Name of the variable.
  129503. * @param array array to be set.
  129504. */
  129505. setArray2(uniformName: string, array: number[]): void;
  129506. /**
  129507. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  129508. * @param uniformName Name of the variable.
  129509. * @param array array to be set.
  129510. * @returns this effect.
  129511. */
  129512. setArray3(uniformName: string, array: number[]): void;
  129513. /**
  129514. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  129515. * @param uniformName Name of the variable.
  129516. * @param array array to be set.
  129517. */
  129518. setArray4(uniformName: string, array: number[]): void;
  129519. /**
  129520. * Sets matrices on a uniform variable.
  129521. * @param uniformName Name of the variable.
  129522. * @param matrices matrices to be set.
  129523. */
  129524. setMatrices(uniformName: string, matrices: Float32Array): void;
  129525. /**
  129526. * Sets matrix on a uniform variable.
  129527. * @param uniformName Name of the variable.
  129528. * @param matrix matrix to be set.
  129529. */
  129530. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  129531. /**
  129532. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  129533. * @param uniformName Name of the variable.
  129534. * @param matrix matrix to be set.
  129535. */
  129536. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  129537. /**
  129538. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  129539. * @param uniformName Name of the variable.
  129540. * @param matrix matrix to be set.
  129541. */
  129542. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  129543. /**
  129544. * Sets a float on a uniform variable.
  129545. * @param uniformName Name of the variable.
  129546. * @param value value to be set.
  129547. * @returns this effect.
  129548. */
  129549. setFloat(uniformName: string, value: number): void;
  129550. /**
  129551. * Sets a Vector2 on a uniform variable.
  129552. * @param uniformName Name of the variable.
  129553. * @param vector2 vector2 to be set.
  129554. */
  129555. setVector2(uniformName: string, vector2: IVector2Like): void;
  129556. /**
  129557. * Sets a float2 on a uniform variable.
  129558. * @param uniformName Name of the variable.
  129559. * @param x First float in float2.
  129560. * @param y Second float in float2.
  129561. */
  129562. setFloat2(uniformName: string, x: number, y: number): void;
  129563. /**
  129564. * Sets a Vector3 on a uniform variable.
  129565. * @param uniformName Name of the variable.
  129566. * @param vector3 Value to be set.
  129567. */
  129568. setVector3(uniformName: string, vector3: IVector3Like): void;
  129569. /**
  129570. * Sets a float3 on a uniform variable.
  129571. * @param uniformName Name of the variable.
  129572. * @param x First float in float3.
  129573. * @param y Second float in float3.
  129574. * @param z Third float in float3.
  129575. */
  129576. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  129577. /**
  129578. * Sets a Vector4 on a uniform variable.
  129579. * @param uniformName Name of the variable.
  129580. * @param vector4 Value to be set.
  129581. */
  129582. setVector4(uniformName: string, vector4: IVector4Like): void;
  129583. /**
  129584. * Sets a float4 on a uniform variable.
  129585. * @param uniformName Name of the variable.
  129586. * @param x First float in float4.
  129587. * @param y Second float in float4.
  129588. * @param z Third float in float4.
  129589. * @param w Fourth float in float4.
  129590. * @returns this effect.
  129591. */
  129592. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  129593. /**
  129594. * Sets a Color3 on a uniform variable.
  129595. * @param uniformName Name of the variable.
  129596. * @param color3 Value to be set.
  129597. */
  129598. setColor3(uniformName: string, color3: IColor3Like): void;
  129599. /**
  129600. * Sets a Color4 on a uniform variable.
  129601. * @param uniformName Name of the variable.
  129602. * @param color3 Value to be set.
  129603. * @param alpha Alpha value to be set.
  129604. */
  129605. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  129606. /**
  129607. * Sets a Color4 on a uniform variable
  129608. * @param uniformName defines the name of the variable
  129609. * @param color4 defines the value to be set
  129610. */
  129611. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  129612. _getVertexShaderCode(): string | null;
  129613. _getFragmentShaderCode(): string | null;
  129614. }
  129615. }
  129616. declare module BABYLON {
  129617. /** @hidden */
  129618. export class WebGPUDataBuffer extends DataBuffer {
  129619. private _buffer;
  129620. constructor(resource: GPUBuffer);
  129621. get underlyingResource(): any;
  129622. }
  129623. }
  129624. declare module BABYLON {
  129625. /**
  129626. * Class used to inline functions in shader code
  129627. */
  129628. export class ShaderCodeInliner {
  129629. private static readonly _RegexpFindFunctionNameAndType;
  129630. private _sourceCode;
  129631. private _functionDescr;
  129632. private _numMaxIterations;
  129633. /** Gets or sets the token used to mark the functions to inline */
  129634. inlineToken: string;
  129635. /** Gets or sets the debug mode */
  129636. debug: boolean;
  129637. /** Gets the code after the inlining process */
  129638. get code(): string;
  129639. /**
  129640. * Initializes the inliner
  129641. * @param sourceCode shader code source to inline
  129642. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129643. */
  129644. constructor(sourceCode: string, numMaxIterations?: number);
  129645. /**
  129646. * Start the processing of the shader code
  129647. */
  129648. processCode(): void;
  129649. private _collectFunctions;
  129650. private _processInlining;
  129651. private _extractBetweenMarkers;
  129652. private _skipWhitespaces;
  129653. private _isIdentifierChar;
  129654. private _removeComments;
  129655. private _replaceFunctionCallsByCode;
  129656. private _findBackward;
  129657. private _escapeRegExp;
  129658. private _replaceNames;
  129659. }
  129660. }
  129661. declare module BABYLON {
  129662. /** @hidden */
  129663. export class WebGPUShaderProcessor implements IShaderProcessor {
  129664. protected _missingVaryings: Array<string>;
  129665. protected _textureArrayProcessing: Array<string>;
  129666. protected _preProcessors: {
  129667. [key: string]: string;
  129668. };
  129669. private _getArraySize;
  129670. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  129671. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  129672. [key: string]: string;
  129673. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129674. attributeProcessor(attribute: string, preProcessors: {
  129675. [key: string]: string;
  129676. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129677. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  129678. [key: string]: string;
  129679. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129680. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129681. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129682. private _applyTextureArrayProcessing;
  129683. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  129684. vertexCode: string;
  129685. fragmentCode: string;
  129686. };
  129687. }
  129688. }
  129689. declare module BABYLON {
  129690. /** @hidden */
  129691. export class WebGPUBufferManager {
  129692. private _device;
  129693. private _deferredReleaseBuffers;
  129694. private static _IsGPUBuffer;
  129695. constructor(device: GPUDevice);
  129696. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  129697. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  129698. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  129699. private _FromHalfFloat;
  129700. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  129701. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  129702. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  129703. destroyDeferredBuffers(): void;
  129704. }
  129705. }
  129706. declare module BABYLON {
  129707. /** @hidden */
  129708. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  129709. private _webgpuTexture;
  129710. private _webgpuMSAATexture;
  129711. get underlyingResource(): Nullable<GPUTexture>;
  129712. get msaaTexture(): Nullable<GPUTexture>;
  129713. set msaaTexture(texture: Nullable<GPUTexture>);
  129714. view: Nullable<GPUTextureView>;
  129715. format: GPUTextureFormat;
  129716. textureUsages: number;
  129717. constructor(existingTexture?: Nullable<GPUTexture>);
  129718. set(hardwareTexture: GPUTexture): void;
  129719. setMSAATexture(hardwareTexture: GPUTexture): void;
  129720. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  129721. createView(descriptor?: GPUTextureViewDescriptor): void;
  129722. reset(): void;
  129723. release(): void;
  129724. }
  129725. }
  129726. declare module BABYLON {
  129727. /** @hidden */
  129728. export class WebGPUTextureHelper {
  129729. private _device;
  129730. private _glslang;
  129731. private _bufferManager;
  129732. private _mipmapSampler;
  129733. private _invertYPreMultiplyAlphaSampler;
  129734. private _pipelines;
  129735. private _compiledShaders;
  129736. private _deferredReleaseTextures;
  129737. private _commandEncoderForCreation;
  129738. static ComputeNumMipmapLevels(width: number, height: number): number;
  129739. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  129740. private _getPipeline;
  129741. private static _GetTextureTypeFromFormat;
  129742. private static _GetBlockInformationFromFormat;
  129743. private static _IsHardwareTexture;
  129744. private static _IsInternalTexture;
  129745. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  129746. static IsImageBitmap(imageBitmap: ImageBitmap | {
  129747. width: number;
  129748. height: number;
  129749. }): imageBitmap is ImageBitmap;
  129750. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  129751. width: number;
  129752. height: number;
  129753. }): imageBitmap is ImageBitmap[];
  129754. setCommandEncoder(encoder: GPUCommandEncoder): void;
  129755. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  129756. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  129757. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129758. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  129759. createTexture(imageBitmap: ImageBitmap | {
  129760. width: number;
  129761. height: number;
  129762. layers: number;
  129763. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129764. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  129765. width: number;
  129766. height: number;
  129767. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129768. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  129769. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129770. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  129771. createMSAATexture(texture: InternalTexture, samples: number): void;
  129772. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  129773. updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  129774. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  129775. releaseTexture(texture: InternalTexture | GPUTexture): void;
  129776. destroyDeferredTextures(): void;
  129777. }
  129778. }
  129779. declare module BABYLON {
  129780. /** @hidden */
  129781. export class WebGPURenderPassWrapper {
  129782. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  129783. renderPass: Nullable<GPURenderPassEncoder>;
  129784. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129785. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129786. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  129787. depthTextureFormat: GPUTextureFormat | undefined;
  129788. constructor();
  129789. reset(fullReset?: boolean): void;
  129790. }
  129791. }
  129792. declare module BABYLON {
  129793. /** @hidden */
  129794. export class WebGPUCacheSampler {
  129795. private _samplers;
  129796. private _device;
  129797. disabled: boolean;
  129798. constructor(device: GPUDevice);
  129799. private static _GetSamplerHashCode;
  129800. private static _GetSamplerFilterDescriptor;
  129801. private static _GetWrappingMode;
  129802. private static _GetSamplerWrappingDescriptor;
  129803. private static _GetSamplerDescriptor;
  129804. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  129805. }
  129806. }
  129807. declare module BABYLON {
  129808. /** @hidden */
  129809. export class WebGPUShaderManager {
  129810. private _shaders;
  129811. private _device;
  129812. constructor(device: GPUDevice);
  129813. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  129814. }
  129815. }
  129816. declare module BABYLON {
  129817. /** @hidden */
  129818. export class WebGPUCacheRenderPipeline {
  129819. static NumCacheHitWithoutHash: number;
  129820. static NumCacheHitWithHash: number;
  129821. static NumCacheMiss: number;
  129822. static NumPipelineCreationLastFrame: number;
  129823. disabled: boolean;
  129824. private static _Cache;
  129825. private static _NumPipelineCreationCurrentFrame;
  129826. private _device;
  129827. private _states;
  129828. private _isDirty;
  129829. private _currentRenderPipeline;
  129830. private _emptyVertexBuffer;
  129831. private _shaderId;
  129832. private _alphaToCoverageEnabled;
  129833. private _frontFace;
  129834. private _cullEnabled;
  129835. private _cullFace;
  129836. private _clampDepth;
  129837. private _rasterizationState;
  129838. private _depthBias;
  129839. private _depthBiasClamp;
  129840. private _depthBiasSlopeScale;
  129841. private _colorFormat;
  129842. private _webgpuColorFormat;
  129843. private _mrtAttachments1;
  129844. private _mrtAttachments2;
  129845. private _mrtFormats;
  129846. private _alphaBlendEnabled;
  129847. private _alphaBlendFuncParams;
  129848. private _alphaBlendEqParams;
  129849. private _writeMask;
  129850. private _colorStates;
  129851. private _depthStencilFormat;
  129852. private _webgpuDepthStencilFormat;
  129853. private _depthTestEnabled;
  129854. private _depthWriteEnabled;
  129855. private _depthCompare;
  129856. private _stencilEnabled;
  129857. private _stencilFrontCompare;
  129858. private _stencilFrontDepthFailOp;
  129859. private _stencilFrontPassOp;
  129860. private _stencilFrontFailOp;
  129861. private _stencilReadMask;
  129862. private _stencilWriteMask;
  129863. private _depthStencilState;
  129864. private _vertexBuffers;
  129865. private _overrideVertexBuffers;
  129866. private _indexBuffer;
  129867. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  129868. reset(): void;
  129869. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  129870. endFrame(): void;
  129871. setAlphaToCoverage(enabled: boolean): void;
  129872. setFrontFace(frontFace: number): void;
  129873. setCullEnabled(enabled: boolean): void;
  129874. setCullFace(cullFace: number): void;
  129875. setClampDepth(clampDepth: boolean): void;
  129876. resetDepthCullingState(): void;
  129877. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  129878. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  129879. setColorFormat(format: GPUTextureFormat): void;
  129880. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  129881. setAlphaBlendEnabled(enabled: boolean): void;
  129882. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  129883. setWriteMask(mask: number): void;
  129884. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  129885. setDepthTestEnabled(enabled: boolean): void;
  129886. setDepthWriteEnabled(enabled: boolean): void;
  129887. setDepthCompare(func: Nullable<number>): void;
  129888. setStencilEnabled(enabled: boolean): void;
  129889. setStencilCompare(func: Nullable<number>): void;
  129890. setStencilDepthFailOp(op: Nullable<number>): void;
  129891. setStencilPassOp(op: Nullable<number>): void;
  129892. setStencilFailOp(op: Nullable<number>): void;
  129893. setStencilReadMask(mask: number): void;
  129894. setStencilWriteMask(mask: number): void;
  129895. resetStencilState(): void;
  129896. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  129897. setBuffers(vertexBuffers: Nullable<{
  129898. [key: string]: Nullable<VertexBuffer>;
  129899. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  129900. [key: string]: Nullable<VertexBuffer>;
  129901. }>): void;
  129902. private static _GetTopology;
  129903. private static _GetAphaBlendOperation;
  129904. private static _GetAphaBlendFactor;
  129905. private static _GetCompareFunction;
  129906. private static _GetStencilOpFunction;
  129907. private static _GetVertexInputDescriptorFormat;
  129908. private _getAphaBlendState;
  129909. private _getColorBlendState;
  129910. private _setShaderStage;
  129911. private _setRasterizationState;
  129912. private _setColorStates;
  129913. private _setDepthStencilState;
  129914. private _setVertexState;
  129915. private _createPipelineLayout;
  129916. private _getVertexInputDescriptor;
  129917. private _createRenderPipeline;
  129918. }
  129919. }
  129920. declare module BABYLON {
  129921. /** @hidden */
  129922. export var clearQuadVertexShader: {
  129923. name: string;
  129924. shader: string;
  129925. };
  129926. }
  129927. declare module BABYLON {
  129928. /** @hidden */
  129929. export var clearQuadPixelShader: {
  129930. name: string;
  129931. shader: string;
  129932. };
  129933. }
  129934. declare module BABYLON {
  129935. /**
  129936. * Options to load the associated Glslang library
  129937. */
  129938. export interface GlslangOptions {
  129939. /**
  129940. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  129941. */
  129942. glslang?: any;
  129943. /**
  129944. * Defines the URL of the glslang JS File.
  129945. */
  129946. jsPath?: string;
  129947. /**
  129948. * Defines the URL of the glslang WASM File.
  129949. */
  129950. wasmPath?: string;
  129951. }
  129952. /**
  129953. * Options to create the WebGPU engine
  129954. */
  129955. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  129956. /**
  129957. * If delta time between frames should be constant
  129958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129959. */
  129960. deterministicLockstep?: boolean;
  129961. /**
  129962. * Maximum about of steps between frames (Default: 4)
  129963. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129964. */
  129965. lockstepMaxSteps?: number;
  129966. /**
  129967. * Defines the seconds between each deterministic lock step
  129968. */
  129969. timeStep?: number;
  129970. /**
  129971. * Defines that engine should ignore modifying touch action attribute and style
  129972. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  129973. */
  129974. doNotHandleTouchAction?: boolean;
  129975. /**
  129976. * Defines if webaudio should be initialized as well
  129977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  129978. */
  129979. audioEngine?: boolean;
  129980. /**
  129981. * Defines the category of adapter to use.
  129982. * Is it the discrete or integrated device.
  129983. */
  129984. powerPreference?: GPUPowerPreference;
  129985. /**
  129986. * Defines the device descriptor used to create a device.
  129987. */
  129988. deviceDescriptor?: GPUDeviceDescriptor;
  129989. /**
  129990. * Defines the requested Swap Chain Format.
  129991. */
  129992. swapChainFormat?: GPUTextureFormat;
  129993. /**
  129994. * Defines wether MSAA is enabled on the canvas.
  129995. */
  129996. antialiasing?: boolean;
  129997. /**
  129998. * Defines wether the stencil buffer should be enabled.
  129999. */
  130000. stencil?: boolean;
  130001. /**
  130002. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  130003. */
  130004. enableGPUDebugMarkers?: boolean;
  130005. /**
  130006. * Options to load the associated Glslang library
  130007. */
  130008. glslangOptions?: GlslangOptions;
  130009. }
  130010. /**
  130011. * The web GPU engine class provides support for WebGPU version of babylon.js.
  130012. */
  130013. export class WebGPUEngine extends Engine {
  130014. private static readonly _glslangDefaultOptions;
  130015. private readonly _uploadEncoderDescriptor;
  130016. private readonly _renderEncoderDescriptor;
  130017. private readonly _renderTargetEncoderDescriptor;
  130018. private readonly _clearDepthValue;
  130019. private readonly _clearReverseDepthValue;
  130020. private readonly _clearStencilValue;
  130021. private readonly _defaultSampleCount;
  130022. private _canvas;
  130023. private _options;
  130024. private _glslang;
  130025. private _adapter;
  130026. private _adapterSupportedExtensions;
  130027. private _device;
  130028. private _deviceEnabledExtensions;
  130029. private _context;
  130030. private _swapChain;
  130031. private _swapChainTexture;
  130032. private _mainPassSampleCount;
  130033. private _textureHelper;
  130034. private _bufferManager;
  130035. private _shaderManager;
  130036. private _cacheSampler;
  130037. private _cacheRenderPipeline;
  130038. private _emptyVertexBuffer;
  130039. private _lastCachedWrapU;
  130040. private _lastCachedWrapV;
  130041. private _lastCachedWrapR;
  130042. private _mrtAttachments;
  130043. private _counters;
  130044. private _mainTexture;
  130045. private _depthTexture;
  130046. private _mainTextureExtends;
  130047. private _depthTextureFormat;
  130048. private _colorFormat;
  130049. private _uploadEncoder;
  130050. private _renderEncoder;
  130051. private _renderTargetEncoder;
  130052. private _commandBuffers;
  130053. private _currentRenderPass;
  130054. private _mainRenderPassWrapper;
  130055. private _rttRenderPassWrapper;
  130056. private _pendingDebugCommands;
  130057. private _currentVertexBuffers;
  130058. private _currentOverrideVertexBuffers;
  130059. private _currentIndexBuffer;
  130060. private __colorWrite;
  130061. private _uniformsBuffers;
  130062. private _forceEnableEffect;
  130063. /** @hidden */
  130064. dbgShowShaderCode: boolean;
  130065. /** @hidden */
  130066. dbgSanityChecks: boolean;
  130067. /** @hidden */
  130068. dbgGenerateLogs: boolean;
  130069. /** @hidden */
  130070. dbgVerboseLogsForFirstFrames: boolean;
  130071. /** @hidden */
  130072. dbgVerboseLogsNumFrames: number;
  130073. /** @hidden */
  130074. dbgShowWarningsNotImplemented: boolean;
  130075. /**
  130076. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  130077. */
  130078. get disableCacheSamplers(): boolean;
  130079. set disableCacheSamplers(disable: boolean);
  130080. /**
  130081. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  130082. */
  130083. get disableCacheRenderPipelines(): boolean;
  130084. set disableCacheRenderPipelines(disable: boolean);
  130085. /**
  130086. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  130087. * @returns true if the engine can be created
  130088. */
  130089. static get IsSupported(): boolean;
  130090. /**
  130091. * Gets a boolean indicating that the engine supports uniform buffers
  130092. */
  130093. get supportsUniformBuffers(): boolean;
  130094. /** Gets the supported extensions by the WebGPU adapter */
  130095. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  130096. /** Gets the currently enabled extensions on the WebGPU device */
  130097. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  130098. /**
  130099. * Returns the name of the engine
  130100. */
  130101. get name(): string;
  130102. /**
  130103. * Returns a string describing the current engine
  130104. */
  130105. get description(): string;
  130106. /**
  130107. * Returns the version of the engine
  130108. */
  130109. get version(): number;
  130110. /**
  130111. * Create a new instance of the gpu engine asynchronously
  130112. * @param canvas Defines the canvas to use to display the result
  130113. * @param options Defines the options passed to the engine to create the GPU context dependencies
  130114. * @returns a promise that resolves with the created engine
  130115. */
  130116. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  130117. /**
  130118. * Create a new instance of the gpu engine.
  130119. * @param canvas Defines the canvas to use to display the result
  130120. * @param options Defines the options passed to the engine to create the GPU context dependencies
  130121. */
  130122. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  130123. /**
  130124. * Initializes the WebGPU context and dependencies.
  130125. * @param glslangOptions Defines the GLSLang compiler options if necessary
  130126. * @returns a promise notifying the readiness of the engine.
  130127. */
  130128. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  130129. private _initGlslang;
  130130. private _initializeLimits;
  130131. private _initializeContextAndSwapChain;
  130132. private _initializeMainAttachments;
  130133. /**
  130134. * Force a specific size of the canvas
  130135. * @param width defines the new canvas' width
  130136. * @param height defines the new canvas' height
  130137. * @param forceSetSize true to force setting the sizes of the underlying canvas
  130138. * @returns true if the size was changed
  130139. */
  130140. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  130141. /**
  130142. * Gets a shader processor implementation fitting with the current engine type.
  130143. * @returns The shader processor implementation.
  130144. */
  130145. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  130146. /** @hidden */
  130147. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  130148. /**
  130149. * Force the entire cache to be cleared
  130150. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  130151. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130152. */
  130153. wipeCaches(bruteForce?: boolean): void;
  130154. /**
  130155. * Enable or disable color writing
  130156. * @param enable defines the state to set
  130157. */
  130158. setColorWrite(enable: boolean): void;
  130159. /**
  130160. * Gets a boolean indicating if color writing is enabled
  130161. * @returns the current color writing state
  130162. */
  130163. getColorWrite(): boolean;
  130164. private _viewportsCurrent;
  130165. private _resetCurrentViewport;
  130166. private _applyViewport;
  130167. /** @hidden */
  130168. _viewport(x: number, y: number, width: number, height: number): void;
  130169. private _scissorsCurrent;
  130170. protected _scissorCached: {
  130171. x: number;
  130172. y: number;
  130173. z: number;
  130174. w: number;
  130175. };
  130176. private _resetCurrentScissor;
  130177. private _applyScissor;
  130178. private _scissorIsActive;
  130179. enableScissor(x: number, y: number, width: number, height: number): void;
  130180. disableScissor(): void;
  130181. /**
  130182. * Clear the current render buffer or the current render target (if any is set up)
  130183. * @param color defines the color to use
  130184. * @param backBuffer defines if the back buffer must be cleared
  130185. * @param depth defines if the depth buffer must be cleared
  130186. * @param stencil defines if the stencil buffer must be cleared
  130187. */
  130188. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130189. /**
  130190. * Clears a list of attachments
  130191. * @param attachments list of the attachments
  130192. * @param colorMain clear color for the main attachment (the first one)
  130193. * @param colorOthers clear color for the other attachments
  130194. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  130195. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  130196. */
  130197. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  130198. /**
  130199. * Creates a vertex buffer
  130200. * @param data the data for the vertex buffer
  130201. * @returns the new buffer
  130202. */
  130203. createVertexBuffer(data: DataArray): DataBuffer;
  130204. /**
  130205. * Creates a vertex buffer
  130206. * @param data the data for the dynamic vertex buffer
  130207. * @returns the new buffer
  130208. */
  130209. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130210. /**
  130211. * Updates a vertex buffer.
  130212. * @param vertexBuffer the vertex buffer to update
  130213. * @param data the data used to update the vertex buffer
  130214. * @param byteOffset the byte offset of the data
  130215. * @param byteLength the byte length of the data
  130216. */
  130217. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130218. /**
  130219. * Creates a new index buffer
  130220. * @param indices defines the content of the index buffer
  130221. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  130222. * @returns a new buffer
  130223. */
  130224. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  130225. /**
  130226. * Update an index buffer
  130227. * @param indexBuffer defines the target index buffer
  130228. * @param indices defines the data to update
  130229. * @param offset defines the offset in the target index buffer where update should start
  130230. */
  130231. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130232. /** @hidden */
  130233. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  130234. /** @hidden */
  130235. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  130236. /**
  130237. * Bind a list of vertex buffers with the engine
  130238. * @param vertexBuffers defines the list of vertex buffers to bind
  130239. * @param indexBuffer defines the index buffer to bind
  130240. * @param effect defines the effect associated with the vertex buffers
  130241. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  130242. */
  130243. bindBuffers(vertexBuffers: {
  130244. [key: string]: Nullable<VertexBuffer>;
  130245. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  130246. [kind: string]: Nullable<VertexBuffer>;
  130247. }): void;
  130248. /** @hidden */
  130249. _releaseBuffer(buffer: DataBuffer): boolean;
  130250. createUniformBuffer(elements: FloatArray): DataBuffer;
  130251. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  130252. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  130253. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  130254. /**
  130255. * Create a new effect (used to store vertex/fragment shaders)
  130256. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  130257. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  130258. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  130259. * @param samplers defines an array of string used to represent textures
  130260. * @param defines defines the string containing the defines to use to compile the shaders
  130261. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  130262. * @param onCompiled defines a function to call when the effect creation is successful
  130263. * @param onError defines a function to call when the effect creation has failed
  130264. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  130265. * @returns the new Effect
  130266. */
  130267. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  130268. private _compileRawShaderToSpirV;
  130269. private _compileShaderToSpirV;
  130270. private _createPipelineStageDescriptor;
  130271. private _compileRawPipelineStageDescriptor;
  130272. private _compilePipelineStageDescriptor;
  130273. /** @hidden */
  130274. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  130275. /** @hidden */
  130276. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  130277. /**
  130278. * Creates a new pipeline context
  130279. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  130280. * @returns the new pipeline
  130281. */
  130282. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  130283. /** @hidden */
  130284. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  130285. /**
  130286. * Gets the list of active attributes for a given WebGPU program
  130287. * @param pipelineContext defines the pipeline context to use
  130288. * @param attributesNames defines the list of attribute names to get
  130289. * @returns an array of indices indicating the offset of each attribute
  130290. */
  130291. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130292. /**
  130293. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130294. * @param effect defines the effect to activate
  130295. */
  130296. enableEffect(effect: Nullable<Effect>): void;
  130297. /** @hidden */
  130298. _releaseEffect(effect: Effect): void;
  130299. /**
  130300. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  130301. */
  130302. releaseEffects(): void;
  130303. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  130304. /**
  130305. * Gets a boolean indicating that only power of 2 textures are supported
  130306. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  130307. */
  130308. get needPOTTextures(): boolean;
  130309. /** @hidden */
  130310. _createHardwareTexture(): HardwareTextureWrapper;
  130311. /** @hidden */
  130312. _releaseTexture(texture: InternalTexture): void;
  130313. /** @hidden */
  130314. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  130315. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  130316. /**
  130317. * Usually called from Texture.ts.
  130318. * Passed information to create a hardware texture
  130319. * @param url defines a value which contains one of the following:
  130320. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130321. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130322. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130323. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130324. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  130325. * @param scene needed for loading to the correct scene
  130326. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130327. * @param onLoad optional callback to be called upon successful completion
  130328. * @param onError optional callback to be called upon failure
  130329. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  130330. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130331. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130332. * @param forcedExtension defines the extension to use to pick the right loader
  130333. * @param mimeType defines an optional mime type
  130334. * @param loaderOptions options to be passed to the loader
  130335. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130336. */
  130337. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  130338. /** @hidden */
  130339. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  130340. /**
  130341. * Creates a cube texture
  130342. * @param rootUrl defines the url where the files to load is located
  130343. * @param scene defines the current scene
  130344. * @param files defines the list of files to load (1 per face)
  130345. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130346. * @param onLoad defines an optional callback raised when the texture is loaded
  130347. * @param onError defines an optional callback raised if there is an issue to load the texture
  130348. * @param format defines the format of the data
  130349. * @param forcedExtension defines the extension to use to pick the right loader
  130350. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130351. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130352. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130353. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130354. * @param loaderOptions options to be passed to the loader
  130355. * @returns the cube texture as an InternalTexture
  130356. */
  130357. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  130358. /**
  130359. * Creates a raw texture
  130360. * @param data defines the data to store in the texture
  130361. * @param width defines the width of the texture
  130362. * @param height defines the height of the texture
  130363. * @param format defines the format of the data
  130364. * @param generateMipMaps defines if the engine should generate the mip levels
  130365. * @param invertY defines if data must be stored with Y axis inverted
  130366. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  130367. * @param compression defines the compression used (null by default)
  130368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130369. * @returns the raw texture inside an InternalTexture
  130370. */
  130371. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  130372. /**
  130373. * Creates a new raw cube texture
  130374. * @param data defines the array of data to use to create each face
  130375. * @param size defines the size of the textures
  130376. * @param format defines the format of the data
  130377. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  130378. * @param generateMipMaps defines if the engine should generate the mip levels
  130379. * @param invertY defines if data must be stored with Y axis inverted
  130380. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130381. * @param compression defines the compression used (null by default)
  130382. * @returns the cube texture as an InternalTexture
  130383. */
  130384. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  130385. /**
  130386. * Creates a new raw cube texture from a specified url
  130387. * @param url defines the url where the data is located
  130388. * @param scene defines the current scene
  130389. * @param size defines the size of the textures
  130390. * @param format defines the format of the data
  130391. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  130392. * @param noMipmap defines if the engine should avoid generating the mip levels
  130393. * @param callback defines a callback used to extract texture data from loaded data
  130394. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  130395. * @param onLoad defines a callback called when texture is loaded
  130396. * @param onError defines a callback called if there is an error
  130397. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130398. * @param invertY defines if data must be stored with Y axis inverted
  130399. * @returns the cube texture as an InternalTexture
  130400. */
  130401. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  130402. /**
  130403. * Creates a new raw 2D array texture
  130404. * @param data defines the data used to create the texture
  130405. * @param width defines the width of the texture
  130406. * @param height defines the height of the texture
  130407. * @param depth defines the number of layers of the texture
  130408. * @param format defines the format of the texture
  130409. * @param generateMipMaps defines if the engine must generate mip levels
  130410. * @param invertY defines if data must be stored with Y axis inverted
  130411. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130412. * @param compression defines the compressed used (can be null)
  130413. * @param textureType defines the compressed used (can be null)
  130414. * @returns a new raw 2D array texture (stored in an InternalTexture)
  130415. */
  130416. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  130417. /**
  130418. * Creates a new raw 3D texture
  130419. * @param data defines the data used to create the texture
  130420. * @param width defines the width of the texture
  130421. * @param height defines the height of the texture
  130422. * @param depth defines the depth of the texture
  130423. * @param format defines the format of the texture
  130424. * @param generateMipMaps defines if the engine must generate mip levels
  130425. * @param invertY defines if data must be stored with Y axis inverted
  130426. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130427. * @param compression defines the compressed used (can be null)
  130428. * @param textureType defines the compressed used (can be null)
  130429. * @returns a new raw 3D texture (stored in an InternalTexture)
  130430. */
  130431. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  130432. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  130433. /**
  130434. * Update the sampling mode of a given texture
  130435. * @param samplingMode defines the required sampling mode
  130436. * @param texture defines the texture to update
  130437. * @param generateMipMaps defines whether to generate mipmaps for the texture
  130438. */
  130439. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  130440. /**
  130441. * Update the sampling mode of a given texture
  130442. * @param texture defines the texture to update
  130443. * @param wrapU defines the texture wrap mode of the u coordinates
  130444. * @param wrapV defines the texture wrap mode of the v coordinates
  130445. * @param wrapR defines the texture wrap mode of the r coordinates
  130446. */
  130447. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  130448. /**
  130449. * Update the dimensions of a texture
  130450. * @param texture texture to update
  130451. * @param width new width of the texture
  130452. * @param height new height of the texture
  130453. * @param depth new depth of the texture
  130454. */
  130455. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  130456. private _setInternalTexture;
  130457. /**
  130458. * Sets a texture to the according uniform.
  130459. * @param channel The texture channel
  130460. * @param unused unused parameter
  130461. * @param texture The texture to apply
  130462. * @param name The name of the uniform in the effect
  130463. */
  130464. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  130465. /**
  130466. * Sets an array of texture to the WebGPU context
  130467. * @param channel defines the channel where the texture array must be set
  130468. * @param unused unused parameter
  130469. * @param textures defines the array of textures to bind
  130470. * @param name name of the channel
  130471. */
  130472. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  130473. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  130474. /** @hidden */
  130475. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  130476. /** @hidden */
  130477. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  130478. private _generateMipmaps;
  130479. /**
  130480. * Update the content of a texture
  130481. * @param texture defines the texture to update
  130482. * @param canvas defines the source containing the data
  130483. * @param invertY defines if data must be stored with Y axis inverted
  130484. * @param premulAlpha defines if alpha is stored as premultiplied
  130485. * @param format defines the format of the data
  130486. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130487. */
  130488. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  130489. /**
  130490. * Update a portion of an internal texture
  130491. * @param texture defines the texture to update
  130492. * @param imageData defines the data to store into the texture
  130493. * @param xOffset defines the x coordinates of the update rectangle
  130494. * @param yOffset defines the y coordinates of the update rectangle
  130495. * @param width defines the width of the update rectangle
  130496. * @param height defines the height of the update rectangle
  130497. * @param faceIndex defines the face index if texture is a cube (0 by default)
  130498. * @param lod defines the lod level to update (0 by default)
  130499. */
  130500. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  130501. /**
  130502. * Update a video texture
  130503. * @param texture defines the texture to update
  130504. * @param video defines the video element to use
  130505. * @param invertY defines if data must be stored with Y axis inverted
  130506. */
  130507. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  130508. /** @hidden */
  130509. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130510. /** @hidden */
  130511. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  130512. /** @hidden */
  130513. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130514. /** @hidden */
  130515. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  130516. /**
  130517. * Update a raw texture
  130518. * @param texture defines the texture to update
  130519. * @param bufferView defines the data to store in the texture
  130520. * @param format defines the format of the data
  130521. * @param invertY defines if data must be stored with Y axis inverted
  130522. * @param compression defines the compression used (null by default)
  130523. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130524. */
  130525. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  130526. /**
  130527. * Update a raw cube texture
  130528. * @param texture defines the texture to udpdate
  130529. * @param bufferView defines the data to store
  130530. * @param format defines the data format
  130531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130532. * @param invertY defines if data must be stored with Y axis inverted
  130533. * @param compression defines the compression used (null by default)
  130534. * @param level defines which level of the texture to update
  130535. */
  130536. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  130537. /**
  130538. * Update a raw 2D array texture
  130539. * @param texture defines the texture to update
  130540. * @param bufferView defines the data to store
  130541. * @param format defines the data format
  130542. * @param invertY defines if data must be stored with Y axis inverted
  130543. * @param compression defines the used compression (can be null)
  130544. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130545. */
  130546. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  130547. /**
  130548. * Update a raw 3D texture
  130549. * @param texture defines the texture to update
  130550. * @param bufferView defines the data to store
  130551. * @param format defines the data format
  130552. * @param invertY defines if data must be stored with Y axis inverted
  130553. * @param compression defines the used compression (can be null)
  130554. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130555. */
  130556. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  130557. /**
  130558. * Reads pixels from the current frame buffer. Please note that this function can be slow
  130559. * @param x defines the x coordinate of the rectangle where pixels must be read
  130560. * @param y defines the y coordinate of the rectangle where pixels must be read
  130561. * @param width defines the width of the rectangle where pixels must be read
  130562. * @param height defines the height of the rectangle where pixels must be read
  130563. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  130564. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  130565. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  130566. */
  130567. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  130568. /** @hidden */
  130569. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  130570. /** @hidden */
  130571. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  130572. /**
  130573. * Creates a new render target texture
  130574. * @param size defines the size of the texture
  130575. * @param options defines the options used to create the texture
  130576. * @returns a new render target texture stored in an InternalTexture
  130577. */
  130578. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130579. /**
  130580. * Create a multi render target texture
  130581. * @param size defines the size of the texture
  130582. * @param options defines the creation options
  130583. * @returns the cube texture as an InternalTexture
  130584. */
  130585. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  130586. /**
  130587. * Creates a new render target cube texture
  130588. * @param size defines the size of the texture
  130589. * @param options defines the options used to create the texture
  130590. * @returns a new render target cube texture stored in an InternalTexture
  130591. */
  130592. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  130593. /** @hidden */
  130594. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  130595. width: number;
  130596. height: number;
  130597. layers?: number;
  130598. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  130599. /** @hidden */
  130600. _createDepthStencilTexture(size: number | {
  130601. width: number;
  130602. height: number;
  130603. layers?: number;
  130604. }, options: DepthTextureCreationOptions): InternalTexture;
  130605. /** @hidden */
  130606. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  130607. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  130608. /**
  130609. * Update the sample count for a given multiple render target texture
  130610. * @param textures defines the textures to update
  130611. * @param samples defines the sample count to set
  130612. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  130613. */
  130614. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  130615. /**
  130616. * Begin a new frame
  130617. */
  130618. beginFrame(): void;
  130619. /**
  130620. * End the current frame
  130621. */
  130622. endFrame(): void;
  130623. /**
  130624. * Force a WebGPU flush (ie. a flush of all waiting commands)
  130625. */
  130626. flushFramebuffer(): void;
  130627. private _startRenderTargetRenderPass;
  130628. private _endRenderTargetRenderPass;
  130629. private _getCurrentRenderPass;
  130630. private _startMainRenderPass;
  130631. private _endMainRenderPass;
  130632. /**
  130633. * Restores the WebGPU state to only draw on the main color attachment
  130634. */
  130635. restoreSingleAttachment(): void;
  130636. /**
  130637. * Creates a layout object to draw/clear on specific textures in a MRT
  130638. * @param textureStatus textureStatus[i] indicates if the i-th is active
  130639. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  130640. */
  130641. buildTextureLayout(textureStatus: boolean[]): number[];
  130642. /**
  130643. * Select a subsets of attachments to draw to.
  130644. * @param attachments index of attachments
  130645. */
  130646. bindAttachments(attachments: number[]): void;
  130647. /**
  130648. * Binds the frame buffer to the specified texture.
  130649. * @param texture The texture to render to or null for the default canvas
  130650. * @param faceIndex The face of the texture to render to in case of cube texture
  130651. * @param requiredWidth The width of the target to render to
  130652. * @param requiredHeight The height of the target to render to
  130653. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130654. * @param lodLevel defines the lod level to bind to the frame buffer
  130655. * @param layer defines the 2d array index to bind to frame buffer to
  130656. */
  130657. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  130658. /**
  130659. * Unbind the current render target texture from the WebGPU context
  130660. * @param texture defines the render target texture to unbind
  130661. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130662. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130663. */
  130664. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130665. /**
  130666. * Unbind a list of render target textures from the WebGPU context
  130667. * @param textures defines the render target textures to unbind
  130668. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130669. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130670. */
  130671. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130672. /**
  130673. * Unbind the current render target and bind the default framebuffer
  130674. */
  130675. restoreDefaultFramebuffer(): void;
  130676. setZOffset(value: number): void;
  130677. private _setColorFormat;
  130678. private _setDepthTextureFormat;
  130679. setDepthBuffer(enable: boolean): void;
  130680. setDepthWrite(enable: boolean): void;
  130681. setStencilBuffer(enable: boolean): void;
  130682. setStencilMask(mask: number): void;
  130683. setStencilFunction(stencilFunc: number): void;
  130684. setStencilFunctionReference(reference: number): void;
  130685. setStencilFunctionMask(mask: number): void;
  130686. setStencilOperationFail(operation: number): void;
  130687. setStencilOperationDepthFail(operation: number): void;
  130688. setStencilOperationPass(operation: number): void;
  130689. setDitheringState(value: boolean): void;
  130690. setRasterizerState(value: boolean): void;
  130691. setDepthFunction(depthFunc: number): void;
  130692. setDepthFunctionToGreater(): void;
  130693. setDepthFunctionToGreaterOrEqual(): void;
  130694. setDepthFunctionToLess(): void;
  130695. setDepthFunctionToLessOrEqual(): void;
  130696. /**
  130697. * Set various states to the context
  130698. * @param culling defines backface culling state
  130699. * @param zOffset defines the value to apply to zOffset (0 by default)
  130700. * @param force defines if states must be applied even if cache is up to date
  130701. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130702. */
  130703. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130704. /**
  130705. * Sets the current alpha mode
  130706. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130707. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130708. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130709. */
  130710. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130711. /**
  130712. * Sets the current alpha equation
  130713. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  130714. */
  130715. setAlphaEquation(equation: number): void;
  130716. private _getBindGroupsToRender;
  130717. private _bindVertexInputs;
  130718. private _setRenderBindGroups;
  130719. private _setRenderPipeline;
  130720. /**
  130721. * Draw a list of indexed primitives
  130722. * @param fillMode defines the primitive to use
  130723. * @param indexStart defines the starting index
  130724. * @param indexCount defines the number of index to draw
  130725. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130726. */
  130727. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130728. /**
  130729. * Draw a list of unindexed primitives
  130730. * @param fillMode defines the primitive to use
  130731. * @param verticesStart defines the index of first vertex to draw
  130732. * @param verticesCount defines the count of vertices to draw
  130733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130734. */
  130735. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130736. private _bundleEncoder;
  130737. /**
  130738. * Start recording all the gpu calls into a bundle.
  130739. */
  130740. startRecordBundle(): void;
  130741. /**
  130742. * Stops recording the bundle.
  130743. * @returns the recorded bundle
  130744. */
  130745. stopRecordBundle(): GPURenderBundle;
  130746. /**
  130747. * Execute the previously recorded bundle.
  130748. * @param bundles defines the bundle to replay
  130749. */
  130750. executeBundles(bundles: GPURenderBundle[]): void;
  130751. /**
  130752. * Dispose and release all associated resources
  130753. */
  130754. dispose(): void;
  130755. /**
  130756. * Gets the current render width
  130757. * @param useScreen defines if screen size must be used (or the current render target if any)
  130758. * @returns a number defining the current render width
  130759. */
  130760. getRenderWidth(useScreen?: boolean): number;
  130761. /**
  130762. * Gets the current render height
  130763. * @param useScreen defines if screen size must be used (or the current render target if any)
  130764. * @returns a number defining the current render height
  130765. */
  130766. getRenderHeight(useScreen?: boolean): number;
  130767. /**
  130768. * Gets the HTML canvas attached with the current WebGPU context
  130769. * @returns a HTML canvas
  130770. */
  130771. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  130772. /** @hidden */
  130773. _debugPushGroup(groupName: string, targetObject?: number): void;
  130774. /** @hidden */
  130775. _debugPopGroup(targetObject?: number): void;
  130776. /** @hidden */
  130777. _debugInsertMarker(text: string, targetObject?: number): void;
  130778. private _debugFlushPendingCommands;
  130779. /**
  130780. * Get the current error code of the WebGPU context
  130781. * @returns the error code
  130782. */
  130783. getError(): number;
  130784. /** @hidden */
  130785. bindSamplers(effect: Effect): void;
  130786. /** @hidden */
  130787. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  130788. /** @hidden */
  130789. _releaseFramebufferObjects(texture: InternalTexture): void;
  130790. /** @hidden */
  130791. applyStates(): void;
  130792. /**
  130793. * Gets a boolean indicating if all created effects are ready
  130794. * @returns always true - No parallel shader compilation
  130795. */
  130796. areAllEffectsReady(): boolean;
  130797. /** @hidden */
  130798. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130799. /** @hidden */
  130800. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130801. /** @hidden */
  130802. _getUnpackAlignement(): number;
  130803. /** @hidden */
  130804. _unpackFlipY(value: boolean): void;
  130805. /** @hidden */
  130806. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  130807. min: number;
  130808. mag: number;
  130809. };
  130810. /** @hidden */
  130811. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130812. /** @hidden */
  130813. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130814. /** @hidden */
  130815. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130816. /** @hidden */
  130817. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130818. /** @hidden */
  130819. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130820. /** @hidden */
  130821. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130822. /** @hidden */
  130823. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  130824. /** @hidden */
  130825. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  130826. /** @hidden */
  130827. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  130828. /** @hidden */
  130829. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  130830. /** @hidden */
  130831. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  130832. /** @hidden */
  130833. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130834. /** @hidden */
  130835. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130836. /** @hidden */
  130837. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  130838. /** @hidden */
  130839. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  130840. /** @hidden */
  130841. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  130842. /** @hidden */
  130843. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  130844. }
  130845. }
  130846. declare module BABYLON {
  130847. /**
  130848. * Define an interface for all classes that will hold resources
  130849. */
  130850. export interface IDisposable {
  130851. /**
  130852. * Releases all held resources
  130853. */
  130854. dispose(): void;
  130855. }
  130856. /** Interface defining initialization parameters for Scene class */
  130857. export interface SceneOptions {
  130858. /**
  130859. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  130860. * It will improve performance when the number of geometries becomes important.
  130861. */
  130862. useGeometryUniqueIdsMap?: boolean;
  130863. /**
  130864. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  130865. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130866. */
  130867. useMaterialMeshMap?: boolean;
  130868. /**
  130869. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  130870. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130871. */
  130872. useClonedMeshMap?: boolean;
  130873. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  130874. virtual?: boolean;
  130875. }
  130876. /**
  130877. * Represents a scene to be rendered by the engine.
  130878. * @see https://doc.babylonjs.com/features/scene
  130879. */
  130880. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  130881. /** The fog is deactivated */
  130882. static readonly FOGMODE_NONE: number;
  130883. /** The fog density is following an exponential function */
  130884. static readonly FOGMODE_EXP: number;
  130885. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  130886. static readonly FOGMODE_EXP2: number;
  130887. /** The fog density is following a linear function. */
  130888. static readonly FOGMODE_LINEAR: number;
  130889. /**
  130890. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  130891. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130892. */
  130893. static MinDeltaTime: number;
  130894. /**
  130895. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  130896. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130897. */
  130898. static MaxDeltaTime: number;
  130899. /**
  130900. * Factory used to create the default material.
  130901. * @param name The name of the material to create
  130902. * @param scene The scene to create the material for
  130903. * @returns The default material
  130904. */
  130905. static DefaultMaterialFactory(scene: Scene): Material;
  130906. /**
  130907. * Factory used to create the a collision coordinator.
  130908. * @returns The collision coordinator
  130909. */
  130910. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  130911. /** @hidden */
  130912. _inputManager: InputManager;
  130913. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  130914. cameraToUseForPointers: Nullable<Camera>;
  130915. /** @hidden */
  130916. readonly _isScene: boolean;
  130917. /** @hidden */
  130918. _blockEntityCollection: boolean;
  130919. /**
  130920. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  130921. */
  130922. autoClear: boolean;
  130923. /**
  130924. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  130925. */
  130926. autoClearDepthAndStencil: boolean;
  130927. /**
  130928. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  130929. */
  130930. clearColor: Color4;
  130931. /**
  130932. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  130933. */
  130934. ambientColor: Color3;
  130935. /**
  130936. * This is use to store the default BRDF lookup for PBR materials in your scene.
  130937. * It should only be one of the following (if not the default embedded one):
  130938. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  130939. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  130940. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  130941. * The material properties need to be setup according to the type of texture in use.
  130942. */
  130943. environmentBRDFTexture: BaseTexture;
  130944. /**
  130945. * Texture used in all pbr material as the reflection texture.
  130946. * As in the majority of the scene they are the same (exception for multi room and so on),
  130947. * this is easier to reference from here than from all the materials.
  130948. */
  130949. get environmentTexture(): Nullable<BaseTexture>;
  130950. /**
  130951. * Texture used in all pbr material as the reflection texture.
  130952. * As in the majority of the scene they are the same (exception for multi room and so on),
  130953. * this is easier to set here than in all the materials.
  130954. */
  130955. set environmentTexture(value: Nullable<BaseTexture>);
  130956. /** @hidden */
  130957. protected _environmentIntensity: number;
  130958. /**
  130959. * Intensity of the environment in all pbr material.
  130960. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130961. * As in the majority of the scene they are the same (exception for multi room and so on),
  130962. * this is easier to reference from here than from all the materials.
  130963. */
  130964. get environmentIntensity(): number;
  130965. /**
  130966. * Intensity of the environment in all pbr material.
  130967. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130968. * As in the majority of the scene they are the same (exception for multi room and so on),
  130969. * this is easier to set here than in all the materials.
  130970. */
  130971. set environmentIntensity(value: number);
  130972. /** @hidden */
  130973. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130974. /**
  130975. * Default image processing configuration used either in the rendering
  130976. * Forward main pass or through the imageProcessingPostProcess if present.
  130977. * As in the majority of the scene they are the same (exception for multi camera),
  130978. * this is easier to reference from here than from all the materials and post process.
  130979. *
  130980. * No setter as we it is a shared configuration, you can set the values instead.
  130981. */
  130982. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130983. private _forceWireframe;
  130984. /**
  130985. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  130986. */
  130987. set forceWireframe(value: boolean);
  130988. get forceWireframe(): boolean;
  130989. private _skipFrustumClipping;
  130990. /**
  130991. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  130992. */
  130993. set skipFrustumClipping(value: boolean);
  130994. get skipFrustumClipping(): boolean;
  130995. private _forcePointsCloud;
  130996. /**
  130997. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  130998. */
  130999. set forcePointsCloud(value: boolean);
  131000. get forcePointsCloud(): boolean;
  131001. /**
  131002. * Gets or sets the active clipplane 1
  131003. */
  131004. clipPlane: Nullable<Plane>;
  131005. /**
  131006. * Gets or sets the active clipplane 2
  131007. */
  131008. clipPlane2: Nullable<Plane>;
  131009. /**
  131010. * Gets or sets the active clipplane 3
  131011. */
  131012. clipPlane3: Nullable<Plane>;
  131013. /**
  131014. * Gets or sets the active clipplane 4
  131015. */
  131016. clipPlane4: Nullable<Plane>;
  131017. /**
  131018. * Gets or sets the active clipplane 5
  131019. */
  131020. clipPlane5: Nullable<Plane>;
  131021. /**
  131022. * Gets or sets the active clipplane 6
  131023. */
  131024. clipPlane6: Nullable<Plane>;
  131025. /**
  131026. * Gets or sets a boolean indicating if animations are enabled
  131027. */
  131028. animationsEnabled: boolean;
  131029. private _animationPropertiesOverride;
  131030. /**
  131031. * Gets or sets the animation properties override
  131032. */
  131033. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  131034. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  131035. /**
  131036. * Gets or sets a boolean indicating if a constant deltatime has to be used
  131037. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  131038. */
  131039. useConstantAnimationDeltaTime: boolean;
  131040. /**
  131041. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  131042. * Please note that it requires to run a ray cast through the scene on every frame
  131043. */
  131044. constantlyUpdateMeshUnderPointer: boolean;
  131045. /**
  131046. * Defines the HTML cursor to use when hovering over interactive elements
  131047. */
  131048. hoverCursor: string;
  131049. /**
  131050. * Defines the HTML default cursor to use (empty by default)
  131051. */
  131052. defaultCursor: string;
  131053. /**
  131054. * Defines whether cursors are handled by the scene.
  131055. */
  131056. doNotHandleCursors: boolean;
  131057. /**
  131058. * This is used to call preventDefault() on pointer down
  131059. * in order to block unwanted artifacts like system double clicks
  131060. */
  131061. preventDefaultOnPointerDown: boolean;
  131062. /**
  131063. * This is used to call preventDefault() on pointer up
  131064. * in order to block unwanted artifacts like system double clicks
  131065. */
  131066. preventDefaultOnPointerUp: boolean;
  131067. /**
  131068. * Gets or sets user defined metadata
  131069. */
  131070. metadata: any;
  131071. /**
  131072. * For internal use only. Please do not use.
  131073. */
  131074. reservedDataStore: any;
  131075. /**
  131076. * Gets the name of the plugin used to load this scene (null by default)
  131077. */
  131078. loadingPluginName: string;
  131079. /**
  131080. * Use this array to add regular expressions used to disable offline support for specific urls
  131081. */
  131082. disableOfflineSupportExceptionRules: RegExp[];
  131083. /**
  131084. * An event triggered when the scene is disposed.
  131085. */
  131086. onDisposeObservable: Observable<Scene>;
  131087. private _onDisposeObserver;
  131088. /** Sets a function to be executed when this scene is disposed. */
  131089. set onDispose(callback: () => void);
  131090. /**
  131091. * An event triggered before rendering the scene (right after animations and physics)
  131092. */
  131093. onBeforeRenderObservable: Observable<Scene>;
  131094. private _onBeforeRenderObserver;
  131095. /** Sets a function to be executed before rendering this scene */
  131096. set beforeRender(callback: Nullable<() => void>);
  131097. /**
  131098. * An event triggered after rendering the scene
  131099. */
  131100. onAfterRenderObservable: Observable<Scene>;
  131101. /**
  131102. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  131103. */
  131104. onAfterRenderCameraObservable: Observable<Camera>;
  131105. private _onAfterRenderObserver;
  131106. /** Sets a function to be executed after rendering this scene */
  131107. set afterRender(callback: Nullable<() => void>);
  131108. /**
  131109. * An event triggered before animating the scene
  131110. */
  131111. onBeforeAnimationsObservable: Observable<Scene>;
  131112. /**
  131113. * An event triggered after animations processing
  131114. */
  131115. onAfterAnimationsObservable: Observable<Scene>;
  131116. /**
  131117. * An event triggered before draw calls are ready to be sent
  131118. */
  131119. onBeforeDrawPhaseObservable: Observable<Scene>;
  131120. /**
  131121. * An event triggered after draw calls have been sent
  131122. */
  131123. onAfterDrawPhaseObservable: Observable<Scene>;
  131124. /**
  131125. * An event triggered when the scene is ready
  131126. */
  131127. onReadyObservable: Observable<Scene>;
  131128. /**
  131129. * An event triggered before rendering a camera
  131130. */
  131131. onBeforeCameraRenderObservable: Observable<Camera>;
  131132. private _onBeforeCameraRenderObserver;
  131133. /** Sets a function to be executed before rendering a camera*/
  131134. set beforeCameraRender(callback: () => void);
  131135. /**
  131136. * An event triggered after rendering a camera
  131137. */
  131138. onAfterCameraRenderObservable: Observable<Camera>;
  131139. private _onAfterCameraRenderObserver;
  131140. /** Sets a function to be executed after rendering a camera*/
  131141. set afterCameraRender(callback: () => void);
  131142. /**
  131143. * An event triggered when active meshes evaluation is about to start
  131144. */
  131145. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  131146. /**
  131147. * An event triggered when active meshes evaluation is done
  131148. */
  131149. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  131150. /**
  131151. * An event triggered when particles rendering is about to start
  131152. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  131153. */
  131154. onBeforeParticlesRenderingObservable: Observable<Scene>;
  131155. /**
  131156. * An event triggered when particles rendering is done
  131157. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  131158. */
  131159. onAfterParticlesRenderingObservable: Observable<Scene>;
  131160. /**
  131161. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  131162. */
  131163. onDataLoadedObservable: Observable<Scene>;
  131164. /**
  131165. * An event triggered when a camera is created
  131166. */
  131167. onNewCameraAddedObservable: Observable<Camera>;
  131168. /**
  131169. * An event triggered when a camera is removed
  131170. */
  131171. onCameraRemovedObservable: Observable<Camera>;
  131172. /**
  131173. * An event triggered when a light is created
  131174. */
  131175. onNewLightAddedObservable: Observable<Light>;
  131176. /**
  131177. * An event triggered when a light is removed
  131178. */
  131179. onLightRemovedObservable: Observable<Light>;
  131180. /**
  131181. * An event triggered when a geometry is created
  131182. */
  131183. onNewGeometryAddedObservable: Observable<Geometry>;
  131184. /**
  131185. * An event triggered when a geometry is removed
  131186. */
  131187. onGeometryRemovedObservable: Observable<Geometry>;
  131188. /**
  131189. * An event triggered when a transform node is created
  131190. */
  131191. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  131192. /**
  131193. * An event triggered when a transform node is removed
  131194. */
  131195. onTransformNodeRemovedObservable: Observable<TransformNode>;
  131196. /**
  131197. * An event triggered when a mesh is created
  131198. */
  131199. onNewMeshAddedObservable: Observable<AbstractMesh>;
  131200. /**
  131201. * An event triggered when a mesh is removed
  131202. */
  131203. onMeshRemovedObservable: Observable<AbstractMesh>;
  131204. /**
  131205. * An event triggered when a skeleton is created
  131206. */
  131207. onNewSkeletonAddedObservable: Observable<Skeleton>;
  131208. /**
  131209. * An event triggered when a skeleton is removed
  131210. */
  131211. onSkeletonRemovedObservable: Observable<Skeleton>;
  131212. /**
  131213. * An event triggered when a material is created
  131214. */
  131215. onNewMaterialAddedObservable: Observable<Material>;
  131216. /**
  131217. * An event triggered when a multi material is created
  131218. */
  131219. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  131220. /**
  131221. * An event triggered when a material is removed
  131222. */
  131223. onMaterialRemovedObservable: Observable<Material>;
  131224. /**
  131225. * An event triggered when a multi material is removed
  131226. */
  131227. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  131228. /**
  131229. * An event triggered when a texture is created
  131230. */
  131231. onNewTextureAddedObservable: Observable<BaseTexture>;
  131232. /**
  131233. * An event triggered when a texture is removed
  131234. */
  131235. onTextureRemovedObservable: Observable<BaseTexture>;
  131236. /**
  131237. * An event triggered when render targets are about to be rendered
  131238. * Can happen multiple times per frame.
  131239. */
  131240. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  131241. /**
  131242. * An event triggered when render targets were rendered.
  131243. * Can happen multiple times per frame.
  131244. */
  131245. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  131246. /**
  131247. * An event triggered before calculating deterministic simulation step
  131248. */
  131249. onBeforeStepObservable: Observable<Scene>;
  131250. /**
  131251. * An event triggered after calculating deterministic simulation step
  131252. */
  131253. onAfterStepObservable: Observable<Scene>;
  131254. /**
  131255. * An event triggered when the activeCamera property is updated
  131256. */
  131257. onActiveCameraChanged: Observable<Scene>;
  131258. /**
  131259. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  131260. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  131261. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  131262. */
  131263. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  131264. /**
  131265. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  131266. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  131267. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  131268. */
  131269. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  131270. /**
  131271. * This Observable will when a mesh has been imported into the scene.
  131272. */
  131273. onMeshImportedObservable: Observable<AbstractMesh>;
  131274. /**
  131275. * This Observable will when an animation file has been imported into the scene.
  131276. */
  131277. onAnimationFileImportedObservable: Observable<Scene>;
  131278. /**
  131279. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  131280. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  131281. */
  131282. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  131283. /** @hidden */
  131284. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  131285. /**
  131286. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  131287. */
  131288. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  131289. /**
  131290. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  131291. */
  131292. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  131293. /**
  131294. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  131295. */
  131296. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  131297. /** Callback called when a pointer move is detected */
  131298. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  131299. /** Callback called when a pointer down is detected */
  131300. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  131301. /** Callback called when a pointer up is detected */
  131302. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  131303. /** Callback called when a pointer pick is detected */
  131304. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  131305. /**
  131306. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  131307. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  131308. */
  131309. onPrePointerObservable: Observable<PointerInfoPre>;
  131310. /**
  131311. * Observable event triggered each time an input event is received from the rendering canvas
  131312. */
  131313. onPointerObservable: Observable<PointerInfo>;
  131314. /**
  131315. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  131316. */
  131317. get unTranslatedPointer(): Vector2;
  131318. /**
  131319. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  131320. */
  131321. static get DragMovementThreshold(): number;
  131322. static set DragMovementThreshold(value: number);
  131323. /**
  131324. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  131325. */
  131326. static get LongPressDelay(): number;
  131327. static set LongPressDelay(value: number);
  131328. /**
  131329. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  131330. */
  131331. static get DoubleClickDelay(): number;
  131332. static set DoubleClickDelay(value: number);
  131333. /** If you need to check double click without raising a single click at first click, enable this flag */
  131334. static get ExclusiveDoubleClickMode(): boolean;
  131335. static set ExclusiveDoubleClickMode(value: boolean);
  131336. /** @hidden */
  131337. _mirroredCameraPosition: Nullable<Vector3>;
  131338. /**
  131339. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  131340. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  131341. */
  131342. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  131343. /**
  131344. * Observable event triggered each time an keyboard event is received from the hosting window
  131345. */
  131346. onKeyboardObservable: Observable<KeyboardInfo>;
  131347. private _useRightHandedSystem;
  131348. /**
  131349. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  131350. */
  131351. set useRightHandedSystem(value: boolean);
  131352. get useRightHandedSystem(): boolean;
  131353. private _timeAccumulator;
  131354. private _currentStepId;
  131355. private _currentInternalStep;
  131356. /**
  131357. * Sets the step Id used by deterministic lock step
  131358. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131359. * @param newStepId defines the step Id
  131360. */
  131361. setStepId(newStepId: number): void;
  131362. /**
  131363. * Gets the step Id used by deterministic lock step
  131364. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131365. * @returns the step Id
  131366. */
  131367. getStepId(): number;
  131368. /**
  131369. * Gets the internal step used by deterministic lock step
  131370. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131371. * @returns the internal step
  131372. */
  131373. getInternalStep(): number;
  131374. private _fogEnabled;
  131375. /**
  131376. * Gets or sets a boolean indicating if fog is enabled on this scene
  131377. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131378. * (Default is true)
  131379. */
  131380. set fogEnabled(value: boolean);
  131381. get fogEnabled(): boolean;
  131382. private _fogMode;
  131383. /**
  131384. * Gets or sets the fog mode to use
  131385. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131386. * | mode | value |
  131387. * | --- | --- |
  131388. * | FOGMODE_NONE | 0 |
  131389. * | FOGMODE_EXP | 1 |
  131390. * | FOGMODE_EXP2 | 2 |
  131391. * | FOGMODE_LINEAR | 3 |
  131392. */
  131393. set fogMode(value: number);
  131394. get fogMode(): number;
  131395. /**
  131396. * Gets or sets the fog color to use
  131397. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131398. * (Default is Color3(0.2, 0.2, 0.3))
  131399. */
  131400. fogColor: Color3;
  131401. /**
  131402. * Gets or sets the fog density to use
  131403. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131404. * (Default is 0.1)
  131405. */
  131406. fogDensity: number;
  131407. /**
  131408. * Gets or sets the fog start distance to use
  131409. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131410. * (Default is 0)
  131411. */
  131412. fogStart: number;
  131413. /**
  131414. * Gets or sets the fog end distance to use
  131415. * @see https://doc.babylonjs.com/babylon101/environment#fog
  131416. * (Default is 1000)
  131417. */
  131418. fogEnd: number;
  131419. /**
  131420. * Flag indicating that the frame buffer binding is handled by another component
  131421. */
  131422. prePass: boolean;
  131423. private _shadowsEnabled;
  131424. /**
  131425. * Gets or sets a boolean indicating if shadows are enabled on this scene
  131426. */
  131427. set shadowsEnabled(value: boolean);
  131428. get shadowsEnabled(): boolean;
  131429. private _lightsEnabled;
  131430. /**
  131431. * Gets or sets a boolean indicating if lights are enabled on this scene
  131432. */
  131433. set lightsEnabled(value: boolean);
  131434. get lightsEnabled(): boolean;
  131435. /** All of the active cameras added to this scene. */
  131436. activeCameras: Nullable<Camera[]>;
  131437. /** @hidden */
  131438. _activeCamera: Nullable<Camera>;
  131439. /** Gets or sets the current active camera */
  131440. get activeCamera(): Nullable<Camera>;
  131441. set activeCamera(value: Nullable<Camera>);
  131442. private _defaultMaterial;
  131443. /** The default material used on meshes when no material is affected */
  131444. get defaultMaterial(): Material;
  131445. /** The default material used on meshes when no material is affected */
  131446. set defaultMaterial(value: Material);
  131447. private _texturesEnabled;
  131448. /**
  131449. * Gets or sets a boolean indicating if textures are enabled on this scene
  131450. */
  131451. set texturesEnabled(value: boolean);
  131452. get texturesEnabled(): boolean;
  131453. /**
  131454. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  131455. */
  131456. physicsEnabled: boolean;
  131457. /**
  131458. * Gets or sets a boolean indicating if particles are enabled on this scene
  131459. */
  131460. particlesEnabled: boolean;
  131461. /**
  131462. * Gets or sets a boolean indicating if sprites are enabled on this scene
  131463. */
  131464. spritesEnabled: boolean;
  131465. private _skeletonsEnabled;
  131466. /**
  131467. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  131468. */
  131469. set skeletonsEnabled(value: boolean);
  131470. get skeletonsEnabled(): boolean;
  131471. /**
  131472. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  131473. */
  131474. lensFlaresEnabled: boolean;
  131475. /**
  131476. * Gets or sets a boolean indicating if collisions are enabled on this scene
  131477. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  131478. */
  131479. collisionsEnabled: boolean;
  131480. private _collisionCoordinator;
  131481. /** @hidden */
  131482. get collisionCoordinator(): ICollisionCoordinator;
  131483. /**
  131484. * Defines the gravity applied to this scene (used only for collisions)
  131485. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  131486. */
  131487. gravity: Vector3;
  131488. /**
  131489. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  131490. */
  131491. postProcessesEnabled: boolean;
  131492. /**
  131493. * Gets the current postprocess manager
  131494. */
  131495. postProcessManager: PostProcessManager;
  131496. /**
  131497. * Gets or sets a boolean indicating if render targets are enabled on this scene
  131498. */
  131499. renderTargetsEnabled: boolean;
  131500. /**
  131501. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  131502. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  131503. */
  131504. dumpNextRenderTargets: boolean;
  131505. /**
  131506. * The list of user defined render targets added to the scene
  131507. */
  131508. customRenderTargets: RenderTargetTexture[];
  131509. /**
  131510. * Defines if texture loading must be delayed
  131511. * If true, textures will only be loaded when they need to be rendered
  131512. */
  131513. useDelayedTextureLoading: boolean;
  131514. /**
  131515. * Gets the list of meshes imported to the scene through SceneLoader
  131516. */
  131517. importedMeshesFiles: String[];
  131518. /**
  131519. * Gets or sets a boolean indicating if probes are enabled on this scene
  131520. */
  131521. probesEnabled: boolean;
  131522. /**
  131523. * Gets or sets the current offline provider to use to store scene data
  131524. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131525. */
  131526. offlineProvider: IOfflineProvider;
  131527. /**
  131528. * Gets or sets the action manager associated with the scene
  131529. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  131530. */
  131531. actionManager: AbstractActionManager;
  131532. private _meshesForIntersections;
  131533. /**
  131534. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  131535. */
  131536. proceduralTexturesEnabled: boolean;
  131537. private _engine;
  131538. private _totalVertices;
  131539. /** @hidden */
  131540. _activeIndices: PerfCounter;
  131541. /** @hidden */
  131542. _activeParticles: PerfCounter;
  131543. /** @hidden */
  131544. _activeBones: PerfCounter;
  131545. private _animationRatio;
  131546. /** @hidden */
  131547. _animationTimeLast: number;
  131548. /** @hidden */
  131549. _animationTime: number;
  131550. /**
  131551. * Gets or sets a general scale for animation speed
  131552. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  131553. */
  131554. animationTimeScale: number;
  131555. /** @hidden */
  131556. _cachedMaterial: Nullable<Material>;
  131557. /** @hidden */
  131558. _cachedEffect: Nullable<Effect>;
  131559. /** @hidden */
  131560. _cachedVisibility: Nullable<number>;
  131561. private _renderId;
  131562. private _frameId;
  131563. private _executeWhenReadyTimeoutId;
  131564. private _intermediateRendering;
  131565. private _viewUpdateFlag;
  131566. private _projectionUpdateFlag;
  131567. /** @hidden */
  131568. _toBeDisposed: Nullable<IDisposable>[];
  131569. private _activeRequests;
  131570. /** @hidden */
  131571. _pendingData: any[];
  131572. private _isDisposed;
  131573. /**
  131574. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  131575. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  131576. */
  131577. dispatchAllSubMeshesOfActiveMeshes: boolean;
  131578. private _activeMeshes;
  131579. private _processedMaterials;
  131580. private _renderTargets;
  131581. /** @hidden */
  131582. _activeParticleSystems: SmartArray<IParticleSystem>;
  131583. private _activeSkeletons;
  131584. private _softwareSkinnedMeshes;
  131585. private _renderingManager;
  131586. /** @hidden */
  131587. _activeAnimatables: Animatable[];
  131588. private _transformMatrix;
  131589. private _sceneUbo;
  131590. /** @hidden */
  131591. _viewMatrix: Matrix;
  131592. /** @hidden */
  131593. _projectionMatrix: Matrix;
  131594. /** @hidden */
  131595. _forcedViewPosition: Nullable<Vector3>;
  131596. /** @hidden */
  131597. _frustumPlanes: Plane[];
  131598. /**
  131599. * Gets the list of frustum planes (built from the active camera)
  131600. */
  131601. get frustumPlanes(): Plane[];
  131602. /**
  131603. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  131604. * This is useful if there are more lights that the maximum simulteanous authorized
  131605. */
  131606. requireLightSorting: boolean;
  131607. /** @hidden */
  131608. readonly useMaterialMeshMap: boolean;
  131609. /** @hidden */
  131610. readonly useClonedMeshMap: boolean;
  131611. private _externalData;
  131612. private _uid;
  131613. /**
  131614. * @hidden
  131615. * Backing store of defined scene components.
  131616. */
  131617. _components: ISceneComponent[];
  131618. /**
  131619. * @hidden
  131620. * Backing store of defined scene components.
  131621. */
  131622. _serializableComponents: ISceneSerializableComponent[];
  131623. /**
  131624. * List of components to register on the next registration step.
  131625. */
  131626. private _transientComponents;
  131627. /**
  131628. * Registers the transient components if needed.
  131629. */
  131630. private _registerTransientComponents;
  131631. /**
  131632. * @hidden
  131633. * Add a component to the scene.
  131634. * Note that the ccomponent could be registered on th next frame if this is called after
  131635. * the register component stage.
  131636. * @param component Defines the component to add to the scene
  131637. */
  131638. _addComponent(component: ISceneComponent): void;
  131639. /**
  131640. * @hidden
  131641. * Gets a component from the scene.
  131642. * @param name defines the name of the component to retrieve
  131643. * @returns the component or null if not present
  131644. */
  131645. _getComponent(name: string): Nullable<ISceneComponent>;
  131646. /**
  131647. * @hidden
  131648. * Defines the actions happening before camera updates.
  131649. */
  131650. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  131651. /**
  131652. * @hidden
  131653. * Defines the actions happening before clear the canvas.
  131654. */
  131655. _beforeClearStage: Stage<SimpleStageAction>;
  131656. /**
  131657. * @hidden
  131658. * Defines the actions when collecting render targets for the frame.
  131659. */
  131660. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  131661. /**
  131662. * @hidden
  131663. * Defines the actions happening for one camera in the frame.
  131664. */
  131665. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  131666. /**
  131667. * @hidden
  131668. * Defines the actions happening during the per mesh ready checks.
  131669. */
  131670. _isReadyForMeshStage: Stage<MeshStageAction>;
  131671. /**
  131672. * @hidden
  131673. * Defines the actions happening before evaluate active mesh checks.
  131674. */
  131675. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  131676. /**
  131677. * @hidden
  131678. * Defines the actions happening during the evaluate sub mesh checks.
  131679. */
  131680. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  131681. /**
  131682. * @hidden
  131683. * Defines the actions happening during the active mesh stage.
  131684. */
  131685. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  131686. /**
  131687. * @hidden
  131688. * Defines the actions happening during the per camera render target step.
  131689. */
  131690. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  131691. /**
  131692. * @hidden
  131693. * Defines the actions happening just before the active camera is drawing.
  131694. */
  131695. _beforeCameraDrawStage: Stage<CameraStageAction>;
  131696. /**
  131697. * @hidden
  131698. * Defines the actions happening just before a render target is drawing.
  131699. */
  131700. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  131701. /**
  131702. * @hidden
  131703. * Defines the actions happening just before a rendering group is drawing.
  131704. */
  131705. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  131706. /**
  131707. * @hidden
  131708. * Defines the actions happening just before a mesh is drawing.
  131709. */
  131710. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  131711. /**
  131712. * @hidden
  131713. * Defines the actions happening just after a mesh has been drawn.
  131714. */
  131715. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  131716. /**
  131717. * @hidden
  131718. * Defines the actions happening just after a rendering group has been drawn.
  131719. */
  131720. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  131721. /**
  131722. * @hidden
  131723. * Defines the actions happening just after the active camera has been drawn.
  131724. */
  131725. _afterCameraDrawStage: Stage<CameraStageAction>;
  131726. /**
  131727. * @hidden
  131728. * Defines the actions happening just after a render target has been drawn.
  131729. */
  131730. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  131731. /**
  131732. * @hidden
  131733. * Defines the actions happening just after rendering all cameras and computing intersections.
  131734. */
  131735. _afterRenderStage: Stage<SimpleStageAction>;
  131736. /**
  131737. * @hidden
  131738. * Defines the actions happening when a pointer move event happens.
  131739. */
  131740. _pointerMoveStage: Stage<PointerMoveStageAction>;
  131741. /**
  131742. * @hidden
  131743. * Defines the actions happening when a pointer down event happens.
  131744. */
  131745. _pointerDownStage: Stage<PointerUpDownStageAction>;
  131746. /**
  131747. * @hidden
  131748. * Defines the actions happening when a pointer up event happens.
  131749. */
  131750. _pointerUpStage: Stage<PointerUpDownStageAction>;
  131751. /**
  131752. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  131753. */
  131754. private geometriesByUniqueId;
  131755. private _renderBundles;
  131756. /**
  131757. * Creates a new Scene
  131758. * @param engine defines the engine to use to render this scene
  131759. * @param options defines the scene options
  131760. */
  131761. constructor(engine: Engine, options?: SceneOptions);
  131762. /**
  131763. * Gets a string identifying the name of the class
  131764. * @returns "Scene" string
  131765. */
  131766. getClassName(): string;
  131767. private _defaultMeshCandidates;
  131768. /**
  131769. * @hidden
  131770. */
  131771. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  131772. private _defaultSubMeshCandidates;
  131773. /**
  131774. * @hidden
  131775. */
  131776. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  131777. /**
  131778. * Sets the default candidate providers for the scene.
  131779. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  131780. * and getCollidingSubMeshCandidates to their default function
  131781. */
  131782. setDefaultCandidateProviders(): void;
  131783. /**
  131784. * Gets the mesh that is currently under the pointer
  131785. */
  131786. get meshUnderPointer(): Nullable<AbstractMesh>;
  131787. /**
  131788. * Gets or sets the current on-screen X position of the pointer
  131789. */
  131790. get pointerX(): number;
  131791. set pointerX(value: number);
  131792. /**
  131793. * Gets or sets the current on-screen Y position of the pointer
  131794. */
  131795. get pointerY(): number;
  131796. set pointerY(value: number);
  131797. /**
  131798. * Gets the cached material (ie. the latest rendered one)
  131799. * @returns the cached material
  131800. */
  131801. getCachedMaterial(): Nullable<Material>;
  131802. /**
  131803. * Gets the cached effect (ie. the latest rendered one)
  131804. * @returns the cached effect
  131805. */
  131806. getCachedEffect(): Nullable<Effect>;
  131807. /**
  131808. * Gets the cached visibility state (ie. the latest rendered one)
  131809. * @returns the cached visibility state
  131810. */
  131811. getCachedVisibility(): Nullable<number>;
  131812. /**
  131813. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  131814. * @param material defines the current material
  131815. * @param effect defines the current effect
  131816. * @param visibility defines the current visibility state
  131817. * @returns true if one parameter is not cached
  131818. */
  131819. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  131820. /**
  131821. * Gets the engine associated with the scene
  131822. * @returns an Engine
  131823. */
  131824. getEngine(): Engine;
  131825. /**
  131826. * Gets the total number of vertices rendered per frame
  131827. * @returns the total number of vertices rendered per frame
  131828. */
  131829. getTotalVertices(): number;
  131830. /**
  131831. * Gets the performance counter for total vertices
  131832. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131833. */
  131834. get totalVerticesPerfCounter(): PerfCounter;
  131835. /**
  131836. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  131837. * @returns the total number of active indices rendered per frame
  131838. */
  131839. getActiveIndices(): number;
  131840. /**
  131841. * Gets the performance counter for active indices
  131842. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131843. */
  131844. get totalActiveIndicesPerfCounter(): PerfCounter;
  131845. /**
  131846. * Gets the total number of active particles rendered per frame
  131847. * @returns the total number of active particles rendered per frame
  131848. */
  131849. getActiveParticles(): number;
  131850. /**
  131851. * Gets the performance counter for active particles
  131852. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131853. */
  131854. get activeParticlesPerfCounter(): PerfCounter;
  131855. /**
  131856. * Gets the total number of active bones rendered per frame
  131857. * @returns the total number of active bones rendered per frame
  131858. */
  131859. getActiveBones(): number;
  131860. /**
  131861. * Gets the performance counter for active bones
  131862. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131863. */
  131864. get activeBonesPerfCounter(): PerfCounter;
  131865. /**
  131866. * Gets the array of active meshes
  131867. * @returns an array of AbstractMesh
  131868. */
  131869. getActiveMeshes(): SmartArray<AbstractMesh>;
  131870. /**
  131871. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  131872. * @returns a number
  131873. */
  131874. getAnimationRatio(): number;
  131875. /**
  131876. * Gets an unique Id for the current render phase
  131877. * @returns a number
  131878. */
  131879. getRenderId(): number;
  131880. /**
  131881. * Gets an unique Id for the current frame
  131882. * @returns a number
  131883. */
  131884. getFrameId(): number;
  131885. /** Call this function if you want to manually increment the render Id*/
  131886. incrementRenderId(): void;
  131887. private _createUbo;
  131888. /**
  131889. * Use this method to simulate a pointer move on a mesh
  131890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131893. * @returns the current scene
  131894. */
  131895. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131896. /**
  131897. * Use this method to simulate a pointer down on a mesh
  131898. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131899. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131900. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131901. * @returns the current scene
  131902. */
  131903. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131904. /**
  131905. * Use this method to simulate a pointer up on a mesh
  131906. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131907. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131908. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131909. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  131910. * @returns the current scene
  131911. */
  131912. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  131913. /**
  131914. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  131915. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  131916. * @returns true if the pointer was captured
  131917. */
  131918. isPointerCaptured(pointerId?: number): boolean;
  131919. /**
  131920. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  131921. * @param attachUp defines if you want to attach events to pointerup
  131922. * @param attachDown defines if you want to attach events to pointerdown
  131923. * @param attachMove defines if you want to attach events to pointermove
  131924. */
  131925. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  131926. /** Detaches all event handlers*/
  131927. detachControl(): void;
  131928. /**
  131929. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  131930. * Delay loaded resources are not taking in account
  131931. * @return true if all required resources are ready
  131932. */
  131933. isReady(): boolean;
  131934. /** Resets all cached information relative to material (including effect and visibility) */
  131935. resetCachedMaterial(): void;
  131936. /**
  131937. * Registers a function to be called before every frame render
  131938. * @param func defines the function to register
  131939. */
  131940. registerBeforeRender(func: () => void): void;
  131941. /**
  131942. * Unregisters a function called before every frame render
  131943. * @param func defines the function to unregister
  131944. */
  131945. unregisterBeforeRender(func: () => void): void;
  131946. /**
  131947. * Registers a function to be called after every frame render
  131948. * @param func defines the function to register
  131949. */
  131950. registerAfterRender(func: () => void): void;
  131951. /**
  131952. * Unregisters a function called after every frame render
  131953. * @param func defines the function to unregister
  131954. */
  131955. unregisterAfterRender(func: () => void): void;
  131956. private _executeOnceBeforeRender;
  131957. /**
  131958. * The provided function will run before render once and will be disposed afterwards.
  131959. * A timeout delay can be provided so that the function will be executed in N ms.
  131960. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  131961. * @param func The function to be executed.
  131962. * @param timeout optional delay in ms
  131963. */
  131964. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  131965. /** @hidden */
  131966. _addPendingData(data: any): void;
  131967. /** @hidden */
  131968. _removePendingData(data: any): void;
  131969. /**
  131970. * Returns the number of items waiting to be loaded
  131971. * @returns the number of items waiting to be loaded
  131972. */
  131973. getWaitingItemsCount(): number;
  131974. /**
  131975. * Returns a boolean indicating if the scene is still loading data
  131976. */
  131977. get isLoading(): boolean;
  131978. /**
  131979. * Registers a function to be executed when the scene is ready
  131980. * @param {Function} func - the function to be executed
  131981. */
  131982. executeWhenReady(func: () => void): void;
  131983. /**
  131984. * Returns a promise that resolves when the scene is ready
  131985. * @returns A promise that resolves when the scene is ready
  131986. */
  131987. whenReadyAsync(): Promise<void>;
  131988. /** @hidden */
  131989. _checkIsReady(): void;
  131990. /**
  131991. * Gets all animatable attached to the scene
  131992. */
  131993. get animatables(): Animatable[];
  131994. /**
  131995. * Resets the last animation time frame.
  131996. * Useful to override when animations start running when loading a scene for the first time.
  131997. */
  131998. resetLastAnimationTimeFrame(): void;
  131999. /**
  132000. * Gets the current view matrix
  132001. * @returns a Matrix
  132002. */
  132003. getViewMatrix(): Matrix;
  132004. /**
  132005. * Gets the current projection matrix
  132006. * @returns a Matrix
  132007. */
  132008. getProjectionMatrix(): Matrix;
  132009. /**
  132010. * Gets the current transform matrix
  132011. * @returns a Matrix made of View * Projection
  132012. */
  132013. getTransformMatrix(): Matrix;
  132014. /**
  132015. * Sets the current transform matrix
  132016. * @param viewL defines the View matrix to use
  132017. * @param projectionL defines the Projection matrix to use
  132018. * @param viewR defines the right View matrix to use (if provided)
  132019. * @param projectionR defines the right Projection matrix to use (if provided)
  132020. */
  132021. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  132022. /**
  132023. * Gets the uniform buffer used to store scene data
  132024. * @returns a UniformBuffer
  132025. */
  132026. getSceneUniformBuffer(): UniformBuffer;
  132027. /**
  132028. * Gets an unique (relatively to the current scene) Id
  132029. * @returns an unique number for the scene
  132030. */
  132031. getUniqueId(): number;
  132032. /**
  132033. * Add a mesh to the list of scene's meshes
  132034. * @param newMesh defines the mesh to add
  132035. * @param recursive if all child meshes should also be added to the scene
  132036. */
  132037. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  132038. /**
  132039. * Remove a mesh for the list of scene's meshes
  132040. * @param toRemove defines the mesh to remove
  132041. * @param recursive if all child meshes should also be removed from the scene
  132042. * @returns the index where the mesh was in the mesh list
  132043. */
  132044. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  132045. /**
  132046. * Add a transform node to the list of scene's transform nodes
  132047. * @param newTransformNode defines the transform node to add
  132048. */
  132049. addTransformNode(newTransformNode: TransformNode): void;
  132050. /**
  132051. * Remove a transform node for the list of scene's transform nodes
  132052. * @param toRemove defines the transform node to remove
  132053. * @returns the index where the transform node was in the transform node list
  132054. */
  132055. removeTransformNode(toRemove: TransformNode): number;
  132056. /**
  132057. * Remove a skeleton for the list of scene's skeletons
  132058. * @param toRemove defines the skeleton to remove
  132059. * @returns the index where the skeleton was in the skeleton list
  132060. */
  132061. removeSkeleton(toRemove: Skeleton): number;
  132062. /**
  132063. * Remove a morph target for the list of scene's morph targets
  132064. * @param toRemove defines the morph target to remove
  132065. * @returns the index where the morph target was in the morph target list
  132066. */
  132067. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  132068. /**
  132069. * Remove a light for the list of scene's lights
  132070. * @param toRemove defines the light to remove
  132071. * @returns the index where the light was in the light list
  132072. */
  132073. removeLight(toRemove: Light): number;
  132074. /**
  132075. * Remove a camera for the list of scene's cameras
  132076. * @param toRemove defines the camera to remove
  132077. * @returns the index where the camera was in the camera list
  132078. */
  132079. removeCamera(toRemove: Camera): number;
  132080. /**
  132081. * Remove a particle system for the list of scene's particle systems
  132082. * @param toRemove defines the particle system to remove
  132083. * @returns the index where the particle system was in the particle system list
  132084. */
  132085. removeParticleSystem(toRemove: IParticleSystem): number;
  132086. /**
  132087. * Remove a animation for the list of scene's animations
  132088. * @param toRemove defines the animation to remove
  132089. * @returns the index where the animation was in the animation list
  132090. */
  132091. removeAnimation(toRemove: Animation): number;
  132092. /**
  132093. * Will stop the animation of the given target
  132094. * @param target - the target
  132095. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  132096. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  132097. */
  132098. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  132099. /**
  132100. * Removes the given animation group from this scene.
  132101. * @param toRemove The animation group to remove
  132102. * @returns The index of the removed animation group
  132103. */
  132104. removeAnimationGroup(toRemove: AnimationGroup): number;
  132105. /**
  132106. * Removes the given multi-material from this scene.
  132107. * @param toRemove The multi-material to remove
  132108. * @returns The index of the removed multi-material
  132109. */
  132110. removeMultiMaterial(toRemove: MultiMaterial): number;
  132111. /**
  132112. * Removes the given material from this scene.
  132113. * @param toRemove The material to remove
  132114. * @returns The index of the removed material
  132115. */
  132116. removeMaterial(toRemove: Material): number;
  132117. /**
  132118. * Removes the given action manager from this scene.
  132119. * @param toRemove The action manager to remove
  132120. * @returns The index of the removed action manager
  132121. */
  132122. removeActionManager(toRemove: AbstractActionManager): number;
  132123. /**
  132124. * Removes the given texture from this scene.
  132125. * @param toRemove The texture to remove
  132126. * @returns The index of the removed texture
  132127. */
  132128. removeTexture(toRemove: BaseTexture): number;
  132129. /**
  132130. * Adds the given light to this scene
  132131. * @param newLight The light to add
  132132. */
  132133. addLight(newLight: Light): void;
  132134. /**
  132135. * Sorts the list list based on light priorities
  132136. */
  132137. sortLightsByPriority(): void;
  132138. /**
  132139. * Adds the given camera to this scene
  132140. * @param newCamera The camera to add
  132141. */
  132142. addCamera(newCamera: Camera): void;
  132143. /**
  132144. * Adds the given skeleton to this scene
  132145. * @param newSkeleton The skeleton to add
  132146. */
  132147. addSkeleton(newSkeleton: Skeleton): void;
  132148. /**
  132149. * Adds the given particle system to this scene
  132150. * @param newParticleSystem The particle system to add
  132151. */
  132152. addParticleSystem(newParticleSystem: IParticleSystem): void;
  132153. /**
  132154. * Adds the given animation to this scene
  132155. * @param newAnimation The animation to add
  132156. */
  132157. addAnimation(newAnimation: Animation): void;
  132158. /**
  132159. * Adds the given animation group to this scene.
  132160. * @param newAnimationGroup The animation group to add
  132161. */
  132162. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  132163. /**
  132164. * Adds the given multi-material to this scene
  132165. * @param newMultiMaterial The multi-material to add
  132166. */
  132167. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  132168. /**
  132169. * Adds the given material to this scene
  132170. * @param newMaterial The material to add
  132171. */
  132172. addMaterial(newMaterial: Material): void;
  132173. /**
  132174. * Adds the given morph target to this scene
  132175. * @param newMorphTargetManager The morph target to add
  132176. */
  132177. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  132178. /**
  132179. * Adds the given geometry to this scene
  132180. * @param newGeometry The geometry to add
  132181. */
  132182. addGeometry(newGeometry: Geometry): void;
  132183. /**
  132184. * Adds the given action manager to this scene
  132185. * @param newActionManager The action manager to add
  132186. */
  132187. addActionManager(newActionManager: AbstractActionManager): void;
  132188. /**
  132189. * Adds the given texture to this scene.
  132190. * @param newTexture The texture to add
  132191. */
  132192. addTexture(newTexture: BaseTexture): void;
  132193. /**
  132194. * Switch active camera
  132195. * @param newCamera defines the new active camera
  132196. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  132197. */
  132198. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  132199. /**
  132200. * sets the active camera of the scene using its ID
  132201. * @param id defines the camera's ID
  132202. * @return the new active camera or null if none found.
  132203. */
  132204. setActiveCameraByID(id: string): Nullable<Camera>;
  132205. /**
  132206. * sets the active camera of the scene using its name
  132207. * @param name defines the camera's name
  132208. * @returns the new active camera or null if none found.
  132209. */
  132210. setActiveCameraByName(name: string): Nullable<Camera>;
  132211. /**
  132212. * get an animation group using its name
  132213. * @param name defines the material's name
  132214. * @return the animation group or null if none found.
  132215. */
  132216. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  132217. /**
  132218. * Get a material using its unique id
  132219. * @param uniqueId defines the material's unique id
  132220. * @return the material or null if none found.
  132221. */
  132222. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  132223. /**
  132224. * get a material using its id
  132225. * @param id defines the material's ID
  132226. * @return the material or null if none found.
  132227. */
  132228. getMaterialByID(id: string): Nullable<Material>;
  132229. /**
  132230. * Gets a the last added material using a given id
  132231. * @param id defines the material's ID
  132232. * @return the last material with the given id or null if none found.
  132233. */
  132234. getLastMaterialByID(id: string): Nullable<Material>;
  132235. /**
  132236. * Gets a material using its name
  132237. * @param name defines the material's name
  132238. * @return the material or null if none found.
  132239. */
  132240. getMaterialByName(name: string): Nullable<Material>;
  132241. /**
  132242. * Get a texture using its unique id
  132243. * @param uniqueId defines the texture's unique id
  132244. * @return the texture or null if none found.
  132245. */
  132246. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  132247. /**
  132248. * Gets a camera using its id
  132249. * @param id defines the id to look for
  132250. * @returns the camera or null if not found
  132251. */
  132252. getCameraByID(id: string): Nullable<Camera>;
  132253. /**
  132254. * Gets a camera using its unique id
  132255. * @param uniqueId defines the unique id to look for
  132256. * @returns the camera or null if not found
  132257. */
  132258. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  132259. /**
  132260. * Gets a camera using its name
  132261. * @param name defines the camera's name
  132262. * @return the camera or null if none found.
  132263. */
  132264. getCameraByName(name: string): Nullable<Camera>;
  132265. /**
  132266. * Gets a bone using its id
  132267. * @param id defines the bone's id
  132268. * @return the bone or null if not found
  132269. */
  132270. getBoneByID(id: string): Nullable<Bone>;
  132271. /**
  132272. * Gets a bone using its id
  132273. * @param name defines the bone's name
  132274. * @return the bone or null if not found
  132275. */
  132276. getBoneByName(name: string): Nullable<Bone>;
  132277. /**
  132278. * Gets a light node using its name
  132279. * @param name defines the the light's name
  132280. * @return the light or null if none found.
  132281. */
  132282. getLightByName(name: string): Nullable<Light>;
  132283. /**
  132284. * Gets a light node using its id
  132285. * @param id defines the light's id
  132286. * @return the light or null if none found.
  132287. */
  132288. getLightByID(id: string): Nullable<Light>;
  132289. /**
  132290. * Gets a light node using its scene-generated unique ID
  132291. * @param uniqueId defines the light's unique id
  132292. * @return the light or null if none found.
  132293. */
  132294. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  132295. /**
  132296. * Gets a particle system by id
  132297. * @param id defines the particle system id
  132298. * @return the corresponding system or null if none found
  132299. */
  132300. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  132301. /**
  132302. * Gets a geometry using its ID
  132303. * @param id defines the geometry's id
  132304. * @return the geometry or null if none found.
  132305. */
  132306. getGeometryByID(id: string): Nullable<Geometry>;
  132307. private _getGeometryByUniqueID;
  132308. /**
  132309. * Add a new geometry to this scene
  132310. * @param geometry defines the geometry to be added to the scene.
  132311. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  132312. * @return a boolean defining if the geometry was added or not
  132313. */
  132314. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  132315. /**
  132316. * Removes an existing geometry
  132317. * @param geometry defines the geometry to be removed from the scene
  132318. * @return a boolean defining if the geometry was removed or not
  132319. */
  132320. removeGeometry(geometry: Geometry): boolean;
  132321. /**
  132322. * Gets the list of geometries attached to the scene
  132323. * @returns an array of Geometry
  132324. */
  132325. getGeometries(): Geometry[];
  132326. /**
  132327. * Gets the first added mesh found of a given ID
  132328. * @param id defines the id to search for
  132329. * @return the mesh found or null if not found at all
  132330. */
  132331. getMeshByID(id: string): Nullable<AbstractMesh>;
  132332. /**
  132333. * Gets a list of meshes using their id
  132334. * @param id defines the id to search for
  132335. * @returns a list of meshes
  132336. */
  132337. getMeshesByID(id: string): Array<AbstractMesh>;
  132338. /**
  132339. * Gets the first added transform node found of a given ID
  132340. * @param id defines the id to search for
  132341. * @return the found transform node or null if not found at all.
  132342. */
  132343. getTransformNodeByID(id: string): Nullable<TransformNode>;
  132344. /**
  132345. * Gets a transform node with its auto-generated unique id
  132346. * @param uniqueId efines the unique id to search for
  132347. * @return the found transform node or null if not found at all.
  132348. */
  132349. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  132350. /**
  132351. * Gets a list of transform nodes using their id
  132352. * @param id defines the id to search for
  132353. * @returns a list of transform nodes
  132354. */
  132355. getTransformNodesByID(id: string): Array<TransformNode>;
  132356. /**
  132357. * Gets a mesh with its auto-generated unique id
  132358. * @param uniqueId defines the unique id to search for
  132359. * @return the found mesh or null if not found at all.
  132360. */
  132361. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  132362. /**
  132363. * Gets a the last added mesh using a given id
  132364. * @param id defines the id to search for
  132365. * @return the found mesh or null if not found at all.
  132366. */
  132367. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  132368. /**
  132369. * Gets a the last added node (Mesh, Camera, Light) using a given id
  132370. * @param id defines the id to search for
  132371. * @return the found node or null if not found at all
  132372. */
  132373. getLastEntryByID(id: string): Nullable<Node>;
  132374. /**
  132375. * Gets a node (Mesh, Camera, Light) using a given id
  132376. * @param id defines the id to search for
  132377. * @return the found node or null if not found at all
  132378. */
  132379. getNodeByID(id: string): Nullable<Node>;
  132380. /**
  132381. * Gets a node (Mesh, Camera, Light) using a given name
  132382. * @param name defines the name to search for
  132383. * @return the found node or null if not found at all.
  132384. */
  132385. getNodeByName(name: string): Nullable<Node>;
  132386. /**
  132387. * Gets a mesh using a given name
  132388. * @param name defines the name to search for
  132389. * @return the found mesh or null if not found at all.
  132390. */
  132391. getMeshByName(name: string): Nullable<AbstractMesh>;
  132392. /**
  132393. * Gets a transform node using a given name
  132394. * @param name defines the name to search for
  132395. * @return the found transform node or null if not found at all.
  132396. */
  132397. getTransformNodeByName(name: string): Nullable<TransformNode>;
  132398. /**
  132399. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  132400. * @param id defines the id to search for
  132401. * @return the found skeleton or null if not found at all.
  132402. */
  132403. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  132404. /**
  132405. * Gets a skeleton using a given auto generated unique id
  132406. * @param uniqueId defines the unique id to search for
  132407. * @return the found skeleton or null if not found at all.
  132408. */
  132409. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  132410. /**
  132411. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  132412. * @param id defines the id to search for
  132413. * @return the found skeleton or null if not found at all.
  132414. */
  132415. getSkeletonById(id: string): Nullable<Skeleton>;
  132416. /**
  132417. * Gets a skeleton using a given name
  132418. * @param name defines the name to search for
  132419. * @return the found skeleton or null if not found at all.
  132420. */
  132421. getSkeletonByName(name: string): Nullable<Skeleton>;
  132422. /**
  132423. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  132424. * @param id defines the id to search for
  132425. * @return the found morph target manager or null if not found at all.
  132426. */
  132427. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  132428. /**
  132429. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  132430. * @param id defines the id to search for
  132431. * @return the found morph target or null if not found at all.
  132432. */
  132433. getMorphTargetById(id: string): Nullable<MorphTarget>;
  132434. /**
  132435. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  132436. * @param name defines the name to search for
  132437. * @return the found morph target or null if not found at all.
  132438. */
  132439. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  132440. /**
  132441. * Gets a post process using a given name (if many are found, this function will pick the first one)
  132442. * @param name defines the name to search for
  132443. * @return the found post process or null if not found at all.
  132444. */
  132445. getPostProcessByName(name: string): Nullable<PostProcess>;
  132446. /**
  132447. * Gets a boolean indicating if the given mesh is active
  132448. * @param mesh defines the mesh to look for
  132449. * @returns true if the mesh is in the active list
  132450. */
  132451. isActiveMesh(mesh: AbstractMesh): boolean;
  132452. /**
  132453. * Return a unique id as a string which can serve as an identifier for the scene
  132454. */
  132455. get uid(): string;
  132456. /**
  132457. * Add an externaly attached data from its key.
  132458. * This method call will fail and return false, if such key already exists.
  132459. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  132460. * @param key the unique key that identifies the data
  132461. * @param data the data object to associate to the key for this Engine instance
  132462. * @return true if no such key were already present and the data was added successfully, false otherwise
  132463. */
  132464. addExternalData<T>(key: string, data: T): boolean;
  132465. /**
  132466. * Get an externaly attached data from its key
  132467. * @param key the unique key that identifies the data
  132468. * @return the associated data, if present (can be null), or undefined if not present
  132469. */
  132470. getExternalData<T>(key: string): Nullable<T>;
  132471. /**
  132472. * Get an externaly attached data from its key, create it using a factory if it's not already present
  132473. * @param key the unique key that identifies the data
  132474. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  132475. * @return the associated data, can be null if the factory returned null.
  132476. */
  132477. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  132478. /**
  132479. * Remove an externaly attached data from the Engine instance
  132480. * @param key the unique key that identifies the data
  132481. * @return true if the data was successfully removed, false if it doesn't exist
  132482. */
  132483. removeExternalData(key: string): boolean;
  132484. private _evaluateSubMesh;
  132485. /**
  132486. * Clear the processed materials smart array preventing retention point in material dispose.
  132487. */
  132488. freeProcessedMaterials(): void;
  132489. private _preventFreeActiveMeshesAndRenderingGroups;
  132490. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  132491. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  132492. * when disposing several meshes in a row or a hierarchy of meshes.
  132493. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  132494. */
  132495. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  132496. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  132497. /**
  132498. * Clear the active meshes smart array preventing retention point in mesh dispose.
  132499. */
  132500. freeActiveMeshes(): void;
  132501. /**
  132502. * Clear the info related to rendering groups preventing retention points during dispose.
  132503. */
  132504. freeRenderingGroups(): void;
  132505. /** @hidden */
  132506. _isInIntermediateRendering(): boolean;
  132507. /**
  132508. * Lambda returning the list of potentially active meshes.
  132509. */
  132510. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  132511. /**
  132512. * Lambda returning the list of potentially active sub meshes.
  132513. */
  132514. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  132515. /**
  132516. * Lambda returning the list of potentially intersecting sub meshes.
  132517. */
  132518. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  132519. /**
  132520. * Lambda returning the list of potentially colliding sub meshes.
  132521. */
  132522. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  132523. /** @hidden */
  132524. _activeMeshesFrozen: boolean;
  132525. private _skipEvaluateActiveMeshesCompletely;
  132526. /**
  132527. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  132528. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  132529. * @param onSuccess optional success callback
  132530. * @param onError optional error callback
  132531. * @returns the current scene
  132532. */
  132533. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  132534. /**
  132535. * Use this function to restart evaluating active meshes on every frame
  132536. * @returns the current scene
  132537. */
  132538. unfreezeActiveMeshes(): Scene;
  132539. private _evaluateActiveMeshes;
  132540. private _activeMesh;
  132541. /**
  132542. * Update the transform matrix to update from the current active camera
  132543. * @param force defines a boolean used to force the update even if cache is up to date
  132544. */
  132545. updateTransformMatrix(force?: boolean): void;
  132546. private _bindFrameBuffer;
  132547. /** @hidden */
  132548. _allowPostProcessClearColor: boolean;
  132549. /** @hidden */
  132550. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  132551. private _processSubCameras;
  132552. private _checkIntersections;
  132553. /** @hidden */
  132554. _advancePhysicsEngineStep(step: number): void;
  132555. /**
  132556. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  132557. */
  132558. getDeterministicFrameTime: () => number;
  132559. /** @hidden */
  132560. _animate(): void;
  132561. /** Execute all animations (for a frame) */
  132562. animate(): void;
  132563. /**
  132564. * Render the scene
  132565. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  132566. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  132567. */
  132568. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  132569. /**
  132570. * Freeze all materials
  132571. * A frozen material will not be updatable but should be faster to render
  132572. */
  132573. freezeMaterials(): void;
  132574. /**
  132575. * Unfreeze all materials
  132576. * A frozen material will not be updatable but should be faster to render
  132577. */
  132578. unfreezeMaterials(): void;
  132579. /**
  132580. * Releases all held ressources
  132581. */
  132582. dispose(): void;
  132583. /**
  132584. * Gets if the scene is already disposed
  132585. */
  132586. get isDisposed(): boolean;
  132587. /**
  132588. * Call this function to reduce memory footprint of the scene.
  132589. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  132590. */
  132591. clearCachedVertexData(): void;
  132592. /**
  132593. * This function will remove the local cached buffer data from texture.
  132594. * It will save memory but will prevent the texture from being rebuilt
  132595. */
  132596. cleanCachedTextureBuffer(): void;
  132597. /**
  132598. * Get the world extend vectors with an optional filter
  132599. *
  132600. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  132601. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  132602. */
  132603. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  132604. min: Vector3;
  132605. max: Vector3;
  132606. };
  132607. /**
  132608. * Creates a ray that can be used to pick in the scene
  132609. * @param x defines the x coordinate of the origin (on-screen)
  132610. * @param y defines the y coordinate of the origin (on-screen)
  132611. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  132612. * @param camera defines the camera to use for the picking
  132613. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  132614. * @returns a Ray
  132615. */
  132616. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  132617. /**
  132618. * Creates a ray that can be used to pick in the scene
  132619. * @param x defines the x coordinate of the origin (on-screen)
  132620. * @param y defines the y coordinate of the origin (on-screen)
  132621. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  132622. * @param result defines the ray where to store the picking ray
  132623. * @param camera defines the camera to use for the picking
  132624. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  132625. * @returns the current scene
  132626. */
  132627. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  132628. /**
  132629. * Creates a ray that can be used to pick in the scene
  132630. * @param x defines the x coordinate of the origin (on-screen)
  132631. * @param y defines the y coordinate of the origin (on-screen)
  132632. * @param camera defines the camera to use for the picking
  132633. * @returns a Ray
  132634. */
  132635. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  132636. /**
  132637. * Creates a ray that can be used to pick in the scene
  132638. * @param x defines the x coordinate of the origin (on-screen)
  132639. * @param y defines the y coordinate of the origin (on-screen)
  132640. * @param result defines the ray where to store the picking ray
  132641. * @param camera defines the camera to use for the picking
  132642. * @returns the current scene
  132643. */
  132644. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  132645. /** Launch a ray to try to pick a mesh in the scene
  132646. * @param x position on screen
  132647. * @param y position on screen
  132648. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  132649. * @param fastCheck defines if the first intersection will be used (and not the closest)
  132650. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132651. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132652. * @returns a PickingInfo
  132653. */
  132654. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  132655. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  132656. * @param x position on screen
  132657. * @param y position on screen
  132658. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  132659. * @param fastCheck defines if the first intersection will be used (and not the closest)
  132660. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132661. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  132662. */
  132663. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  132664. /** Use the given ray to pick a mesh in the scene
  132665. * @param ray The ray to use to pick meshes
  132666. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  132667. * @param fastCheck defines if the first intersection will be used (and not the closest)
  132668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132669. * @returns a PickingInfo
  132670. */
  132671. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  132672. /**
  132673. * Launch a ray to try to pick a mesh in the scene
  132674. * @param x X position on screen
  132675. * @param y Y position on screen
  132676. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  132677. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132678. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132679. * @returns an array of PickingInfo
  132680. */
  132681. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  132682. /**
  132683. * Launch a ray to try to pick a mesh in the scene
  132684. * @param ray Ray to use
  132685. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  132686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  132687. * @returns an array of PickingInfo
  132688. */
  132689. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  132690. /**
  132691. * Force the value of meshUnderPointer
  132692. * @param mesh defines the mesh to use
  132693. * @param pointerId optional pointer id when using more than one pointer
  132694. */
  132695. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  132696. /**
  132697. * Gets the mesh under the pointer
  132698. * @returns a Mesh or null if no mesh is under the pointer
  132699. */
  132700. getPointerOverMesh(): Nullable<AbstractMesh>;
  132701. /** @hidden */
  132702. _rebuildGeometries(): void;
  132703. /** @hidden */
  132704. _rebuildTextures(): void;
  132705. private _getByTags;
  132706. /**
  132707. * Get a list of meshes by tags
  132708. * @param tagsQuery defines the tags query to use
  132709. * @param forEach defines a predicate used to filter results
  132710. * @returns an array of Mesh
  132711. */
  132712. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  132713. /**
  132714. * Get a list of cameras by tags
  132715. * @param tagsQuery defines the tags query to use
  132716. * @param forEach defines a predicate used to filter results
  132717. * @returns an array of Camera
  132718. */
  132719. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  132720. /**
  132721. * Get a list of lights by tags
  132722. * @param tagsQuery defines the tags query to use
  132723. * @param forEach defines a predicate used to filter results
  132724. * @returns an array of Light
  132725. */
  132726. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  132727. /**
  132728. * Get a list of materials by tags
  132729. * @param tagsQuery defines the tags query to use
  132730. * @param forEach defines a predicate used to filter results
  132731. * @returns an array of Material
  132732. */
  132733. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  132734. /**
  132735. * Get a list of transform nodes by tags
  132736. * @param tagsQuery defines the tags query to use
  132737. * @param forEach defines a predicate used to filter results
  132738. * @returns an array of TransformNode
  132739. */
  132740. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  132741. /**
  132742. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  132743. * This allowed control for front to back rendering or reversly depending of the special needs.
  132744. *
  132745. * @param renderingGroupId The rendering group id corresponding to its index
  132746. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  132747. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  132748. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  132749. */
  132750. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  132751. /**
  132752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  132753. *
  132754. * @param renderingGroupId The rendering group id corresponding to its index
  132755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132756. * @param depth Automatically clears depth between groups if true and autoClear is true.
  132757. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  132758. */
  132759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  132760. /**
  132761. * Gets the current auto clear configuration for one rendering group of the rendering
  132762. * manager.
  132763. * @param index the rendering group index to get the information for
  132764. * @returns The auto clear setup for the requested rendering group
  132765. */
  132766. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  132767. private _blockMaterialDirtyMechanism;
  132768. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  132769. get blockMaterialDirtyMechanism(): boolean;
  132770. set blockMaterialDirtyMechanism(value: boolean);
  132771. /**
  132772. * Will flag all materials as dirty to trigger new shader compilation
  132773. * @param flag defines the flag used to specify which material part must be marked as dirty
  132774. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  132775. */
  132776. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  132777. /** @hidden */
  132778. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  132779. /** @hidden */
  132780. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  132781. /** @hidden */
  132782. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  132783. /** @hidden */
  132784. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  132785. /** @hidden */
  132786. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  132787. /** @hidden */
  132788. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  132789. }
  132790. }
  132791. declare module BABYLON {
  132792. /**
  132793. * Set of assets to keep when moving a scene into an asset container.
  132794. */
  132795. export class KeepAssets extends AbstractScene {
  132796. }
  132797. /**
  132798. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  132799. */
  132800. export class InstantiatedEntries {
  132801. /**
  132802. * List of new root nodes (eg. nodes with no parent)
  132803. */
  132804. rootNodes: TransformNode[];
  132805. /**
  132806. * List of new skeletons
  132807. */
  132808. skeletons: Skeleton[];
  132809. /**
  132810. * List of new animation groups
  132811. */
  132812. animationGroups: AnimationGroup[];
  132813. }
  132814. /**
  132815. * Container with a set of assets that can be added or removed from a scene.
  132816. */
  132817. export class AssetContainer extends AbstractScene {
  132818. private _wasAddedToScene;
  132819. /**
  132820. * The scene the AssetContainer belongs to.
  132821. */
  132822. scene: Scene;
  132823. /**
  132824. * Instantiates an AssetContainer.
  132825. * @param scene The scene the AssetContainer belongs to.
  132826. */
  132827. constructor(scene: Scene);
  132828. /**
  132829. * Instantiate or clone all meshes and add the new ones to the scene.
  132830. * Skeletons and animation groups will all be cloned
  132831. * @param nameFunction defines an optional function used to get new names for clones
  132832. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  132833. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  132834. */
  132835. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  132836. /**
  132837. * Adds all the assets from the container to the scene.
  132838. */
  132839. addAllToScene(): void;
  132840. /**
  132841. * Removes all the assets in the container from the scene
  132842. */
  132843. removeAllFromScene(): void;
  132844. /**
  132845. * Disposes all the assets in the container
  132846. */
  132847. dispose(): void;
  132848. private _moveAssets;
  132849. /**
  132850. * Removes all the assets contained in the scene and adds them to the container.
  132851. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  132852. */
  132853. moveAllFromScene(keepAssets?: KeepAssets): void;
  132854. /**
  132855. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  132856. * @returns the root mesh
  132857. */
  132858. createRootMesh(): Mesh;
  132859. /**
  132860. * Merge animations (direct and animation groups) from this asset container into a scene
  132861. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132862. * @param animatables set of animatables to retarget to a node from the scene
  132863. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  132864. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  132865. */
  132866. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  132867. }
  132868. }
  132869. declare module BABYLON {
  132870. /**
  132871. * Defines how the parser contract is defined.
  132872. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  132873. */
  132874. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  132875. /**
  132876. * Defines how the individual parser contract is defined.
  132877. * These parser can parse an individual asset
  132878. */
  132879. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  132880. /**
  132881. * Base class of the scene acting as a container for the different elements composing a scene.
  132882. * This class is dynamically extended by the different components of the scene increasing
  132883. * flexibility and reducing coupling
  132884. */
  132885. export abstract class AbstractScene {
  132886. /**
  132887. * Stores the list of available parsers in the application.
  132888. */
  132889. private static _BabylonFileParsers;
  132890. /**
  132891. * Stores the list of available individual parsers in the application.
  132892. */
  132893. private static _IndividualBabylonFileParsers;
  132894. /**
  132895. * Adds a parser in the list of available ones
  132896. * @param name Defines the name of the parser
  132897. * @param parser Defines the parser to add
  132898. */
  132899. static AddParser(name: string, parser: BabylonFileParser): void;
  132900. /**
  132901. * Gets a general parser from the list of avaialble ones
  132902. * @param name Defines the name of the parser
  132903. * @returns the requested parser or null
  132904. */
  132905. static GetParser(name: string): Nullable<BabylonFileParser>;
  132906. /**
  132907. * Adds n individual parser in the list of available ones
  132908. * @param name Defines the name of the parser
  132909. * @param parser Defines the parser to add
  132910. */
  132911. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  132912. /**
  132913. * Gets an individual parser from the list of avaialble ones
  132914. * @param name Defines the name of the parser
  132915. * @returns the requested parser or null
  132916. */
  132917. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  132918. /**
  132919. * Parser json data and populate both a scene and its associated container object
  132920. * @param jsonData Defines the data to parse
  132921. * @param scene Defines the scene to parse the data for
  132922. * @param container Defines the container attached to the parsing sequence
  132923. * @param rootUrl Defines the root url of the data
  132924. */
  132925. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  132926. /**
  132927. * Gets the list of root nodes (ie. nodes with no parent)
  132928. */
  132929. rootNodes: Node[];
  132930. /** All of the cameras added to this scene
  132931. * @see https://doc.babylonjs.com/babylon101/cameras
  132932. */
  132933. cameras: Camera[];
  132934. /**
  132935. * All of the lights added to this scene
  132936. * @see https://doc.babylonjs.com/babylon101/lights
  132937. */
  132938. lights: Light[];
  132939. /**
  132940. * All of the (abstract) meshes added to this scene
  132941. */
  132942. meshes: AbstractMesh[];
  132943. /**
  132944. * The list of skeletons added to the scene
  132945. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  132946. */
  132947. skeletons: Skeleton[];
  132948. /**
  132949. * All of the particle systems added to this scene
  132950. * @see https://doc.babylonjs.com/babylon101/particles
  132951. */
  132952. particleSystems: IParticleSystem[];
  132953. /**
  132954. * Gets a list of Animations associated with the scene
  132955. */
  132956. animations: Animation[];
  132957. /**
  132958. * All of the animation groups added to this scene
  132959. * @see https://doc.babylonjs.com/how_to/group
  132960. */
  132961. animationGroups: AnimationGroup[];
  132962. /**
  132963. * All of the multi-materials added to this scene
  132964. * @see https://doc.babylonjs.com/how_to/multi_materials
  132965. */
  132966. multiMaterials: MultiMaterial[];
  132967. /**
  132968. * All of the materials added to this scene
  132969. * In the context of a Scene, it is not supposed to be modified manually.
  132970. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  132971. * Note also that the order of the Material within the array is not significant and might change.
  132972. * @see https://doc.babylonjs.com/babylon101/materials
  132973. */
  132974. materials: Material[];
  132975. /**
  132976. * The list of morph target managers added to the scene
  132977. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  132978. */
  132979. morphTargetManagers: MorphTargetManager[];
  132980. /**
  132981. * The list of geometries used in the scene.
  132982. */
  132983. geometries: Geometry[];
  132984. /**
  132985. * All of the tranform nodes added to this scene
  132986. * In the context of a Scene, it is not supposed to be modified manually.
  132987. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  132988. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  132989. * @see https://doc.babylonjs.com/how_to/transformnode
  132990. */
  132991. transformNodes: TransformNode[];
  132992. /**
  132993. * ActionManagers available on the scene.
  132994. */
  132995. actionManagers: AbstractActionManager[];
  132996. /**
  132997. * Textures to keep.
  132998. */
  132999. textures: BaseTexture[];
  133000. /** @hidden */
  133001. protected _environmentTexture: Nullable<BaseTexture>;
  133002. /**
  133003. * Texture used in all pbr material as the reflection texture.
  133004. * As in the majority of the scene they are the same (exception for multi room and so on),
  133005. * this is easier to reference from here than from all the materials.
  133006. */
  133007. get environmentTexture(): Nullable<BaseTexture>;
  133008. set environmentTexture(value: Nullable<BaseTexture>);
  133009. /**
  133010. * The list of postprocesses added to the scene
  133011. */
  133012. postProcesses: PostProcess[];
  133013. /**
  133014. * @returns all meshes, lights, cameras, transformNodes and bones
  133015. */
  133016. getNodes(): Array<Node>;
  133017. }
  133018. }
  133019. declare module BABYLON {
  133020. /**
  133021. * Interface used to define options for Sound class
  133022. */
  133023. export interface ISoundOptions {
  133024. /**
  133025. * Does the sound autoplay once loaded.
  133026. */
  133027. autoplay?: boolean;
  133028. /**
  133029. * Does the sound loop after it finishes playing once.
  133030. */
  133031. loop?: boolean;
  133032. /**
  133033. * Sound's volume
  133034. */
  133035. volume?: number;
  133036. /**
  133037. * Is it a spatial sound?
  133038. */
  133039. spatialSound?: boolean;
  133040. /**
  133041. * Maximum distance to hear that sound
  133042. */
  133043. maxDistance?: number;
  133044. /**
  133045. * Uses user defined attenuation function
  133046. */
  133047. useCustomAttenuation?: boolean;
  133048. /**
  133049. * Define the roll off factor of spatial sounds.
  133050. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133051. */
  133052. rolloffFactor?: number;
  133053. /**
  133054. * Define the reference distance the sound should be heard perfectly.
  133055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133056. */
  133057. refDistance?: number;
  133058. /**
  133059. * Define the distance attenuation model the sound will follow.
  133060. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133061. */
  133062. distanceModel?: string;
  133063. /**
  133064. * Defines the playback speed (1 by default)
  133065. */
  133066. playbackRate?: number;
  133067. /**
  133068. * Defines if the sound is from a streaming source
  133069. */
  133070. streaming?: boolean;
  133071. /**
  133072. * Defines an optional length (in seconds) inside the sound file
  133073. */
  133074. length?: number;
  133075. /**
  133076. * Defines an optional offset (in seconds) inside the sound file
  133077. */
  133078. offset?: number;
  133079. /**
  133080. * If true, URLs will not be required to state the audio file codec to use.
  133081. */
  133082. skipCodecCheck?: boolean;
  133083. }
  133084. }
  133085. declare module BABYLON {
  133086. /**
  133087. * Defines a sound that can be played in the application.
  133088. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  133089. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133090. */
  133091. export class Sound {
  133092. /**
  133093. * The name of the sound in the scene.
  133094. */
  133095. name: string;
  133096. /**
  133097. * Does the sound autoplay once loaded.
  133098. */
  133099. autoplay: boolean;
  133100. private _loop;
  133101. /**
  133102. * Does the sound loop after it finishes playing once.
  133103. */
  133104. get loop(): boolean;
  133105. set loop(value: boolean);
  133106. /**
  133107. * Does the sound use a custom attenuation curve to simulate the falloff
  133108. * happening when the source gets further away from the camera.
  133109. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  133110. */
  133111. useCustomAttenuation: boolean;
  133112. /**
  133113. * The sound track id this sound belongs to.
  133114. */
  133115. soundTrackId: number;
  133116. /**
  133117. * Is this sound currently played.
  133118. */
  133119. isPlaying: boolean;
  133120. /**
  133121. * Is this sound currently paused.
  133122. */
  133123. isPaused: boolean;
  133124. /**
  133125. * Does this sound enables spatial sound.
  133126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133127. */
  133128. spatialSound: boolean;
  133129. /**
  133130. * Define the reference distance the sound should be heard perfectly.
  133131. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133132. */
  133133. refDistance: number;
  133134. /**
  133135. * Define the roll off factor of spatial sounds.
  133136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133137. */
  133138. rolloffFactor: number;
  133139. /**
  133140. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  133141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133142. */
  133143. maxDistance: number;
  133144. /**
  133145. * Define the distance attenuation model the sound will follow.
  133146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133147. */
  133148. distanceModel: string;
  133149. /**
  133150. * @hidden
  133151. * Back Compat
  133152. **/
  133153. onended: () => any;
  133154. /**
  133155. * Gets or sets an object used to store user defined information for the sound.
  133156. */
  133157. metadata: any;
  133158. /**
  133159. * Observable event when the current playing sound finishes.
  133160. */
  133161. onEndedObservable: Observable<Sound>;
  133162. /**
  133163. * Gets the current time for the sound.
  133164. */
  133165. get currentTime(): number;
  133166. private _panningModel;
  133167. private _playbackRate;
  133168. private _streaming;
  133169. private _startTime;
  133170. private _startOffset;
  133171. private _position;
  133172. /** @hidden */
  133173. _positionInEmitterSpace: boolean;
  133174. private _localDirection;
  133175. private _volume;
  133176. private _isReadyToPlay;
  133177. private _isDirectional;
  133178. private _readyToPlayCallback;
  133179. private _audioBuffer;
  133180. private _soundSource;
  133181. private _streamingSource;
  133182. private _soundPanner;
  133183. private _soundGain;
  133184. private _inputAudioNode;
  133185. private _outputAudioNode;
  133186. private _coneInnerAngle;
  133187. private _coneOuterAngle;
  133188. private _coneOuterGain;
  133189. private _scene;
  133190. private _connectedTransformNode;
  133191. private _customAttenuationFunction;
  133192. private _registerFunc;
  133193. private _isOutputConnected;
  133194. private _htmlAudioElement;
  133195. private _urlType;
  133196. private _length?;
  133197. private _offset?;
  133198. /** @hidden */
  133199. static _SceneComponentInitialization: (scene: Scene) => void;
  133200. /**
  133201. * Create a sound and attach it to a scene
  133202. * @param name Name of your sound
  133203. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  133204. * @param scene defines the scene the sound belongs to
  133205. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  133206. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  133207. */
  133208. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  133209. /**
  133210. * Release the sound and its associated resources
  133211. */
  133212. dispose(): void;
  133213. /**
  133214. * Gets if the sounds is ready to be played or not.
  133215. * @returns true if ready, otherwise false
  133216. */
  133217. isReady(): boolean;
  133218. /**
  133219. * Get the current class name.
  133220. * @returns current class name
  133221. */
  133222. getClassName(): string;
  133223. private _soundLoaded;
  133224. /**
  133225. * Sets the data of the sound from an audiobuffer
  133226. * @param audioBuffer The audioBuffer containing the data
  133227. */
  133228. setAudioBuffer(audioBuffer: AudioBuffer): void;
  133229. /**
  133230. * Updates the current sounds options such as maxdistance, loop...
  133231. * @param options A JSON object containing values named as the object properties
  133232. */
  133233. updateOptions(options: ISoundOptions): void;
  133234. private _createSpatialParameters;
  133235. private _updateSpatialParameters;
  133236. /**
  133237. * Switch the panning model to HRTF:
  133238. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  133239. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133240. */
  133241. switchPanningModelToHRTF(): void;
  133242. /**
  133243. * Switch the panning model to Equal Power:
  133244. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  133245. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133246. */
  133247. switchPanningModelToEqualPower(): void;
  133248. private _switchPanningModel;
  133249. /**
  133250. * Connect this sound to a sound track audio node like gain...
  133251. * @param soundTrackAudioNode the sound track audio node to connect to
  133252. */
  133253. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  133254. /**
  133255. * Transform this sound into a directional source
  133256. * @param coneInnerAngle Size of the inner cone in degree
  133257. * @param coneOuterAngle Size of the outer cone in degree
  133258. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  133259. */
  133260. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  133261. /**
  133262. * Gets or sets the inner angle for the directional cone.
  133263. */
  133264. get directionalConeInnerAngle(): number;
  133265. /**
  133266. * Gets or sets the inner angle for the directional cone.
  133267. */
  133268. set directionalConeInnerAngle(value: number);
  133269. /**
  133270. * Gets or sets the outer angle for the directional cone.
  133271. */
  133272. get directionalConeOuterAngle(): number;
  133273. /**
  133274. * Gets or sets the outer angle for the directional cone.
  133275. */
  133276. set directionalConeOuterAngle(value: number);
  133277. /**
  133278. * Sets the position of the emitter if spatial sound is enabled
  133279. * @param newPosition Defines the new posisiton
  133280. */
  133281. setPosition(newPosition: Vector3): void;
  133282. /**
  133283. * Sets the local direction of the emitter if spatial sound is enabled
  133284. * @param newLocalDirection Defines the new local direction
  133285. */
  133286. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  133287. private _updateDirection;
  133288. /** @hidden */
  133289. updateDistanceFromListener(): void;
  133290. /**
  133291. * Sets a new custom attenuation function for the sound.
  133292. * @param callback Defines the function used for the attenuation
  133293. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  133294. */
  133295. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  133296. /**
  133297. * Play the sound
  133298. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  133299. * @param offset (optional) Start the sound at a specific time in seconds
  133300. * @param length (optional) Sound duration (in seconds)
  133301. */
  133302. play(time?: number, offset?: number, length?: number): void;
  133303. private _onended;
  133304. /**
  133305. * Stop the sound
  133306. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  133307. */
  133308. stop(time?: number): void;
  133309. /**
  133310. * Put the sound in pause
  133311. */
  133312. pause(): void;
  133313. /**
  133314. * Sets a dedicated volume for this sounds
  133315. * @param newVolume Define the new volume of the sound
  133316. * @param time Define time for gradual change to new volume
  133317. */
  133318. setVolume(newVolume: number, time?: number): void;
  133319. /**
  133320. * Set the sound play back rate
  133321. * @param newPlaybackRate Define the playback rate the sound should be played at
  133322. */
  133323. setPlaybackRate(newPlaybackRate: number): void;
  133324. /**
  133325. * Gets the volume of the sound.
  133326. * @returns the volume of the sound
  133327. */
  133328. getVolume(): number;
  133329. /**
  133330. * Attach the sound to a dedicated mesh
  133331. * @param transformNode The transform node to connect the sound with
  133332. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  133333. */
  133334. attachToMesh(transformNode: TransformNode): void;
  133335. /**
  133336. * Detach the sound from the previously attached mesh
  133337. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  133338. */
  133339. detachFromMesh(): void;
  133340. private _onRegisterAfterWorldMatrixUpdate;
  133341. /**
  133342. * Clone the current sound in the scene.
  133343. * @returns the new sound clone
  133344. */
  133345. clone(): Nullable<Sound>;
  133346. /**
  133347. * Gets the current underlying audio buffer containing the data
  133348. * @returns the audio buffer
  133349. */
  133350. getAudioBuffer(): Nullable<AudioBuffer>;
  133351. /**
  133352. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  133353. * @returns the source node
  133354. */
  133355. getSoundSource(): Nullable<AudioBufferSourceNode>;
  133356. /**
  133357. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  133358. * @returns the gain node
  133359. */
  133360. getSoundGain(): Nullable<GainNode>;
  133361. /**
  133362. * Serializes the Sound in a JSON representation
  133363. * @returns the JSON representation of the sound
  133364. */
  133365. serialize(): any;
  133366. /**
  133367. * Parse a JSON representation of a sound to innstantiate in a given scene
  133368. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  133369. * @param scene Define the scene the new parsed sound should be created in
  133370. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  133371. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  133372. * @returns the newly parsed sound
  133373. */
  133374. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  133375. }
  133376. }
  133377. declare module BABYLON {
  133378. /**
  133379. * This defines an action helpful to play a defined sound on a triggered action.
  133380. */
  133381. export class PlaySoundAction extends Action {
  133382. private _sound;
  133383. /**
  133384. * Instantiate the action
  133385. * @param triggerOptions defines the trigger options
  133386. * @param sound defines the sound to play
  133387. * @param condition defines the trigger related conditions
  133388. */
  133389. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  133390. /** @hidden */
  133391. _prepare(): void;
  133392. /**
  133393. * Execute the action and play the sound.
  133394. */
  133395. execute(): void;
  133396. /**
  133397. * Serializes the actions and its related information.
  133398. * @param parent defines the object to serialize in
  133399. * @returns the serialized object
  133400. */
  133401. serialize(parent: any): any;
  133402. }
  133403. /**
  133404. * This defines an action helpful to stop a defined sound on a triggered action.
  133405. */
  133406. export class StopSoundAction extends Action {
  133407. private _sound;
  133408. /**
  133409. * Instantiate the action
  133410. * @param triggerOptions defines the trigger options
  133411. * @param sound defines the sound to stop
  133412. * @param condition defines the trigger related conditions
  133413. */
  133414. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  133415. /** @hidden */
  133416. _prepare(): void;
  133417. /**
  133418. * Execute the action and stop the sound.
  133419. */
  133420. execute(): void;
  133421. /**
  133422. * Serializes the actions and its related information.
  133423. * @param parent defines the object to serialize in
  133424. * @returns the serialized object
  133425. */
  133426. serialize(parent: any): any;
  133427. }
  133428. }
  133429. declare module BABYLON {
  133430. /**
  133431. * This defines an action responsible to change the value of a property
  133432. * by interpolating between its current value and the newly set one once triggered.
  133433. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  133434. */
  133435. export class InterpolateValueAction extends Action {
  133436. /**
  133437. * Defines the path of the property where the value should be interpolated
  133438. */
  133439. propertyPath: string;
  133440. /**
  133441. * Defines the target value at the end of the interpolation.
  133442. */
  133443. value: any;
  133444. /**
  133445. * Defines the time it will take for the property to interpolate to the value.
  133446. */
  133447. duration: number;
  133448. /**
  133449. * Defines if the other scene animations should be stopped when the action has been triggered
  133450. */
  133451. stopOtherAnimations?: boolean;
  133452. /**
  133453. * Defines a callback raised once the interpolation animation has been done.
  133454. */
  133455. onInterpolationDone?: () => void;
  133456. /**
  133457. * Observable triggered once the interpolation animation has been done.
  133458. */
  133459. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  133460. private _target;
  133461. private _effectiveTarget;
  133462. private _property;
  133463. /**
  133464. * Instantiate the action
  133465. * @param triggerOptions defines the trigger options
  133466. * @param target defines the object containing the value to interpolate
  133467. * @param propertyPath defines the path to the property in the target object
  133468. * @param value defines the target value at the end of the interpolation
  133469. * @param duration deines the time it will take for the property to interpolate to the value.
  133470. * @param condition defines the trigger related conditions
  133471. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  133472. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  133473. */
  133474. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  133475. /** @hidden */
  133476. _prepare(): void;
  133477. /**
  133478. * Execute the action starts the value interpolation.
  133479. */
  133480. execute(): void;
  133481. /**
  133482. * Serializes the actions and its related information.
  133483. * @param parent defines the object to serialize in
  133484. * @returns the serialized object
  133485. */
  133486. serialize(parent: any): any;
  133487. }
  133488. }
  133489. declare module BABYLON {
  133490. /**
  133491. * This represents the default audio engine used in babylon.
  133492. * It is responsible to play, synchronize and analyse sounds throughout the application.
  133493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133494. */
  133495. export class AudioEngine implements IAudioEngine {
  133496. private _audioContext;
  133497. private _audioContextInitialized;
  133498. private _muteButton;
  133499. private _hostElement;
  133500. /**
  133501. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  133502. */
  133503. canUseWebAudio: boolean;
  133504. /**
  133505. * The master gain node defines the global audio volume of your audio engine.
  133506. */
  133507. masterGain: GainNode;
  133508. /**
  133509. * Defines if Babylon should emit a warning if WebAudio is not supported.
  133510. * @ignoreNaming
  133511. */
  133512. WarnedWebAudioUnsupported: boolean;
  133513. /**
  133514. * Gets whether or not mp3 are supported by your browser.
  133515. */
  133516. isMP3supported: boolean;
  133517. /**
  133518. * Gets whether or not ogg are supported by your browser.
  133519. */
  133520. isOGGsupported: boolean;
  133521. /**
  133522. * Gets whether audio has been unlocked on the device.
  133523. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  133524. * a user interaction has happened.
  133525. */
  133526. unlocked: boolean;
  133527. /**
  133528. * Defines if the audio engine relies on a custom unlocked button.
  133529. * In this case, the embedded button will not be displayed.
  133530. */
  133531. useCustomUnlockedButton: boolean;
  133532. /**
  133533. * Event raised when audio has been unlocked on the browser.
  133534. */
  133535. onAudioUnlockedObservable: Observable<IAudioEngine>;
  133536. /**
  133537. * Event raised when audio has been locked on the browser.
  133538. */
  133539. onAudioLockedObservable: Observable<IAudioEngine>;
  133540. /**
  133541. * Gets the current AudioContext if available.
  133542. */
  133543. get audioContext(): Nullable<AudioContext>;
  133544. private _connectedAnalyser;
  133545. /**
  133546. * Instantiates a new audio engine.
  133547. *
  133548. * There should be only one per page as some browsers restrict the number
  133549. * of audio contexts you can create.
  133550. * @param hostElement defines the host element where to display the mute icon if necessary
  133551. */
  133552. constructor(hostElement?: Nullable<HTMLElement>);
  133553. /**
  133554. * Flags the audio engine in Locked state.
  133555. * This happens due to new browser policies preventing audio to autoplay.
  133556. */
  133557. lock(): void;
  133558. /**
  133559. * Unlocks the audio engine once a user action has been done on the dom.
  133560. * This is helpful to resume play once browser policies have been satisfied.
  133561. */
  133562. unlock(): void;
  133563. private _resumeAudioContext;
  133564. private _initializeAudioContext;
  133565. private _tryToRun;
  133566. private _triggerRunningState;
  133567. private _triggerSuspendedState;
  133568. private _displayMuteButton;
  133569. private _moveButtonToTopLeft;
  133570. private _onResize;
  133571. private _hideMuteButton;
  133572. /**
  133573. * Destroy and release the resources associated with the audio ccontext.
  133574. */
  133575. dispose(): void;
  133576. /**
  133577. * Gets the global volume sets on the master gain.
  133578. * @returns the global volume if set or -1 otherwise
  133579. */
  133580. getGlobalVolume(): number;
  133581. /**
  133582. * Sets the global volume of your experience (sets on the master gain).
  133583. * @param newVolume Defines the new global volume of the application
  133584. */
  133585. setGlobalVolume(newVolume: number): void;
  133586. /**
  133587. * Connect the audio engine to an audio analyser allowing some amazing
  133588. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  133589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  133590. * @param analyser The analyser to connect to the engine
  133591. */
  133592. connectToAnalyser(analyser: Analyser): void;
  133593. }
  133594. }
  133595. declare module BABYLON {
  133596. /**
  133597. * Options allowed during the creation of a sound track.
  133598. */
  133599. export interface ISoundTrackOptions {
  133600. /**
  133601. * The volume the sound track should take during creation
  133602. */
  133603. volume?: number;
  133604. /**
  133605. * Define if the sound track is the main sound track of the scene
  133606. */
  133607. mainTrack?: boolean;
  133608. }
  133609. /**
  133610. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  133611. * It will be also used in a future release to apply effects on a specific track.
  133612. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  133613. */
  133614. export class SoundTrack {
  133615. /**
  133616. * The unique identifier of the sound track in the scene.
  133617. */
  133618. id: number;
  133619. /**
  133620. * The list of sounds included in the sound track.
  133621. */
  133622. soundCollection: Array<Sound>;
  133623. private _outputAudioNode;
  133624. private _scene;
  133625. private _connectedAnalyser;
  133626. private _options;
  133627. private _isInitialized;
  133628. /**
  133629. * Creates a new sound track.
  133630. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  133631. * @param scene Define the scene the sound track belongs to
  133632. * @param options
  133633. */
  133634. constructor(scene: Scene, options?: ISoundTrackOptions);
  133635. private _initializeSoundTrackAudioGraph;
  133636. /**
  133637. * Release the sound track and its associated resources
  133638. */
  133639. dispose(): void;
  133640. /**
  133641. * Adds a sound to this sound track
  133642. * @param sound define the cound to add
  133643. * @ignoreNaming
  133644. */
  133645. addSound(sound: Sound): void;
  133646. /**
  133647. * Removes a sound to this sound track
  133648. * @param sound define the cound to remove
  133649. * @ignoreNaming
  133650. */
  133651. removeSound(sound: Sound): void;
  133652. /**
  133653. * Set a global volume for the full sound track.
  133654. * @param newVolume Define the new volume of the sound track
  133655. */
  133656. setVolume(newVolume: number): void;
  133657. /**
  133658. * Switch the panning model to HRTF:
  133659. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  133660. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133661. */
  133662. switchPanningModelToHRTF(): void;
  133663. /**
  133664. * Switch the panning model to Equal Power:
  133665. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  133666. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133667. */
  133668. switchPanningModelToEqualPower(): void;
  133669. /**
  133670. * Connect the sound track to an audio analyser allowing some amazing
  133671. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  133672. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  133673. * @param analyser The analyser to connect to the engine
  133674. */
  133675. connectToAnalyser(analyser: Analyser): void;
  133676. }
  133677. }
  133678. declare module BABYLON {
  133679. interface AbstractScene {
  133680. /**
  133681. * The list of sounds used in the scene.
  133682. */
  133683. sounds: Nullable<Array<Sound>>;
  133684. }
  133685. interface Scene {
  133686. /**
  133687. * @hidden
  133688. * Backing field
  133689. */
  133690. _mainSoundTrack: SoundTrack;
  133691. /**
  133692. * The main sound track played by the scene.
  133693. * It cotains your primary collection of sounds.
  133694. */
  133695. mainSoundTrack: SoundTrack;
  133696. /**
  133697. * The list of sound tracks added to the scene
  133698. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133699. */
  133700. soundTracks: Nullable<Array<SoundTrack>>;
  133701. /**
  133702. * Gets a sound using a given name
  133703. * @param name defines the name to search for
  133704. * @return the found sound or null if not found at all.
  133705. */
  133706. getSoundByName(name: string): Nullable<Sound>;
  133707. /**
  133708. * Gets or sets if audio support is enabled
  133709. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133710. */
  133711. audioEnabled: boolean;
  133712. /**
  133713. * Gets or sets if audio will be output to headphones
  133714. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133715. */
  133716. headphone: boolean;
  133717. /**
  133718. * Gets or sets custom audio listener position provider
  133719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133720. */
  133721. audioListenerPositionProvider: Nullable<() => Vector3>;
  133722. /**
  133723. * Gets or sets a refresh rate when using 3D audio positioning
  133724. */
  133725. audioPositioningRefreshRate: number;
  133726. }
  133727. /**
  133728. * Defines the sound scene component responsible to manage any sounds
  133729. * in a given scene.
  133730. */
  133731. export class AudioSceneComponent implements ISceneSerializableComponent {
  133732. private static _CameraDirectionLH;
  133733. private static _CameraDirectionRH;
  133734. /**
  133735. * The component name helpfull to identify the component in the list of scene components.
  133736. */
  133737. readonly name: string;
  133738. /**
  133739. * The scene the component belongs to.
  133740. */
  133741. scene: Scene;
  133742. private _audioEnabled;
  133743. /**
  133744. * Gets whether audio is enabled or not.
  133745. * Please use related enable/disable method to switch state.
  133746. */
  133747. get audioEnabled(): boolean;
  133748. private _headphone;
  133749. /**
  133750. * Gets whether audio is outputing to headphone or not.
  133751. * Please use the according Switch methods to change output.
  133752. */
  133753. get headphone(): boolean;
  133754. /**
  133755. * Gets or sets a refresh rate when using 3D audio positioning
  133756. */
  133757. audioPositioningRefreshRate: number;
  133758. private _audioListenerPositionProvider;
  133759. /**
  133760. * Gets the current audio listener position provider
  133761. */
  133762. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  133763. /**
  133764. * Sets a custom listener position for all sounds in the scene
  133765. * By default, this is the position of the first active camera
  133766. */
  133767. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  133768. /**
  133769. * Creates a new instance of the component for the given scene
  133770. * @param scene Defines the scene to register the component in
  133771. */
  133772. constructor(scene: Scene);
  133773. /**
  133774. * Registers the component in a given scene
  133775. */
  133776. register(): void;
  133777. /**
  133778. * Rebuilds the elements related to this component in case of
  133779. * context lost for instance.
  133780. */
  133781. rebuild(): void;
  133782. /**
  133783. * Serializes the component data to the specified json object
  133784. * @param serializationObject The object to serialize to
  133785. */
  133786. serialize(serializationObject: any): void;
  133787. /**
  133788. * Adds all the elements from the container to the scene
  133789. * @param container the container holding the elements
  133790. */
  133791. addFromContainer(container: AbstractScene): void;
  133792. /**
  133793. * Removes all the elements in the container from the scene
  133794. * @param container contains the elements to remove
  133795. * @param dispose if the removed element should be disposed (default: false)
  133796. */
  133797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133798. /**
  133799. * Disposes the component and the associated ressources.
  133800. */
  133801. dispose(): void;
  133802. /**
  133803. * Disables audio in the associated scene.
  133804. */
  133805. disableAudio(): void;
  133806. /**
  133807. * Enables audio in the associated scene.
  133808. */
  133809. enableAudio(): void;
  133810. /**
  133811. * Switch audio to headphone output.
  133812. */
  133813. switchAudioModeForHeadphones(): void;
  133814. /**
  133815. * Switch audio to normal speakers.
  133816. */
  133817. switchAudioModeForNormalSpeakers(): void;
  133818. private _cachedCameraDirection;
  133819. private _cachedCameraPosition;
  133820. private _lastCheck;
  133821. private _afterRender;
  133822. }
  133823. }
  133824. declare module BABYLON {
  133825. /**
  133826. * Wraps one or more Sound objects and selects one with random weight for playback.
  133827. */
  133828. export class WeightedSound {
  133829. /** When true a Sound will be selected and played when the current playing Sound completes. */
  133830. loop: boolean;
  133831. private _coneInnerAngle;
  133832. private _coneOuterAngle;
  133833. private _volume;
  133834. /** A Sound is currently playing. */
  133835. isPlaying: boolean;
  133836. /** A Sound is currently paused. */
  133837. isPaused: boolean;
  133838. private _sounds;
  133839. private _weights;
  133840. private _currentIndex?;
  133841. /**
  133842. * Creates a new WeightedSound from the list of sounds given.
  133843. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  133844. * @param sounds Array of Sounds that will be selected from.
  133845. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  133846. */
  133847. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  133848. /**
  133849. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  133850. */
  133851. get directionalConeInnerAngle(): number;
  133852. /**
  133853. * The size of cone in degress for a directional sound in which there will be no attenuation.
  133854. */
  133855. set directionalConeInnerAngle(value: number);
  133856. /**
  133857. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133858. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133859. */
  133860. get directionalConeOuterAngle(): number;
  133861. /**
  133862. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133863. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133864. */
  133865. set directionalConeOuterAngle(value: number);
  133866. /**
  133867. * Playback volume.
  133868. */
  133869. get volume(): number;
  133870. /**
  133871. * Playback volume.
  133872. */
  133873. set volume(value: number);
  133874. private _onended;
  133875. /**
  133876. * Suspend playback
  133877. */
  133878. pause(): void;
  133879. /**
  133880. * Stop playback
  133881. */
  133882. stop(): void;
  133883. /**
  133884. * Start playback.
  133885. * @param startOffset Position the clip head at a specific time in seconds.
  133886. */
  133887. play(startOffset?: number): void;
  133888. }
  133889. }
  133890. declare module BABYLON {
  133891. /**
  133892. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  133893. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133894. */
  133895. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  133896. /**
  133897. * Gets the name of the behavior.
  133898. */
  133899. get name(): string;
  133900. /**
  133901. * The easing function used by animations
  133902. */
  133903. static EasingFunction: BackEase;
  133904. /**
  133905. * The easing mode used by animations
  133906. */
  133907. static EasingMode: number;
  133908. /**
  133909. * The duration of the animation, in milliseconds
  133910. */
  133911. transitionDuration: number;
  133912. /**
  133913. * Length of the distance animated by the transition when lower radius is reached
  133914. */
  133915. lowerRadiusTransitionRange: number;
  133916. /**
  133917. * Length of the distance animated by the transition when upper radius is reached
  133918. */
  133919. upperRadiusTransitionRange: number;
  133920. private _autoTransitionRange;
  133921. /**
  133922. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133923. */
  133924. get autoTransitionRange(): boolean;
  133925. /**
  133926. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133927. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  133928. */
  133929. set autoTransitionRange(value: boolean);
  133930. private _attachedCamera;
  133931. private _onAfterCheckInputsObserver;
  133932. private _onMeshTargetChangedObserver;
  133933. /**
  133934. * Initializes the behavior.
  133935. */
  133936. init(): void;
  133937. /**
  133938. * Attaches the behavior to its arc rotate camera.
  133939. * @param camera Defines the camera to attach the behavior to
  133940. */
  133941. attach(camera: ArcRotateCamera): void;
  133942. /**
  133943. * Detaches the behavior from its current arc rotate camera.
  133944. */
  133945. detach(): void;
  133946. private _radiusIsAnimating;
  133947. private _radiusBounceTransition;
  133948. private _animatables;
  133949. private _cachedWheelPrecision;
  133950. /**
  133951. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  133952. * @param radiusLimit The limit to check against.
  133953. * @return Bool to indicate if at limit.
  133954. */
  133955. private _isRadiusAtLimit;
  133956. /**
  133957. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  133958. * @param radiusDelta The delta by which to animate to. Can be negative.
  133959. */
  133960. private _applyBoundRadiusAnimation;
  133961. /**
  133962. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  133963. */
  133964. protected _clearAnimationLocks(): void;
  133965. /**
  133966. * Stops and removes all animations that have been applied to the camera
  133967. */
  133968. stopAllAnimations(): void;
  133969. }
  133970. }
  133971. declare module BABYLON {
  133972. /**
  133973. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  133974. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133975. */
  133976. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  133977. /**
  133978. * Gets the name of the behavior.
  133979. */
  133980. get name(): string;
  133981. private _mode;
  133982. private _radiusScale;
  133983. private _positionScale;
  133984. private _defaultElevation;
  133985. private _elevationReturnTime;
  133986. private _elevationReturnWaitTime;
  133987. private _zoomStopsAnimation;
  133988. private _framingTime;
  133989. /**
  133990. * The easing function used by animations
  133991. */
  133992. static EasingFunction: ExponentialEase;
  133993. /**
  133994. * The easing mode used by animations
  133995. */
  133996. static EasingMode: number;
  133997. /**
  133998. * Sets the current mode used by the behavior
  133999. */
  134000. set mode(mode: number);
  134001. /**
  134002. * Gets current mode used by the behavior.
  134003. */
  134004. get mode(): number;
  134005. /**
  134006. * Sets the scale applied to the radius (1 by default)
  134007. */
  134008. set radiusScale(radius: number);
  134009. /**
  134010. * Gets the scale applied to the radius
  134011. */
  134012. get radiusScale(): number;
  134013. /**
  134014. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  134015. */
  134016. set positionScale(scale: number);
  134017. /**
  134018. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  134019. */
  134020. get positionScale(): number;
  134021. /**
  134022. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  134023. * behaviour is triggered, in radians.
  134024. */
  134025. set defaultElevation(elevation: number);
  134026. /**
  134027. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  134028. * behaviour is triggered, in radians.
  134029. */
  134030. get defaultElevation(): number;
  134031. /**
  134032. * Sets the time (in milliseconds) taken to return to the default beta position.
  134033. * Negative value indicates camera should not return to default.
  134034. */
  134035. set elevationReturnTime(speed: number);
  134036. /**
  134037. * Gets the time (in milliseconds) taken to return to the default beta position.
  134038. * Negative value indicates camera should not return to default.
  134039. */
  134040. get elevationReturnTime(): number;
  134041. /**
  134042. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  134043. */
  134044. set elevationReturnWaitTime(time: number);
  134045. /**
  134046. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  134047. */
  134048. get elevationReturnWaitTime(): number;
  134049. /**
  134050. * Sets the flag that indicates if user zooming should stop animation.
  134051. */
  134052. set zoomStopsAnimation(flag: boolean);
  134053. /**
  134054. * Gets the flag that indicates if user zooming should stop animation.
  134055. */
  134056. get zoomStopsAnimation(): boolean;
  134057. /**
  134058. * Sets the transition time when framing the mesh, in milliseconds
  134059. */
  134060. set framingTime(time: number);
  134061. /**
  134062. * Gets the transition time when framing the mesh, in milliseconds
  134063. */
  134064. get framingTime(): number;
  134065. /**
  134066. * Define if the behavior should automatically change the configured
  134067. * camera limits and sensibilities.
  134068. */
  134069. autoCorrectCameraLimitsAndSensibility: boolean;
  134070. private _onPrePointerObservableObserver;
  134071. private _onAfterCheckInputsObserver;
  134072. private _onMeshTargetChangedObserver;
  134073. private _attachedCamera;
  134074. private _isPointerDown;
  134075. private _lastInteractionTime;
  134076. /**
  134077. * Initializes the behavior.
  134078. */
  134079. init(): void;
  134080. /**
  134081. * Attaches the behavior to its arc rotate camera.
  134082. * @param camera Defines the camera to attach the behavior to
  134083. */
  134084. attach(camera: ArcRotateCamera): void;
  134085. /**
  134086. * Detaches the behavior from its current arc rotate camera.
  134087. */
  134088. detach(): void;
  134089. private _animatables;
  134090. private _betaIsAnimating;
  134091. private _betaTransition;
  134092. private _radiusTransition;
  134093. private _vectorTransition;
  134094. /**
  134095. * Targets the given mesh and updates zoom level accordingly.
  134096. * @param mesh The mesh to target.
  134097. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134098. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134099. */
  134100. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134101. /**
  134102. * Targets the given mesh with its children and updates zoom level accordingly.
  134103. * @param mesh The mesh to target.
  134104. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134105. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134106. */
  134107. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134108. /**
  134109. * Targets the given meshes with their children and updates zoom level accordingly.
  134110. * @param meshes The mesh to target.
  134111. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134112. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134113. */
  134114. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134115. /**
  134116. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  134117. * @param minimumWorld Determines the smaller position of the bounding box extend
  134118. * @param maximumWorld Determines the bigger position of the bounding box extend
  134119. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134120. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134121. */
  134122. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134123. /**
  134124. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  134125. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  134126. * frustum width.
  134127. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  134128. * to fully enclose the mesh in the viewing frustum.
  134129. */
  134130. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  134131. /**
  134132. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  134133. * is automatically returned to its default position (expected to be above ground plane).
  134134. */
  134135. private _maintainCameraAboveGround;
  134136. /**
  134137. * Returns the frustum slope based on the canvas ratio and camera FOV
  134138. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  134139. */
  134140. private _getFrustumSlope;
  134141. /**
  134142. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  134143. */
  134144. private _clearAnimationLocks;
  134145. /**
  134146. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  134147. */
  134148. private _applyUserInteraction;
  134149. /**
  134150. * Stops and removes all animations that have been applied to the camera
  134151. */
  134152. stopAllAnimations(): void;
  134153. /**
  134154. * Gets a value indicating if the user is moving the camera
  134155. */
  134156. get isUserIsMoving(): boolean;
  134157. /**
  134158. * The camera can move all the way towards the mesh.
  134159. */
  134160. static IgnoreBoundsSizeMode: number;
  134161. /**
  134162. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  134163. */
  134164. static FitFrustumSidesMode: number;
  134165. }
  134166. }
  134167. declare module BABYLON {
  134168. /**
  134169. * Base class for Camera Pointer Inputs.
  134170. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  134171. * for example usage.
  134172. */
  134173. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  134174. /**
  134175. * Defines the camera the input is attached to.
  134176. */
  134177. abstract camera: Camera;
  134178. /**
  134179. * Whether keyboard modifier keys are pressed at time of last mouse event.
  134180. */
  134181. protected _altKey: boolean;
  134182. protected _ctrlKey: boolean;
  134183. protected _metaKey: boolean;
  134184. protected _shiftKey: boolean;
  134185. /**
  134186. * Which mouse buttons were pressed at time of last mouse event.
  134187. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  134188. */
  134189. protected _buttonsPressed: number;
  134190. /**
  134191. * Defines the buttons associated with the input to handle camera move.
  134192. */
  134193. buttons: number[];
  134194. /**
  134195. * Attach the input controls to a specific dom element to get the input from.
  134196. * @param element Defines the element the controls should be listened from
  134197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134198. */
  134199. attachControl(noPreventDefault?: boolean): void;
  134200. /**
  134201. * Detach the current controls from the specified dom element.
  134202. */
  134203. detachControl(): void;
  134204. /**
  134205. * Gets the class name of the current input.
  134206. * @returns the class name
  134207. */
  134208. getClassName(): string;
  134209. /**
  134210. * Get the friendly name associated with the input class.
  134211. * @returns the input friendly name
  134212. */
  134213. getSimpleName(): string;
  134214. /**
  134215. * Called on pointer POINTERDOUBLETAP event.
  134216. * Override this method to provide functionality on POINTERDOUBLETAP event.
  134217. */
  134218. protected onDoubleTap(type: string): void;
  134219. /**
  134220. * Called on pointer POINTERMOVE event if only a single touch is active.
  134221. * Override this method to provide functionality.
  134222. */
  134223. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  134224. /**
  134225. * Called on pointer POINTERMOVE event if multiple touches are active.
  134226. * Override this method to provide functionality.
  134227. */
  134228. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  134229. /**
  134230. * Called on JS contextmenu event.
  134231. * Override this method to provide functionality.
  134232. */
  134233. protected onContextMenu(evt: PointerEvent): void;
  134234. /**
  134235. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  134236. * press.
  134237. * Override this method to provide functionality.
  134238. */
  134239. protected onButtonDown(evt: PointerEvent): void;
  134240. /**
  134241. * Called each time a new POINTERUP event occurs. Ie, for each button
  134242. * release.
  134243. * Override this method to provide functionality.
  134244. */
  134245. protected onButtonUp(evt: PointerEvent): void;
  134246. /**
  134247. * Called when window becomes inactive.
  134248. * Override this method to provide functionality.
  134249. */
  134250. protected onLostFocus(): void;
  134251. private _pointerInput;
  134252. private _observer;
  134253. private _onLostFocus;
  134254. private pointA;
  134255. private pointB;
  134256. }
  134257. }
  134258. declare module BABYLON {
  134259. /**
  134260. * Manage the pointers inputs to control an arc rotate camera.
  134261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134262. */
  134263. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  134264. /**
  134265. * Defines the camera the input is attached to.
  134266. */
  134267. camera: ArcRotateCamera;
  134268. /**
  134269. * Gets the class name of the current input.
  134270. * @returns the class name
  134271. */
  134272. getClassName(): string;
  134273. /**
  134274. * Defines the buttons associated with the input to handle camera move.
  134275. */
  134276. buttons: number[];
  134277. /**
  134278. * Defines the pointer angular sensibility along the X axis or how fast is
  134279. * the camera rotating.
  134280. */
  134281. angularSensibilityX: number;
  134282. /**
  134283. * Defines the pointer angular sensibility along the Y axis or how fast is
  134284. * the camera rotating.
  134285. */
  134286. angularSensibilityY: number;
  134287. /**
  134288. * Defines the pointer pinch precision or how fast is the camera zooming.
  134289. */
  134290. pinchPrecision: number;
  134291. /**
  134292. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  134293. * from 0.
  134294. * It defines the percentage of current camera.radius to use as delta when
  134295. * pinch zoom is used.
  134296. */
  134297. pinchDeltaPercentage: number;
  134298. /**
  134299. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  134300. * that any object in the plane at the camera's target point will scale
  134301. * perfectly with finger motion.
  134302. * Overrides pinchDeltaPercentage and pinchPrecision.
  134303. */
  134304. useNaturalPinchZoom: boolean;
  134305. /**
  134306. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  134307. */
  134308. pinchZoom: boolean;
  134309. /**
  134310. * Defines the pointer panning sensibility or how fast is the camera moving.
  134311. */
  134312. panningSensibility: number;
  134313. /**
  134314. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  134315. */
  134316. multiTouchPanning: boolean;
  134317. /**
  134318. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  134319. * zoom (pinch) through multitouch.
  134320. */
  134321. multiTouchPanAndZoom: boolean;
  134322. /**
  134323. * Revers pinch action direction.
  134324. */
  134325. pinchInwards: boolean;
  134326. private _isPanClick;
  134327. private _twoFingerActivityCount;
  134328. private _isPinching;
  134329. /**
  134330. * Move camera from multi touch panning positions.
  134331. */
  134332. private _computeMultiTouchPanning;
  134333. /**
  134334. * Move camera from pinch zoom distances.
  134335. */
  134336. private _computePinchZoom;
  134337. /**
  134338. * Called on pointer POINTERMOVE event if only a single touch is active.
  134339. */
  134340. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  134341. /**
  134342. * Called on pointer POINTERDOUBLETAP event.
  134343. */
  134344. protected onDoubleTap(type: string): void;
  134345. /**
  134346. * Called on pointer POINTERMOVE event if multiple touches are active.
  134347. */
  134348. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  134349. /**
  134350. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  134351. * press.
  134352. */
  134353. protected onButtonDown(evt: PointerEvent): void;
  134354. /**
  134355. * Called each time a new POINTERUP event occurs. Ie, for each button
  134356. * release.
  134357. */
  134358. protected onButtonUp(evt: PointerEvent): void;
  134359. /**
  134360. * Called when window becomes inactive.
  134361. */
  134362. protected onLostFocus(): void;
  134363. }
  134364. }
  134365. declare module BABYLON {
  134366. /**
  134367. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  134368. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134369. */
  134370. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  134371. /**
  134372. * Defines the camera the input is attached to.
  134373. */
  134374. camera: ArcRotateCamera;
  134375. /**
  134376. * Defines the list of key codes associated with the up action (increase alpha)
  134377. */
  134378. keysUp: number[];
  134379. /**
  134380. * Defines the list of key codes associated with the down action (decrease alpha)
  134381. */
  134382. keysDown: number[];
  134383. /**
  134384. * Defines the list of key codes associated with the left action (increase beta)
  134385. */
  134386. keysLeft: number[];
  134387. /**
  134388. * Defines the list of key codes associated with the right action (decrease beta)
  134389. */
  134390. keysRight: number[];
  134391. /**
  134392. * Defines the list of key codes associated with the reset action.
  134393. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  134394. */
  134395. keysReset: number[];
  134396. /**
  134397. * Defines the panning sensibility of the inputs.
  134398. * (How fast is the camera panning)
  134399. */
  134400. panningSensibility: number;
  134401. /**
  134402. * Defines the zooming sensibility of the inputs.
  134403. * (How fast is the camera zooming)
  134404. */
  134405. zoomingSensibility: number;
  134406. /**
  134407. * Defines whether maintaining the alt key down switch the movement mode from
  134408. * orientation to zoom.
  134409. */
  134410. useAltToZoom: boolean;
  134411. /**
  134412. * Rotation speed of the camera
  134413. */
  134414. angularSpeed: number;
  134415. private _keys;
  134416. private _ctrlPressed;
  134417. private _altPressed;
  134418. private _onCanvasBlurObserver;
  134419. private _onKeyboardObserver;
  134420. private _engine;
  134421. private _scene;
  134422. /**
  134423. * Attach the input controls to a specific dom element to get the input from.
  134424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134425. */
  134426. attachControl(noPreventDefault?: boolean): void;
  134427. /**
  134428. * Detach the current controls from the specified dom element.
  134429. */
  134430. detachControl(): void;
  134431. /**
  134432. * Update the current camera state depending on the inputs that have been used this frame.
  134433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  134434. */
  134435. checkInputs(): void;
  134436. /**
  134437. * Gets the class name of the current intput.
  134438. * @returns the class name
  134439. */
  134440. getClassName(): string;
  134441. /**
  134442. * Get the friendly name associated with the input class.
  134443. * @returns the input friendly name
  134444. */
  134445. getSimpleName(): string;
  134446. }
  134447. }
  134448. declare module BABYLON {
  134449. /**
  134450. * Manage the mouse wheel inputs to control an arc rotate camera.
  134451. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134452. */
  134453. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  134454. /**
  134455. * Defines the camera the input is attached to.
  134456. */
  134457. camera: ArcRotateCamera;
  134458. /**
  134459. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  134460. */
  134461. wheelPrecision: number;
  134462. /**
  134463. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  134464. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  134465. */
  134466. wheelDeltaPercentage: number;
  134467. private _wheel;
  134468. private _observer;
  134469. private computeDeltaFromMouseWheelLegacyEvent;
  134470. /**
  134471. * Attach the input controls to a specific dom element to get the input from.
  134472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134473. */
  134474. attachControl(noPreventDefault?: boolean): void;
  134475. /**
  134476. * Detach the current controls from the specified dom element.
  134477. */
  134478. detachControl(): void;
  134479. /**
  134480. * Gets the class name of the current intput.
  134481. * @returns the class name
  134482. */
  134483. getClassName(): string;
  134484. /**
  134485. * Get the friendly name associated with the input class.
  134486. * @returns the input friendly name
  134487. */
  134488. getSimpleName(): string;
  134489. }
  134490. }
  134491. declare module BABYLON {
  134492. /**
  134493. * Default Inputs manager for the ArcRotateCamera.
  134494. * It groups all the default supported inputs for ease of use.
  134495. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134496. */
  134497. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  134498. /**
  134499. * Instantiates a new ArcRotateCameraInputsManager.
  134500. * @param camera Defines the camera the inputs belong to
  134501. */
  134502. constructor(camera: ArcRotateCamera);
  134503. /**
  134504. * Add mouse wheel input support to the input manager.
  134505. * @returns the current input manager
  134506. */
  134507. addMouseWheel(): ArcRotateCameraInputsManager;
  134508. /**
  134509. * Add pointers input support to the input manager.
  134510. * @returns the current input manager
  134511. */
  134512. addPointers(): ArcRotateCameraInputsManager;
  134513. /**
  134514. * Add keyboard input support to the input manager.
  134515. * @returns the current input manager
  134516. */
  134517. addKeyboard(): ArcRotateCameraInputsManager;
  134518. }
  134519. }
  134520. declare module BABYLON {
  134521. /**
  134522. * This represents an orbital type of camera.
  134523. *
  134524. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  134525. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  134526. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  134527. */
  134528. export class ArcRotateCamera extends TargetCamera {
  134529. /**
  134530. * Defines the rotation angle of the camera along the longitudinal axis.
  134531. */
  134532. alpha: number;
  134533. /**
  134534. * Defines the rotation angle of the camera along the latitudinal axis.
  134535. */
  134536. beta: number;
  134537. /**
  134538. * Defines the radius of the camera from it s target point.
  134539. */
  134540. radius: number;
  134541. protected _target: Vector3;
  134542. protected _targetHost: Nullable<AbstractMesh>;
  134543. /**
  134544. * Defines the target point of the camera.
  134545. * The camera looks towards it form the radius distance.
  134546. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  134547. */
  134548. get target(): Vector3;
  134549. set target(value: Vector3);
  134550. /**
  134551. * Define the current local position of the camera in the scene
  134552. */
  134553. get position(): Vector3;
  134554. set position(newPosition: Vector3);
  134555. protected _upToYMatrix: Matrix;
  134556. protected _YToUpMatrix: Matrix;
  134557. /**
  134558. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  134559. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  134560. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  134561. */
  134562. set upVector(vec: Vector3);
  134563. get upVector(): Vector3;
  134564. /**
  134565. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  134566. */
  134567. setMatUp(): void;
  134568. /**
  134569. * Current inertia value on the longitudinal axis.
  134570. * The bigger this number the longer it will take for the camera to stop.
  134571. */
  134572. inertialAlphaOffset: number;
  134573. /**
  134574. * Current inertia value on the latitudinal axis.
  134575. * The bigger this number the longer it will take for the camera to stop.
  134576. */
  134577. inertialBetaOffset: number;
  134578. /**
  134579. * Current inertia value on the radius axis.
  134580. * The bigger this number the longer it will take for the camera to stop.
  134581. */
  134582. inertialRadiusOffset: number;
  134583. /**
  134584. * Minimum allowed angle on the longitudinal axis.
  134585. * This can help limiting how the Camera is able to move in the scene.
  134586. */
  134587. lowerAlphaLimit: Nullable<number>;
  134588. /**
  134589. * Maximum allowed angle on the longitudinal axis.
  134590. * This can help limiting how the Camera is able to move in the scene.
  134591. */
  134592. upperAlphaLimit: Nullable<number>;
  134593. /**
  134594. * Minimum allowed angle on the latitudinal axis.
  134595. * This can help limiting how the Camera is able to move in the scene.
  134596. */
  134597. lowerBetaLimit: number;
  134598. /**
  134599. * Maximum allowed angle on the latitudinal axis.
  134600. * This can help limiting how the Camera is able to move in the scene.
  134601. */
  134602. upperBetaLimit: number;
  134603. /**
  134604. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  134605. * This can help limiting how the Camera is able to move in the scene.
  134606. */
  134607. lowerRadiusLimit: Nullable<number>;
  134608. /**
  134609. * Maximum allowed distance of the camera to the target (The camera can not get further).
  134610. * This can help limiting how the Camera is able to move in the scene.
  134611. */
  134612. upperRadiusLimit: Nullable<number>;
  134613. /**
  134614. * Defines the current inertia value used during panning of the camera along the X axis.
  134615. */
  134616. inertialPanningX: number;
  134617. /**
  134618. * Defines the current inertia value used during panning of the camera along the Y axis.
  134619. */
  134620. inertialPanningY: number;
  134621. /**
  134622. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  134623. * Basically if your fingers moves away from more than this distance you will be considered
  134624. * in pinch mode.
  134625. */
  134626. pinchToPanMaxDistance: number;
  134627. /**
  134628. * Defines the maximum distance the camera can pan.
  134629. * This could help keeping the cammera always in your scene.
  134630. */
  134631. panningDistanceLimit: Nullable<number>;
  134632. /**
  134633. * Defines the target of the camera before paning.
  134634. */
  134635. panningOriginTarget: Vector3;
  134636. /**
  134637. * Defines the value of the inertia used during panning.
  134638. * 0 would mean stop inertia and one would mean no decelleration at all.
  134639. */
  134640. panningInertia: number;
  134641. /**
  134642. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  134643. */
  134644. get angularSensibilityX(): number;
  134645. set angularSensibilityX(value: number);
  134646. /**
  134647. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  134648. */
  134649. get angularSensibilityY(): number;
  134650. set angularSensibilityY(value: number);
  134651. /**
  134652. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  134653. */
  134654. get pinchPrecision(): number;
  134655. set pinchPrecision(value: number);
  134656. /**
  134657. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  134658. * It will be used instead of pinchDeltaPrecision if different from 0.
  134659. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  134660. */
  134661. get pinchDeltaPercentage(): number;
  134662. set pinchDeltaPercentage(value: number);
  134663. /**
  134664. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  134665. * and pinch delta percentage.
  134666. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  134667. * that any object in the plane at the camera's target point will scale
  134668. * perfectly with finger motion.
  134669. */
  134670. get useNaturalPinchZoom(): boolean;
  134671. set useNaturalPinchZoom(value: boolean);
  134672. /**
  134673. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  134674. */
  134675. get panningSensibility(): number;
  134676. set panningSensibility(value: number);
  134677. /**
  134678. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  134679. */
  134680. get keysUp(): number[];
  134681. set keysUp(value: number[]);
  134682. /**
  134683. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  134684. */
  134685. get keysDown(): number[];
  134686. set keysDown(value: number[]);
  134687. /**
  134688. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  134689. */
  134690. get keysLeft(): number[];
  134691. set keysLeft(value: number[]);
  134692. /**
  134693. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  134694. */
  134695. get keysRight(): number[];
  134696. set keysRight(value: number[]);
  134697. /**
  134698. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  134699. */
  134700. get wheelPrecision(): number;
  134701. set wheelPrecision(value: number);
  134702. /**
  134703. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  134704. * It will be used instead of pinchDeltaPrecision if different from 0.
  134705. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  134706. */
  134707. get wheelDeltaPercentage(): number;
  134708. set wheelDeltaPercentage(value: number);
  134709. /**
  134710. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  134711. */
  134712. zoomOnFactor: number;
  134713. /**
  134714. * Defines a screen offset for the camera position.
  134715. */
  134716. targetScreenOffset: Vector2;
  134717. /**
  134718. * Allows the camera to be completely reversed.
  134719. * If false the camera can not arrive upside down.
  134720. */
  134721. allowUpsideDown: boolean;
  134722. /**
  134723. * Define if double tap/click is used to restore the previously saved state of the camera.
  134724. */
  134725. useInputToRestoreState: boolean;
  134726. /** @hidden */
  134727. _viewMatrix: Matrix;
  134728. /** @hidden */
  134729. _useCtrlForPanning: boolean;
  134730. /** @hidden */
  134731. _panningMouseButton: number;
  134732. /**
  134733. * Defines the input associated to the camera.
  134734. */
  134735. inputs: ArcRotateCameraInputsManager;
  134736. /** @hidden */
  134737. _reset: () => void;
  134738. /**
  134739. * Defines the allowed panning axis.
  134740. */
  134741. panningAxis: Vector3;
  134742. protected _transformedDirection: Vector3;
  134743. private _bouncingBehavior;
  134744. /**
  134745. * Gets the bouncing behavior of the camera if it has been enabled.
  134746. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  134747. */
  134748. get bouncingBehavior(): Nullable<BouncingBehavior>;
  134749. /**
  134750. * Defines if the bouncing behavior of the camera is enabled on the camera.
  134751. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  134752. */
  134753. get useBouncingBehavior(): boolean;
  134754. set useBouncingBehavior(value: boolean);
  134755. private _framingBehavior;
  134756. /**
  134757. * Gets the framing behavior of the camera if it has been enabled.
  134758. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  134759. */
  134760. get framingBehavior(): Nullable<FramingBehavior>;
  134761. /**
  134762. * Defines if the framing behavior of the camera is enabled on the camera.
  134763. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  134764. */
  134765. get useFramingBehavior(): boolean;
  134766. set useFramingBehavior(value: boolean);
  134767. private _autoRotationBehavior;
  134768. /**
  134769. * Gets the auto rotation behavior of the camera if it has been enabled.
  134770. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134771. */
  134772. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  134773. /**
  134774. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  134775. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134776. */
  134777. get useAutoRotationBehavior(): boolean;
  134778. set useAutoRotationBehavior(value: boolean);
  134779. /**
  134780. * Observable triggered when the mesh target has been changed on the camera.
  134781. */
  134782. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  134783. /**
  134784. * Event raised when the camera is colliding with a mesh.
  134785. */
  134786. onCollide: (collidedMesh: AbstractMesh) => void;
  134787. /**
  134788. * Defines whether the camera should check collision with the objects oh the scene.
  134789. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  134790. */
  134791. checkCollisions: boolean;
  134792. /**
  134793. * Defines the collision radius of the camera.
  134794. * This simulates a sphere around the camera.
  134795. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  134796. */
  134797. collisionRadius: Vector3;
  134798. protected _collider: Collider;
  134799. protected _previousPosition: Vector3;
  134800. protected _collisionVelocity: Vector3;
  134801. protected _newPosition: Vector3;
  134802. protected _previousAlpha: number;
  134803. protected _previousBeta: number;
  134804. protected _previousRadius: number;
  134805. protected _collisionTriggered: boolean;
  134806. protected _targetBoundingCenter: Nullable<Vector3>;
  134807. private _computationVector;
  134808. /**
  134809. * Instantiates a new ArcRotateCamera in a given scene
  134810. * @param name Defines the name of the camera
  134811. * @param alpha Defines the camera rotation along the logitudinal axis
  134812. * @param beta Defines the camera rotation along the latitudinal axis
  134813. * @param radius Defines the camera distance from its target
  134814. * @param target Defines the camera target
  134815. * @param scene Defines the scene the camera belongs to
  134816. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  134817. */
  134818. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  134819. /** @hidden */
  134820. _initCache(): void;
  134821. /** @hidden */
  134822. _updateCache(ignoreParentClass?: boolean): void;
  134823. protected _getTargetPosition(): Vector3;
  134824. private _storedAlpha;
  134825. private _storedBeta;
  134826. private _storedRadius;
  134827. private _storedTarget;
  134828. private _storedTargetScreenOffset;
  134829. /**
  134830. * Stores the current state of the camera (alpha, beta, radius and target)
  134831. * @returns the camera itself
  134832. */
  134833. storeState(): Camera;
  134834. /**
  134835. * @hidden
  134836. * Restored camera state. You must call storeState() first
  134837. */
  134838. _restoreStateValues(): boolean;
  134839. /** @hidden */
  134840. _isSynchronizedViewMatrix(): boolean;
  134841. /**
  134842. * Attach the input controls to a specific dom element to get the input from.
  134843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134844. */
  134845. attachControl(noPreventDefault?: boolean): void;
  134846. /**
  134847. * Attach the input controls to a specific dom element to get the input from.
  134848. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  134849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134850. */
  134851. attachControl(ignored: any, noPreventDefault?: boolean): void;
  134852. /**
  134853. * Attached controls to the current camera.
  134854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134855. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134856. */
  134857. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134858. /**
  134859. * Attached controls to the current camera.
  134860. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  134861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134862. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134863. */
  134864. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134865. /**
  134866. * Attached controls to the current camera.
  134867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134868. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134869. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  134870. */
  134871. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  134872. /**
  134873. * Detach the current controls from the specified dom element.
  134874. */
  134875. detachControl(): void;
  134876. /**
  134877. * Detach the current controls from the specified dom element.
  134878. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  134879. */
  134880. detachControl(ignored: any): void;
  134881. /** @hidden */
  134882. _checkInputs(): void;
  134883. protected _checkLimits(): void;
  134884. /**
  134885. * Rebuilds angles (alpha, beta) and radius from the give position and target
  134886. */
  134887. rebuildAnglesAndRadius(): void;
  134888. /**
  134889. * Use a position to define the current camera related information like alpha, beta and radius
  134890. * @param position Defines the position to set the camera at
  134891. */
  134892. setPosition(position: Vector3): void;
  134893. /**
  134894. * Defines the target the camera should look at.
  134895. * This will automatically adapt alpha beta and radius to fit within the new target.
  134896. * @param target Defines the new target as a Vector or a mesh
  134897. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  134898. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  134899. */
  134900. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  134901. /** @hidden */
  134902. _getViewMatrix(): Matrix;
  134903. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  134904. /**
  134905. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  134906. * @param meshes Defines the mesh to zoom on
  134907. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  134908. */
  134909. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  134910. /**
  134911. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  134912. * The target will be changed but the radius
  134913. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  134914. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  134915. */
  134916. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  134917. min: Vector3;
  134918. max: Vector3;
  134919. distance: number;
  134920. }, doNotUpdateMaxZ?: boolean): void;
  134921. /**
  134922. * @override
  134923. * Override Camera.createRigCamera
  134924. */
  134925. createRigCamera(name: string, cameraIndex: number): Camera;
  134926. /**
  134927. * @hidden
  134928. * @override
  134929. * Override Camera._updateRigCameras
  134930. */
  134931. _updateRigCameras(): void;
  134932. /**
  134933. * Destroy the camera and release the current resources hold by it.
  134934. */
  134935. dispose(): void;
  134936. /**
  134937. * Gets the current object class name.
  134938. * @return the class name
  134939. */
  134940. getClassName(): string;
  134941. }
  134942. }
  134943. declare module BABYLON {
  134944. /**
  134945. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  134946. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134947. */
  134948. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  134949. /**
  134950. * Gets the name of the behavior.
  134951. */
  134952. get name(): string;
  134953. private _zoomStopsAnimation;
  134954. private _idleRotationSpeed;
  134955. private _idleRotationWaitTime;
  134956. private _idleRotationSpinupTime;
  134957. /**
  134958. * Sets the flag that indicates if user zooming should stop animation.
  134959. */
  134960. set zoomStopsAnimation(flag: boolean);
  134961. /**
  134962. * Gets the flag that indicates if user zooming should stop animation.
  134963. */
  134964. get zoomStopsAnimation(): boolean;
  134965. /**
  134966. * Sets the default speed at which the camera rotates around the model.
  134967. */
  134968. set idleRotationSpeed(speed: number);
  134969. /**
  134970. * Gets the default speed at which the camera rotates around the model.
  134971. */
  134972. get idleRotationSpeed(): number;
  134973. /**
  134974. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  134975. */
  134976. set idleRotationWaitTime(time: number);
  134977. /**
  134978. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  134979. */
  134980. get idleRotationWaitTime(): number;
  134981. /**
  134982. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134983. */
  134984. set idleRotationSpinupTime(time: number);
  134985. /**
  134986. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134987. */
  134988. get idleRotationSpinupTime(): number;
  134989. /**
  134990. * Gets a value indicating if the camera is currently rotating because of this behavior
  134991. */
  134992. get rotationInProgress(): boolean;
  134993. private _onPrePointerObservableObserver;
  134994. private _onAfterCheckInputsObserver;
  134995. private _attachedCamera;
  134996. private _isPointerDown;
  134997. private _lastFrameTime;
  134998. private _lastInteractionTime;
  134999. private _cameraRotationSpeed;
  135000. /**
  135001. * Initializes the behavior.
  135002. */
  135003. init(): void;
  135004. /**
  135005. * Attaches the behavior to its arc rotate camera.
  135006. * @param camera Defines the camera to attach the behavior to
  135007. */
  135008. attach(camera: ArcRotateCamera): void;
  135009. /**
  135010. * Detaches the behavior from its current arc rotate camera.
  135011. */
  135012. detach(): void;
  135013. /**
  135014. * Returns true if user is scrolling.
  135015. * @return true if user is scrolling.
  135016. */
  135017. private _userIsZooming;
  135018. private _lastFrameRadius;
  135019. private _shouldAnimationStopForInteraction;
  135020. /**
  135021. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  135022. */
  135023. private _applyUserInteraction;
  135024. private _userIsMoving;
  135025. }
  135026. }
  135027. declare module BABYLON {
  135028. /**
  135029. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  135030. */
  135031. export class AttachToBoxBehavior implements Behavior<Mesh> {
  135032. private ui;
  135033. /**
  135034. * The name of the behavior
  135035. */
  135036. name: string;
  135037. /**
  135038. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  135039. */
  135040. distanceAwayFromFace: number;
  135041. /**
  135042. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  135043. */
  135044. distanceAwayFromBottomOfFace: number;
  135045. private _faceVectors;
  135046. private _target;
  135047. private _scene;
  135048. private _onRenderObserver;
  135049. private _tmpMatrix;
  135050. private _tmpVector;
  135051. /**
  135052. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  135053. * @param ui The transform node that should be attched to the mesh
  135054. */
  135055. constructor(ui: TransformNode);
  135056. /**
  135057. * Initializes the behavior
  135058. */
  135059. init(): void;
  135060. private _closestFace;
  135061. private _zeroVector;
  135062. private _lookAtTmpMatrix;
  135063. private _lookAtToRef;
  135064. /**
  135065. * Attaches the AttachToBoxBehavior to the passed in mesh
  135066. * @param target The mesh that the specified node will be attached to
  135067. */
  135068. attach(target: Mesh): void;
  135069. /**
  135070. * Detaches the behavior from the mesh
  135071. */
  135072. detach(): void;
  135073. }
  135074. }
  135075. declare module BABYLON {
  135076. /**
  135077. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  135078. */
  135079. export class FadeInOutBehavior implements Behavior<Mesh> {
  135080. /**
  135081. * Time in milliseconds to delay before fading in (Default: 0)
  135082. */
  135083. delay: number;
  135084. /**
  135085. * Time in milliseconds for the mesh to fade in (Default: 300)
  135086. */
  135087. fadeInTime: number;
  135088. private _millisecondsPerFrame;
  135089. private _hovered;
  135090. private _hoverValue;
  135091. private _ownerNode;
  135092. /**
  135093. * Instatiates the FadeInOutBehavior
  135094. */
  135095. constructor();
  135096. /**
  135097. * The name of the behavior
  135098. */
  135099. get name(): string;
  135100. /**
  135101. * Initializes the behavior
  135102. */
  135103. init(): void;
  135104. /**
  135105. * Attaches the fade behavior on the passed in mesh
  135106. * @param ownerNode The mesh that will be faded in/out once attached
  135107. */
  135108. attach(ownerNode: Mesh): void;
  135109. /**
  135110. * Detaches the behavior from the mesh
  135111. */
  135112. detach(): void;
  135113. /**
  135114. * Triggers the mesh to begin fading in or out
  135115. * @param value if the object should fade in or out (true to fade in)
  135116. */
  135117. fadeIn(value: boolean): void;
  135118. private _update;
  135119. private _setAllVisibility;
  135120. }
  135121. }
  135122. declare module BABYLON {
  135123. /**
  135124. * Class containing a set of static utilities functions for managing Pivots
  135125. * @hidden
  135126. */
  135127. export class PivotTools {
  135128. private static _PivotCached;
  135129. private static _OldPivotPoint;
  135130. private static _PivotTranslation;
  135131. private static _PivotTmpVector;
  135132. private static _PivotPostMultiplyPivotMatrix;
  135133. /** @hidden */
  135134. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  135135. /** @hidden */
  135136. static _RestorePivotPoint(mesh: AbstractMesh): void;
  135137. }
  135138. }
  135139. declare module BABYLON {
  135140. /**
  135141. * Class containing static functions to help procedurally build meshes
  135142. */
  135143. export class PlaneBuilder {
  135144. /**
  135145. * Creates a plane mesh
  135146. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  135147. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  135148. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  135149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135152. * @param name defines the name of the mesh
  135153. * @param options defines the options used to create the mesh
  135154. * @param scene defines the hosting scene
  135155. * @returns the plane mesh
  135156. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135157. */
  135158. static CreatePlane(name: string, options: {
  135159. size?: number;
  135160. width?: number;
  135161. height?: number;
  135162. sideOrientation?: number;
  135163. frontUVs?: Vector4;
  135164. backUVs?: Vector4;
  135165. updatable?: boolean;
  135166. sourcePlane?: Plane;
  135167. }, scene?: Nullable<Scene>): Mesh;
  135168. }
  135169. }
  135170. declare module BABYLON {
  135171. /**
  135172. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  135173. */
  135174. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  135175. private static _AnyMouseID;
  135176. /**
  135177. * Abstract mesh the behavior is set on
  135178. */
  135179. attachedNode: AbstractMesh;
  135180. private _dragPlane;
  135181. private _scene;
  135182. private _pointerObserver;
  135183. private _beforeRenderObserver;
  135184. private static _planeScene;
  135185. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  135186. /**
  135187. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  135188. */
  135189. maxDragAngle: number;
  135190. /**
  135191. * @hidden
  135192. */
  135193. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  135194. /**
  135195. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  135196. */
  135197. currentDraggingPointerID: number;
  135198. /**
  135199. * The last position where the pointer hit the drag plane in world space
  135200. */
  135201. lastDragPosition: Vector3;
  135202. /**
  135203. * If the behavior is currently in a dragging state
  135204. */
  135205. dragging: boolean;
  135206. /**
  135207. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  135208. */
  135209. dragDeltaRatio: number;
  135210. /**
  135211. * If the drag plane orientation should be updated during the dragging (Default: true)
  135212. */
  135213. updateDragPlane: boolean;
  135214. private _debugMode;
  135215. private _moving;
  135216. /**
  135217. * Fires each time the attached mesh is dragged with the pointer
  135218. * * delta between last drag position and current drag position in world space
  135219. * * dragDistance along the drag axis
  135220. * * dragPlaneNormal normal of the current drag plane used during the drag
  135221. * * dragPlanePoint in world space where the drag intersects the drag plane
  135222. */
  135223. onDragObservable: Observable<{
  135224. delta: Vector3;
  135225. dragPlanePoint: Vector3;
  135226. dragPlaneNormal: Vector3;
  135227. dragDistance: number;
  135228. pointerId: number;
  135229. }>;
  135230. /**
  135231. * Fires each time a drag begins (eg. mouse down on mesh)
  135232. */
  135233. onDragStartObservable: Observable<{
  135234. dragPlanePoint: Vector3;
  135235. pointerId: number;
  135236. }>;
  135237. /**
  135238. * Fires each time a drag ends (eg. mouse release after drag)
  135239. */
  135240. onDragEndObservable: Observable<{
  135241. dragPlanePoint: Vector3;
  135242. pointerId: number;
  135243. }>;
  135244. /**
  135245. * If the attached mesh should be moved when dragged
  135246. */
  135247. moveAttached: boolean;
  135248. /**
  135249. * If the drag behavior will react to drag events (Default: true)
  135250. */
  135251. enabled: boolean;
  135252. /**
  135253. * If pointer events should start and release the drag (Default: true)
  135254. */
  135255. startAndReleaseDragOnPointerEvents: boolean;
  135256. /**
  135257. * If camera controls should be detached during the drag
  135258. */
  135259. detachCameraControls: boolean;
  135260. /**
  135261. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  135262. */
  135263. useObjectOrientationForDragging: boolean;
  135264. private _options;
  135265. /**
  135266. * Gets the options used by the behavior
  135267. */
  135268. get options(): {
  135269. dragAxis?: Vector3;
  135270. dragPlaneNormal?: Vector3;
  135271. };
  135272. /**
  135273. * Sets the options used by the behavior
  135274. */
  135275. set options(options: {
  135276. dragAxis?: Vector3;
  135277. dragPlaneNormal?: Vector3;
  135278. });
  135279. /**
  135280. * Creates a pointer drag behavior that can be attached to a mesh
  135281. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  135282. */
  135283. constructor(options?: {
  135284. dragAxis?: Vector3;
  135285. dragPlaneNormal?: Vector3;
  135286. });
  135287. /**
  135288. * Predicate to determine if it is valid to move the object to a new position when it is moved
  135289. */
  135290. validateDrag: (targetPosition: Vector3) => boolean;
  135291. /**
  135292. * The name of the behavior
  135293. */
  135294. get name(): string;
  135295. /**
  135296. * Initializes the behavior
  135297. */
  135298. init(): void;
  135299. private _tmpVector;
  135300. private _alternatePickedPoint;
  135301. private _worldDragAxis;
  135302. private _targetPosition;
  135303. private _attachedToElement;
  135304. /**
  135305. * Attaches the drag behavior the passed in mesh
  135306. * @param ownerNode The mesh that will be dragged around once attached
  135307. * @param predicate Predicate to use for pick filtering
  135308. */
  135309. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  135310. /**
  135311. * Force relase the drag action by code.
  135312. */
  135313. releaseDrag(): void;
  135314. private _startDragRay;
  135315. private _lastPointerRay;
  135316. /**
  135317. * Simulates the start of a pointer drag event on the behavior
  135318. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  135319. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  135320. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  135321. */
  135322. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  135323. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  135324. private _dragDelta;
  135325. protected _moveDrag(ray: Ray): void;
  135326. private _pickWithRayOnDragPlane;
  135327. private _pointA;
  135328. private _pointC;
  135329. private _localAxis;
  135330. private _lookAt;
  135331. private _updateDragPlanePosition;
  135332. /**
  135333. * Detaches the behavior from the mesh
  135334. */
  135335. detach(): void;
  135336. }
  135337. }
  135338. declare module BABYLON {
  135339. /**
  135340. * A behavior that when attached to a mesh will allow the mesh to be scaled
  135341. */
  135342. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  135343. private _dragBehaviorA;
  135344. private _dragBehaviorB;
  135345. private _startDistance;
  135346. private _initialScale;
  135347. private _targetScale;
  135348. private _ownerNode;
  135349. private _sceneRenderObserver;
  135350. /**
  135351. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  135352. */
  135353. constructor();
  135354. /**
  135355. * The name of the behavior
  135356. */
  135357. get name(): string;
  135358. /**
  135359. * Initializes the behavior
  135360. */
  135361. init(): void;
  135362. private _getCurrentDistance;
  135363. /**
  135364. * Attaches the scale behavior the passed in mesh
  135365. * @param ownerNode The mesh that will be scaled around once attached
  135366. */
  135367. attach(ownerNode: Mesh): void;
  135368. /**
  135369. * Detaches the behavior from the mesh
  135370. */
  135371. detach(): void;
  135372. }
  135373. }
  135374. declare module BABYLON {
  135375. /**
  135376. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  135377. */
  135378. export class SixDofDragBehavior implements Behavior<Mesh> {
  135379. private static _virtualScene;
  135380. private _ownerNode;
  135381. private _sceneRenderObserver;
  135382. private _scene;
  135383. private _targetPosition;
  135384. private _virtualOriginMesh;
  135385. private _virtualDragMesh;
  135386. private _pointerObserver;
  135387. private _moving;
  135388. private _startingOrientation;
  135389. private _attachedToElement;
  135390. /**
  135391. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  135392. */
  135393. private zDragFactor;
  135394. /**
  135395. * If the object should rotate to face the drag origin
  135396. */
  135397. rotateDraggedObject: boolean;
  135398. /**
  135399. * If the behavior is currently in a dragging state
  135400. */
  135401. dragging: boolean;
  135402. /**
  135403. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  135404. */
  135405. dragDeltaRatio: number;
  135406. /**
  135407. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  135408. */
  135409. currentDraggingPointerID: number;
  135410. /**
  135411. * If camera controls should be detached during the drag
  135412. */
  135413. detachCameraControls: boolean;
  135414. /**
  135415. * Fires each time a drag starts
  135416. */
  135417. onDragStartObservable: Observable<{}>;
  135418. /**
  135419. * Fires each time a drag happens
  135420. */
  135421. onDragObservable: Observable<void>;
  135422. /**
  135423. * Fires each time a drag ends (eg. mouse release after drag)
  135424. */
  135425. onDragEndObservable: Observable<{}>;
  135426. /**
  135427. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  135428. */
  135429. constructor();
  135430. /**
  135431. * The name of the behavior
  135432. */
  135433. get name(): string;
  135434. /**
  135435. * Initializes the behavior
  135436. */
  135437. init(): void;
  135438. /**
  135439. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  135440. */
  135441. private get _pointerCamera();
  135442. /**
  135443. * Attaches the scale behavior the passed in mesh
  135444. * @param ownerNode The mesh that will be scaled around once attached
  135445. */
  135446. attach(ownerNode: Mesh): void;
  135447. /**
  135448. * Detaches the behavior from the mesh
  135449. */
  135450. detach(): void;
  135451. }
  135452. }
  135453. declare module BABYLON {
  135454. /**
  135455. * Class used to apply inverse kinematics to bones
  135456. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  135457. */
  135458. export class BoneIKController {
  135459. private static _tmpVecs;
  135460. private static _tmpQuat;
  135461. private static _tmpMats;
  135462. /**
  135463. * Gets or sets the target mesh
  135464. */
  135465. targetMesh: AbstractMesh;
  135466. /** Gets or sets the mesh used as pole */
  135467. poleTargetMesh: AbstractMesh;
  135468. /**
  135469. * Gets or sets the bone used as pole
  135470. */
  135471. poleTargetBone: Nullable<Bone>;
  135472. /**
  135473. * Gets or sets the target position
  135474. */
  135475. targetPosition: Vector3;
  135476. /**
  135477. * Gets or sets the pole target position
  135478. */
  135479. poleTargetPosition: Vector3;
  135480. /**
  135481. * Gets or sets the pole target local offset
  135482. */
  135483. poleTargetLocalOffset: Vector3;
  135484. /**
  135485. * Gets or sets the pole angle
  135486. */
  135487. poleAngle: number;
  135488. /**
  135489. * Gets or sets the mesh associated with the controller
  135490. */
  135491. mesh: AbstractMesh;
  135492. /**
  135493. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  135494. */
  135495. slerpAmount: number;
  135496. private _bone1Quat;
  135497. private _bone1Mat;
  135498. private _bone2Ang;
  135499. private _bone1;
  135500. private _bone2;
  135501. private _bone1Length;
  135502. private _bone2Length;
  135503. private _maxAngle;
  135504. private _maxReach;
  135505. private _rightHandedSystem;
  135506. private _bendAxis;
  135507. private _slerping;
  135508. private _adjustRoll;
  135509. /**
  135510. * Gets or sets maximum allowed angle
  135511. */
  135512. get maxAngle(): number;
  135513. set maxAngle(value: number);
  135514. /**
  135515. * Creates a new BoneIKController
  135516. * @param mesh defines the mesh to control
  135517. * @param bone defines the bone to control
  135518. * @param options defines options to set up the controller
  135519. */
  135520. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  135521. targetMesh?: AbstractMesh;
  135522. poleTargetMesh?: AbstractMesh;
  135523. poleTargetBone?: Bone;
  135524. poleTargetLocalOffset?: Vector3;
  135525. poleAngle?: number;
  135526. bendAxis?: Vector3;
  135527. maxAngle?: number;
  135528. slerpAmount?: number;
  135529. });
  135530. private _setMaxAngle;
  135531. /**
  135532. * Force the controller to update the bones
  135533. */
  135534. update(): void;
  135535. }
  135536. }
  135537. declare module BABYLON {
  135538. /**
  135539. * Class used to make a bone look toward a point in space
  135540. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  135541. */
  135542. export class BoneLookController {
  135543. private static _tmpVecs;
  135544. private static _tmpQuat;
  135545. private static _tmpMats;
  135546. /**
  135547. * The target Vector3 that the bone will look at
  135548. */
  135549. target: Vector3;
  135550. /**
  135551. * The mesh that the bone is attached to
  135552. */
  135553. mesh: AbstractMesh;
  135554. /**
  135555. * The bone that will be looking to the target
  135556. */
  135557. bone: Bone;
  135558. /**
  135559. * The up axis of the coordinate system that is used when the bone is rotated
  135560. */
  135561. upAxis: Vector3;
  135562. /**
  135563. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  135564. */
  135565. upAxisSpace: Space;
  135566. /**
  135567. * Used to make an adjustment to the yaw of the bone
  135568. */
  135569. adjustYaw: number;
  135570. /**
  135571. * Used to make an adjustment to the pitch of the bone
  135572. */
  135573. adjustPitch: number;
  135574. /**
  135575. * Used to make an adjustment to the roll of the bone
  135576. */
  135577. adjustRoll: number;
  135578. /**
  135579. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  135580. */
  135581. slerpAmount: number;
  135582. private _minYaw;
  135583. private _maxYaw;
  135584. private _minPitch;
  135585. private _maxPitch;
  135586. private _minYawSin;
  135587. private _minYawCos;
  135588. private _maxYawSin;
  135589. private _maxYawCos;
  135590. private _midYawConstraint;
  135591. private _minPitchTan;
  135592. private _maxPitchTan;
  135593. private _boneQuat;
  135594. private _slerping;
  135595. private _transformYawPitch;
  135596. private _transformYawPitchInv;
  135597. private _firstFrameSkipped;
  135598. private _yawRange;
  135599. private _fowardAxis;
  135600. /**
  135601. * Gets or sets the minimum yaw angle that the bone can look to
  135602. */
  135603. get minYaw(): number;
  135604. set minYaw(value: number);
  135605. /**
  135606. * Gets or sets the maximum yaw angle that the bone can look to
  135607. */
  135608. get maxYaw(): number;
  135609. set maxYaw(value: number);
  135610. /**
  135611. * Gets or sets the minimum pitch angle that the bone can look to
  135612. */
  135613. get minPitch(): number;
  135614. set minPitch(value: number);
  135615. /**
  135616. * Gets or sets the maximum pitch angle that the bone can look to
  135617. */
  135618. get maxPitch(): number;
  135619. set maxPitch(value: number);
  135620. /**
  135621. * Create a BoneLookController
  135622. * @param mesh the mesh that the bone belongs to
  135623. * @param bone the bone that will be looking to the target
  135624. * @param target the target Vector3 to look at
  135625. * @param options optional settings:
  135626. * * maxYaw: the maximum angle the bone will yaw to
  135627. * * minYaw: the minimum angle the bone will yaw to
  135628. * * maxPitch: the maximum angle the bone will pitch to
  135629. * * minPitch: the minimum angle the bone will yaw to
  135630. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  135631. * * upAxis: the up axis of the coordinate system
  135632. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  135633. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  135634. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  135635. * * adjustYaw: used to make an adjustment to the yaw of the bone
  135636. * * adjustPitch: used to make an adjustment to the pitch of the bone
  135637. * * adjustRoll: used to make an adjustment to the roll of the bone
  135638. **/
  135639. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  135640. maxYaw?: number;
  135641. minYaw?: number;
  135642. maxPitch?: number;
  135643. minPitch?: number;
  135644. slerpAmount?: number;
  135645. upAxis?: Vector3;
  135646. upAxisSpace?: Space;
  135647. yawAxis?: Vector3;
  135648. pitchAxis?: Vector3;
  135649. adjustYaw?: number;
  135650. adjustPitch?: number;
  135651. adjustRoll?: number;
  135652. });
  135653. /**
  135654. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  135655. */
  135656. update(): void;
  135657. private _getAngleDiff;
  135658. private _getAngleBetween;
  135659. private _isAngleBetween;
  135660. }
  135661. }
  135662. declare module BABYLON {
  135663. /**
  135664. * Manage the gamepad inputs to control an arc rotate camera.
  135665. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135666. */
  135667. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  135668. /**
  135669. * Defines the camera the input is attached to.
  135670. */
  135671. camera: ArcRotateCamera;
  135672. /**
  135673. * Defines the gamepad the input is gathering event from.
  135674. */
  135675. gamepad: Nullable<Gamepad>;
  135676. /**
  135677. * Defines the gamepad rotation sensiblity.
  135678. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  135679. */
  135680. gamepadRotationSensibility: number;
  135681. /**
  135682. * Defines the gamepad move sensiblity.
  135683. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  135684. */
  135685. gamepadMoveSensibility: number;
  135686. private _yAxisScale;
  135687. /**
  135688. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  135689. */
  135690. get invertYAxis(): boolean;
  135691. set invertYAxis(value: boolean);
  135692. private _onGamepadConnectedObserver;
  135693. private _onGamepadDisconnectedObserver;
  135694. /**
  135695. * Attach the input controls to a specific dom element to get the input from.
  135696. */
  135697. attachControl(): void;
  135698. /**
  135699. * Detach the current controls from the specified dom element.
  135700. */
  135701. detachControl(): void;
  135702. /**
  135703. * Update the current camera state depending on the inputs that have been used this frame.
  135704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135705. */
  135706. checkInputs(): void;
  135707. /**
  135708. * Gets the class name of the current intput.
  135709. * @returns the class name
  135710. */
  135711. getClassName(): string;
  135712. /**
  135713. * Get the friendly name associated with the input class.
  135714. * @returns the input friendly name
  135715. */
  135716. getSimpleName(): string;
  135717. }
  135718. }
  135719. declare module BABYLON {
  135720. interface ArcRotateCameraInputsManager {
  135721. /**
  135722. * Add orientation input support to the input manager.
  135723. * @returns the current input manager
  135724. */
  135725. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  135726. }
  135727. /**
  135728. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  135729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135730. */
  135731. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  135732. /**
  135733. * Defines the camera the input is attached to.
  135734. */
  135735. camera: ArcRotateCamera;
  135736. /**
  135737. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  135738. */
  135739. alphaCorrection: number;
  135740. /**
  135741. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  135742. */
  135743. gammaCorrection: number;
  135744. private _alpha;
  135745. private _gamma;
  135746. private _dirty;
  135747. private _deviceOrientationHandler;
  135748. /**
  135749. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  135750. */
  135751. constructor();
  135752. /**
  135753. * Attach the input controls to a specific dom element to get the input from.
  135754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135755. */
  135756. attachControl(noPreventDefault?: boolean): void;
  135757. /** @hidden */
  135758. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  135759. /**
  135760. * Update the current camera state depending on the inputs that have been used this frame.
  135761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135762. */
  135763. checkInputs(): void;
  135764. /**
  135765. * Detach the current controls from the specified dom element.
  135766. */
  135767. detachControl(): void;
  135768. /**
  135769. * Gets the class name of the current intput.
  135770. * @returns the class name
  135771. */
  135772. getClassName(): string;
  135773. /**
  135774. * Get the friendly name associated with the input class.
  135775. * @returns the input friendly name
  135776. */
  135777. getSimpleName(): string;
  135778. }
  135779. }
  135780. declare module BABYLON {
  135781. /**
  135782. * Listen to mouse events to control the camera.
  135783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135784. */
  135785. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  135786. /**
  135787. * Defines the camera the input is attached to.
  135788. */
  135789. camera: FlyCamera;
  135790. /**
  135791. * Defines if touch is enabled. (Default is true.)
  135792. */
  135793. touchEnabled: boolean;
  135794. /**
  135795. * Defines the buttons associated with the input to handle camera rotation.
  135796. */
  135797. buttons: number[];
  135798. /**
  135799. * Assign buttons for Yaw control.
  135800. */
  135801. buttonsYaw: number[];
  135802. /**
  135803. * Assign buttons for Pitch control.
  135804. */
  135805. buttonsPitch: number[];
  135806. /**
  135807. * Assign buttons for Roll control.
  135808. */
  135809. buttonsRoll: number[];
  135810. /**
  135811. * Detect if any button is being pressed while mouse is moved.
  135812. * -1 = Mouse locked.
  135813. * 0 = Left button.
  135814. * 1 = Middle Button.
  135815. * 2 = Right Button.
  135816. */
  135817. activeButton: number;
  135818. /**
  135819. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  135820. * Higher values reduce its sensitivity.
  135821. */
  135822. angularSensibility: number;
  135823. private _observer;
  135824. private _rollObserver;
  135825. private previousPosition;
  135826. private noPreventDefault;
  135827. private element;
  135828. /**
  135829. * Listen to mouse events to control the camera.
  135830. * @param touchEnabled Define if touch is enabled. (Default is true.)
  135831. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135832. */
  135833. constructor(touchEnabled?: boolean);
  135834. /**
  135835. * Attach the mouse control to the HTML DOM element.
  135836. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  135837. */
  135838. attachControl(noPreventDefault?: boolean): void;
  135839. /**
  135840. * Detach the current controls from the specified dom element.
  135841. */
  135842. detachControl(): void;
  135843. /**
  135844. * Gets the class name of the current input.
  135845. * @returns the class name.
  135846. */
  135847. getClassName(): string;
  135848. /**
  135849. * Get the friendly name associated with the input class.
  135850. * @returns the input's friendly name.
  135851. */
  135852. getSimpleName(): string;
  135853. private _pointerInput;
  135854. private _onMouseMove;
  135855. /**
  135856. * Rotate camera by mouse offset.
  135857. */
  135858. private rotateCamera;
  135859. }
  135860. }
  135861. declare module BABYLON {
  135862. /**
  135863. * Default Inputs manager for the FlyCamera.
  135864. * It groups all the default supported inputs for ease of use.
  135865. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135866. */
  135867. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  135868. /**
  135869. * Instantiates a new FlyCameraInputsManager.
  135870. * @param camera Defines the camera the inputs belong to.
  135871. */
  135872. constructor(camera: FlyCamera);
  135873. /**
  135874. * Add keyboard input support to the input manager.
  135875. * @returns the new FlyCameraKeyboardMoveInput().
  135876. */
  135877. addKeyboard(): FlyCameraInputsManager;
  135878. /**
  135879. * Add mouse input support to the input manager.
  135880. * @param touchEnabled Enable touch screen support.
  135881. * @returns the new FlyCameraMouseInput().
  135882. */
  135883. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  135884. }
  135885. }
  135886. declare module BABYLON {
  135887. /**
  135888. * This is a flying camera, designed for 3D movement and rotation in all directions,
  135889. * such as in a 3D Space Shooter or a Flight Simulator.
  135890. */
  135891. export class FlyCamera extends TargetCamera {
  135892. /**
  135893. * Define the collision ellipsoid of the camera.
  135894. * This is helpful for simulating a camera body, like a player's body.
  135895. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  135896. */
  135897. ellipsoid: Vector3;
  135898. /**
  135899. * Define an offset for the position of the ellipsoid around the camera.
  135900. * This can be helpful if the camera is attached away from the player's body center,
  135901. * such as at its head.
  135902. */
  135903. ellipsoidOffset: Vector3;
  135904. /**
  135905. * Enable or disable collisions of the camera with the rest of the scene objects.
  135906. */
  135907. checkCollisions: boolean;
  135908. /**
  135909. * Enable or disable gravity on the camera.
  135910. */
  135911. applyGravity: boolean;
  135912. /**
  135913. * Define the current direction the camera is moving to.
  135914. */
  135915. cameraDirection: Vector3;
  135916. /**
  135917. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  135918. * This overrides and empties cameraRotation.
  135919. */
  135920. rotationQuaternion: Quaternion;
  135921. /**
  135922. * Track Roll to maintain the wanted Rolling when looking around.
  135923. */
  135924. _trackRoll: number;
  135925. /**
  135926. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  135927. */
  135928. rollCorrect: number;
  135929. /**
  135930. * Mimic a banked turn, Rolling the camera when Yawing.
  135931. * It's recommended to use rollCorrect = 10 for faster banking correction.
  135932. */
  135933. bankedTurn: boolean;
  135934. /**
  135935. * Limit in radians for how much Roll banking will add. (Default: 90°)
  135936. */
  135937. bankedTurnLimit: number;
  135938. /**
  135939. * Value of 0 disables the banked Roll.
  135940. * Value of 1 is equal to the Yaw angle in radians.
  135941. */
  135942. bankedTurnMultiplier: number;
  135943. /**
  135944. * The inputs manager loads all the input sources, such as keyboard and mouse.
  135945. */
  135946. inputs: FlyCameraInputsManager;
  135947. /**
  135948. * Gets the input sensibility for mouse input.
  135949. * Higher values reduce sensitivity.
  135950. */
  135951. get angularSensibility(): number;
  135952. /**
  135953. * Sets the input sensibility for a mouse input.
  135954. * Higher values reduce sensitivity.
  135955. */
  135956. set angularSensibility(value: number);
  135957. /**
  135958. * Get the keys for camera movement forward.
  135959. */
  135960. get keysForward(): number[];
  135961. /**
  135962. * Set the keys for camera movement forward.
  135963. */
  135964. set keysForward(value: number[]);
  135965. /**
  135966. * Get the keys for camera movement backward.
  135967. */
  135968. get keysBackward(): number[];
  135969. set keysBackward(value: number[]);
  135970. /**
  135971. * Get the keys for camera movement up.
  135972. */
  135973. get keysUp(): number[];
  135974. /**
  135975. * Set the keys for camera movement up.
  135976. */
  135977. set keysUp(value: number[]);
  135978. /**
  135979. * Get the keys for camera movement down.
  135980. */
  135981. get keysDown(): number[];
  135982. /**
  135983. * Set the keys for camera movement down.
  135984. */
  135985. set keysDown(value: number[]);
  135986. /**
  135987. * Get the keys for camera movement left.
  135988. */
  135989. get keysLeft(): number[];
  135990. /**
  135991. * Set the keys for camera movement left.
  135992. */
  135993. set keysLeft(value: number[]);
  135994. /**
  135995. * Set the keys for camera movement right.
  135996. */
  135997. get keysRight(): number[];
  135998. /**
  135999. * Set the keys for camera movement right.
  136000. */
  136001. set keysRight(value: number[]);
  136002. /**
  136003. * Event raised when the camera collides with a mesh in the scene.
  136004. */
  136005. onCollide: (collidedMesh: AbstractMesh) => void;
  136006. private _collider;
  136007. private _needMoveForGravity;
  136008. private _oldPosition;
  136009. private _diffPosition;
  136010. private _newPosition;
  136011. /** @hidden */
  136012. _localDirection: Vector3;
  136013. /** @hidden */
  136014. _transformedDirection: Vector3;
  136015. /**
  136016. * Instantiates a FlyCamera.
  136017. * This is a flying camera, designed for 3D movement and rotation in all directions,
  136018. * such as in a 3D Space Shooter or a Flight Simulator.
  136019. * @param name Define the name of the camera in the scene.
  136020. * @param position Define the starting position of the camera in the scene.
  136021. * @param scene Define the scene the camera belongs to.
  136022. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  136023. */
  136024. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  136025. /**
  136026. * Attach the input controls to a specific dom element to get the input from.
  136027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136028. */
  136029. attachControl(noPreventDefault?: boolean): void;
  136030. /**
  136031. * Detach a control from the HTML DOM element.
  136032. * The camera will stop reacting to that input.
  136033. */
  136034. detachControl(): void;
  136035. private _collisionMask;
  136036. /**
  136037. * Get the mask that the camera ignores in collision events.
  136038. */
  136039. get collisionMask(): number;
  136040. /**
  136041. * Set the mask that the camera ignores in collision events.
  136042. */
  136043. set collisionMask(mask: number);
  136044. /** @hidden */
  136045. _collideWithWorld(displacement: Vector3): void;
  136046. /** @hidden */
  136047. private _onCollisionPositionChange;
  136048. /** @hidden */
  136049. _checkInputs(): void;
  136050. /** @hidden */
  136051. _decideIfNeedsToMove(): boolean;
  136052. /** @hidden */
  136053. _updatePosition(): void;
  136054. /**
  136055. * Restore the Roll to its target value at the rate specified.
  136056. * @param rate - Higher means slower restoring.
  136057. * @hidden
  136058. */
  136059. restoreRoll(rate: number): void;
  136060. /**
  136061. * Destroy the camera and release the current resources held by it.
  136062. */
  136063. dispose(): void;
  136064. /**
  136065. * Get the current object class name.
  136066. * @returns the class name.
  136067. */
  136068. getClassName(): string;
  136069. }
  136070. }
  136071. declare module BABYLON {
  136072. /**
  136073. * Listen to keyboard events to control the camera.
  136074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136075. */
  136076. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  136077. /**
  136078. * Defines the camera the input is attached to.
  136079. */
  136080. camera: FlyCamera;
  136081. /**
  136082. * The list of keyboard keys used to control the forward move of the camera.
  136083. */
  136084. keysForward: number[];
  136085. /**
  136086. * The list of keyboard keys used to control the backward move of the camera.
  136087. */
  136088. keysBackward: number[];
  136089. /**
  136090. * The list of keyboard keys used to control the forward move of the camera.
  136091. */
  136092. keysUp: number[];
  136093. /**
  136094. * The list of keyboard keys used to control the backward move of the camera.
  136095. */
  136096. keysDown: number[];
  136097. /**
  136098. * The list of keyboard keys used to control the right strafe move of the camera.
  136099. */
  136100. keysRight: number[];
  136101. /**
  136102. * The list of keyboard keys used to control the left strafe move of the camera.
  136103. */
  136104. keysLeft: number[];
  136105. private _keys;
  136106. private _onCanvasBlurObserver;
  136107. private _onKeyboardObserver;
  136108. private _engine;
  136109. private _scene;
  136110. /**
  136111. * Attach the input controls to a specific dom element to get the input from.
  136112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136113. */
  136114. attachControl(noPreventDefault?: boolean): void;
  136115. /**
  136116. * Detach the current controls from the specified dom element.
  136117. */
  136118. detachControl(): void;
  136119. /**
  136120. * Gets the class name of the current intput.
  136121. * @returns the class name
  136122. */
  136123. getClassName(): string;
  136124. /** @hidden */
  136125. _onLostFocus(e: FocusEvent): void;
  136126. /**
  136127. * Get the friendly name associated with the input class.
  136128. * @returns the input friendly name
  136129. */
  136130. getSimpleName(): string;
  136131. /**
  136132. * Update the current camera state depending on the inputs that have been used this frame.
  136133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136134. */
  136135. checkInputs(): void;
  136136. }
  136137. }
  136138. declare module BABYLON {
  136139. /**
  136140. * Manage the mouse wheel inputs to control a follow camera.
  136141. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136142. */
  136143. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  136144. /**
  136145. * Defines the camera the input is attached to.
  136146. */
  136147. camera: FollowCamera;
  136148. /**
  136149. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  136150. */
  136151. axisControlRadius: boolean;
  136152. /**
  136153. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  136154. */
  136155. axisControlHeight: boolean;
  136156. /**
  136157. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  136158. */
  136159. axisControlRotation: boolean;
  136160. /**
  136161. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  136162. * relation to mouseWheel events.
  136163. */
  136164. wheelPrecision: number;
  136165. /**
  136166. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  136167. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  136168. */
  136169. wheelDeltaPercentage: number;
  136170. private _wheel;
  136171. private _observer;
  136172. /**
  136173. * Attach the input controls to a specific dom element to get the input from.
  136174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136175. */
  136176. attachControl(noPreventDefault?: boolean): void;
  136177. /**
  136178. * Detach the current controls from the specified dom element.
  136179. */
  136180. detachControl(): void;
  136181. /**
  136182. * Gets the class name of the current intput.
  136183. * @returns the class name
  136184. */
  136185. getClassName(): string;
  136186. /**
  136187. * Get the friendly name associated with the input class.
  136188. * @returns the input friendly name
  136189. */
  136190. getSimpleName(): string;
  136191. }
  136192. }
  136193. declare module BABYLON {
  136194. /**
  136195. * Manage the pointers inputs to control an follow camera.
  136196. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136197. */
  136198. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  136199. /**
  136200. * Defines the camera the input is attached to.
  136201. */
  136202. camera: FollowCamera;
  136203. /**
  136204. * Gets the class name of the current input.
  136205. * @returns the class name
  136206. */
  136207. getClassName(): string;
  136208. /**
  136209. * Defines the pointer angular sensibility along the X axis or how fast is
  136210. * the camera rotating.
  136211. * A negative number will reverse the axis direction.
  136212. */
  136213. angularSensibilityX: number;
  136214. /**
  136215. * Defines the pointer angular sensibility along the Y axis or how fast is
  136216. * the camera rotating.
  136217. * A negative number will reverse the axis direction.
  136218. */
  136219. angularSensibilityY: number;
  136220. /**
  136221. * Defines the pointer pinch precision or how fast is the camera zooming.
  136222. * A negative number will reverse the axis direction.
  136223. */
  136224. pinchPrecision: number;
  136225. /**
  136226. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  136227. * from 0.
  136228. * It defines the percentage of current camera.radius to use as delta when
  136229. * pinch zoom is used.
  136230. */
  136231. pinchDeltaPercentage: number;
  136232. /**
  136233. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  136234. */
  136235. axisXControlRadius: boolean;
  136236. /**
  136237. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  136238. */
  136239. axisXControlHeight: boolean;
  136240. /**
  136241. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  136242. */
  136243. axisXControlRotation: boolean;
  136244. /**
  136245. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  136246. */
  136247. axisYControlRadius: boolean;
  136248. /**
  136249. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  136250. */
  136251. axisYControlHeight: boolean;
  136252. /**
  136253. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  136254. */
  136255. axisYControlRotation: boolean;
  136256. /**
  136257. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  136258. */
  136259. axisPinchControlRadius: boolean;
  136260. /**
  136261. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  136262. */
  136263. axisPinchControlHeight: boolean;
  136264. /**
  136265. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  136266. */
  136267. axisPinchControlRotation: boolean;
  136268. /**
  136269. * Log error messages if basic misconfiguration has occurred.
  136270. */
  136271. warningEnable: boolean;
  136272. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  136273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  136274. private _warningCounter;
  136275. private _warning;
  136276. }
  136277. }
  136278. declare module BABYLON {
  136279. /**
  136280. * Default Inputs manager for the FollowCamera.
  136281. * It groups all the default supported inputs for ease of use.
  136282. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136283. */
  136284. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  136285. /**
  136286. * Instantiates a new FollowCameraInputsManager.
  136287. * @param camera Defines the camera the inputs belong to
  136288. */
  136289. constructor(camera: FollowCamera);
  136290. /**
  136291. * Add keyboard input support to the input manager.
  136292. * @returns the current input manager
  136293. */
  136294. addKeyboard(): FollowCameraInputsManager;
  136295. /**
  136296. * Add mouse wheel input support to the input manager.
  136297. * @returns the current input manager
  136298. */
  136299. addMouseWheel(): FollowCameraInputsManager;
  136300. /**
  136301. * Add pointers input support to the input manager.
  136302. * @returns the current input manager
  136303. */
  136304. addPointers(): FollowCameraInputsManager;
  136305. /**
  136306. * Add orientation input support to the input manager.
  136307. * @returns the current input manager
  136308. */
  136309. addVRDeviceOrientation(): FollowCameraInputsManager;
  136310. }
  136311. }
  136312. declare module BABYLON {
  136313. /**
  136314. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  136315. * an arc rotate version arcFollowCamera are available.
  136316. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136317. */
  136318. export class FollowCamera extends TargetCamera {
  136319. /**
  136320. * Distance the follow camera should follow an object at
  136321. */
  136322. radius: number;
  136323. /**
  136324. * Minimum allowed distance of the camera to the axis of rotation
  136325. * (The camera can not get closer).
  136326. * This can help limiting how the Camera is able to move in the scene.
  136327. */
  136328. lowerRadiusLimit: Nullable<number>;
  136329. /**
  136330. * Maximum allowed distance of the camera to the axis of rotation
  136331. * (The camera can not get further).
  136332. * This can help limiting how the Camera is able to move in the scene.
  136333. */
  136334. upperRadiusLimit: Nullable<number>;
  136335. /**
  136336. * Define a rotation offset between the camera and the object it follows
  136337. */
  136338. rotationOffset: number;
  136339. /**
  136340. * Minimum allowed angle to camera position relative to target object.
  136341. * This can help limiting how the Camera is able to move in the scene.
  136342. */
  136343. lowerRotationOffsetLimit: Nullable<number>;
  136344. /**
  136345. * Maximum allowed angle to camera position relative to target object.
  136346. * This can help limiting how the Camera is able to move in the scene.
  136347. */
  136348. upperRotationOffsetLimit: Nullable<number>;
  136349. /**
  136350. * Define a height offset between the camera and the object it follows.
  136351. * It can help following an object from the top (like a car chaing a plane)
  136352. */
  136353. heightOffset: number;
  136354. /**
  136355. * Minimum allowed height of camera position relative to target object.
  136356. * This can help limiting how the Camera is able to move in the scene.
  136357. */
  136358. lowerHeightOffsetLimit: Nullable<number>;
  136359. /**
  136360. * Maximum allowed height of camera position relative to target object.
  136361. * This can help limiting how the Camera is able to move in the scene.
  136362. */
  136363. upperHeightOffsetLimit: Nullable<number>;
  136364. /**
  136365. * Define how fast the camera can accelerate to follow it s target.
  136366. */
  136367. cameraAcceleration: number;
  136368. /**
  136369. * Define the speed limit of the camera following an object.
  136370. */
  136371. maxCameraSpeed: number;
  136372. /**
  136373. * Define the target of the camera.
  136374. */
  136375. lockedTarget: Nullable<AbstractMesh>;
  136376. /**
  136377. * Defines the input associated with the camera.
  136378. */
  136379. inputs: FollowCameraInputsManager;
  136380. /**
  136381. * Instantiates the follow camera.
  136382. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136383. * @param name Define the name of the camera in the scene
  136384. * @param position Define the position of the camera
  136385. * @param scene Define the scene the camera belong to
  136386. * @param lockedTarget Define the target of the camera
  136387. */
  136388. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  136389. private _follow;
  136390. /**
  136391. * Attach the input controls to a specific dom element to get the input from.
  136392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136393. */
  136394. attachControl(noPreventDefault?: boolean): void;
  136395. /**
  136396. * Detach the current controls from the specified dom element.
  136397. */
  136398. detachControl(): void;
  136399. /** @hidden */
  136400. _checkInputs(): void;
  136401. private _checkLimits;
  136402. /**
  136403. * Gets the camera class name.
  136404. * @returns the class name
  136405. */
  136406. getClassName(): string;
  136407. }
  136408. /**
  136409. * Arc Rotate version of the follow camera.
  136410. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  136411. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136412. */
  136413. export class ArcFollowCamera extends TargetCamera {
  136414. /** The longitudinal angle of the camera */
  136415. alpha: number;
  136416. /** The latitudinal angle of the camera */
  136417. beta: number;
  136418. /** The radius of the camera from its target */
  136419. radius: number;
  136420. private _cartesianCoordinates;
  136421. /** Define the camera target (the mesh it should follow) */
  136422. private _meshTarget;
  136423. /**
  136424. * Instantiates a new ArcFollowCamera
  136425. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  136426. * @param name Define the name of the camera
  136427. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  136428. * @param beta Define the rotation angle of the camera around the elevation axis
  136429. * @param radius Define the radius of the camera from its target point
  136430. * @param target Define the target of the camera
  136431. * @param scene Define the scene the camera belongs to
  136432. */
  136433. constructor(name: string,
  136434. /** The longitudinal angle of the camera */
  136435. alpha: number,
  136436. /** The latitudinal angle of the camera */
  136437. beta: number,
  136438. /** The radius of the camera from its target */
  136439. radius: number,
  136440. /** Define the camera target (the mesh it should follow) */
  136441. target: Nullable<AbstractMesh>, scene: Scene);
  136442. private _follow;
  136443. /** @hidden */
  136444. _checkInputs(): void;
  136445. /**
  136446. * Returns the class name of the object.
  136447. * It is mostly used internally for serialization purposes.
  136448. */
  136449. getClassName(): string;
  136450. }
  136451. }
  136452. declare module BABYLON {
  136453. /**
  136454. * Manage the keyboard inputs to control the movement of a follow camera.
  136455. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136456. */
  136457. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  136458. /**
  136459. * Defines the camera the input is attached to.
  136460. */
  136461. camera: FollowCamera;
  136462. /**
  136463. * Defines the list of key codes associated with the up action (increase heightOffset)
  136464. */
  136465. keysHeightOffsetIncr: number[];
  136466. /**
  136467. * Defines the list of key codes associated with the down action (decrease heightOffset)
  136468. */
  136469. keysHeightOffsetDecr: number[];
  136470. /**
  136471. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  136472. */
  136473. keysHeightOffsetModifierAlt: boolean;
  136474. /**
  136475. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  136476. */
  136477. keysHeightOffsetModifierCtrl: boolean;
  136478. /**
  136479. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  136480. */
  136481. keysHeightOffsetModifierShift: boolean;
  136482. /**
  136483. * Defines the list of key codes associated with the left action (increase rotationOffset)
  136484. */
  136485. keysRotationOffsetIncr: number[];
  136486. /**
  136487. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  136488. */
  136489. keysRotationOffsetDecr: number[];
  136490. /**
  136491. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  136492. */
  136493. keysRotationOffsetModifierAlt: boolean;
  136494. /**
  136495. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  136496. */
  136497. keysRotationOffsetModifierCtrl: boolean;
  136498. /**
  136499. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  136500. */
  136501. keysRotationOffsetModifierShift: boolean;
  136502. /**
  136503. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  136504. */
  136505. keysRadiusIncr: number[];
  136506. /**
  136507. * Defines the list of key codes associated with the zoom-out action (increase radius)
  136508. */
  136509. keysRadiusDecr: number[];
  136510. /**
  136511. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  136512. */
  136513. keysRadiusModifierAlt: boolean;
  136514. /**
  136515. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  136516. */
  136517. keysRadiusModifierCtrl: boolean;
  136518. /**
  136519. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  136520. */
  136521. keysRadiusModifierShift: boolean;
  136522. /**
  136523. * Defines the rate of change of heightOffset.
  136524. */
  136525. heightSensibility: number;
  136526. /**
  136527. * Defines the rate of change of rotationOffset.
  136528. */
  136529. rotationSensibility: number;
  136530. /**
  136531. * Defines the rate of change of radius.
  136532. */
  136533. radiusSensibility: number;
  136534. private _keys;
  136535. private _ctrlPressed;
  136536. private _altPressed;
  136537. private _shiftPressed;
  136538. private _onCanvasBlurObserver;
  136539. private _onKeyboardObserver;
  136540. private _engine;
  136541. private _scene;
  136542. /**
  136543. * Attach the input controls to a specific dom element to get the input from.
  136544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136545. */
  136546. attachControl(noPreventDefault?: boolean): void;
  136547. /**
  136548. * Detach the current controls from the specified dom element.
  136549. */
  136550. detachControl(): void;
  136551. /**
  136552. * Update the current camera state depending on the inputs that have been used this frame.
  136553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136554. */
  136555. checkInputs(): void;
  136556. /**
  136557. * Gets the class name of the current input.
  136558. * @returns the class name
  136559. */
  136560. getClassName(): string;
  136561. /**
  136562. * Get the friendly name associated with the input class.
  136563. * @returns the input friendly name
  136564. */
  136565. getSimpleName(): string;
  136566. /**
  136567. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  136568. * allow modification of the heightOffset value.
  136569. */
  136570. private _modifierHeightOffset;
  136571. /**
  136572. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  136573. * allow modification of the rotationOffset value.
  136574. */
  136575. private _modifierRotationOffset;
  136576. /**
  136577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  136578. * allow modification of the radius value.
  136579. */
  136580. private _modifierRadius;
  136581. }
  136582. }
  136583. declare module BABYLON {
  136584. interface FreeCameraInputsManager {
  136585. /**
  136586. * @hidden
  136587. */
  136588. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  136589. /**
  136590. * Add orientation input support to the input manager.
  136591. * @returns the current input manager
  136592. */
  136593. addDeviceOrientation(): FreeCameraInputsManager;
  136594. }
  136595. /**
  136596. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  136597. * Screen rotation is taken into account.
  136598. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136599. */
  136600. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  136601. private _camera;
  136602. private _screenOrientationAngle;
  136603. private _constantTranform;
  136604. private _screenQuaternion;
  136605. private _alpha;
  136606. private _beta;
  136607. private _gamma;
  136608. /**
  136609. * Can be used to detect if a device orientation sensor is available on a device
  136610. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  136611. * @returns a promise that will resolve on orientation change
  136612. */
  136613. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  136614. /**
  136615. * @hidden
  136616. */
  136617. _onDeviceOrientationChangedObservable: Observable<void>;
  136618. /**
  136619. * Instantiates a new input
  136620. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136621. */
  136622. constructor();
  136623. /**
  136624. * Define the camera controlled by the input.
  136625. */
  136626. get camera(): FreeCamera;
  136627. set camera(camera: FreeCamera);
  136628. /**
  136629. * Attach the input controls to a specific dom element to get the input from.
  136630. */
  136631. attachControl(): void;
  136632. private _orientationChanged;
  136633. private _deviceOrientation;
  136634. /**
  136635. * Detach the current controls from the specified dom element.
  136636. */
  136637. detachControl(): void;
  136638. /**
  136639. * Update the current camera state depending on the inputs that have been used this frame.
  136640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136641. */
  136642. checkInputs(): void;
  136643. /**
  136644. * Gets the class name of the current intput.
  136645. * @returns the class name
  136646. */
  136647. getClassName(): string;
  136648. /**
  136649. * Get the friendly name associated with the input class.
  136650. * @returns the input friendly name
  136651. */
  136652. getSimpleName(): string;
  136653. }
  136654. }
  136655. declare module BABYLON {
  136656. /**
  136657. * Manage the gamepad inputs to control a free camera.
  136658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136659. */
  136660. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  136661. /**
  136662. * Define the camera the input is attached to.
  136663. */
  136664. camera: FreeCamera;
  136665. /**
  136666. * Define the Gamepad controlling the input
  136667. */
  136668. gamepad: Nullable<Gamepad>;
  136669. /**
  136670. * Defines the gamepad rotation sensiblity.
  136671. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  136672. */
  136673. gamepadAngularSensibility: number;
  136674. /**
  136675. * Defines the gamepad move sensiblity.
  136676. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  136677. */
  136678. gamepadMoveSensibility: number;
  136679. private _yAxisScale;
  136680. /**
  136681. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  136682. */
  136683. get invertYAxis(): boolean;
  136684. set invertYAxis(value: boolean);
  136685. private _onGamepadConnectedObserver;
  136686. private _onGamepadDisconnectedObserver;
  136687. private _cameraTransform;
  136688. private _deltaTransform;
  136689. private _vector3;
  136690. private _vector2;
  136691. /**
  136692. * Attach the input controls to a specific dom element to get the input from.
  136693. */
  136694. attachControl(): void;
  136695. /**
  136696. * Detach the current controls from the specified dom element.
  136697. */
  136698. detachControl(): void;
  136699. /**
  136700. * Update the current camera state depending on the inputs that have been used this frame.
  136701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136702. */
  136703. checkInputs(): void;
  136704. /**
  136705. * Gets the class name of the current intput.
  136706. * @returns the class name
  136707. */
  136708. getClassName(): string;
  136709. /**
  136710. * Get the friendly name associated with the input class.
  136711. * @returns the input friendly name
  136712. */
  136713. getSimpleName(): string;
  136714. }
  136715. }
  136716. declare module BABYLON {
  136717. /**
  136718. * Defines the potential axis of a Joystick
  136719. */
  136720. export enum JoystickAxis {
  136721. /** X axis */
  136722. X = 0,
  136723. /** Y axis */
  136724. Y = 1,
  136725. /** Z axis */
  136726. Z = 2
  136727. }
  136728. /**
  136729. * Represents the different customization options available
  136730. * for VirtualJoystick
  136731. */
  136732. interface VirtualJoystickCustomizations {
  136733. /**
  136734. * Size of the joystick's puck
  136735. */
  136736. puckSize: number;
  136737. /**
  136738. * Size of the joystick's container
  136739. */
  136740. containerSize: number;
  136741. /**
  136742. * Color of the joystick && puck
  136743. */
  136744. color: string;
  136745. /**
  136746. * Image URL for the joystick's puck
  136747. */
  136748. puckImage?: string;
  136749. /**
  136750. * Image URL for the joystick's container
  136751. */
  136752. containerImage?: string;
  136753. /**
  136754. * Defines the unmoving position of the joystick container
  136755. */
  136756. position?: {
  136757. x: number;
  136758. y: number;
  136759. };
  136760. /**
  136761. * Defines whether or not the joystick container is always visible
  136762. */
  136763. alwaysVisible: boolean;
  136764. /**
  136765. * Defines whether or not to limit the movement of the puck to the joystick's container
  136766. */
  136767. limitToContainer: boolean;
  136768. }
  136769. /**
  136770. * Class used to define virtual joystick (used in touch mode)
  136771. */
  136772. export class VirtualJoystick {
  136773. /**
  136774. * Gets or sets a boolean indicating that left and right values must be inverted
  136775. */
  136776. reverseLeftRight: boolean;
  136777. /**
  136778. * Gets or sets a boolean indicating that up and down values must be inverted
  136779. */
  136780. reverseUpDown: boolean;
  136781. /**
  136782. * Gets the offset value for the position (ie. the change of the position value)
  136783. */
  136784. deltaPosition: Vector3;
  136785. /**
  136786. * Gets a boolean indicating if the virtual joystick was pressed
  136787. */
  136788. pressed: boolean;
  136789. /**
  136790. * Canvas the virtual joystick will render onto, default z-index of this is 5
  136791. */
  136792. static Canvas: Nullable<HTMLCanvasElement>;
  136793. /**
  136794. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  136795. */
  136796. limitToContainer: boolean;
  136797. private static _globalJoystickIndex;
  136798. private static _alwaysVisibleSticks;
  136799. private static vjCanvasContext;
  136800. private static vjCanvasWidth;
  136801. private static vjCanvasHeight;
  136802. private static halfWidth;
  136803. private static _GetDefaultOptions;
  136804. private _action;
  136805. private _axisTargetedByLeftAndRight;
  136806. private _axisTargetedByUpAndDown;
  136807. private _joystickSensibility;
  136808. private _inversedSensibility;
  136809. private _joystickPointerID;
  136810. private _joystickColor;
  136811. private _joystickPointerPos;
  136812. private _joystickPreviousPointerPos;
  136813. private _joystickPointerStartPos;
  136814. private _deltaJoystickVector;
  136815. private _leftJoystick;
  136816. private _touches;
  136817. private _joystickPosition;
  136818. private _alwaysVisible;
  136819. private _puckImage;
  136820. private _containerImage;
  136821. private _joystickPuckSize;
  136822. private _joystickContainerSize;
  136823. private _clearPuckSize;
  136824. private _clearContainerSize;
  136825. private _clearPuckSizeOffset;
  136826. private _clearContainerSizeOffset;
  136827. private _onPointerDownHandlerRef;
  136828. private _onPointerMoveHandlerRef;
  136829. private _onPointerUpHandlerRef;
  136830. private _onResize;
  136831. /**
  136832. * Creates a new virtual joystick
  136833. * @param leftJoystick defines that the joystick is for left hand (false by default)
  136834. * @param customizations Defines the options we want to customize the VirtualJoystick
  136835. */
  136836. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  136837. /**
  136838. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  136839. * @param newJoystickSensibility defines the new sensibility
  136840. */
  136841. setJoystickSensibility(newJoystickSensibility: number): void;
  136842. private _onPointerDown;
  136843. private _onPointerMove;
  136844. private _onPointerUp;
  136845. /**
  136846. * Change the color of the virtual joystick
  136847. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  136848. */
  136849. setJoystickColor(newColor: string): void;
  136850. /**
  136851. * Size of the joystick's container
  136852. */
  136853. set containerSize(newSize: number);
  136854. get containerSize(): number;
  136855. /**
  136856. * Size of the joystick's puck
  136857. */
  136858. set puckSize(newSize: number);
  136859. get puckSize(): number;
  136860. /**
  136861. * Clears the set position of the joystick
  136862. */
  136863. clearPosition(): void;
  136864. /**
  136865. * Defines whether or not the joystick container is always visible
  136866. */
  136867. set alwaysVisible(value: boolean);
  136868. get alwaysVisible(): boolean;
  136869. /**
  136870. * Sets the constant position of the Joystick container
  136871. * @param x X axis coordinate
  136872. * @param y Y axis coordinate
  136873. */
  136874. setPosition(x: number, y: number): void;
  136875. /**
  136876. * Defines a callback to call when the joystick is touched
  136877. * @param action defines the callback
  136878. */
  136879. setActionOnTouch(action: () => any): void;
  136880. /**
  136881. * Defines which axis you'd like to control for left & right
  136882. * @param axis defines the axis to use
  136883. */
  136884. setAxisForLeftRight(axis: JoystickAxis): void;
  136885. /**
  136886. * Defines which axis you'd like to control for up & down
  136887. * @param axis defines the axis to use
  136888. */
  136889. setAxisForUpDown(axis: JoystickAxis): void;
  136890. /**
  136891. * Clears the canvas from the previous puck / container draw
  136892. */
  136893. private _clearPreviousDraw;
  136894. /**
  136895. * Loads `urlPath` to be used for the container's image
  136896. * @param urlPath defines the urlPath of an image to use
  136897. */
  136898. setContainerImage(urlPath: string): void;
  136899. /**
  136900. * Loads `urlPath` to be used for the puck's image
  136901. * @param urlPath defines the urlPath of an image to use
  136902. */
  136903. setPuckImage(urlPath: string): void;
  136904. /**
  136905. * Draws the Virtual Joystick's container
  136906. */
  136907. private _drawContainer;
  136908. /**
  136909. * Draws the Virtual Joystick's puck
  136910. */
  136911. private _drawPuck;
  136912. private _drawVirtualJoystick;
  136913. /**
  136914. * Release internal HTML canvas
  136915. */
  136916. releaseCanvas(): void;
  136917. }
  136918. }
  136919. declare module BABYLON {
  136920. interface FreeCameraInputsManager {
  136921. /**
  136922. * Add virtual joystick input support to the input manager.
  136923. * @returns the current input manager
  136924. */
  136925. addVirtualJoystick(): FreeCameraInputsManager;
  136926. }
  136927. /**
  136928. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  136929. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136930. */
  136931. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  136932. /**
  136933. * Defines the camera the input is attached to.
  136934. */
  136935. camera: FreeCamera;
  136936. private _leftjoystick;
  136937. private _rightjoystick;
  136938. /**
  136939. * Gets the left stick of the virtual joystick.
  136940. * @returns The virtual Joystick
  136941. */
  136942. getLeftJoystick(): VirtualJoystick;
  136943. /**
  136944. * Gets the right stick of the virtual joystick.
  136945. * @returns The virtual Joystick
  136946. */
  136947. getRightJoystick(): VirtualJoystick;
  136948. /**
  136949. * Update the current camera state depending on the inputs that have been used this frame.
  136950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136951. */
  136952. checkInputs(): void;
  136953. /**
  136954. * Attach the input controls to a specific dom element to get the input from.
  136955. */
  136956. attachControl(): void;
  136957. /**
  136958. * Detach the current controls from the specified dom element.
  136959. */
  136960. detachControl(): void;
  136961. /**
  136962. * Gets the class name of the current intput.
  136963. * @returns the class name
  136964. */
  136965. getClassName(): string;
  136966. /**
  136967. * Get the friendly name associated with the input class.
  136968. * @returns the input friendly name
  136969. */
  136970. getSimpleName(): string;
  136971. }
  136972. }
  136973. declare module BABYLON {
  136974. /**
  136975. * This represents a FPS type of camera controlled by touch.
  136976. * This is like a universal camera minus the Gamepad controls.
  136977. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136978. */
  136979. export class TouchCamera extends FreeCamera {
  136980. /**
  136981. * Defines the touch sensibility for rotation.
  136982. * The higher the faster.
  136983. */
  136984. get touchAngularSensibility(): number;
  136985. set touchAngularSensibility(value: number);
  136986. /**
  136987. * Defines the touch sensibility for move.
  136988. * The higher the faster.
  136989. */
  136990. get touchMoveSensibility(): number;
  136991. set touchMoveSensibility(value: number);
  136992. /**
  136993. * Instantiates a new touch camera.
  136994. * This represents a FPS type of camera controlled by touch.
  136995. * This is like a universal camera minus the Gamepad controls.
  136996. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136997. * @param name Define the name of the camera in the scene
  136998. * @param position Define the start position of the camera in the scene
  136999. * @param scene Define the scene the camera belongs to
  137000. */
  137001. constructor(name: string, position: Vector3, scene: Scene);
  137002. /**
  137003. * Gets the current object class name.
  137004. * @return the class name
  137005. */
  137006. getClassName(): string;
  137007. /** @hidden */
  137008. _setupInputs(): void;
  137009. }
  137010. }
  137011. declare module BABYLON {
  137012. /**
  137013. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  137014. * being tilted forward or back and left or right.
  137015. */
  137016. export class DeviceOrientationCamera extends FreeCamera {
  137017. private _initialQuaternion;
  137018. private _quaternionCache;
  137019. private _tmpDragQuaternion;
  137020. private _disablePointerInputWhenUsingDeviceOrientation;
  137021. /**
  137022. * Creates a new device orientation camera
  137023. * @param name The name of the camera
  137024. * @param position The start position camera
  137025. * @param scene The scene the camera belongs to
  137026. */
  137027. constructor(name: string, position: Vector3, scene: Scene);
  137028. /**
  137029. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  137030. */
  137031. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  137032. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  137033. private _dragFactor;
  137034. /**
  137035. * Enabled turning on the y axis when the orientation sensor is active
  137036. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  137037. */
  137038. enableHorizontalDragging(dragFactor?: number): void;
  137039. /**
  137040. * Gets the current instance class name ("DeviceOrientationCamera").
  137041. * This helps avoiding instanceof at run time.
  137042. * @returns the class name
  137043. */
  137044. getClassName(): string;
  137045. /**
  137046. * @hidden
  137047. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  137048. */
  137049. _checkInputs(): void;
  137050. /**
  137051. * Reset the camera to its default orientation on the specified axis only.
  137052. * @param axis The axis to reset
  137053. */
  137054. resetToCurrentRotation(axis?: Axis): void;
  137055. }
  137056. }
  137057. declare module BABYLON {
  137058. /**
  137059. * Defines supported buttons for XBox360 compatible gamepads
  137060. */
  137061. export enum Xbox360Button {
  137062. /** A */
  137063. A = 0,
  137064. /** B */
  137065. B = 1,
  137066. /** X */
  137067. X = 2,
  137068. /** Y */
  137069. Y = 3,
  137070. /** Left button */
  137071. LB = 4,
  137072. /** Right button */
  137073. RB = 5,
  137074. /** Back */
  137075. Back = 8,
  137076. /** Start */
  137077. Start = 9,
  137078. /** Left stick */
  137079. LeftStick = 10,
  137080. /** Right stick */
  137081. RightStick = 11
  137082. }
  137083. /** Defines values for XBox360 DPad */
  137084. export enum Xbox360Dpad {
  137085. /** Up */
  137086. Up = 12,
  137087. /** Down */
  137088. Down = 13,
  137089. /** Left */
  137090. Left = 14,
  137091. /** Right */
  137092. Right = 15
  137093. }
  137094. /**
  137095. * Defines a XBox360 gamepad
  137096. */
  137097. export class Xbox360Pad extends Gamepad {
  137098. private _leftTrigger;
  137099. private _rightTrigger;
  137100. private _onlefttriggerchanged;
  137101. private _onrighttriggerchanged;
  137102. private _onbuttondown;
  137103. private _onbuttonup;
  137104. private _ondpaddown;
  137105. private _ondpadup;
  137106. /** Observable raised when a button is pressed */
  137107. onButtonDownObservable: Observable<Xbox360Button>;
  137108. /** Observable raised when a button is released */
  137109. onButtonUpObservable: Observable<Xbox360Button>;
  137110. /** Observable raised when a pad is pressed */
  137111. onPadDownObservable: Observable<Xbox360Dpad>;
  137112. /** Observable raised when a pad is released */
  137113. onPadUpObservable: Observable<Xbox360Dpad>;
  137114. private _buttonA;
  137115. private _buttonB;
  137116. private _buttonX;
  137117. private _buttonY;
  137118. private _buttonBack;
  137119. private _buttonStart;
  137120. private _buttonLB;
  137121. private _buttonRB;
  137122. private _buttonLeftStick;
  137123. private _buttonRightStick;
  137124. private _dPadUp;
  137125. private _dPadDown;
  137126. private _dPadLeft;
  137127. private _dPadRight;
  137128. private _isXboxOnePad;
  137129. /**
  137130. * Creates a new XBox360 gamepad object
  137131. * @param id defines the id of this gamepad
  137132. * @param index defines its index
  137133. * @param gamepad defines the internal HTML gamepad object
  137134. * @param xboxOne defines if it is a XBox One gamepad
  137135. */
  137136. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  137137. /**
  137138. * Defines the callback to call when left trigger is pressed
  137139. * @param callback defines the callback to use
  137140. */
  137141. onlefttriggerchanged(callback: (value: number) => void): void;
  137142. /**
  137143. * Defines the callback to call when right trigger is pressed
  137144. * @param callback defines the callback to use
  137145. */
  137146. onrighttriggerchanged(callback: (value: number) => void): void;
  137147. /**
  137148. * Gets the left trigger value
  137149. */
  137150. get leftTrigger(): number;
  137151. /**
  137152. * Sets the left trigger value
  137153. */
  137154. set leftTrigger(newValue: number);
  137155. /**
  137156. * Gets the right trigger value
  137157. */
  137158. get rightTrigger(): number;
  137159. /**
  137160. * Sets the right trigger value
  137161. */
  137162. set rightTrigger(newValue: number);
  137163. /**
  137164. * Defines the callback to call when a button is pressed
  137165. * @param callback defines the callback to use
  137166. */
  137167. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  137168. /**
  137169. * Defines the callback to call when a button is released
  137170. * @param callback defines the callback to use
  137171. */
  137172. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  137173. /**
  137174. * Defines the callback to call when a pad is pressed
  137175. * @param callback defines the callback to use
  137176. */
  137177. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  137178. /**
  137179. * Defines the callback to call when a pad is released
  137180. * @param callback defines the callback to use
  137181. */
  137182. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  137183. private _setButtonValue;
  137184. private _setDPadValue;
  137185. /**
  137186. * Gets the value of the `A` button
  137187. */
  137188. get buttonA(): number;
  137189. /**
  137190. * Sets the value of the `A` button
  137191. */
  137192. set buttonA(value: number);
  137193. /**
  137194. * Gets the value of the `B` button
  137195. */
  137196. get buttonB(): number;
  137197. /**
  137198. * Sets the value of the `B` button
  137199. */
  137200. set buttonB(value: number);
  137201. /**
  137202. * Gets the value of the `X` button
  137203. */
  137204. get buttonX(): number;
  137205. /**
  137206. * Sets the value of the `X` button
  137207. */
  137208. set buttonX(value: number);
  137209. /**
  137210. * Gets the value of the `Y` button
  137211. */
  137212. get buttonY(): number;
  137213. /**
  137214. * Sets the value of the `Y` button
  137215. */
  137216. set buttonY(value: number);
  137217. /**
  137218. * Gets the value of the `Start` button
  137219. */
  137220. get buttonStart(): number;
  137221. /**
  137222. * Sets the value of the `Start` button
  137223. */
  137224. set buttonStart(value: number);
  137225. /**
  137226. * Gets the value of the `Back` button
  137227. */
  137228. get buttonBack(): number;
  137229. /**
  137230. * Sets the value of the `Back` button
  137231. */
  137232. set buttonBack(value: number);
  137233. /**
  137234. * Gets the value of the `Left` button
  137235. */
  137236. get buttonLB(): number;
  137237. /**
  137238. * Sets the value of the `Left` button
  137239. */
  137240. set buttonLB(value: number);
  137241. /**
  137242. * Gets the value of the `Right` button
  137243. */
  137244. get buttonRB(): number;
  137245. /**
  137246. * Sets the value of the `Right` button
  137247. */
  137248. set buttonRB(value: number);
  137249. /**
  137250. * Gets the value of the Left joystick
  137251. */
  137252. get buttonLeftStick(): number;
  137253. /**
  137254. * Sets the value of the Left joystick
  137255. */
  137256. set buttonLeftStick(value: number);
  137257. /**
  137258. * Gets the value of the Right joystick
  137259. */
  137260. get buttonRightStick(): number;
  137261. /**
  137262. * Sets the value of the Right joystick
  137263. */
  137264. set buttonRightStick(value: number);
  137265. /**
  137266. * Gets the value of D-pad up
  137267. */
  137268. get dPadUp(): number;
  137269. /**
  137270. * Sets the value of D-pad up
  137271. */
  137272. set dPadUp(value: number);
  137273. /**
  137274. * Gets the value of D-pad down
  137275. */
  137276. get dPadDown(): number;
  137277. /**
  137278. * Sets the value of D-pad down
  137279. */
  137280. set dPadDown(value: number);
  137281. /**
  137282. * Gets the value of D-pad left
  137283. */
  137284. get dPadLeft(): number;
  137285. /**
  137286. * Sets the value of D-pad left
  137287. */
  137288. set dPadLeft(value: number);
  137289. /**
  137290. * Gets the value of D-pad right
  137291. */
  137292. get dPadRight(): number;
  137293. /**
  137294. * Sets the value of D-pad right
  137295. */
  137296. set dPadRight(value: number);
  137297. /**
  137298. * Force the gamepad to synchronize with device values
  137299. */
  137300. update(): void;
  137301. /**
  137302. * Disposes the gamepad
  137303. */
  137304. dispose(): void;
  137305. }
  137306. }
  137307. declare module BABYLON {
  137308. /**
  137309. * Defines supported buttons for DualShock compatible gamepads
  137310. */
  137311. export enum DualShockButton {
  137312. /** Cross */
  137313. Cross = 0,
  137314. /** Circle */
  137315. Circle = 1,
  137316. /** Square */
  137317. Square = 2,
  137318. /** Triangle */
  137319. Triangle = 3,
  137320. /** L1 */
  137321. L1 = 4,
  137322. /** R1 */
  137323. R1 = 5,
  137324. /** Share */
  137325. Share = 8,
  137326. /** Options */
  137327. Options = 9,
  137328. /** Left stick */
  137329. LeftStick = 10,
  137330. /** Right stick */
  137331. RightStick = 11
  137332. }
  137333. /** Defines values for DualShock DPad */
  137334. export enum DualShockDpad {
  137335. /** Up */
  137336. Up = 12,
  137337. /** Down */
  137338. Down = 13,
  137339. /** Left */
  137340. Left = 14,
  137341. /** Right */
  137342. Right = 15
  137343. }
  137344. /**
  137345. * Defines a DualShock gamepad
  137346. */
  137347. export class DualShockPad extends Gamepad {
  137348. private _leftTrigger;
  137349. private _rightTrigger;
  137350. private _onlefttriggerchanged;
  137351. private _onrighttriggerchanged;
  137352. private _onbuttondown;
  137353. private _onbuttonup;
  137354. private _ondpaddown;
  137355. private _ondpadup;
  137356. /** Observable raised when a button is pressed */
  137357. onButtonDownObservable: Observable<DualShockButton>;
  137358. /** Observable raised when a button is released */
  137359. onButtonUpObservable: Observable<DualShockButton>;
  137360. /** Observable raised when a pad is pressed */
  137361. onPadDownObservable: Observable<DualShockDpad>;
  137362. /** Observable raised when a pad is released */
  137363. onPadUpObservable: Observable<DualShockDpad>;
  137364. private _buttonCross;
  137365. private _buttonCircle;
  137366. private _buttonSquare;
  137367. private _buttonTriangle;
  137368. private _buttonShare;
  137369. private _buttonOptions;
  137370. private _buttonL1;
  137371. private _buttonR1;
  137372. private _buttonLeftStick;
  137373. private _buttonRightStick;
  137374. private _dPadUp;
  137375. private _dPadDown;
  137376. private _dPadLeft;
  137377. private _dPadRight;
  137378. /**
  137379. * Creates a new DualShock gamepad object
  137380. * @param id defines the id of this gamepad
  137381. * @param index defines its index
  137382. * @param gamepad defines the internal HTML gamepad object
  137383. */
  137384. constructor(id: string, index: number, gamepad: any);
  137385. /**
  137386. * Defines the callback to call when left trigger is pressed
  137387. * @param callback defines the callback to use
  137388. */
  137389. onlefttriggerchanged(callback: (value: number) => void): void;
  137390. /**
  137391. * Defines the callback to call when right trigger is pressed
  137392. * @param callback defines the callback to use
  137393. */
  137394. onrighttriggerchanged(callback: (value: number) => void): void;
  137395. /**
  137396. * Gets the left trigger value
  137397. */
  137398. get leftTrigger(): number;
  137399. /**
  137400. * Sets the left trigger value
  137401. */
  137402. set leftTrigger(newValue: number);
  137403. /**
  137404. * Gets the right trigger value
  137405. */
  137406. get rightTrigger(): number;
  137407. /**
  137408. * Sets the right trigger value
  137409. */
  137410. set rightTrigger(newValue: number);
  137411. /**
  137412. * Defines the callback to call when a button is pressed
  137413. * @param callback defines the callback to use
  137414. */
  137415. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  137416. /**
  137417. * Defines the callback to call when a button is released
  137418. * @param callback defines the callback to use
  137419. */
  137420. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  137421. /**
  137422. * Defines the callback to call when a pad is pressed
  137423. * @param callback defines the callback to use
  137424. */
  137425. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  137426. /**
  137427. * Defines the callback to call when a pad is released
  137428. * @param callback defines the callback to use
  137429. */
  137430. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  137431. private _setButtonValue;
  137432. private _setDPadValue;
  137433. /**
  137434. * Gets the value of the `Cross` button
  137435. */
  137436. get buttonCross(): number;
  137437. /**
  137438. * Sets the value of the `Cross` button
  137439. */
  137440. set buttonCross(value: number);
  137441. /**
  137442. * Gets the value of the `Circle` button
  137443. */
  137444. get buttonCircle(): number;
  137445. /**
  137446. * Sets the value of the `Circle` button
  137447. */
  137448. set buttonCircle(value: number);
  137449. /**
  137450. * Gets the value of the `Square` button
  137451. */
  137452. get buttonSquare(): number;
  137453. /**
  137454. * Sets the value of the `Square` button
  137455. */
  137456. set buttonSquare(value: number);
  137457. /**
  137458. * Gets the value of the `Triangle` button
  137459. */
  137460. get buttonTriangle(): number;
  137461. /**
  137462. * Sets the value of the `Triangle` button
  137463. */
  137464. set buttonTriangle(value: number);
  137465. /**
  137466. * Gets the value of the `Options` button
  137467. */
  137468. get buttonOptions(): number;
  137469. /**
  137470. * Sets the value of the `Options` button
  137471. */
  137472. set buttonOptions(value: number);
  137473. /**
  137474. * Gets the value of the `Share` button
  137475. */
  137476. get buttonShare(): number;
  137477. /**
  137478. * Sets the value of the `Share` button
  137479. */
  137480. set buttonShare(value: number);
  137481. /**
  137482. * Gets the value of the `L1` button
  137483. */
  137484. get buttonL1(): number;
  137485. /**
  137486. * Sets the value of the `L1` button
  137487. */
  137488. set buttonL1(value: number);
  137489. /**
  137490. * Gets the value of the `R1` button
  137491. */
  137492. get buttonR1(): number;
  137493. /**
  137494. * Sets the value of the `R1` button
  137495. */
  137496. set buttonR1(value: number);
  137497. /**
  137498. * Gets the value of the Left joystick
  137499. */
  137500. get buttonLeftStick(): number;
  137501. /**
  137502. * Sets the value of the Left joystick
  137503. */
  137504. set buttonLeftStick(value: number);
  137505. /**
  137506. * Gets the value of the Right joystick
  137507. */
  137508. get buttonRightStick(): number;
  137509. /**
  137510. * Sets the value of the Right joystick
  137511. */
  137512. set buttonRightStick(value: number);
  137513. /**
  137514. * Gets the value of D-pad up
  137515. */
  137516. get dPadUp(): number;
  137517. /**
  137518. * Sets the value of D-pad up
  137519. */
  137520. set dPadUp(value: number);
  137521. /**
  137522. * Gets the value of D-pad down
  137523. */
  137524. get dPadDown(): number;
  137525. /**
  137526. * Sets the value of D-pad down
  137527. */
  137528. set dPadDown(value: number);
  137529. /**
  137530. * Gets the value of D-pad left
  137531. */
  137532. get dPadLeft(): number;
  137533. /**
  137534. * Sets the value of D-pad left
  137535. */
  137536. set dPadLeft(value: number);
  137537. /**
  137538. * Gets the value of D-pad right
  137539. */
  137540. get dPadRight(): number;
  137541. /**
  137542. * Sets the value of D-pad right
  137543. */
  137544. set dPadRight(value: number);
  137545. /**
  137546. * Force the gamepad to synchronize with device values
  137547. */
  137548. update(): void;
  137549. /**
  137550. * Disposes the gamepad
  137551. */
  137552. dispose(): void;
  137553. }
  137554. }
  137555. declare module BABYLON {
  137556. /**
  137557. * Manager for handling gamepads
  137558. */
  137559. export class GamepadManager {
  137560. private _scene?;
  137561. private _babylonGamepads;
  137562. private _oneGamepadConnected;
  137563. /** @hidden */
  137564. _isMonitoring: boolean;
  137565. private _gamepadEventSupported;
  137566. private _gamepadSupport?;
  137567. /**
  137568. * observable to be triggered when the gamepad controller has been connected
  137569. */
  137570. onGamepadConnectedObservable: Observable<Gamepad>;
  137571. /**
  137572. * observable to be triggered when the gamepad controller has been disconnected
  137573. */
  137574. onGamepadDisconnectedObservable: Observable<Gamepad>;
  137575. private _onGamepadConnectedEvent;
  137576. private _onGamepadDisconnectedEvent;
  137577. /**
  137578. * Initializes the gamepad manager
  137579. * @param _scene BabylonJS scene
  137580. */
  137581. constructor(_scene?: Scene | undefined);
  137582. /**
  137583. * The gamepads in the game pad manager
  137584. */
  137585. get gamepads(): Gamepad[];
  137586. /**
  137587. * Get the gamepad controllers based on type
  137588. * @param type The type of gamepad controller
  137589. * @returns Nullable gamepad
  137590. */
  137591. getGamepadByType(type?: number): Nullable<Gamepad>;
  137592. /**
  137593. * Disposes the gamepad manager
  137594. */
  137595. dispose(): void;
  137596. private _addNewGamepad;
  137597. private _startMonitoringGamepads;
  137598. private _stopMonitoringGamepads;
  137599. /** @hidden */
  137600. _checkGamepadsStatus(): void;
  137601. private _updateGamepadObjects;
  137602. }
  137603. }
  137604. declare module BABYLON {
  137605. interface Scene {
  137606. /** @hidden */
  137607. _gamepadManager: Nullable<GamepadManager>;
  137608. /**
  137609. * Gets the gamepad manager associated with the scene
  137610. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  137611. */
  137612. gamepadManager: GamepadManager;
  137613. }
  137614. /**
  137615. * Interface representing a free camera inputs manager
  137616. */
  137617. interface FreeCameraInputsManager {
  137618. /**
  137619. * Adds gamepad input support to the FreeCameraInputsManager.
  137620. * @returns the FreeCameraInputsManager
  137621. */
  137622. addGamepad(): FreeCameraInputsManager;
  137623. }
  137624. /**
  137625. * Interface representing an arc rotate camera inputs manager
  137626. */
  137627. interface ArcRotateCameraInputsManager {
  137628. /**
  137629. * Adds gamepad input support to the ArcRotateCamera InputManager.
  137630. * @returns the camera inputs manager
  137631. */
  137632. addGamepad(): ArcRotateCameraInputsManager;
  137633. }
  137634. /**
  137635. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  137636. */
  137637. export class GamepadSystemSceneComponent implements ISceneComponent {
  137638. /**
  137639. * The component name helpfull to identify the component in the list of scene components.
  137640. */
  137641. readonly name: string;
  137642. /**
  137643. * The scene the component belongs to.
  137644. */
  137645. scene: Scene;
  137646. /**
  137647. * Creates a new instance of the component for the given scene
  137648. * @param scene Defines the scene to register the component in
  137649. */
  137650. constructor(scene: Scene);
  137651. /**
  137652. * Registers the component in a given scene
  137653. */
  137654. register(): void;
  137655. /**
  137656. * Rebuilds the elements related to this component in case of
  137657. * context lost for instance.
  137658. */
  137659. rebuild(): void;
  137660. /**
  137661. * Disposes the component and the associated ressources
  137662. */
  137663. dispose(): void;
  137664. private _beforeCameraUpdate;
  137665. }
  137666. }
  137667. declare module BABYLON {
  137668. /**
  137669. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  137670. * which still works and will still be found in many Playgrounds.
  137671. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137672. */
  137673. export class UniversalCamera extends TouchCamera {
  137674. /**
  137675. * Defines the gamepad rotation sensiblity.
  137676. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  137677. */
  137678. get gamepadAngularSensibility(): number;
  137679. set gamepadAngularSensibility(value: number);
  137680. /**
  137681. * Defines the gamepad move sensiblity.
  137682. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  137683. */
  137684. get gamepadMoveSensibility(): number;
  137685. set gamepadMoveSensibility(value: number);
  137686. /**
  137687. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  137688. * which still works and will still be found in many Playgrounds.
  137689. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137690. * @param name Define the name of the camera in the scene
  137691. * @param position Define the start position of the camera in the scene
  137692. * @param scene Define the scene the camera belongs to
  137693. */
  137694. constructor(name: string, position: Vector3, scene: Scene);
  137695. /**
  137696. * Gets the current object class name.
  137697. * @return the class name
  137698. */
  137699. getClassName(): string;
  137700. }
  137701. }
  137702. declare module BABYLON {
  137703. /**
  137704. * This represents a FPS type of camera. This is only here for back compat purpose.
  137705. * Please use the UniversalCamera instead as both are identical.
  137706. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137707. */
  137708. export class GamepadCamera extends UniversalCamera {
  137709. /**
  137710. * Instantiates a new Gamepad Camera
  137711. * This represents a FPS type of camera. This is only here for back compat purpose.
  137712. * Please use the UniversalCamera instead as both are identical.
  137713. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137714. * @param name Define the name of the camera in the scene
  137715. * @param position Define the start position of the camera in the scene
  137716. * @param scene Define the scene the camera belongs to
  137717. */
  137718. constructor(name: string, position: Vector3, scene: Scene);
  137719. /**
  137720. * Gets the current object class name.
  137721. * @return the class name
  137722. */
  137723. getClassName(): string;
  137724. }
  137725. }
  137726. declare module BABYLON {
  137727. /** @hidden */
  137728. export var anaglyphPixelShader: {
  137729. name: string;
  137730. shader: string;
  137731. };
  137732. }
  137733. declare module BABYLON {
  137734. /**
  137735. * Postprocess used to generate anaglyphic rendering
  137736. */
  137737. export class AnaglyphPostProcess extends PostProcess {
  137738. private _passedProcess;
  137739. /**
  137740. * Gets a string identifying the name of the class
  137741. * @returns "AnaglyphPostProcess" string
  137742. */
  137743. getClassName(): string;
  137744. /**
  137745. * Creates a new AnaglyphPostProcess
  137746. * @param name defines postprocess name
  137747. * @param options defines creation options or target ratio scale
  137748. * @param rigCameras defines cameras using this postprocess
  137749. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  137750. * @param engine defines hosting engine
  137751. * @param reusable defines if the postprocess will be reused multiple times per frame
  137752. */
  137753. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  137754. }
  137755. }
  137756. declare module BABYLON {
  137757. /**
  137758. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  137759. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137760. */
  137761. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  137762. /**
  137763. * Creates a new AnaglyphArcRotateCamera
  137764. * @param name defines camera name
  137765. * @param alpha defines alpha angle (in radians)
  137766. * @param beta defines beta angle (in radians)
  137767. * @param radius defines radius
  137768. * @param target defines camera target
  137769. * @param interaxialDistance defines distance between each color axis
  137770. * @param scene defines the hosting scene
  137771. */
  137772. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  137773. /**
  137774. * Gets camera class name
  137775. * @returns AnaglyphArcRotateCamera
  137776. */
  137777. getClassName(): string;
  137778. }
  137779. }
  137780. declare module BABYLON {
  137781. /**
  137782. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  137783. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137784. */
  137785. export class AnaglyphFreeCamera extends FreeCamera {
  137786. /**
  137787. * Creates a new AnaglyphFreeCamera
  137788. * @param name defines camera name
  137789. * @param position defines initial position
  137790. * @param interaxialDistance defines distance between each color axis
  137791. * @param scene defines the hosting scene
  137792. */
  137793. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137794. /**
  137795. * Gets camera class name
  137796. * @returns AnaglyphFreeCamera
  137797. */
  137798. getClassName(): string;
  137799. }
  137800. }
  137801. declare module BABYLON {
  137802. /**
  137803. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  137804. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137805. */
  137806. export class AnaglyphGamepadCamera extends GamepadCamera {
  137807. /**
  137808. * Creates a new AnaglyphGamepadCamera
  137809. * @param name defines camera name
  137810. * @param position defines initial position
  137811. * @param interaxialDistance defines distance between each color axis
  137812. * @param scene defines the hosting scene
  137813. */
  137814. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137815. /**
  137816. * Gets camera class name
  137817. * @returns AnaglyphGamepadCamera
  137818. */
  137819. getClassName(): string;
  137820. }
  137821. }
  137822. declare module BABYLON {
  137823. /**
  137824. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  137825. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137826. */
  137827. export class AnaglyphUniversalCamera extends UniversalCamera {
  137828. /**
  137829. * Creates a new AnaglyphUniversalCamera
  137830. * @param name defines camera name
  137831. * @param position defines initial position
  137832. * @param interaxialDistance defines distance between each color axis
  137833. * @param scene defines the hosting scene
  137834. */
  137835. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137836. /**
  137837. * Gets camera class name
  137838. * @returns AnaglyphUniversalCamera
  137839. */
  137840. getClassName(): string;
  137841. }
  137842. }
  137843. declare module BABYLON {
  137844. /** @hidden */
  137845. export var stereoscopicInterlacePixelShader: {
  137846. name: string;
  137847. shader: string;
  137848. };
  137849. }
  137850. declare module BABYLON {
  137851. /**
  137852. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  137853. */
  137854. export class StereoscopicInterlacePostProcessI extends PostProcess {
  137855. private _stepSize;
  137856. private _passedProcess;
  137857. /**
  137858. * Gets a string identifying the name of the class
  137859. * @returns "StereoscopicInterlacePostProcessI" string
  137860. */
  137861. getClassName(): string;
  137862. /**
  137863. * Initializes a StereoscopicInterlacePostProcessI
  137864. * @param name The name of the effect.
  137865. * @param rigCameras The rig cameras to be appled to the post process
  137866. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  137867. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  137868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137869. * @param engine The engine which the post process will be applied. (default: current engine)
  137870. * @param reusable If the post process can be reused on the same frame. (default: false)
  137871. */
  137872. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137873. }
  137874. /**
  137875. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  137876. */
  137877. export class StereoscopicInterlacePostProcess extends PostProcess {
  137878. private _stepSize;
  137879. private _passedProcess;
  137880. /**
  137881. * Gets a string identifying the name of the class
  137882. * @returns "StereoscopicInterlacePostProcess" string
  137883. */
  137884. getClassName(): string;
  137885. /**
  137886. * Initializes a StereoscopicInterlacePostProcess
  137887. * @param name The name of the effect.
  137888. * @param rigCameras The rig cameras to be appled to the post process
  137889. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  137890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137891. * @param engine The engine which the post process will be applied. (default: current engine)
  137892. * @param reusable If the post process can be reused on the same frame. (default: false)
  137893. */
  137894. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137895. }
  137896. }
  137897. declare module BABYLON {
  137898. /**
  137899. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  137900. * @see https://doc.babylonjs.com/features/cameras
  137901. */
  137902. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  137903. /**
  137904. * Creates a new StereoscopicArcRotateCamera
  137905. * @param name defines camera name
  137906. * @param alpha defines alpha angle (in radians)
  137907. * @param beta defines beta angle (in radians)
  137908. * @param radius defines radius
  137909. * @param target defines camera target
  137910. * @param interaxialDistance defines distance between each color axis
  137911. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137912. * @param scene defines the hosting scene
  137913. */
  137914. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137915. /**
  137916. * Gets camera class name
  137917. * @returns StereoscopicArcRotateCamera
  137918. */
  137919. getClassName(): string;
  137920. }
  137921. }
  137922. declare module BABYLON {
  137923. /**
  137924. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  137925. * @see https://doc.babylonjs.com/features/cameras
  137926. */
  137927. export class StereoscopicFreeCamera extends FreeCamera {
  137928. /**
  137929. * Creates a new StereoscopicFreeCamera
  137930. * @param name defines camera name
  137931. * @param position defines initial position
  137932. * @param interaxialDistance defines distance between each color axis
  137933. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137934. * @param scene defines the hosting scene
  137935. */
  137936. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137937. /**
  137938. * Gets camera class name
  137939. * @returns StereoscopicFreeCamera
  137940. */
  137941. getClassName(): string;
  137942. }
  137943. }
  137944. declare module BABYLON {
  137945. /**
  137946. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  137947. * @see https://doc.babylonjs.com/features/cameras
  137948. */
  137949. export class StereoscopicGamepadCamera extends GamepadCamera {
  137950. /**
  137951. * Creates a new StereoscopicGamepadCamera
  137952. * @param name defines camera name
  137953. * @param position defines initial position
  137954. * @param interaxialDistance defines distance between each color axis
  137955. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137956. * @param scene defines the hosting scene
  137957. */
  137958. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137959. /**
  137960. * Gets camera class name
  137961. * @returns StereoscopicGamepadCamera
  137962. */
  137963. getClassName(): string;
  137964. }
  137965. }
  137966. declare module BABYLON {
  137967. /**
  137968. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  137969. * @see https://doc.babylonjs.com/features/cameras
  137970. */
  137971. export class StereoscopicUniversalCamera extends UniversalCamera {
  137972. /**
  137973. * Creates a new StereoscopicUniversalCamera
  137974. * @param name defines camera name
  137975. * @param position defines initial position
  137976. * @param interaxialDistance defines distance between each color axis
  137977. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137978. * @param scene defines the hosting scene
  137979. */
  137980. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137981. /**
  137982. * Gets camera class name
  137983. * @returns StereoscopicUniversalCamera
  137984. */
  137985. getClassName(): string;
  137986. }
  137987. }
  137988. declare module BABYLON {
  137989. /**
  137990. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  137991. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137992. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  137993. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  137994. */
  137995. export class VirtualJoysticksCamera extends FreeCamera {
  137996. /**
  137997. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  137998. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137999. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  138000. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  138001. * @param name Define the name of the camera in the scene
  138002. * @param position Define the start position of the camera in the scene
  138003. * @param scene Define the scene the camera belongs to
  138004. */
  138005. constructor(name: string, position: Vector3, scene: Scene);
  138006. /**
  138007. * Gets the current object class name.
  138008. * @return the class name
  138009. */
  138010. getClassName(): string;
  138011. }
  138012. }
  138013. declare module BABYLON {
  138014. /**
  138015. * This represents all the required metrics to create a VR camera.
  138016. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  138017. */
  138018. export class VRCameraMetrics {
  138019. /**
  138020. * Define the horizontal resolution off the screen.
  138021. */
  138022. hResolution: number;
  138023. /**
  138024. * Define the vertical resolution off the screen.
  138025. */
  138026. vResolution: number;
  138027. /**
  138028. * Define the horizontal screen size.
  138029. */
  138030. hScreenSize: number;
  138031. /**
  138032. * Define the vertical screen size.
  138033. */
  138034. vScreenSize: number;
  138035. /**
  138036. * Define the vertical screen center position.
  138037. */
  138038. vScreenCenter: number;
  138039. /**
  138040. * Define the distance of the eyes to the screen.
  138041. */
  138042. eyeToScreenDistance: number;
  138043. /**
  138044. * Define the distance between both lenses
  138045. */
  138046. lensSeparationDistance: number;
  138047. /**
  138048. * Define the distance between both viewer's eyes.
  138049. */
  138050. interpupillaryDistance: number;
  138051. /**
  138052. * Define the distortion factor of the VR postprocess.
  138053. * Please, touch with care.
  138054. */
  138055. distortionK: number[];
  138056. /**
  138057. * Define the chromatic aberration correction factors for the VR post process.
  138058. */
  138059. chromaAbCorrection: number[];
  138060. /**
  138061. * Define the scale factor of the post process.
  138062. * The smaller the better but the slower.
  138063. */
  138064. postProcessScaleFactor: number;
  138065. /**
  138066. * Define an offset for the lens center.
  138067. */
  138068. lensCenterOffset: number;
  138069. /**
  138070. * Define if the current vr camera should compensate the distortion of the lense or not.
  138071. */
  138072. compensateDistortion: boolean;
  138073. /**
  138074. * Defines if multiview should be enabled when rendering (Default: false)
  138075. */
  138076. multiviewEnabled: boolean;
  138077. /**
  138078. * Gets the rendering aspect ratio based on the provided resolutions.
  138079. */
  138080. get aspectRatio(): number;
  138081. /**
  138082. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  138083. */
  138084. get aspectRatioFov(): number;
  138085. /**
  138086. * @hidden
  138087. */
  138088. get leftHMatrix(): Matrix;
  138089. /**
  138090. * @hidden
  138091. */
  138092. get rightHMatrix(): Matrix;
  138093. /**
  138094. * @hidden
  138095. */
  138096. get leftPreViewMatrix(): Matrix;
  138097. /**
  138098. * @hidden
  138099. */
  138100. get rightPreViewMatrix(): Matrix;
  138101. /**
  138102. * Get the default VRMetrics based on the most generic setup.
  138103. * @returns the default vr metrics
  138104. */
  138105. static GetDefault(): VRCameraMetrics;
  138106. }
  138107. }
  138108. declare module BABYLON {
  138109. /** @hidden */
  138110. export var vrDistortionCorrectionPixelShader: {
  138111. name: string;
  138112. shader: string;
  138113. };
  138114. }
  138115. declare module BABYLON {
  138116. /**
  138117. * VRDistortionCorrectionPostProcess used for mobile VR
  138118. */
  138119. export class VRDistortionCorrectionPostProcess extends PostProcess {
  138120. private _isRightEye;
  138121. private _distortionFactors;
  138122. private _postProcessScaleFactor;
  138123. private _lensCenterOffset;
  138124. private _scaleIn;
  138125. private _scaleFactor;
  138126. private _lensCenter;
  138127. /**
  138128. * Gets a string identifying the name of the class
  138129. * @returns "VRDistortionCorrectionPostProcess" string
  138130. */
  138131. getClassName(): string;
  138132. /**
  138133. * Initializes the VRDistortionCorrectionPostProcess
  138134. * @param name The name of the effect.
  138135. * @param camera The camera to apply the render pass to.
  138136. * @param isRightEye If this is for the right eye distortion
  138137. * @param vrMetrics All the required metrics for the VR camera
  138138. */
  138139. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  138140. }
  138141. }
  138142. declare module BABYLON {
  138143. /**
  138144. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  138145. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  138146. */
  138147. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  138148. /**
  138149. * Creates a new VRDeviceOrientationArcRotateCamera
  138150. * @param name defines camera name
  138151. * @param alpha defines the camera rotation along the logitudinal axis
  138152. * @param beta defines the camera rotation along the latitudinal axis
  138153. * @param radius defines the camera distance from its target
  138154. * @param target defines the camera target
  138155. * @param scene defines the scene the camera belongs to
  138156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  138157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  138158. */
  138159. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  138160. /**
  138161. * Gets camera class name
  138162. * @returns VRDeviceOrientationArcRotateCamera
  138163. */
  138164. getClassName(): string;
  138165. }
  138166. }
  138167. declare module BABYLON {
  138168. /**
  138169. * Camera used to simulate VR rendering (based on FreeCamera)
  138170. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  138171. */
  138172. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  138173. /**
  138174. * Creates a new VRDeviceOrientationFreeCamera
  138175. * @param name defines camera name
  138176. * @param position defines the start position of the camera
  138177. * @param scene defines the scene the camera belongs to
  138178. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  138179. * @param vrCameraMetrics defines the vr metrics associated to the camera
  138180. */
  138181. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  138182. /**
  138183. * Gets camera class name
  138184. * @returns VRDeviceOrientationFreeCamera
  138185. */
  138186. getClassName(): string;
  138187. }
  138188. }
  138189. declare module BABYLON {
  138190. /**
  138191. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  138192. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  138193. */
  138194. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  138195. /**
  138196. * Creates a new VRDeviceOrientationGamepadCamera
  138197. * @param name defines camera name
  138198. * @param position defines the start position of the camera
  138199. * @param scene defines the scene the camera belongs to
  138200. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  138201. * @param vrCameraMetrics defines the vr metrics associated to the camera
  138202. */
  138203. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  138204. /**
  138205. * Gets camera class name
  138206. * @returns VRDeviceOrientationGamepadCamera
  138207. */
  138208. getClassName(): string;
  138209. }
  138210. }
  138211. declare module BABYLON {
  138212. /**
  138213. * A class extending Texture allowing drawing on a texture
  138214. * @see https://doc.babylonjs.com/how_to/dynamictexture
  138215. */
  138216. export class DynamicTexture extends Texture {
  138217. private _generateMipMaps;
  138218. private _canvas;
  138219. private _context;
  138220. /**
  138221. * Creates a DynamicTexture
  138222. * @param name defines the name of the texture
  138223. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  138224. * @param scene defines the scene where you want the texture
  138225. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  138226. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  138227. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  138228. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  138229. */
  138230. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  138231. /**
  138232. * Get the current class name of the texture useful for serialization or dynamic coding.
  138233. * @returns "DynamicTexture"
  138234. */
  138235. getClassName(): string;
  138236. /**
  138237. * Gets the current state of canRescale
  138238. */
  138239. get canRescale(): boolean;
  138240. private _recreate;
  138241. /**
  138242. * Scales the texture
  138243. * @param ratio the scale factor to apply to both width and height
  138244. */
  138245. scale(ratio: number): void;
  138246. /**
  138247. * Resizes the texture
  138248. * @param width the new width
  138249. * @param height the new height
  138250. */
  138251. scaleTo(width: number, height: number): void;
  138252. /**
  138253. * Gets the context of the canvas used by the texture
  138254. * @returns the canvas context of the dynamic texture
  138255. */
  138256. getContext(): CanvasRenderingContext2D;
  138257. /**
  138258. * Clears the texture
  138259. */
  138260. clear(): void;
  138261. /**
  138262. * Updates the texture
  138263. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  138264. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  138265. */
  138266. update(invertY?: boolean, premulAlpha?: boolean): void;
  138267. /**
  138268. * Draws text onto the texture
  138269. * @param text defines the text to be drawn
  138270. * @param x defines the placement of the text from the left
  138271. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  138272. * @param font defines the font to be used with font-style, font-size, font-name
  138273. * @param color defines the color used for the text
  138274. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  138275. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  138276. * @param update defines whether texture is immediately update (default is true)
  138277. */
  138278. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  138279. /**
  138280. * Clones the texture
  138281. * @returns the clone of the texture.
  138282. */
  138283. clone(): DynamicTexture;
  138284. /**
  138285. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  138286. * @returns a serialized dynamic texture object
  138287. */
  138288. serialize(): any;
  138289. private _IsCanvasElement;
  138290. /** @hidden */
  138291. _rebuild(): void;
  138292. }
  138293. }
  138294. declare module BABYLON {
  138295. /**
  138296. * Class containing static functions to help procedurally build meshes
  138297. */
  138298. export class GroundBuilder {
  138299. /**
  138300. * Creates a ground mesh
  138301. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  138302. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  138303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138304. * @param name defines the name of the mesh
  138305. * @param options defines the options used to create the mesh
  138306. * @param scene defines the hosting scene
  138307. * @returns the ground mesh
  138308. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  138309. */
  138310. static CreateGround(name: string, options: {
  138311. width?: number;
  138312. height?: number;
  138313. subdivisions?: number;
  138314. subdivisionsX?: number;
  138315. subdivisionsY?: number;
  138316. updatable?: boolean;
  138317. }, scene: any): Mesh;
  138318. /**
  138319. * Creates a tiled ground mesh
  138320. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  138321. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  138322. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  138323. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  138324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138325. * @param name defines the name of the mesh
  138326. * @param options defines the options used to create the mesh
  138327. * @param scene defines the hosting scene
  138328. * @returns the tiled ground mesh
  138329. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  138330. */
  138331. static CreateTiledGround(name: string, options: {
  138332. xmin: number;
  138333. zmin: number;
  138334. xmax: number;
  138335. zmax: number;
  138336. subdivisions?: {
  138337. w: number;
  138338. h: number;
  138339. };
  138340. precision?: {
  138341. w: number;
  138342. h: number;
  138343. };
  138344. updatable?: boolean;
  138345. }, scene?: Nullable<Scene>): Mesh;
  138346. /**
  138347. * Creates a ground mesh from a height map
  138348. * * The parameter `url` sets the URL of the height map image resource.
  138349. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  138350. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  138351. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  138352. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  138353. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  138354. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  138355. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  138356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138357. * @param name defines the name of the mesh
  138358. * @param url defines the url to the height map
  138359. * @param options defines the options used to create the mesh
  138360. * @param scene defines the hosting scene
  138361. * @returns the ground mesh
  138362. * @see https://doc.babylonjs.com/babylon101/height_map
  138363. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  138364. */
  138365. static CreateGroundFromHeightMap(name: string, url: string, options: {
  138366. width?: number;
  138367. height?: number;
  138368. subdivisions?: number;
  138369. minHeight?: number;
  138370. maxHeight?: number;
  138371. colorFilter?: Color3;
  138372. alphaFilter?: number;
  138373. updatable?: boolean;
  138374. onReady?: (mesh: GroundMesh) => void;
  138375. }, scene?: Nullable<Scene>): GroundMesh;
  138376. }
  138377. }
  138378. declare module BABYLON {
  138379. /**
  138380. * Class containing static functions to help procedurally build meshes
  138381. */
  138382. export class TorusBuilder {
  138383. /**
  138384. * Creates a torus mesh
  138385. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  138386. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  138387. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  138388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138391. * @param name defines the name of the mesh
  138392. * @param options defines the options used to create the mesh
  138393. * @param scene defines the hosting scene
  138394. * @returns the torus mesh
  138395. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  138396. */
  138397. static CreateTorus(name: string, options: {
  138398. diameter?: number;
  138399. thickness?: number;
  138400. tessellation?: number;
  138401. updatable?: boolean;
  138402. sideOrientation?: number;
  138403. frontUVs?: Vector4;
  138404. backUVs?: Vector4;
  138405. }, scene: any): Mesh;
  138406. }
  138407. }
  138408. declare module BABYLON {
  138409. /**
  138410. * Class containing static functions to help procedurally build meshes
  138411. */
  138412. export class CylinderBuilder {
  138413. /**
  138414. * Creates a cylinder or a cone mesh
  138415. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  138416. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  138417. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  138418. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  138419. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  138420. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  138421. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  138422. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  138423. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  138424. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  138425. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  138426. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  138427. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  138428. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  138429. * * If `enclose` is false, a ring surface is one element.
  138430. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  138431. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  138432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138435. * @param name defines the name of the mesh
  138436. * @param options defines the options used to create the mesh
  138437. * @param scene defines the hosting scene
  138438. * @returns the cylinder mesh
  138439. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  138440. */
  138441. static CreateCylinder(name: string, options: {
  138442. height?: number;
  138443. diameterTop?: number;
  138444. diameterBottom?: number;
  138445. diameter?: number;
  138446. tessellation?: number;
  138447. subdivisions?: number;
  138448. arc?: number;
  138449. faceColors?: Color4[];
  138450. faceUV?: Vector4[];
  138451. updatable?: boolean;
  138452. hasRings?: boolean;
  138453. enclose?: boolean;
  138454. cap?: number;
  138455. sideOrientation?: number;
  138456. frontUVs?: Vector4;
  138457. backUVs?: Vector4;
  138458. }, scene: any): Mesh;
  138459. }
  138460. }
  138461. declare module BABYLON {
  138462. /**
  138463. * States of the webXR experience
  138464. */
  138465. export enum WebXRState {
  138466. /**
  138467. * Transitioning to being in XR mode
  138468. */
  138469. ENTERING_XR = 0,
  138470. /**
  138471. * Transitioning to non XR mode
  138472. */
  138473. EXITING_XR = 1,
  138474. /**
  138475. * In XR mode and presenting
  138476. */
  138477. IN_XR = 2,
  138478. /**
  138479. * Not entered XR mode
  138480. */
  138481. NOT_IN_XR = 3
  138482. }
  138483. /**
  138484. * The state of the XR camera's tracking
  138485. */
  138486. export enum WebXRTrackingState {
  138487. /**
  138488. * No transformation received, device is not being tracked
  138489. */
  138490. NOT_TRACKING = 0,
  138491. /**
  138492. * Tracking lost - using emulated position
  138493. */
  138494. TRACKING_LOST = 1,
  138495. /**
  138496. * Transformation tracking works normally
  138497. */
  138498. TRACKING = 2
  138499. }
  138500. /**
  138501. * Abstraction of the XR render target
  138502. */
  138503. export interface WebXRRenderTarget extends IDisposable {
  138504. /**
  138505. * xrpresent context of the canvas which can be used to display/mirror xr content
  138506. */
  138507. canvasContext: WebGLRenderingContext;
  138508. /**
  138509. * xr layer for the canvas
  138510. */
  138511. xrLayer: Nullable<XRWebGLLayer>;
  138512. /**
  138513. * Initializes the xr layer for the session
  138514. * @param xrSession xr session
  138515. * @returns a promise that will resolve once the XR Layer has been created
  138516. */
  138517. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  138518. }
  138519. }
  138520. declare module BABYLON {
  138521. /**
  138522. * COnfiguration object for WebXR output canvas
  138523. */
  138524. export class WebXRManagedOutputCanvasOptions {
  138525. /**
  138526. * An optional canvas in case you wish to create it yourself and provide it here.
  138527. * If not provided, a new canvas will be created
  138528. */
  138529. canvasElement?: HTMLCanvasElement;
  138530. /**
  138531. * Options for this XR Layer output
  138532. */
  138533. canvasOptions?: XRWebGLLayerInit;
  138534. /**
  138535. * CSS styling for a newly created canvas (if not provided)
  138536. */
  138537. newCanvasCssStyle?: string;
  138538. /**
  138539. * Get the default values of the configuration object
  138540. * @param engine defines the engine to use (can be null)
  138541. * @returns default values of this configuration object
  138542. */
  138543. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  138544. }
  138545. /**
  138546. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  138547. */
  138548. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  138549. private _options;
  138550. private _canvas;
  138551. private _engine;
  138552. private _originalCanvasSize;
  138553. /**
  138554. * Rendering context of the canvas which can be used to display/mirror xr content
  138555. */
  138556. canvasContext: WebGLRenderingContext;
  138557. /**
  138558. * xr layer for the canvas
  138559. */
  138560. xrLayer: Nullable<XRWebGLLayer>;
  138561. /**
  138562. * Obseervers registered here will be triggered when the xr layer was initialized
  138563. */
  138564. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  138565. /**
  138566. * Initializes the canvas to be added/removed upon entering/exiting xr
  138567. * @param _xrSessionManager The XR Session manager
  138568. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  138569. */
  138570. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  138571. /**
  138572. * Disposes of the object
  138573. */
  138574. dispose(): void;
  138575. /**
  138576. * Initializes the xr layer for the session
  138577. * @param xrSession xr session
  138578. * @returns a promise that will resolve once the XR Layer has been created
  138579. */
  138580. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  138581. private _addCanvas;
  138582. private _removeCanvas;
  138583. private _setCanvasSize;
  138584. private _setManagedOutputCanvas;
  138585. }
  138586. }
  138587. declare module BABYLON {
  138588. /**
  138589. * Manages an XRSession to work with Babylon's engine
  138590. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  138591. */
  138592. export class WebXRSessionManager implements IDisposable {
  138593. /** The scene which the session should be created for */
  138594. scene: Scene;
  138595. private _referenceSpace;
  138596. private _rttProvider;
  138597. private _sessionEnded;
  138598. private _xrNavigator;
  138599. private baseLayer;
  138600. /**
  138601. * The base reference space from which the session started. good if you want to reset your
  138602. * reference space
  138603. */
  138604. baseReferenceSpace: XRReferenceSpace;
  138605. /**
  138606. * Current XR frame
  138607. */
  138608. currentFrame: Nullable<XRFrame>;
  138609. /** WebXR timestamp updated every frame */
  138610. currentTimestamp: number;
  138611. /**
  138612. * Used just in case of a failure to initialize an immersive session.
  138613. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  138614. */
  138615. defaultHeightCompensation: number;
  138616. /**
  138617. * Fires every time a new xrFrame arrives which can be used to update the camera
  138618. */
  138619. onXRFrameObservable: Observable<XRFrame>;
  138620. /**
  138621. * Fires when the reference space changed
  138622. */
  138623. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  138624. /**
  138625. * Fires when the xr session is ended either by the device or manually done
  138626. */
  138627. onXRSessionEnded: Observable<any>;
  138628. /**
  138629. * Fires when the xr session is ended either by the device or manually done
  138630. */
  138631. onXRSessionInit: Observable<XRSession>;
  138632. /**
  138633. * Underlying xr session
  138634. */
  138635. session: XRSession;
  138636. /**
  138637. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  138638. * or get the offset the player is currently at.
  138639. */
  138640. viewerReferenceSpace: XRReferenceSpace;
  138641. /**
  138642. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  138643. * @param scene The scene which the session should be created for
  138644. */
  138645. constructor(
  138646. /** The scene which the session should be created for */
  138647. scene: Scene);
  138648. /**
  138649. * The current reference space used in this session. This reference space can constantly change!
  138650. * It is mainly used to offset the camera's position.
  138651. */
  138652. get referenceSpace(): XRReferenceSpace;
  138653. /**
  138654. * Set a new reference space and triggers the observable
  138655. */
  138656. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  138657. /**
  138658. * Disposes of the session manager
  138659. */
  138660. dispose(): void;
  138661. /**
  138662. * Stops the xrSession and restores the render loop
  138663. * @returns Promise which resolves after it exits XR
  138664. */
  138665. exitXRAsync(): Promise<void>;
  138666. /**
  138667. * Gets the correct render target texture to be rendered this frame for this eye
  138668. * @param eye the eye for which to get the render target
  138669. * @returns the render target for the specified eye
  138670. */
  138671. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  138672. /**
  138673. * Creates a WebXRRenderTarget object for the XR session
  138674. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  138675. * @param options optional options to provide when creating a new render target
  138676. * @returns a WebXR render target to which the session can render
  138677. */
  138678. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  138679. /**
  138680. * Initializes the manager
  138681. * After initialization enterXR can be called to start an XR session
  138682. * @returns Promise which resolves after it is initialized
  138683. */
  138684. initializeAsync(): Promise<void>;
  138685. /**
  138686. * Initializes an xr session
  138687. * @param xrSessionMode mode to initialize
  138688. * @param xrSessionInit defines optional and required values to pass to the session builder
  138689. * @returns a promise which will resolve once the session has been initialized
  138690. */
  138691. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  138692. /**
  138693. * Checks if a session would be supported for the creation options specified
  138694. * @param sessionMode session mode to check if supported eg. immersive-vr
  138695. * @returns A Promise that resolves to true if supported and false if not
  138696. */
  138697. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  138698. /**
  138699. * Resets the reference space to the one started the session
  138700. */
  138701. resetReferenceSpace(): void;
  138702. /**
  138703. * Starts rendering to the xr layer
  138704. */
  138705. runXRRenderLoop(): void;
  138706. /**
  138707. * Sets the reference space on the xr session
  138708. * @param referenceSpaceType space to set
  138709. * @returns a promise that will resolve once the reference space has been set
  138710. */
  138711. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  138712. /**
  138713. * Updates the render state of the session
  138714. * @param state state to set
  138715. * @returns a promise that resolves once the render state has been updated
  138716. */
  138717. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  138718. /**
  138719. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  138720. * @param sessionMode defines the session to test
  138721. * @returns a promise with boolean as final value
  138722. */
  138723. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  138724. /**
  138725. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  138726. */
  138727. get isNative(): boolean;
  138728. private _createRenderTargetTexture;
  138729. }
  138730. }
  138731. declare module BABYLON {
  138732. /**
  138733. * WebXR Camera which holds the views for the xrSession
  138734. * @see https://doc.babylonjs.com/how_to/webxr_camera
  138735. */
  138736. export class WebXRCamera extends FreeCamera {
  138737. private _xrSessionManager;
  138738. private _firstFrame;
  138739. private _referenceQuaternion;
  138740. private _referencedPosition;
  138741. private _xrInvPositionCache;
  138742. private _xrInvQuaternionCache;
  138743. private _trackingState;
  138744. /**
  138745. * Observable raised before camera teleportation
  138746. */
  138747. onBeforeCameraTeleport: Observable<Vector3>;
  138748. /**
  138749. * Observable raised after camera teleportation
  138750. */
  138751. onAfterCameraTeleport: Observable<Vector3>;
  138752. /**
  138753. * Notifies when the camera's tracking state has changed.
  138754. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  138755. */
  138756. onTrackingStateChanged: Observable<WebXRTrackingState>;
  138757. /**
  138758. * Should position compensation execute on first frame.
  138759. * This is used when copying the position from a native (non XR) camera
  138760. */
  138761. compensateOnFirstFrame: boolean;
  138762. /**
  138763. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  138764. * @param name the name of the camera
  138765. * @param scene the scene to add the camera to
  138766. * @param _xrSessionManager a constructed xr session manager
  138767. */
  138768. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  138769. /**
  138770. * Get the current XR tracking state of the camera
  138771. */
  138772. get trackingState(): WebXRTrackingState;
  138773. private _setTrackingState;
  138774. /**
  138775. * Return the user's height, unrelated to the current ground.
  138776. * This will be the y position of this camera, when ground level is 0.
  138777. */
  138778. get realWorldHeight(): number;
  138779. /** @hidden */
  138780. _updateForDualEyeDebugging(): void;
  138781. /**
  138782. * Sets this camera's transformation based on a non-vr camera
  138783. * @param otherCamera the non-vr camera to copy the transformation from
  138784. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  138785. */
  138786. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  138787. /**
  138788. * Gets the current instance class name ("WebXRCamera").
  138789. * @returns the class name
  138790. */
  138791. getClassName(): string;
  138792. private _rotate180;
  138793. private _updateFromXRSession;
  138794. private _updateNumberOfRigCameras;
  138795. private _updateReferenceSpace;
  138796. private _updateReferenceSpaceOffset;
  138797. }
  138798. }
  138799. declare module BABYLON {
  138800. /**
  138801. * Defining the interface required for a (webxr) feature
  138802. */
  138803. export interface IWebXRFeature extends IDisposable {
  138804. /**
  138805. * Is this feature attached
  138806. */
  138807. attached: boolean;
  138808. /**
  138809. * Should auto-attach be disabled?
  138810. */
  138811. disableAutoAttach: boolean;
  138812. /**
  138813. * Attach the feature to the session
  138814. * Will usually be called by the features manager
  138815. *
  138816. * @param force should attachment be forced (even when already attached)
  138817. * @returns true if successful.
  138818. */
  138819. attach(force?: boolean): boolean;
  138820. /**
  138821. * Detach the feature from the session
  138822. * Will usually be called by the features manager
  138823. *
  138824. * @returns true if successful.
  138825. */
  138826. detach(): boolean;
  138827. /**
  138828. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  138829. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  138830. *
  138831. * @returns whether or not the feature is compatible in this environment
  138832. */
  138833. isCompatible(): boolean;
  138834. /**
  138835. * Was this feature disposed;
  138836. */
  138837. isDisposed: boolean;
  138838. /**
  138839. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  138840. */
  138841. xrNativeFeatureName?: string;
  138842. /**
  138843. * A list of (Babylon WebXR) features this feature depends on
  138844. */
  138845. dependsOn?: string[];
  138846. /**
  138847. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  138848. */
  138849. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  138850. }
  138851. /**
  138852. * A list of the currently available features without referencing them
  138853. */
  138854. export class WebXRFeatureName {
  138855. /**
  138856. * The name of the anchor system feature
  138857. */
  138858. static readonly ANCHOR_SYSTEM: string;
  138859. /**
  138860. * The name of the background remover feature
  138861. */
  138862. static readonly BACKGROUND_REMOVER: string;
  138863. /**
  138864. * The name of the hit test feature
  138865. */
  138866. static readonly HIT_TEST: string;
  138867. /**
  138868. * The name of the mesh detection feature
  138869. */
  138870. static readonly MESH_DETECTION: string;
  138871. /**
  138872. * physics impostors for xr controllers feature
  138873. */
  138874. static readonly PHYSICS_CONTROLLERS: string;
  138875. /**
  138876. * The name of the plane detection feature
  138877. */
  138878. static readonly PLANE_DETECTION: string;
  138879. /**
  138880. * The name of the pointer selection feature
  138881. */
  138882. static readonly POINTER_SELECTION: string;
  138883. /**
  138884. * The name of the teleportation feature
  138885. */
  138886. static readonly TELEPORTATION: string;
  138887. /**
  138888. * The name of the feature points feature.
  138889. */
  138890. static readonly FEATURE_POINTS: string;
  138891. /**
  138892. * The name of the hand tracking feature.
  138893. */
  138894. static readonly HAND_TRACKING: string;
  138895. /**
  138896. * The name of the image tracking feature
  138897. */
  138898. static readonly IMAGE_TRACKING: string;
  138899. }
  138900. /**
  138901. * Defining the constructor of a feature. Used to register the modules.
  138902. */
  138903. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  138904. /**
  138905. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  138906. * It is mainly used in AR sessions.
  138907. *
  138908. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  138909. */
  138910. export class WebXRFeaturesManager implements IDisposable {
  138911. private _xrSessionManager;
  138912. private static readonly _AvailableFeatures;
  138913. private _features;
  138914. /**
  138915. * constructs a new features manages.
  138916. *
  138917. * @param _xrSessionManager an instance of WebXRSessionManager
  138918. */
  138919. constructor(_xrSessionManager: WebXRSessionManager);
  138920. /**
  138921. * Used to register a module. After calling this function a developer can use this feature in the scene.
  138922. * Mainly used internally.
  138923. *
  138924. * @param featureName the name of the feature to register
  138925. * @param constructorFunction the function used to construct the module
  138926. * @param version the (babylon) version of the module
  138927. * @param stable is that a stable version of this module
  138928. */
  138929. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  138930. /**
  138931. * Returns a constructor of a specific feature.
  138932. *
  138933. * @param featureName the name of the feature to construct
  138934. * @param version the version of the feature to load
  138935. * @param xrSessionManager the xrSessionManager. Used to construct the module
  138936. * @param options optional options provided to the module.
  138937. * @returns a function that, when called, will return a new instance of this feature
  138938. */
  138939. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  138940. /**
  138941. * Can be used to return the list of features currently registered
  138942. *
  138943. * @returns an Array of available features
  138944. */
  138945. static GetAvailableFeatures(): string[];
  138946. /**
  138947. * Gets the versions available for a specific feature
  138948. * @param featureName the name of the feature
  138949. * @returns an array with the available versions
  138950. */
  138951. static GetAvailableVersions(featureName: string): string[];
  138952. /**
  138953. * Return the latest unstable version of this feature
  138954. * @param featureName the name of the feature to search
  138955. * @returns the version number. if not found will return -1
  138956. */
  138957. static GetLatestVersionOfFeature(featureName: string): number;
  138958. /**
  138959. * Return the latest stable version of this feature
  138960. * @param featureName the name of the feature to search
  138961. * @returns the version number. if not found will return -1
  138962. */
  138963. static GetStableVersionOfFeature(featureName: string): number;
  138964. /**
  138965. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  138966. * Can be used during a session to start a feature
  138967. * @param featureName the name of feature to attach
  138968. */
  138969. attachFeature(featureName: string): void;
  138970. /**
  138971. * Can be used inside a session or when the session ends to detach a specific feature
  138972. * @param featureName the name of the feature to detach
  138973. */
  138974. detachFeature(featureName: string): void;
  138975. /**
  138976. * Used to disable an already-enabled feature
  138977. * The feature will be disposed and will be recreated once enabled.
  138978. * @param featureName the feature to disable
  138979. * @returns true if disable was successful
  138980. */
  138981. disableFeature(featureName: string | {
  138982. Name: string;
  138983. }): boolean;
  138984. /**
  138985. * dispose this features manager
  138986. */
  138987. dispose(): void;
  138988. /**
  138989. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  138990. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  138991. *
  138992. * @param featureName the name of the feature to load or the class of the feature
  138993. * @param version optional version to load. if not provided the latest version will be enabled
  138994. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  138995. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  138996. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  138997. * @returns a new constructed feature or throws an error if feature not found.
  138998. */
  138999. enableFeature(featureName: string | {
  139000. Name: string;
  139001. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  139002. /**
  139003. * get the implementation of an enabled feature.
  139004. * @param featureName the name of the feature to load
  139005. * @returns the feature class, if found
  139006. */
  139007. getEnabledFeature(featureName: string): IWebXRFeature;
  139008. /**
  139009. * Get the list of enabled features
  139010. * @returns an array of enabled features
  139011. */
  139012. getEnabledFeatures(): string[];
  139013. /**
  139014. * This function will extend the session creation configuration object with enabled features.
  139015. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  139016. * according to the defined "required" variable, provided during enableFeature call
  139017. * @param xrSessionInit the xr Session init object to extend
  139018. *
  139019. * @returns an extended XRSessionInit object
  139020. */
  139021. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  139022. }
  139023. }
  139024. declare module BABYLON {
  139025. /**
  139026. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  139027. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  139028. */
  139029. export class WebXRExperienceHelper implements IDisposable {
  139030. private scene;
  139031. private _nonVRCamera;
  139032. private _originalSceneAutoClear;
  139033. private _supported;
  139034. /**
  139035. * Camera used to render xr content
  139036. */
  139037. camera: WebXRCamera;
  139038. /** A features manager for this xr session */
  139039. featuresManager: WebXRFeaturesManager;
  139040. /**
  139041. * Observers registered here will be triggered after the camera's initial transformation is set
  139042. * This can be used to set a different ground level or an extra rotation.
  139043. *
  139044. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  139045. * to the position set after this observable is done executing.
  139046. */
  139047. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  139048. /**
  139049. * Fires when the state of the experience helper has changed
  139050. */
  139051. onStateChangedObservable: Observable<WebXRState>;
  139052. /** Session manager used to keep track of xr session */
  139053. sessionManager: WebXRSessionManager;
  139054. /**
  139055. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  139056. */
  139057. state: WebXRState;
  139058. /**
  139059. * Creates a WebXRExperienceHelper
  139060. * @param scene The scene the helper should be created in
  139061. */
  139062. private constructor();
  139063. /**
  139064. * Creates the experience helper
  139065. * @param scene the scene to attach the experience helper to
  139066. * @returns a promise for the experience helper
  139067. */
  139068. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  139069. /**
  139070. * Disposes of the experience helper
  139071. */
  139072. dispose(): void;
  139073. /**
  139074. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  139075. * @param sessionMode options for the XR session
  139076. * @param referenceSpaceType frame of reference of the XR session
  139077. * @param renderTarget the output canvas that will be used to enter XR mode
  139078. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  139079. * @returns promise that resolves after xr mode has entered
  139080. */
  139081. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  139082. /**
  139083. * Exits XR mode and returns the scene to its original state
  139084. * @returns promise that resolves after xr mode has exited
  139085. */
  139086. exitXRAsync(): Promise<void>;
  139087. private _nonXRToXRCamera;
  139088. private _setState;
  139089. }
  139090. }
  139091. declare module BABYLON {
  139092. /**
  139093. * X-Y values for axes in WebXR
  139094. */
  139095. export interface IWebXRMotionControllerAxesValue {
  139096. /**
  139097. * The value of the x axis
  139098. */
  139099. x: number;
  139100. /**
  139101. * The value of the y-axis
  139102. */
  139103. y: number;
  139104. }
  139105. /**
  139106. * changed / previous values for the values of this component
  139107. */
  139108. export interface IWebXRMotionControllerComponentChangesValues<T> {
  139109. /**
  139110. * current (this frame) value
  139111. */
  139112. current: T;
  139113. /**
  139114. * previous (last change) value
  139115. */
  139116. previous: T;
  139117. }
  139118. /**
  139119. * Represents changes in the component between current frame and last values recorded
  139120. */
  139121. export interface IWebXRMotionControllerComponentChanges {
  139122. /**
  139123. * will be populated with previous and current values if axes changed
  139124. */
  139125. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  139126. /**
  139127. * will be populated with previous and current values if pressed changed
  139128. */
  139129. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  139130. /**
  139131. * will be populated with previous and current values if touched changed
  139132. */
  139133. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  139134. /**
  139135. * will be populated with previous and current values if value changed
  139136. */
  139137. value?: IWebXRMotionControllerComponentChangesValues<number>;
  139138. }
  139139. /**
  139140. * This class represents a single component (for example button or thumbstick) of a motion controller
  139141. */
  139142. export class WebXRControllerComponent implements IDisposable {
  139143. /**
  139144. * the id of this component
  139145. */
  139146. id: string;
  139147. /**
  139148. * the type of the component
  139149. */
  139150. type: MotionControllerComponentType;
  139151. private _buttonIndex;
  139152. private _axesIndices;
  139153. private _axes;
  139154. private _changes;
  139155. private _currentValue;
  139156. private _hasChanges;
  139157. private _pressed;
  139158. private _touched;
  139159. /**
  139160. * button component type
  139161. */
  139162. static BUTTON_TYPE: MotionControllerComponentType;
  139163. /**
  139164. * squeeze component type
  139165. */
  139166. static SQUEEZE_TYPE: MotionControllerComponentType;
  139167. /**
  139168. * Thumbstick component type
  139169. */
  139170. static THUMBSTICK_TYPE: MotionControllerComponentType;
  139171. /**
  139172. * Touchpad component type
  139173. */
  139174. static TOUCHPAD_TYPE: MotionControllerComponentType;
  139175. /**
  139176. * trigger component type
  139177. */
  139178. static TRIGGER_TYPE: MotionControllerComponentType;
  139179. /**
  139180. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  139181. * the axes data changes
  139182. */
  139183. onAxisValueChangedObservable: Observable<{
  139184. x: number;
  139185. y: number;
  139186. }>;
  139187. /**
  139188. * Observers registered here will be triggered when the state of a button changes
  139189. * State change is either pressed / touched / value
  139190. */
  139191. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  139192. /**
  139193. * Creates a new component for a motion controller.
  139194. * It is created by the motion controller itself
  139195. *
  139196. * @param id the id of this component
  139197. * @param type the type of the component
  139198. * @param _buttonIndex index in the buttons array of the gamepad
  139199. * @param _axesIndices indices of the values in the axes array of the gamepad
  139200. */
  139201. constructor(
  139202. /**
  139203. * the id of this component
  139204. */
  139205. id: string,
  139206. /**
  139207. * the type of the component
  139208. */
  139209. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  139210. /**
  139211. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  139212. */
  139213. get axes(): IWebXRMotionControllerAxesValue;
  139214. /**
  139215. * Get the changes. Elements will be populated only if they changed with their previous and current value
  139216. */
  139217. get changes(): IWebXRMotionControllerComponentChanges;
  139218. /**
  139219. * Return whether or not the component changed the last frame
  139220. */
  139221. get hasChanges(): boolean;
  139222. /**
  139223. * is the button currently pressed
  139224. */
  139225. get pressed(): boolean;
  139226. /**
  139227. * is the button currently touched
  139228. */
  139229. get touched(): boolean;
  139230. /**
  139231. * Get the current value of this component
  139232. */
  139233. get value(): number;
  139234. /**
  139235. * Dispose this component
  139236. */
  139237. dispose(): void;
  139238. /**
  139239. * Are there axes correlating to this component
  139240. * @return true is axes data is available
  139241. */
  139242. isAxes(): boolean;
  139243. /**
  139244. * Is this component a button (hence - pressable)
  139245. * @returns true if can be pressed
  139246. */
  139247. isButton(): boolean;
  139248. /**
  139249. * update this component using the gamepad object it is in. Called on every frame
  139250. * @param nativeController the native gamepad controller object
  139251. */
  139252. update(nativeController: IMinimalMotionControllerObject): void;
  139253. }
  139254. }
  139255. declare module BABYLON {
  139256. /**
  139257. * Type used for the success callback of ImportMesh
  139258. */
  139259. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  139260. /**
  139261. * Interface used for the result of ImportMeshAsync
  139262. */
  139263. export interface ISceneLoaderAsyncResult {
  139264. /**
  139265. * The array of loaded meshes
  139266. */
  139267. readonly meshes: AbstractMesh[];
  139268. /**
  139269. * The array of loaded particle systems
  139270. */
  139271. readonly particleSystems: IParticleSystem[];
  139272. /**
  139273. * The array of loaded skeletons
  139274. */
  139275. readonly skeletons: Skeleton[];
  139276. /**
  139277. * The array of loaded animation groups
  139278. */
  139279. readonly animationGroups: AnimationGroup[];
  139280. /**
  139281. * The array of loaded transform nodes
  139282. */
  139283. readonly transformNodes: TransformNode[];
  139284. /**
  139285. * The array of loaded geometries
  139286. */
  139287. readonly geometries: Geometry[];
  139288. /**
  139289. * The array of loaded lights
  139290. */
  139291. readonly lights: Light[];
  139292. }
  139293. /**
  139294. * Interface used to represent data loading progression
  139295. */
  139296. export interface ISceneLoaderProgressEvent {
  139297. /**
  139298. * Defines if data length to load can be evaluated
  139299. */
  139300. readonly lengthComputable: boolean;
  139301. /**
  139302. * Defines the loaded data length
  139303. */
  139304. readonly loaded: number;
  139305. /**
  139306. * Defines the data length to load
  139307. */
  139308. readonly total: number;
  139309. }
  139310. /**
  139311. * Interface used by SceneLoader plugins to define supported file extensions
  139312. */
  139313. export interface ISceneLoaderPluginExtensions {
  139314. /**
  139315. * Defines the list of supported extensions
  139316. */
  139317. [extension: string]: {
  139318. isBinary: boolean;
  139319. };
  139320. }
  139321. /**
  139322. * Interface used by SceneLoader plugin factory
  139323. */
  139324. export interface ISceneLoaderPluginFactory {
  139325. /**
  139326. * Defines the name of the factory
  139327. */
  139328. name: string;
  139329. /**
  139330. * Function called to create a new plugin
  139331. * @return the new plugin
  139332. */
  139333. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  139334. /**
  139335. * The callback that returns true if the data can be directly loaded.
  139336. * @param data string containing the file data
  139337. * @returns if the data can be loaded directly
  139338. */
  139339. canDirectLoad?(data: string): boolean;
  139340. }
  139341. /**
  139342. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  139343. */
  139344. export interface ISceneLoaderPluginBase {
  139345. /**
  139346. * The friendly name of this plugin.
  139347. */
  139348. name: string;
  139349. /**
  139350. * The file extensions supported by this plugin.
  139351. */
  139352. extensions: string | ISceneLoaderPluginExtensions;
  139353. /**
  139354. * The callback called when loading from a url.
  139355. * @param scene scene loading this url
  139356. * @param url url to load
  139357. * @param onSuccess callback called when the file successfully loads
  139358. * @param onProgress callback called while file is loading (if the server supports this mode)
  139359. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  139360. * @param onError callback called when the file fails to load
  139361. * @returns a file request object
  139362. */
  139363. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  139364. /**
  139365. * The callback called when loading from a file object.
  139366. * @param scene scene loading this file
  139367. * @param file defines the file to load
  139368. * @param onSuccess defines the callback to call when data is loaded
  139369. * @param onProgress defines the callback to call during loading process
  139370. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  139371. * @param onError defines the callback to call when an error occurs
  139372. * @returns a file request object
  139373. */
  139374. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  139375. /**
  139376. * The callback that returns true if the data can be directly loaded.
  139377. * @param data string containing the file data
  139378. * @returns if the data can be loaded directly
  139379. */
  139380. canDirectLoad?(data: string): boolean;
  139381. /**
  139382. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  139383. * @param scene scene loading this data
  139384. * @param data string containing the data
  139385. * @returns data to pass to the plugin
  139386. */
  139387. directLoad?(scene: Scene, data: string): any;
  139388. /**
  139389. * The callback that allows custom handling of the root url based on the response url.
  139390. * @param rootUrl the original root url
  139391. * @param responseURL the response url if available
  139392. * @returns the new root url
  139393. */
  139394. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  139395. }
  139396. /**
  139397. * Interface used to define a SceneLoader plugin
  139398. */
  139399. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  139400. /**
  139401. * Import meshes into a scene.
  139402. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139403. * @param scene The scene to import into
  139404. * @param data The data to import
  139405. * @param rootUrl The root url for scene and resources
  139406. * @param meshes The meshes array to import into
  139407. * @param particleSystems The particle systems array to import into
  139408. * @param skeletons The skeletons array to import into
  139409. * @param onError The callback when import fails
  139410. * @returns True if successful or false otherwise
  139411. */
  139412. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  139413. /**
  139414. * Load into a scene.
  139415. * @param scene The scene to load into
  139416. * @param data The data to import
  139417. * @param rootUrl The root url for scene and resources
  139418. * @param onError The callback when import fails
  139419. * @returns True if successful or false otherwise
  139420. */
  139421. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  139422. /**
  139423. * Load into an asset container.
  139424. * @param scene The scene to load into
  139425. * @param data The data to import
  139426. * @param rootUrl The root url for scene and resources
  139427. * @param onError The callback when import fails
  139428. * @returns The loaded asset container
  139429. */
  139430. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  139431. }
  139432. /**
  139433. * Interface used to define an async SceneLoader plugin
  139434. */
  139435. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  139436. /**
  139437. * Import meshes into a scene.
  139438. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139439. * @param scene The scene to import into
  139440. * @param data The data to import
  139441. * @param rootUrl The root url for scene and resources
  139442. * @param onProgress The callback when the load progresses
  139443. * @param fileName Defines the name of the file to load
  139444. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  139445. */
  139446. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  139447. /**
  139448. * Load into a scene.
  139449. * @param scene The scene to load into
  139450. * @param data The data to import
  139451. * @param rootUrl The root url for scene and resources
  139452. * @param onProgress The callback when the load progresses
  139453. * @param fileName Defines the name of the file to load
  139454. * @returns Nothing
  139455. */
  139456. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  139457. /**
  139458. * Load into an asset container.
  139459. * @param scene The scene to load into
  139460. * @param data The data to import
  139461. * @param rootUrl The root url for scene and resources
  139462. * @param onProgress The callback when the load progresses
  139463. * @param fileName Defines the name of the file to load
  139464. * @returns The loaded asset container
  139465. */
  139466. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  139467. }
  139468. /**
  139469. * Mode that determines how to handle old animation groups before loading new ones.
  139470. */
  139471. export enum SceneLoaderAnimationGroupLoadingMode {
  139472. /**
  139473. * Reset all old animations to initial state then dispose them.
  139474. */
  139475. Clean = 0,
  139476. /**
  139477. * Stop all old animations.
  139478. */
  139479. Stop = 1,
  139480. /**
  139481. * Restart old animations from first frame.
  139482. */
  139483. Sync = 2,
  139484. /**
  139485. * Old animations remains untouched.
  139486. */
  139487. NoSync = 3
  139488. }
  139489. /**
  139490. * Defines a plugin registered by the SceneLoader
  139491. */
  139492. interface IRegisteredPlugin {
  139493. /**
  139494. * Defines the plugin to use
  139495. */
  139496. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  139497. /**
  139498. * Defines if the plugin supports binary data
  139499. */
  139500. isBinary: boolean;
  139501. }
  139502. /**
  139503. * Class used to load scene from various file formats using registered plugins
  139504. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  139505. */
  139506. export class SceneLoader {
  139507. /**
  139508. * No logging while loading
  139509. */
  139510. static readonly NO_LOGGING: number;
  139511. /**
  139512. * Minimal logging while loading
  139513. */
  139514. static readonly MINIMAL_LOGGING: number;
  139515. /**
  139516. * Summary logging while loading
  139517. */
  139518. static readonly SUMMARY_LOGGING: number;
  139519. /**
  139520. * Detailled logging while loading
  139521. */
  139522. static readonly DETAILED_LOGGING: number;
  139523. /**
  139524. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  139525. */
  139526. static get ForceFullSceneLoadingForIncremental(): boolean;
  139527. static set ForceFullSceneLoadingForIncremental(value: boolean);
  139528. /**
  139529. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  139530. */
  139531. static get ShowLoadingScreen(): boolean;
  139532. static set ShowLoadingScreen(value: boolean);
  139533. /**
  139534. * Defines the current logging level (while loading the scene)
  139535. * @ignorenaming
  139536. */
  139537. static get loggingLevel(): number;
  139538. static set loggingLevel(value: number);
  139539. /**
  139540. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  139541. */
  139542. static get CleanBoneMatrixWeights(): boolean;
  139543. static set CleanBoneMatrixWeights(value: boolean);
  139544. /**
  139545. * Event raised when a plugin is used to load a scene
  139546. */
  139547. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  139548. private static _registeredPlugins;
  139549. private static _showingLoadingScreen;
  139550. /**
  139551. * Gets the default plugin (used to load Babylon files)
  139552. * @returns the .babylon plugin
  139553. */
  139554. static GetDefaultPlugin(): IRegisteredPlugin;
  139555. private static _GetPluginForExtension;
  139556. private static _GetPluginForDirectLoad;
  139557. private static _GetPluginForFilename;
  139558. private static _GetDirectLoad;
  139559. private static _LoadData;
  139560. private static _GetFileInfo;
  139561. /**
  139562. * Gets a plugin that can load the given extension
  139563. * @param extension defines the extension to load
  139564. * @returns a plugin or null if none works
  139565. */
  139566. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  139567. /**
  139568. * Gets a boolean indicating that the given extension can be loaded
  139569. * @param extension defines the extension to load
  139570. * @returns true if the extension is supported
  139571. */
  139572. static IsPluginForExtensionAvailable(extension: string): boolean;
  139573. /**
  139574. * Adds a new plugin to the list of registered plugins
  139575. * @param plugin defines the plugin to add
  139576. */
  139577. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  139578. /**
  139579. * Import meshes into a scene
  139580. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139581. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139582. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139583. * @param scene the instance of BABYLON.Scene to append to
  139584. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  139585. * @param onProgress a callback with a progress event for each file being loaded
  139586. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139587. * @param pluginExtension the extension used to determine the plugin
  139588. * @returns The loaded plugin
  139589. */
  139590. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  139591. /**
  139592. * Import meshes into a scene
  139593. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  139594. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139595. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139596. * @param scene the instance of BABYLON.Scene to append to
  139597. * @param onProgress a callback with a progress event for each file being loaded
  139598. * @param pluginExtension the extension used to determine the plugin
  139599. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  139600. */
  139601. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  139602. /**
  139603. * Load a scene
  139604. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139605. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139606. * @param engine is the instance of BABYLON.Engine to use to create the scene
  139607. * @param onSuccess a callback with the scene when import succeeds
  139608. * @param onProgress a callback with a progress event for each file being loaded
  139609. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139610. * @param pluginExtension the extension used to determine the plugin
  139611. * @returns The loaded plugin
  139612. */
  139613. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  139614. /**
  139615. * Load a scene
  139616. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139617. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139618. * @param engine is the instance of BABYLON.Engine to use to create the scene
  139619. * @param onProgress a callback with a progress event for each file being loaded
  139620. * @param pluginExtension the extension used to determine the plugin
  139621. * @returns The loaded scene
  139622. */
  139623. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  139624. /**
  139625. * Append a scene
  139626. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139627. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139628. * @param scene is the instance of BABYLON.Scene to append to
  139629. * @param onSuccess a callback with the scene when import succeeds
  139630. * @param onProgress a callback with a progress event for each file being loaded
  139631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139632. * @param pluginExtension the extension used to determine the plugin
  139633. * @returns The loaded plugin
  139634. */
  139635. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  139636. /**
  139637. * Append a scene
  139638. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139639. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139640. * @param scene is the instance of BABYLON.Scene to append to
  139641. * @param onProgress a callback with a progress event for each file being loaded
  139642. * @param pluginExtension the extension used to determine the plugin
  139643. * @returns The given scene
  139644. */
  139645. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  139646. /**
  139647. * Load a scene into an asset container
  139648. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139649. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139650. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  139651. * @param onSuccess a callback with the scene when import succeeds
  139652. * @param onProgress a callback with a progress event for each file being loaded
  139653. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139654. * @param pluginExtension the extension used to determine the plugin
  139655. * @returns The loaded plugin
  139656. */
  139657. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  139658. /**
  139659. * Load a scene into an asset container
  139660. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139661. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  139662. * @param scene is the instance of Scene to append to
  139663. * @param onProgress a callback with a progress event for each file being loaded
  139664. * @param pluginExtension the extension used to determine the plugin
  139665. * @returns The loaded asset container
  139666. */
  139667. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  139668. /**
  139669. * Import animations from a file into a scene
  139670. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139671. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139672. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  139673. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  139674. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  139675. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  139676. * @param onSuccess a callback with the scene when import succeeds
  139677. * @param onProgress a callback with a progress event for each file being loaded
  139678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139679. * @param pluginExtension the extension used to determine the plugin
  139680. */
  139681. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): void;
  139682. /**
  139683. * Import animations from a file into a scene
  139684. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  139685. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  139686. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  139687. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  139688. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  139689. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  139690. * @param onSuccess a callback with the scene when import succeeds
  139691. * @param onProgress a callback with a progress event for each file being loaded
  139692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  139693. * @param pluginExtension the extension used to determine the plugin
  139694. * @returns the updated scene with imported animations
  139695. */
  139696. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  139697. }
  139698. }
  139699. declare module BABYLON {
  139700. /**
  139701. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  139702. */
  139703. export type MotionControllerHandedness = "none" | "left" | "right";
  139704. /**
  139705. * The type of components available in motion controllers.
  139706. * This is not the name of the component.
  139707. */
  139708. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  139709. /**
  139710. * The state of a controller component
  139711. */
  139712. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  139713. /**
  139714. * The schema of motion controller layout.
  139715. * No object will be initialized using this interface
  139716. * This is used just to define the profile.
  139717. */
  139718. export interface IMotionControllerLayout {
  139719. /**
  139720. * Path to load the assets. Usually relative to the base path
  139721. */
  139722. assetPath: string;
  139723. /**
  139724. * Available components (unsorted)
  139725. */
  139726. components: {
  139727. /**
  139728. * A map of component Ids
  139729. */
  139730. [componentId: string]: {
  139731. /**
  139732. * The type of input the component outputs
  139733. */
  139734. type: MotionControllerComponentType;
  139735. /**
  139736. * The indices of this component in the gamepad object
  139737. */
  139738. gamepadIndices: {
  139739. /**
  139740. * Index of button
  139741. */
  139742. button?: number;
  139743. /**
  139744. * If available, index of x-axis
  139745. */
  139746. xAxis?: number;
  139747. /**
  139748. * If available, index of y-axis
  139749. */
  139750. yAxis?: number;
  139751. };
  139752. /**
  139753. * The mesh's root node name
  139754. */
  139755. rootNodeName: string;
  139756. /**
  139757. * Animation definitions for this model
  139758. */
  139759. visualResponses: {
  139760. [stateKey: string]: {
  139761. /**
  139762. * What property will be animated
  139763. */
  139764. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  139765. /**
  139766. * What states influence this visual response
  139767. */
  139768. states: MotionControllerComponentStateType[];
  139769. /**
  139770. * Type of animation - movement or visibility
  139771. */
  139772. valueNodeProperty: "transform" | "visibility";
  139773. /**
  139774. * Base node name to move. Its position will be calculated according to the min and max nodes
  139775. */
  139776. valueNodeName?: string;
  139777. /**
  139778. * Minimum movement node
  139779. */
  139780. minNodeName?: string;
  139781. /**
  139782. * Max movement node
  139783. */
  139784. maxNodeName?: string;
  139785. };
  139786. };
  139787. /**
  139788. * If touch enabled, what is the name of node to display user feedback
  139789. */
  139790. touchPointNodeName?: string;
  139791. };
  139792. };
  139793. /**
  139794. * Is it xr standard mapping or not
  139795. */
  139796. gamepadMapping: "" | "xr-standard";
  139797. /**
  139798. * Base root node of this entire model
  139799. */
  139800. rootNodeName: string;
  139801. /**
  139802. * Defines the main button component id
  139803. */
  139804. selectComponentId: string;
  139805. }
  139806. /**
  139807. * A definition for the layout map in the input profile
  139808. */
  139809. export interface IMotionControllerLayoutMap {
  139810. /**
  139811. * Layouts with handedness type as a key
  139812. */
  139813. [handedness: string]: IMotionControllerLayout;
  139814. }
  139815. /**
  139816. * The XR Input profile schema
  139817. * Profiles can be found here:
  139818. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  139819. */
  139820. export interface IMotionControllerProfile {
  139821. /**
  139822. * fallback profiles for this profileId
  139823. */
  139824. fallbackProfileIds: string[];
  139825. /**
  139826. * The layout map, with handedness as key
  139827. */
  139828. layouts: IMotionControllerLayoutMap;
  139829. /**
  139830. * The id of this profile
  139831. * correlates to the profile(s) in the xrInput.profiles array
  139832. */
  139833. profileId: string;
  139834. }
  139835. /**
  139836. * A helper-interface for the 3 meshes needed for controller button animation
  139837. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  139838. */
  139839. export interface IMotionControllerButtonMeshMap {
  139840. /**
  139841. * the mesh that defines the pressed value mesh position.
  139842. * This is used to find the max-position of this button
  139843. */
  139844. pressedMesh: AbstractMesh;
  139845. /**
  139846. * the mesh that defines the unpressed value mesh position.
  139847. * This is used to find the min (or initial) position of this button
  139848. */
  139849. unpressedMesh: AbstractMesh;
  139850. /**
  139851. * The mesh that will be changed when value changes
  139852. */
  139853. valueMesh: AbstractMesh;
  139854. }
  139855. /**
  139856. * A helper-interface for the 3 meshes needed for controller axis animation.
  139857. * This will be expanded when touchpad animations are fully supported
  139858. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  139859. */
  139860. export interface IMotionControllerMeshMap {
  139861. /**
  139862. * the mesh that defines the maximum value mesh position.
  139863. */
  139864. maxMesh?: AbstractMesh;
  139865. /**
  139866. * the mesh that defines the minimum value mesh position.
  139867. */
  139868. minMesh?: AbstractMesh;
  139869. /**
  139870. * The mesh that will be changed when axis value changes
  139871. */
  139872. valueMesh?: AbstractMesh;
  139873. }
  139874. /**
  139875. * The elements needed for change-detection of the gamepad objects in motion controllers
  139876. */
  139877. export interface IMinimalMotionControllerObject {
  139878. /**
  139879. * Available axes of this controller
  139880. */
  139881. axes: number[];
  139882. /**
  139883. * An array of available buttons
  139884. */
  139885. buttons: Array<{
  139886. /**
  139887. * Value of the button/trigger
  139888. */
  139889. value: number;
  139890. /**
  139891. * If the button/trigger is currently touched
  139892. */
  139893. touched: boolean;
  139894. /**
  139895. * If the button/trigger is currently pressed
  139896. */
  139897. pressed: boolean;
  139898. }>;
  139899. /**
  139900. * EXPERIMENTAL haptic support.
  139901. */
  139902. hapticActuators?: Array<{
  139903. pulse: (value: number, duration: number) => Promise<boolean>;
  139904. }>;
  139905. }
  139906. /**
  139907. * An Abstract Motion controller
  139908. * This class receives an xrInput and a profile layout and uses those to initialize the components
  139909. * Each component has an observable to check for changes in value and state
  139910. */
  139911. export abstract class WebXRAbstractMotionController implements IDisposable {
  139912. protected scene: Scene;
  139913. protected layout: IMotionControllerLayout;
  139914. /**
  139915. * The gamepad object correlating to this controller
  139916. */
  139917. gamepadObject: IMinimalMotionControllerObject;
  139918. /**
  139919. * handedness (left/right/none) of this controller
  139920. */
  139921. handedness: MotionControllerHandedness;
  139922. private _initComponent;
  139923. private _modelReady;
  139924. /**
  139925. * A map of components (WebXRControllerComponent) in this motion controller
  139926. * Components have a ComponentType and can also have both button and axis definitions
  139927. */
  139928. readonly components: {
  139929. [id: string]: WebXRControllerComponent;
  139930. };
  139931. /**
  139932. * Disable the model's animation. Can be set at any time.
  139933. */
  139934. disableAnimation: boolean;
  139935. /**
  139936. * Observers registered here will be triggered when the model of this controller is done loading
  139937. */
  139938. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  139939. /**
  139940. * The profile id of this motion controller
  139941. */
  139942. abstract profileId: string;
  139943. /**
  139944. * The root mesh of the model. It is null if the model was not yet initialized
  139945. */
  139946. rootMesh: Nullable<AbstractMesh>;
  139947. /**
  139948. * constructs a new abstract motion controller
  139949. * @param scene the scene to which the model of the controller will be added
  139950. * @param layout The profile layout to load
  139951. * @param gamepadObject The gamepad object correlating to this controller
  139952. * @param handedness handedness (left/right/none) of this controller
  139953. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  139954. */
  139955. constructor(scene: Scene, layout: IMotionControllerLayout,
  139956. /**
  139957. * The gamepad object correlating to this controller
  139958. */
  139959. gamepadObject: IMinimalMotionControllerObject,
  139960. /**
  139961. * handedness (left/right/none) of this controller
  139962. */
  139963. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  139964. /**
  139965. * Dispose this controller, the model mesh and all its components
  139966. */
  139967. dispose(): void;
  139968. /**
  139969. * Returns all components of specific type
  139970. * @param type the type to search for
  139971. * @return an array of components with this type
  139972. */
  139973. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  139974. /**
  139975. * get a component based an its component id as defined in layout.components
  139976. * @param id the id of the component
  139977. * @returns the component correlates to the id or undefined if not found
  139978. */
  139979. getComponent(id: string): WebXRControllerComponent;
  139980. /**
  139981. * Get the list of components available in this motion controller
  139982. * @returns an array of strings correlating to available components
  139983. */
  139984. getComponentIds(): string[];
  139985. /**
  139986. * Get the first component of specific type
  139987. * @param type type of component to find
  139988. * @return a controller component or null if not found
  139989. */
  139990. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  139991. /**
  139992. * Get the main (Select) component of this controller as defined in the layout
  139993. * @returns the main component of this controller
  139994. */
  139995. getMainComponent(): WebXRControllerComponent;
  139996. /**
  139997. * Loads the model correlating to this controller
  139998. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  139999. * @returns A promise fulfilled with the result of the model loading
  140000. */
  140001. loadModel(): Promise<boolean>;
  140002. /**
  140003. * Update this model using the current XRFrame
  140004. * @param xrFrame the current xr frame to use and update the model
  140005. */
  140006. updateFromXRFrame(xrFrame: XRFrame): void;
  140007. /**
  140008. * Backwards compatibility due to a deeply-integrated typo
  140009. */
  140010. get handness(): XREye;
  140011. /**
  140012. * Pulse (vibrate) this controller
  140013. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  140014. * Consecutive calls to this function will cancel the last pulse call
  140015. *
  140016. * @param value the strength of the pulse in 0.0...1.0 range
  140017. * @param duration Duration of the pulse in milliseconds
  140018. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  140019. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  140020. */
  140021. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  140022. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  140023. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  140024. /**
  140025. * Moves the axis on the controller mesh based on its current state
  140026. * @param axis the index of the axis
  140027. * @param axisValue the value of the axis which determines the meshes new position
  140028. * @hidden
  140029. */
  140030. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  140031. /**
  140032. * Update the model itself with the current frame data
  140033. * @param xrFrame the frame to use for updating the model mesh
  140034. */
  140035. protected updateModel(xrFrame: XRFrame): void;
  140036. /**
  140037. * Get the filename and path for this controller's model
  140038. * @returns a map of filename and path
  140039. */
  140040. protected abstract _getFilenameAndPath(): {
  140041. filename: string;
  140042. path: string;
  140043. };
  140044. /**
  140045. * This function is called before the mesh is loaded. It checks for loading constraints.
  140046. * For example, this function can check if the GLB loader is available
  140047. * If this function returns false, the generic controller will be loaded instead
  140048. * @returns Is the client ready to load the mesh
  140049. */
  140050. protected abstract _getModelLoadingConstraints(): boolean;
  140051. /**
  140052. * This function will be called after the model was successfully loaded and can be used
  140053. * for mesh transformations before it is available for the user
  140054. * @param meshes the loaded meshes
  140055. */
  140056. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  140057. /**
  140058. * Set the root mesh for this controller. Important for the WebXR controller class
  140059. * @param meshes the loaded meshes
  140060. */
  140061. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  140062. /**
  140063. * A function executed each frame that updates the mesh (if needed)
  140064. * @param xrFrame the current xrFrame
  140065. */
  140066. protected abstract _updateModel(xrFrame: XRFrame): void;
  140067. private _getGenericFilenameAndPath;
  140068. private _getGenericParentMesh;
  140069. }
  140070. }
  140071. declare module BABYLON {
  140072. /**
  140073. * A generic trigger-only motion controller for WebXR
  140074. */
  140075. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  140076. /**
  140077. * Static version of the profile id of this controller
  140078. */
  140079. static ProfileId: string;
  140080. profileId: string;
  140081. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  140082. protected _getFilenameAndPath(): {
  140083. filename: string;
  140084. path: string;
  140085. };
  140086. protected _getModelLoadingConstraints(): boolean;
  140087. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  140088. protected _setRootMesh(meshes: AbstractMesh[]): void;
  140089. protected _updateModel(): void;
  140090. }
  140091. }
  140092. declare module BABYLON {
  140093. /**
  140094. * Class containing static functions to help procedurally build meshes
  140095. */
  140096. export class SphereBuilder {
  140097. /**
  140098. * Creates a sphere mesh
  140099. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  140100. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  140101. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  140102. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  140103. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  140104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140107. * @param name defines the name of the mesh
  140108. * @param options defines the options used to create the mesh
  140109. * @param scene defines the hosting scene
  140110. * @returns the sphere mesh
  140111. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  140112. */
  140113. static CreateSphere(name: string, options: {
  140114. segments?: number;
  140115. diameter?: number;
  140116. diameterX?: number;
  140117. diameterY?: number;
  140118. diameterZ?: number;
  140119. arc?: number;
  140120. slice?: number;
  140121. sideOrientation?: number;
  140122. frontUVs?: Vector4;
  140123. backUVs?: Vector4;
  140124. updatable?: boolean;
  140125. }, scene?: Nullable<Scene>): Mesh;
  140126. }
  140127. }
  140128. declare module BABYLON {
  140129. /**
  140130. * A profiled motion controller has its profile loaded from an online repository.
  140131. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  140132. */
  140133. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  140134. private _repositoryUrl;
  140135. private _buttonMeshMapping;
  140136. private _touchDots;
  140137. /**
  140138. * The profile ID of this controller. Will be populated when the controller initializes.
  140139. */
  140140. profileId: string;
  140141. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  140142. dispose(): void;
  140143. protected _getFilenameAndPath(): {
  140144. filename: string;
  140145. path: string;
  140146. };
  140147. protected _getModelLoadingConstraints(): boolean;
  140148. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  140149. protected _setRootMesh(meshes: AbstractMesh[]): void;
  140150. protected _updateModel(_xrFrame: XRFrame): void;
  140151. }
  140152. }
  140153. declare module BABYLON {
  140154. /**
  140155. * A construction function type to create a new controller based on an xrInput object
  140156. */
  140157. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  140158. /**
  140159. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  140160. *
  140161. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  140162. * it should be replaced with auto-loaded controllers.
  140163. *
  140164. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  140165. */
  140166. export class WebXRMotionControllerManager {
  140167. private static _AvailableControllers;
  140168. private static _Fallbacks;
  140169. private static _ProfileLoadingPromises;
  140170. private static _ProfilesList;
  140171. /**
  140172. * The base URL of the online controller repository. Can be changed at any time.
  140173. */
  140174. static BaseRepositoryUrl: string;
  140175. /**
  140176. * Which repository gets priority - local or online
  140177. */
  140178. static PrioritizeOnlineRepository: boolean;
  140179. /**
  140180. * Use the online repository, or use only locally-defined controllers
  140181. */
  140182. static UseOnlineRepository: boolean;
  140183. /**
  140184. * Clear the cache used for profile loading and reload when requested again
  140185. */
  140186. static ClearProfilesCache(): void;
  140187. /**
  140188. * Register the default fallbacks.
  140189. * This function is called automatically when this file is imported.
  140190. */
  140191. static DefaultFallbacks(): void;
  140192. /**
  140193. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  140194. * @param profileId the profile to which a fallback needs to be found
  140195. * @return an array with corresponding fallback profiles
  140196. */
  140197. static FindFallbackWithProfileId(profileId: string): string[];
  140198. /**
  140199. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  140200. * The order of search:
  140201. *
  140202. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  140203. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  140204. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  140205. * 4) return the generic trigger controller if none were found
  140206. *
  140207. * @param xrInput the xrInput to which a new controller is initialized
  140208. * @param scene the scene to which the model will be added
  140209. * @param forceProfile force a certain profile for this controller
  140210. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  140211. */
  140212. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  140213. /**
  140214. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  140215. *
  140216. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  140217. *
  140218. * @param type the profile type to register
  140219. * @param constructFunction the function to be called when loading this profile
  140220. */
  140221. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  140222. /**
  140223. * Register a fallback to a specific profile.
  140224. * @param profileId the profileId that will receive the fallbacks
  140225. * @param fallbacks A list of fallback profiles
  140226. */
  140227. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  140228. /**
  140229. * Will update the list of profiles available in the repository
  140230. * @return a promise that resolves to a map of profiles available online
  140231. */
  140232. static UpdateProfilesList(): Promise<{
  140233. [profile: string]: string;
  140234. }>;
  140235. private static _LoadProfileFromRepository;
  140236. private static _LoadProfilesFromAvailableControllers;
  140237. }
  140238. }
  140239. declare module BABYLON {
  140240. /**
  140241. * Configuration options for the WebXR controller creation
  140242. */
  140243. export interface IWebXRControllerOptions {
  140244. /**
  140245. * Should the controller mesh be animated when a user interacts with it
  140246. * The pressed buttons / thumbstick and touchpad animations will be disabled
  140247. */
  140248. disableMotionControllerAnimation?: boolean;
  140249. /**
  140250. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  140251. */
  140252. doNotLoadControllerMesh?: boolean;
  140253. /**
  140254. * Force a specific controller type for this controller.
  140255. * This can be used when creating your own profile or when testing different controllers
  140256. */
  140257. forceControllerProfile?: string;
  140258. /**
  140259. * Defines a rendering group ID for meshes that will be loaded.
  140260. * This is for the default controllers only.
  140261. */
  140262. renderingGroupId?: number;
  140263. }
  140264. /**
  140265. * Represents an XR controller
  140266. */
  140267. export class WebXRInputSource {
  140268. private _scene;
  140269. /** The underlying input source for the controller */
  140270. inputSource: XRInputSource;
  140271. private _options;
  140272. private _tmpVector;
  140273. private _uniqueId;
  140274. private _disposed;
  140275. /**
  140276. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  140277. */
  140278. grip?: AbstractMesh;
  140279. /**
  140280. * If available, this is the gamepad object related to this controller.
  140281. * Using this object it is possible to get click events and trackpad changes of the
  140282. * webxr controller that is currently being used.
  140283. */
  140284. motionController?: WebXRAbstractMotionController;
  140285. /**
  140286. * Event that fires when the controller is removed/disposed.
  140287. * The object provided as event data is this controller, after associated assets were disposed.
  140288. * uniqueId is still available.
  140289. */
  140290. onDisposeObservable: Observable<WebXRInputSource>;
  140291. /**
  140292. * Will be triggered when the mesh associated with the motion controller is done loading.
  140293. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  140294. * A shortened version of controller -> motion controller -> on mesh loaded.
  140295. */
  140296. onMeshLoadedObservable: Observable<AbstractMesh>;
  140297. /**
  140298. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  140299. */
  140300. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  140301. /**
  140302. * Pointer which can be used to select objects or attach a visible laser to
  140303. */
  140304. pointer: AbstractMesh;
  140305. /**
  140306. * Creates the input source object
  140307. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  140308. * @param _scene the scene which the controller should be associated to
  140309. * @param inputSource the underlying input source for the controller
  140310. * @param _options options for this controller creation
  140311. */
  140312. constructor(_scene: Scene,
  140313. /** The underlying input source for the controller */
  140314. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  140315. /**
  140316. * Get this controllers unique id
  140317. */
  140318. get uniqueId(): string;
  140319. /**
  140320. * Disposes of the object
  140321. */
  140322. dispose(): void;
  140323. /**
  140324. * Gets a world space ray coming from the pointer or grip
  140325. * @param result the resulting ray
  140326. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  140327. */
  140328. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  140329. /**
  140330. * Updates the controller pose based on the given XRFrame
  140331. * @param xrFrame xr frame to update the pose with
  140332. * @param referenceSpace reference space to use
  140333. */
  140334. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  140335. }
  140336. }
  140337. declare module BABYLON {
  140338. /**
  140339. * The schema for initialization options of the XR Input class
  140340. */
  140341. export interface IWebXRInputOptions {
  140342. /**
  140343. * If set to true no model will be automatically loaded
  140344. */
  140345. doNotLoadControllerMeshes?: boolean;
  140346. /**
  140347. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  140348. * If not found, the xr input profile data will be used.
  140349. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  140350. */
  140351. forceInputProfile?: string;
  140352. /**
  140353. * Do not send a request to the controller repository to load the profile.
  140354. *
  140355. * Instead, use the controllers available in babylon itself.
  140356. */
  140357. disableOnlineControllerRepository?: boolean;
  140358. /**
  140359. * A custom URL for the controllers repository
  140360. */
  140361. customControllersRepositoryURL?: string;
  140362. /**
  140363. * Should the controller model's components not move according to the user input
  140364. */
  140365. disableControllerAnimation?: boolean;
  140366. /**
  140367. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  140368. */
  140369. controllerOptions?: IWebXRControllerOptions;
  140370. }
  140371. /**
  140372. * XR input used to track XR inputs such as controllers/rays
  140373. */
  140374. export class WebXRInput implements IDisposable {
  140375. /**
  140376. * the xr session manager for this session
  140377. */
  140378. xrSessionManager: WebXRSessionManager;
  140379. /**
  140380. * the WebXR camera for this session. Mainly used for teleportation
  140381. */
  140382. xrCamera: WebXRCamera;
  140383. private readonly options;
  140384. /**
  140385. * XR controllers being tracked
  140386. */
  140387. controllers: Array<WebXRInputSource>;
  140388. private _frameObserver;
  140389. private _sessionEndedObserver;
  140390. private _sessionInitObserver;
  140391. /**
  140392. * Event when a controller has been connected/added
  140393. */
  140394. onControllerAddedObservable: Observable<WebXRInputSource>;
  140395. /**
  140396. * Event when a controller has been removed/disconnected
  140397. */
  140398. onControllerRemovedObservable: Observable<WebXRInputSource>;
  140399. /**
  140400. * Initializes the WebXRInput
  140401. * @param xrSessionManager the xr session manager for this session
  140402. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  140403. * @param options = initialization options for this xr input
  140404. */
  140405. constructor(
  140406. /**
  140407. * the xr session manager for this session
  140408. */
  140409. xrSessionManager: WebXRSessionManager,
  140410. /**
  140411. * the WebXR camera for this session. Mainly used for teleportation
  140412. */
  140413. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  140414. private _onInputSourcesChange;
  140415. private _addAndRemoveControllers;
  140416. /**
  140417. * Disposes of the object
  140418. */
  140419. dispose(): void;
  140420. }
  140421. }
  140422. declare module BABYLON {
  140423. /**
  140424. * This is the base class for all WebXR features.
  140425. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  140426. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  140427. */
  140428. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  140429. protected _xrSessionManager: WebXRSessionManager;
  140430. private _attached;
  140431. private _removeOnDetach;
  140432. /**
  140433. * Is this feature disposed?
  140434. */
  140435. isDisposed: boolean;
  140436. /**
  140437. * Should auto-attach be disabled?
  140438. */
  140439. disableAutoAttach: boolean;
  140440. /**
  140441. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  140442. */
  140443. xrNativeFeatureName: string;
  140444. /**
  140445. * Construct a new (abstract) WebXR feature
  140446. * @param _xrSessionManager the xr session manager for this feature
  140447. */
  140448. constructor(_xrSessionManager: WebXRSessionManager);
  140449. /**
  140450. * Is this feature attached
  140451. */
  140452. get attached(): boolean;
  140453. /**
  140454. * attach this feature
  140455. *
  140456. * @param force should attachment be forced (even when already attached)
  140457. * @returns true if successful, false is failed or already attached
  140458. */
  140459. attach(force?: boolean): boolean;
  140460. /**
  140461. * detach this feature.
  140462. *
  140463. * @returns true if successful, false if failed or already detached
  140464. */
  140465. detach(): boolean;
  140466. /**
  140467. * Dispose this feature and all of the resources attached
  140468. */
  140469. dispose(): void;
  140470. /**
  140471. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  140472. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  140473. *
  140474. * @returns whether or not the feature is compatible in this environment
  140475. */
  140476. isCompatible(): boolean;
  140477. /**
  140478. * This is used to register callbacks that will automatically be removed when detach is called.
  140479. * @param observable the observable to which the observer will be attached
  140480. * @param callback the callback to register
  140481. */
  140482. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  140483. /**
  140484. * Code in this function will be executed on each xrFrame received from the browser.
  140485. * This function will not execute after the feature is detached.
  140486. * @param _xrFrame the current frame
  140487. */
  140488. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  140489. }
  140490. }
  140491. declare module BABYLON {
  140492. /**
  140493. * Renders a layer on top of an existing scene
  140494. */
  140495. export class UtilityLayerRenderer implements IDisposable {
  140496. /** the original scene that will be rendered on top of */
  140497. originalScene: Scene;
  140498. private _pointerCaptures;
  140499. private _lastPointerEvents;
  140500. private static _DefaultUtilityLayer;
  140501. private static _DefaultKeepDepthUtilityLayer;
  140502. private _sharedGizmoLight;
  140503. private _renderCamera;
  140504. /**
  140505. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  140506. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  140507. * @returns the camera that is used when rendering the utility layer
  140508. */
  140509. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  140510. /**
  140511. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  140512. * @param cam the camera that should be used when rendering the utility layer
  140513. */
  140514. setRenderCamera(cam: Nullable<Camera>): void;
  140515. /**
  140516. * @hidden
  140517. * Light which used by gizmos to get light shading
  140518. */
  140519. _getSharedGizmoLight(): HemisphericLight;
  140520. /**
  140521. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  140522. */
  140523. pickUtilitySceneFirst: boolean;
  140524. /**
  140525. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  140526. */
  140527. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  140528. /**
  140529. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  140530. */
  140531. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  140532. /**
  140533. * The scene that is rendered on top of the original scene
  140534. */
  140535. utilityLayerScene: Scene;
  140536. /**
  140537. * If the utility layer should automatically be rendered on top of existing scene
  140538. */
  140539. shouldRender: boolean;
  140540. /**
  140541. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  140542. */
  140543. onlyCheckPointerDownEvents: boolean;
  140544. /**
  140545. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  140546. */
  140547. processAllEvents: boolean;
  140548. /**
  140549. * Observable raised when the pointer move from the utility layer scene to the main scene
  140550. */
  140551. onPointerOutObservable: Observable<number>;
  140552. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  140553. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  140554. private _afterRenderObserver;
  140555. private _sceneDisposeObserver;
  140556. private _originalPointerObserver;
  140557. /**
  140558. * Instantiates a UtilityLayerRenderer
  140559. * @param originalScene the original scene that will be rendered on top of
  140560. * @param handleEvents boolean indicating if the utility layer should handle events
  140561. */
  140562. constructor(
  140563. /** the original scene that will be rendered on top of */
  140564. originalScene: Scene, handleEvents?: boolean);
  140565. private _notifyObservers;
  140566. /**
  140567. * Renders the utility layers scene on top of the original scene
  140568. */
  140569. render(): void;
  140570. /**
  140571. * Disposes of the renderer
  140572. */
  140573. dispose(): void;
  140574. private _updateCamera;
  140575. }
  140576. }
  140577. declare module BABYLON {
  140578. /**
  140579. * Options interface for the pointer selection module
  140580. */
  140581. export interface IWebXRControllerPointerSelectionOptions {
  140582. /**
  140583. * if provided, this scene will be used to render meshes.
  140584. */
  140585. customUtilityLayerScene?: Scene;
  140586. /**
  140587. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  140588. * If not disabled, the last picked point will be used to execute a pointer up event
  140589. * If disabled, pointer up event will be triggered right after the pointer down event.
  140590. * Used in screen and gaze target ray mode only
  140591. */
  140592. disablePointerUpOnTouchOut: boolean;
  140593. /**
  140594. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  140595. */
  140596. forceGazeMode: boolean;
  140597. /**
  140598. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  140599. * to start a new countdown to the pointer down event.
  140600. * Defaults to 1.
  140601. */
  140602. gazeModePointerMovedFactor?: number;
  140603. /**
  140604. * Different button type to use instead of the main component
  140605. */
  140606. overrideButtonId?: string;
  140607. /**
  140608. * use this rendering group id for the meshes (optional)
  140609. */
  140610. renderingGroupId?: number;
  140611. /**
  140612. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  140613. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  140614. * 3000 means 3 seconds between pointing at something and selecting it
  140615. */
  140616. timeToSelect?: number;
  140617. /**
  140618. * Should meshes created here be added to a utility layer or the main scene
  140619. */
  140620. useUtilityLayer?: boolean;
  140621. /**
  140622. * Optional WebXR camera to be used for gaze selection
  140623. */
  140624. gazeCamera?: WebXRCamera;
  140625. /**
  140626. * the xr input to use with this pointer selection
  140627. */
  140628. xrInput: WebXRInput;
  140629. /**
  140630. * Should the scene pointerX and pointerY update be disabled
  140631. * This is required for fullscreen AR GUI, but might slow down other experiences.
  140632. * Disable in VR, if not needed.
  140633. * The first rig camera (left eye) will be used to calculate the projection
  140634. */
  140635. disableScenePointerVectorUpdate: boolean;
  140636. /**
  140637. * Enable pointer selection on all controllers instead of switching between them
  140638. */
  140639. enablePointerSelectionOnAllControllers?: boolean;
  140640. /**
  140641. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  140642. * If switch is enabled, it will still allow the user to switch between the different controllers
  140643. */
  140644. preferredHandedness?: XRHandedness;
  140645. /**
  140646. * Disable switching the pointer selection from one controller to the other.
  140647. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  140648. */
  140649. disableSwitchOnClick?: boolean;
  140650. /**
  140651. * The maximum distance of the pointer selection feature. Defaults to 100.
  140652. */
  140653. maxPointerDistance?: number;
  140654. }
  140655. /**
  140656. * A module that will enable pointer selection for motion controllers of XR Input Sources
  140657. */
  140658. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  140659. private readonly _options;
  140660. private static _idCounter;
  140661. private _attachController;
  140662. private _controllers;
  140663. private _scene;
  140664. private _tmpVectorForPickCompare;
  140665. private _attachedController;
  140666. /**
  140667. * The module's name
  140668. */
  140669. static readonly Name: string;
  140670. /**
  140671. * The (Babylon) version of this module.
  140672. * This is an integer representing the implementation version.
  140673. * This number does not correspond to the WebXR specs version
  140674. */
  140675. static readonly Version: number;
  140676. /**
  140677. * Disable lighting on the laser pointer (so it will always be visible)
  140678. */
  140679. disablePointerLighting: boolean;
  140680. /**
  140681. * Disable lighting on the selection mesh (so it will always be visible)
  140682. */
  140683. disableSelectionMeshLighting: boolean;
  140684. /**
  140685. * Should the laser pointer be displayed
  140686. */
  140687. displayLaserPointer: boolean;
  140688. /**
  140689. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  140690. */
  140691. displaySelectionMesh: boolean;
  140692. /**
  140693. * This color will be set to the laser pointer when selection is triggered
  140694. */
  140695. laserPointerPickedColor: Color3;
  140696. /**
  140697. * Default color of the laser pointer
  140698. */
  140699. laserPointerDefaultColor: Color3;
  140700. /**
  140701. * default color of the selection ring
  140702. */
  140703. selectionMeshDefaultColor: Color3;
  140704. /**
  140705. * This color will be applied to the selection ring when selection is triggered
  140706. */
  140707. selectionMeshPickedColor: Color3;
  140708. /**
  140709. * Optional filter to be used for ray selection. This predicate shares behavior with
  140710. * scene.pointerMovePredicate which takes priority if it is also assigned.
  140711. */
  140712. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  140713. /**
  140714. * constructs a new background remover module
  140715. * @param _xrSessionManager the session manager for this module
  140716. * @param _options read-only options to be used in this module
  140717. */
  140718. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  140719. /**
  140720. * attach this feature
  140721. * Will usually be called by the features manager
  140722. *
  140723. * @returns true if successful.
  140724. */
  140725. attach(): boolean;
  140726. /**
  140727. * detach this feature.
  140728. * Will usually be called by the features manager
  140729. *
  140730. * @returns true if successful.
  140731. */
  140732. detach(): boolean;
  140733. /**
  140734. * Will get the mesh under a specific pointer.
  140735. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  140736. * @param controllerId the controllerId to check
  140737. * @returns The mesh under pointer or null if no mesh is under the pointer
  140738. */
  140739. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  140740. /**
  140741. * Get the xr controller that correlates to the pointer id in the pointer event
  140742. *
  140743. * @param id the pointer id to search for
  140744. * @returns the controller that correlates to this id or null if not found
  140745. */
  140746. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  140747. private _identityMatrix;
  140748. private _screenCoordinatesRef;
  140749. private _viewportRef;
  140750. protected _onXRFrame(_xrFrame: XRFrame): void;
  140751. private _attachGazeMode;
  140752. private _attachScreenRayMode;
  140753. private _attachTrackedPointerRayMode;
  140754. private _convertNormalToDirectionOfRay;
  140755. private _detachController;
  140756. private _generateNewMeshPair;
  140757. private _pickingMoved;
  140758. private _updatePointerDistance;
  140759. /** @hidden */
  140760. get lasterPointerDefaultColor(): Color3;
  140761. }
  140762. }
  140763. declare module BABYLON {
  140764. /**
  140765. * Button which can be used to enter a different mode of XR
  140766. */
  140767. export class WebXREnterExitUIButton {
  140768. /** button element */
  140769. element: HTMLElement;
  140770. /** XR initialization options for the button */
  140771. sessionMode: XRSessionMode;
  140772. /** Reference space type */
  140773. referenceSpaceType: XRReferenceSpaceType;
  140774. /**
  140775. * Creates a WebXREnterExitUIButton
  140776. * @param element button element
  140777. * @param sessionMode XR initialization session mode
  140778. * @param referenceSpaceType the type of reference space to be used
  140779. */
  140780. constructor(
  140781. /** button element */
  140782. element: HTMLElement,
  140783. /** XR initialization options for the button */
  140784. sessionMode: XRSessionMode,
  140785. /** Reference space type */
  140786. referenceSpaceType: XRReferenceSpaceType);
  140787. /**
  140788. * Extendable function which can be used to update the button's visuals when the state changes
  140789. * @param activeButton the current active button in the UI
  140790. */
  140791. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  140792. }
  140793. /**
  140794. * Options to create the webXR UI
  140795. */
  140796. export class WebXREnterExitUIOptions {
  140797. /**
  140798. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  140799. */
  140800. customButtons?: Array<WebXREnterExitUIButton>;
  140801. /**
  140802. * A reference space type to use when creating the default button.
  140803. * Default is local-floor
  140804. */
  140805. referenceSpaceType?: XRReferenceSpaceType;
  140806. /**
  140807. * Context to enter xr with
  140808. */
  140809. renderTarget?: Nullable<WebXRRenderTarget>;
  140810. /**
  140811. * A session mode to use when creating the default button.
  140812. * Default is immersive-vr
  140813. */
  140814. sessionMode?: XRSessionMode;
  140815. /**
  140816. * A list of optional features to init the session with
  140817. */
  140818. optionalFeatures?: string[];
  140819. /**
  140820. * A list of optional features to init the session with
  140821. */
  140822. requiredFeatures?: string[];
  140823. /**
  140824. * If defined, this function will be executed if the UI encounters an error when entering XR
  140825. */
  140826. onError?: (error: any) => void;
  140827. }
  140828. /**
  140829. * UI to allow the user to enter/exit XR mode
  140830. */
  140831. export class WebXREnterExitUI implements IDisposable {
  140832. private scene;
  140833. /** version of the options passed to this UI */
  140834. options: WebXREnterExitUIOptions;
  140835. private _activeButton;
  140836. private _buttons;
  140837. /**
  140838. * The HTML Div Element to which buttons are added.
  140839. */
  140840. readonly overlay: HTMLDivElement;
  140841. /**
  140842. * Fired every time the active button is changed.
  140843. *
  140844. * When xr is entered via a button that launches xr that button will be the callback parameter
  140845. *
  140846. * When exiting xr the callback parameter will be null)
  140847. */
  140848. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  140849. /**
  140850. *
  140851. * @param scene babylon scene object to use
  140852. * @param options (read-only) version of the options passed to this UI
  140853. */
  140854. private constructor();
  140855. /**
  140856. * Creates UI to allow the user to enter/exit XR mode
  140857. * @param scene the scene to add the ui to
  140858. * @param helper the xr experience helper to enter/exit xr with
  140859. * @param options options to configure the UI
  140860. * @returns the created ui
  140861. */
  140862. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  140863. /**
  140864. * Disposes of the XR UI component
  140865. */
  140866. dispose(): void;
  140867. private _updateButtons;
  140868. }
  140869. }
  140870. declare module BABYLON {
  140871. /**
  140872. * Class containing static functions to help procedurally build meshes
  140873. */
  140874. export class LinesBuilder {
  140875. /**
  140876. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  140877. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  140878. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  140879. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  140880. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  140881. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  140882. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140883. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  140884. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  140885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  140887. * @param name defines the name of the new line system
  140888. * @param options defines the options used to create the line system
  140889. * @param scene defines the hosting scene
  140890. * @returns a new line system mesh
  140891. */
  140892. static CreateLineSystem(name: string, options: {
  140893. lines: Vector3[][];
  140894. updatable?: boolean;
  140895. instance?: Nullable<LinesMesh>;
  140896. colors?: Nullable<Color4[][]>;
  140897. useVertexAlpha?: boolean;
  140898. }, scene: Nullable<Scene>): LinesMesh;
  140899. /**
  140900. * Creates a line mesh
  140901. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  140902. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140903. * * The parameter `points` is an array successive Vector3
  140904. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  140905. * * The optional parameter `colors` is an array of successive Color4, one per line point
  140906. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  140907. * * When updating an instance, remember that only point positions can change, not the number of points
  140908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  140910. * @param name defines the name of the new line system
  140911. * @param options defines the options used to create the line system
  140912. * @param scene defines the hosting scene
  140913. * @returns a new line mesh
  140914. */
  140915. static CreateLines(name: string, options: {
  140916. points: Vector3[];
  140917. updatable?: boolean;
  140918. instance?: Nullable<LinesMesh>;
  140919. colors?: Color4[];
  140920. useVertexAlpha?: boolean;
  140921. }, scene?: Nullable<Scene>): LinesMesh;
  140922. /**
  140923. * Creates a dashed line mesh
  140924. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  140925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140926. * * The parameter `points` is an array successive Vector3
  140927. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  140928. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  140929. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  140930. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  140931. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140932. * * When updating an instance, remember that only point positions can change, not the number of points
  140933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140934. * @param name defines the name of the mesh
  140935. * @param options defines the options used to create the mesh
  140936. * @param scene defines the hosting scene
  140937. * @returns the dashed line mesh
  140938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  140939. */
  140940. static CreateDashedLines(name: string, options: {
  140941. points: Vector3[];
  140942. dashSize?: number;
  140943. gapSize?: number;
  140944. dashNb?: number;
  140945. updatable?: boolean;
  140946. instance?: LinesMesh;
  140947. useVertexAlpha?: boolean;
  140948. }, scene?: Nullable<Scene>): LinesMesh;
  140949. }
  140950. }
  140951. declare module BABYLON {
  140952. /**
  140953. * Construction options for a timer
  140954. */
  140955. export interface ITimerOptions<T> {
  140956. /**
  140957. * Time-to-end
  140958. */
  140959. timeout: number;
  140960. /**
  140961. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  140962. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  140963. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  140964. */
  140965. contextObservable: Observable<T>;
  140966. /**
  140967. * Optional parameters when adding an observer to the observable
  140968. */
  140969. observableParameters?: {
  140970. mask?: number;
  140971. insertFirst?: boolean;
  140972. scope?: any;
  140973. };
  140974. /**
  140975. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  140976. */
  140977. breakCondition?: (data?: ITimerData<T>) => boolean;
  140978. /**
  140979. * Will be triggered when the time condition has met
  140980. */
  140981. onEnded?: (data: ITimerData<any>) => void;
  140982. /**
  140983. * Will be triggered when the break condition has met (prematurely ended)
  140984. */
  140985. onAborted?: (data: ITimerData<any>) => void;
  140986. /**
  140987. * Optional function to execute on each tick (or count)
  140988. */
  140989. onTick?: (data: ITimerData<any>) => void;
  140990. }
  140991. /**
  140992. * An interface defining the data sent by the timer
  140993. */
  140994. export interface ITimerData<T> {
  140995. /**
  140996. * When did it start
  140997. */
  140998. startTime: number;
  140999. /**
  141000. * Time now
  141001. */
  141002. currentTime: number;
  141003. /**
  141004. * Time passed since started
  141005. */
  141006. deltaTime: number;
  141007. /**
  141008. * How much is completed, in [0.0...1.0].
  141009. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  141010. */
  141011. completeRate: number;
  141012. /**
  141013. * What the registered observable sent in the last count
  141014. */
  141015. payload: T;
  141016. }
  141017. /**
  141018. * The current state of the timer
  141019. */
  141020. export enum TimerState {
  141021. /**
  141022. * Timer initialized, not yet started
  141023. */
  141024. INIT = 0,
  141025. /**
  141026. * Timer started and counting
  141027. */
  141028. STARTED = 1,
  141029. /**
  141030. * Timer ended (whether aborted or time reached)
  141031. */
  141032. ENDED = 2
  141033. }
  141034. /**
  141035. * A simple version of the timer. Will take options and start the timer immediately after calling it
  141036. *
  141037. * @param options options with which to initialize this timer
  141038. */
  141039. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  141040. /**
  141041. * An advanced implementation of a timer class
  141042. */
  141043. export class AdvancedTimer<T = any> implements IDisposable {
  141044. /**
  141045. * Will notify each time the timer calculates the remaining time
  141046. */
  141047. onEachCountObservable: Observable<ITimerData<T>>;
  141048. /**
  141049. * Will trigger when the timer was aborted due to the break condition
  141050. */
  141051. onTimerAbortedObservable: Observable<ITimerData<T>>;
  141052. /**
  141053. * Will trigger when the timer ended successfully
  141054. */
  141055. onTimerEndedObservable: Observable<ITimerData<T>>;
  141056. /**
  141057. * Will trigger when the timer state has changed
  141058. */
  141059. onStateChangedObservable: Observable<TimerState>;
  141060. private _observer;
  141061. private _contextObservable;
  141062. private _observableParameters;
  141063. private _startTime;
  141064. private _timer;
  141065. private _state;
  141066. private _breakCondition;
  141067. private _timeToEnd;
  141068. private _breakOnNextTick;
  141069. /**
  141070. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  141071. * @param options construction options for this advanced timer
  141072. */
  141073. constructor(options: ITimerOptions<T>);
  141074. /**
  141075. * set a breaking condition for this timer. Default is to never break during count
  141076. * @param predicate the new break condition. Returns true to break, false otherwise
  141077. */
  141078. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  141079. /**
  141080. * Reset ALL associated observables in this advanced timer
  141081. */
  141082. clearObservables(): void;
  141083. /**
  141084. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  141085. *
  141086. * @param timeToEnd how much time to measure until timer ended
  141087. */
  141088. start(timeToEnd?: number): void;
  141089. /**
  141090. * Will force a stop on the next tick.
  141091. */
  141092. stop(): void;
  141093. /**
  141094. * Dispose this timer, clearing all resources
  141095. */
  141096. dispose(): void;
  141097. private _setState;
  141098. private _tick;
  141099. private _stop;
  141100. }
  141101. }
  141102. declare module BABYLON {
  141103. /**
  141104. * The options container for the teleportation module
  141105. */
  141106. export interface IWebXRTeleportationOptions {
  141107. /**
  141108. * if provided, this scene will be used to render meshes.
  141109. */
  141110. customUtilityLayerScene?: Scene;
  141111. /**
  141112. * Values to configure the default target mesh
  141113. */
  141114. defaultTargetMeshOptions?: {
  141115. /**
  141116. * Fill color of the teleportation area
  141117. */
  141118. teleportationFillColor?: string;
  141119. /**
  141120. * Border color for the teleportation area
  141121. */
  141122. teleportationBorderColor?: string;
  141123. /**
  141124. * Disable the mesh's animation sequence
  141125. */
  141126. disableAnimation?: boolean;
  141127. /**
  141128. * Disable lighting on the material or the ring and arrow
  141129. */
  141130. disableLighting?: boolean;
  141131. /**
  141132. * Override the default material of the torus and arrow
  141133. */
  141134. torusArrowMaterial?: Material;
  141135. };
  141136. /**
  141137. * A list of meshes to use as floor meshes.
  141138. * Meshes can be added and removed after initializing the feature using the
  141139. * addFloorMesh and removeFloorMesh functions
  141140. * If empty, rotation will still work
  141141. */
  141142. floorMeshes?: AbstractMesh[];
  141143. /**
  141144. * use this rendering group id for the meshes (optional)
  141145. */
  141146. renderingGroupId?: number;
  141147. /**
  141148. * Should teleportation move only to snap points
  141149. */
  141150. snapPointsOnly?: boolean;
  141151. /**
  141152. * An array of points to which the teleportation will snap to.
  141153. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  141154. */
  141155. snapPositions?: Vector3[];
  141156. /**
  141157. * How close should the teleportation ray be in order to snap to position.
  141158. * Default to 0.8 units (meters)
  141159. */
  141160. snapToPositionRadius?: number;
  141161. /**
  141162. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  141163. * If you want to support rotation, make sure your mesh has a direction indicator.
  141164. *
  141165. * When left untouched, the default mesh will be initialized.
  141166. */
  141167. teleportationTargetMesh?: AbstractMesh;
  141168. /**
  141169. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  141170. */
  141171. timeToTeleport?: number;
  141172. /**
  141173. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  141174. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  141175. */
  141176. useMainComponentOnly?: boolean;
  141177. /**
  141178. * Should meshes created here be added to a utility layer or the main scene
  141179. */
  141180. useUtilityLayer?: boolean;
  141181. /**
  141182. * Babylon XR Input class for controller
  141183. */
  141184. xrInput: WebXRInput;
  141185. /**
  141186. * Meshes that the teleportation ray cannot go through
  141187. */
  141188. pickBlockerMeshes?: AbstractMesh[];
  141189. /**
  141190. * Should teleport work only on a specific hand?
  141191. */
  141192. forceHandedness?: XRHandedness;
  141193. /**
  141194. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  141195. */
  141196. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  141197. }
  141198. /**
  141199. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  141200. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  141201. * the input of the attached controllers.
  141202. */
  141203. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  141204. private _options;
  141205. private _controllers;
  141206. private _currentTeleportationControllerId;
  141207. private _floorMeshes;
  141208. private _quadraticBezierCurve;
  141209. private _selectionFeature;
  141210. private _snapToPositions;
  141211. private _snappedToPoint;
  141212. private _teleportationRingMaterial?;
  141213. private _tmpRay;
  141214. private _tmpVector;
  141215. private _tmpQuaternion;
  141216. /**
  141217. * The module's name
  141218. */
  141219. static readonly Name: string;
  141220. /**
  141221. * The (Babylon) version of this module.
  141222. * This is an integer representing the implementation version.
  141223. * This number does not correspond to the webxr specs version
  141224. */
  141225. static readonly Version: number;
  141226. /**
  141227. * Is movement backwards enabled
  141228. */
  141229. backwardsMovementEnabled: boolean;
  141230. /**
  141231. * Distance to travel when moving backwards
  141232. */
  141233. backwardsTeleportationDistance: number;
  141234. /**
  141235. * The distance from the user to the inspection point in the direction of the controller
  141236. * A higher number will allow the user to move further
  141237. * defaults to 5 (meters, in xr units)
  141238. */
  141239. parabolicCheckRadius: number;
  141240. /**
  141241. * Should the module support parabolic ray on top of direct ray
  141242. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  141243. * Very helpful when moving between floors / different heights
  141244. */
  141245. parabolicRayEnabled: boolean;
  141246. /**
  141247. * The second type of ray - straight line.
  141248. * Should it be enabled or should the parabolic line be the only one.
  141249. */
  141250. straightRayEnabled: boolean;
  141251. /**
  141252. * How much rotation should be applied when rotating right and left
  141253. */
  141254. rotationAngle: number;
  141255. private _rotationEnabled;
  141256. /**
  141257. * Is rotation enabled when moving forward?
  141258. * Disabling this feature will prevent the user from deciding the direction when teleporting
  141259. */
  141260. get rotationEnabled(): boolean;
  141261. /**
  141262. * Sets wether rotation is enabled or not
  141263. * @param enabled is rotation enabled when teleportation is shown
  141264. */
  141265. set rotationEnabled(enabled: boolean);
  141266. /**
  141267. * Exposes the currently set teleportation target mesh.
  141268. */
  141269. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  141270. /**
  141271. * constructs a new anchor system
  141272. * @param _xrSessionManager an instance of WebXRSessionManager
  141273. * @param _options configuration object for this feature
  141274. */
  141275. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  141276. /**
  141277. * Get the snapPointsOnly flag
  141278. */
  141279. get snapPointsOnly(): boolean;
  141280. /**
  141281. * Sets the snapPointsOnly flag
  141282. * @param snapToPoints should teleportation be exclusively to snap points
  141283. */
  141284. set snapPointsOnly(snapToPoints: boolean);
  141285. /**
  141286. * Add a new mesh to the floor meshes array
  141287. * @param mesh the mesh to use as floor mesh
  141288. */
  141289. addFloorMesh(mesh: AbstractMesh): void;
  141290. /**
  141291. * Add a new snap-to point to fix teleportation to this position
  141292. * @param newSnapPoint The new Snap-To point
  141293. */
  141294. addSnapPoint(newSnapPoint: Vector3): void;
  141295. attach(): boolean;
  141296. detach(): boolean;
  141297. dispose(): void;
  141298. /**
  141299. * Remove a mesh from the floor meshes array
  141300. * @param mesh the mesh to remove
  141301. */
  141302. removeFloorMesh(mesh: AbstractMesh): void;
  141303. /**
  141304. * Remove a mesh from the floor meshes array using its name
  141305. * @param name the mesh name to remove
  141306. */
  141307. removeFloorMeshByName(name: string): void;
  141308. /**
  141309. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  141310. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  141311. * @returns was the point found and removed or not
  141312. */
  141313. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  141314. /**
  141315. * This function sets a selection feature that will be disabled when
  141316. * the forward ray is shown and will be reattached when hidden.
  141317. * This is used to remove the selection rays when moving.
  141318. * @param selectionFeature the feature to disable when forward movement is enabled
  141319. */
  141320. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  141321. protected _onXRFrame(_xrFrame: XRFrame): void;
  141322. private _attachController;
  141323. private _createDefaultTargetMesh;
  141324. private _detachController;
  141325. private _findClosestSnapPointWithRadius;
  141326. private _setTargetMeshPosition;
  141327. private _setTargetMeshVisibility;
  141328. private _showParabolicPath;
  141329. private _teleportForward;
  141330. }
  141331. }
  141332. declare module BABYLON {
  141333. /**
  141334. * Options for the default xr helper
  141335. */
  141336. export class WebXRDefaultExperienceOptions {
  141337. /**
  141338. * Enable or disable default UI to enter XR
  141339. */
  141340. disableDefaultUI?: boolean;
  141341. /**
  141342. * Should teleportation not initialize. defaults to false.
  141343. */
  141344. disableTeleportation?: boolean;
  141345. /**
  141346. * Floor meshes that will be used for teleport
  141347. */
  141348. floorMeshes?: Array<AbstractMesh>;
  141349. /**
  141350. * If set to true, the first frame will not be used to reset position
  141351. * The first frame is mainly used when copying transformation from the old camera
  141352. * Mainly used in AR
  141353. */
  141354. ignoreNativeCameraTransformation?: boolean;
  141355. /**
  141356. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  141357. */
  141358. inputOptions?: IWebXRInputOptions;
  141359. /**
  141360. * optional configuration for the output canvas
  141361. */
  141362. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  141363. /**
  141364. * optional UI options. This can be used among other to change session mode and reference space type
  141365. */
  141366. uiOptions?: WebXREnterExitUIOptions;
  141367. /**
  141368. * When loading teleportation and pointer select, use stable versions instead of latest.
  141369. */
  141370. useStablePlugins?: boolean;
  141371. /**
  141372. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  141373. */
  141374. renderingGroupId?: number;
  141375. /**
  141376. * A list of optional features to init the session with
  141377. * If set to true, all features we support will be added
  141378. */
  141379. optionalFeatures?: boolean | string[];
  141380. }
  141381. /**
  141382. * Default experience which provides a similar setup to the previous webVRExperience
  141383. */
  141384. export class WebXRDefaultExperience {
  141385. /**
  141386. * Base experience
  141387. */
  141388. baseExperience: WebXRExperienceHelper;
  141389. /**
  141390. * Enables ui for entering/exiting xr
  141391. */
  141392. enterExitUI: WebXREnterExitUI;
  141393. /**
  141394. * Input experience extension
  141395. */
  141396. input: WebXRInput;
  141397. /**
  141398. * Enables laser pointer and selection
  141399. */
  141400. pointerSelection: WebXRControllerPointerSelection;
  141401. /**
  141402. * Default target xr should render to
  141403. */
  141404. renderTarget: WebXRRenderTarget;
  141405. /**
  141406. * Enables teleportation
  141407. */
  141408. teleportation: WebXRMotionControllerTeleportation;
  141409. private constructor();
  141410. /**
  141411. * Creates the default xr experience
  141412. * @param scene scene
  141413. * @param options options for basic configuration
  141414. * @returns resulting WebXRDefaultExperience
  141415. */
  141416. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  141417. /**
  141418. * DIsposes of the experience helper
  141419. */
  141420. dispose(): void;
  141421. }
  141422. }
  141423. declare module BABYLON {
  141424. /**
  141425. * Options to modify the vr teleportation behavior.
  141426. */
  141427. export interface VRTeleportationOptions {
  141428. /**
  141429. * The name of the mesh which should be used as the teleportation floor. (default: null)
  141430. */
  141431. floorMeshName?: string;
  141432. /**
  141433. * A list of meshes to be used as the teleportation floor. (default: empty)
  141434. */
  141435. floorMeshes?: Mesh[];
  141436. /**
  141437. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  141438. */
  141439. teleportationMode?: number;
  141440. /**
  141441. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  141442. */
  141443. teleportationTime?: number;
  141444. /**
  141445. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  141446. */
  141447. teleportationSpeed?: number;
  141448. /**
  141449. * The easing function used in the animation or null for Linear. (default CircleEase)
  141450. */
  141451. easingFunction?: EasingFunction;
  141452. }
  141453. /**
  141454. * Options to modify the vr experience helper's behavior.
  141455. */
  141456. export interface VRExperienceHelperOptions extends WebVROptions {
  141457. /**
  141458. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  141459. */
  141460. createDeviceOrientationCamera?: boolean;
  141461. /**
  141462. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  141463. */
  141464. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  141465. /**
  141466. * Uses the main button on the controller to toggle the laser casted. (default: true)
  141467. */
  141468. laserToggle?: boolean;
  141469. /**
  141470. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  141471. */
  141472. floorMeshes?: Mesh[];
  141473. /**
  141474. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  141475. */
  141476. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  141477. /**
  141478. * Defines if WebXR should be used instead of WebVR (if available)
  141479. */
  141480. useXR?: boolean;
  141481. }
  141482. /**
  141483. * Event containing information after VR has been entered
  141484. */
  141485. export class OnAfterEnteringVRObservableEvent {
  141486. /**
  141487. * If entering vr was successful
  141488. */
  141489. success: boolean;
  141490. }
  141491. /**
  141492. * Helps to quickly add VR support to an existing scene.
  141493. * See https://doc.babylonjs.com/how_to/webvr_helper
  141494. */
  141495. export class VRExperienceHelper {
  141496. /** Options to modify the vr experience helper's behavior. */
  141497. webVROptions: VRExperienceHelperOptions;
  141498. private _scene;
  141499. private _position;
  141500. private _btnVR;
  141501. private _btnVRDisplayed;
  141502. private _webVRsupported;
  141503. private _webVRready;
  141504. private _webVRrequesting;
  141505. private _webVRpresenting;
  141506. private _hasEnteredVR;
  141507. private _fullscreenVRpresenting;
  141508. private _inputElement;
  141509. private _webVRCamera;
  141510. private _vrDeviceOrientationCamera;
  141511. private _deviceOrientationCamera;
  141512. private _existingCamera;
  141513. private _onKeyDown;
  141514. private _onVrDisplayPresentChange;
  141515. private _onVRDisplayChanged;
  141516. private _onVRRequestPresentStart;
  141517. private _onVRRequestPresentComplete;
  141518. /**
  141519. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  141520. */
  141521. enableGazeEvenWhenNoPointerLock: boolean;
  141522. /**
  141523. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  141524. */
  141525. exitVROnDoubleTap: boolean;
  141526. /**
  141527. * Observable raised right before entering VR.
  141528. */
  141529. onEnteringVRObservable: Observable<VRExperienceHelper>;
  141530. /**
  141531. * Observable raised when entering VR has completed.
  141532. */
  141533. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  141534. /**
  141535. * Observable raised when exiting VR.
  141536. */
  141537. onExitingVRObservable: Observable<VRExperienceHelper>;
  141538. /**
  141539. * Observable raised when controller mesh is loaded.
  141540. */
  141541. onControllerMeshLoadedObservable: Observable<WebVRController>;
  141542. /** Return this.onEnteringVRObservable
  141543. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  141544. */
  141545. get onEnteringVR(): Observable<VRExperienceHelper>;
  141546. /** Return this.onExitingVRObservable
  141547. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  141548. */
  141549. get onExitingVR(): Observable<VRExperienceHelper>;
  141550. /** Return this.onControllerMeshLoadedObservable
  141551. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  141552. */
  141553. get onControllerMeshLoaded(): Observable<WebVRController>;
  141554. private _rayLength;
  141555. private _useCustomVRButton;
  141556. private _teleportationRequested;
  141557. private _teleportActive;
  141558. private _floorMeshName;
  141559. private _floorMeshesCollection;
  141560. private _teleportationMode;
  141561. private _teleportationTime;
  141562. private _teleportationSpeed;
  141563. private _teleportationEasing;
  141564. private _rotationAllowed;
  141565. private _teleportBackwardsVector;
  141566. private _teleportationTarget;
  141567. private _isDefaultTeleportationTarget;
  141568. private _postProcessMove;
  141569. private _teleportationFillColor;
  141570. private _teleportationBorderColor;
  141571. private _rotationAngle;
  141572. private _haloCenter;
  141573. private _cameraGazer;
  141574. private _padSensibilityUp;
  141575. private _padSensibilityDown;
  141576. private _leftController;
  141577. private _rightController;
  141578. private _gazeColor;
  141579. private _laserColor;
  141580. private _pickedLaserColor;
  141581. private _pickedGazeColor;
  141582. /**
  141583. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  141584. */
  141585. onNewMeshSelected: Observable<AbstractMesh>;
  141586. /**
  141587. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  141588. * This observable will provide the mesh and the controller used to select the mesh
  141589. */
  141590. onMeshSelectedWithController: Observable<{
  141591. mesh: AbstractMesh;
  141592. controller: WebVRController;
  141593. }>;
  141594. /**
  141595. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  141596. */
  141597. onNewMeshPicked: Observable<PickingInfo>;
  141598. private _circleEase;
  141599. /**
  141600. * Observable raised before camera teleportation
  141601. */
  141602. onBeforeCameraTeleport: Observable<Vector3>;
  141603. /**
  141604. * Observable raised after camera teleportation
  141605. */
  141606. onAfterCameraTeleport: Observable<Vector3>;
  141607. /**
  141608. * Observable raised when current selected mesh gets unselected
  141609. */
  141610. onSelectedMeshUnselected: Observable<AbstractMesh>;
  141611. private _raySelectionPredicate;
  141612. /**
  141613. * To be optionaly changed by user to define custom ray selection
  141614. */
  141615. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  141616. /**
  141617. * To be optionaly changed by user to define custom selection logic (after ray selection)
  141618. */
  141619. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  141620. /**
  141621. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  141622. */
  141623. teleportationEnabled: boolean;
  141624. private _defaultHeight;
  141625. private _teleportationInitialized;
  141626. private _interactionsEnabled;
  141627. private _interactionsRequested;
  141628. private _displayGaze;
  141629. private _displayLaserPointer;
  141630. /**
  141631. * The mesh used to display where the user is going to teleport.
  141632. */
  141633. get teleportationTarget(): Mesh;
  141634. /**
  141635. * Sets the mesh to be used to display where the user is going to teleport.
  141636. */
  141637. set teleportationTarget(value: Mesh);
  141638. /**
  141639. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  141640. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  141641. * See https://doc.babylonjs.com/resources/baking_transformations
  141642. */
  141643. get gazeTrackerMesh(): Mesh;
  141644. set gazeTrackerMesh(value: Mesh);
  141645. /**
  141646. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  141647. */
  141648. updateGazeTrackerScale: boolean;
  141649. /**
  141650. * If the gaze trackers color should be updated when selecting meshes
  141651. */
  141652. updateGazeTrackerColor: boolean;
  141653. /**
  141654. * If the controller laser color should be updated when selecting meshes
  141655. */
  141656. updateControllerLaserColor: boolean;
  141657. /**
  141658. * The gaze tracking mesh corresponding to the left controller
  141659. */
  141660. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  141661. /**
  141662. * The gaze tracking mesh corresponding to the right controller
  141663. */
  141664. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  141665. /**
  141666. * If the ray of the gaze should be displayed.
  141667. */
  141668. get displayGaze(): boolean;
  141669. /**
  141670. * Sets if the ray of the gaze should be displayed.
  141671. */
  141672. set displayGaze(value: boolean);
  141673. /**
  141674. * If the ray of the LaserPointer should be displayed.
  141675. */
  141676. get displayLaserPointer(): boolean;
  141677. /**
  141678. * Sets if the ray of the LaserPointer should be displayed.
  141679. */
  141680. set displayLaserPointer(value: boolean);
  141681. /**
  141682. * The deviceOrientationCamera used as the camera when not in VR.
  141683. */
  141684. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  141685. /**
  141686. * Based on the current WebVR support, returns the current VR camera used.
  141687. */
  141688. get currentVRCamera(): Nullable<Camera>;
  141689. /**
  141690. * The webVRCamera which is used when in VR.
  141691. */
  141692. get webVRCamera(): WebVRFreeCamera;
  141693. /**
  141694. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  141695. */
  141696. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  141697. /**
  141698. * The html button that is used to trigger entering into VR.
  141699. */
  141700. get vrButton(): Nullable<HTMLButtonElement>;
  141701. private get _teleportationRequestInitiated();
  141702. /**
  141703. * Defines whether or not Pointer lock should be requested when switching to
  141704. * full screen.
  141705. */
  141706. requestPointerLockOnFullScreen: boolean;
  141707. /**
  141708. * If asking to force XR, this will be populated with the default xr experience
  141709. */
  141710. xr: WebXRDefaultExperience;
  141711. /**
  141712. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  141713. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  141714. */
  141715. xrTestDone: boolean;
  141716. /**
  141717. * Instantiates a VRExperienceHelper.
  141718. * Helps to quickly add VR support to an existing scene.
  141719. * @param scene The scene the VRExperienceHelper belongs to.
  141720. * @param webVROptions Options to modify the vr experience helper's behavior.
  141721. */
  141722. constructor(scene: Scene,
  141723. /** Options to modify the vr experience helper's behavior. */
  141724. webVROptions?: VRExperienceHelperOptions);
  141725. private completeVRInit;
  141726. private _onDefaultMeshLoaded;
  141727. private _onResize;
  141728. private _onFullscreenChange;
  141729. /**
  141730. * Gets a value indicating if we are currently in VR mode.
  141731. */
  141732. get isInVRMode(): boolean;
  141733. private onVrDisplayPresentChange;
  141734. private onVRDisplayChanged;
  141735. private moveButtonToBottomRight;
  141736. private displayVRButton;
  141737. private updateButtonVisibility;
  141738. private _cachedAngularSensibility;
  141739. /**
  141740. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  141741. * Otherwise, will use the fullscreen API.
  141742. */
  141743. enterVR(): void;
  141744. /**
  141745. * Attempt to exit VR, or fullscreen.
  141746. */
  141747. exitVR(): void;
  141748. /**
  141749. * The position of the vr experience helper.
  141750. */
  141751. get position(): Vector3;
  141752. /**
  141753. * Sets the position of the vr experience helper.
  141754. */
  141755. set position(value: Vector3);
  141756. /**
  141757. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  141758. */
  141759. enableInteractions(): void;
  141760. private get _noControllerIsActive();
  141761. private beforeRender;
  141762. private _isTeleportationFloor;
  141763. /**
  141764. * Adds a floor mesh to be used for teleportation.
  141765. * @param floorMesh the mesh to be used for teleportation.
  141766. */
  141767. addFloorMesh(floorMesh: Mesh): void;
  141768. /**
  141769. * Removes a floor mesh from being used for teleportation.
  141770. * @param floorMesh the mesh to be removed.
  141771. */
  141772. removeFloorMesh(floorMesh: Mesh): void;
  141773. /**
  141774. * Enables interactions and teleportation using the VR controllers and gaze.
  141775. * @param vrTeleportationOptions options to modify teleportation behavior.
  141776. */
  141777. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  141778. private _onNewGamepadConnected;
  141779. private _tryEnableInteractionOnController;
  141780. private _onNewGamepadDisconnected;
  141781. private _enableInteractionOnController;
  141782. private _checkTeleportWithRay;
  141783. private _checkRotate;
  141784. private _checkTeleportBackwards;
  141785. private _enableTeleportationOnController;
  141786. private _createTeleportationCircles;
  141787. private _displayTeleportationTarget;
  141788. private _hideTeleportationTarget;
  141789. private _rotateCamera;
  141790. private _moveTeleportationSelectorTo;
  141791. private _workingVector;
  141792. private _workingQuaternion;
  141793. private _workingMatrix;
  141794. /**
  141795. * Time Constant Teleportation Mode
  141796. */
  141797. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  141798. /**
  141799. * Speed Constant Teleportation Mode
  141800. */
  141801. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  141802. /**
  141803. * Teleports the users feet to the desired location
  141804. * @param location The location where the user's feet should be placed
  141805. */
  141806. teleportCamera(location: Vector3): void;
  141807. private _convertNormalToDirectionOfRay;
  141808. private _castRayAndSelectObject;
  141809. private _notifySelectedMeshUnselected;
  141810. /**
  141811. * Permanently set new colors for the laser pointer
  141812. * @param color the new laser color
  141813. * @param pickedColor the new laser color when picked mesh detected
  141814. */
  141815. setLaserColor(color: Color3, pickedColor?: Color3): void;
  141816. /**
  141817. * Set lighting enabled / disabled on the laser pointer of both controllers
  141818. * @param enabled should the lighting be enabled on the laser pointer
  141819. */
  141820. setLaserLightingState(enabled?: boolean): void;
  141821. /**
  141822. * Permanently set new colors for the gaze pointer
  141823. * @param color the new gaze color
  141824. * @param pickedColor the new gaze color when picked mesh detected
  141825. */
  141826. setGazeColor(color: Color3, pickedColor?: Color3): void;
  141827. /**
  141828. * Sets the color of the laser ray from the vr controllers.
  141829. * @param color new color for the ray.
  141830. */
  141831. changeLaserColor(color: Color3): void;
  141832. /**
  141833. * Sets the color of the ray from the vr headsets gaze.
  141834. * @param color new color for the ray.
  141835. */
  141836. changeGazeColor(color: Color3): void;
  141837. /**
  141838. * Exits VR and disposes of the vr experience helper
  141839. */
  141840. dispose(): void;
  141841. /**
  141842. * Gets the name of the VRExperienceHelper class
  141843. * @returns "VRExperienceHelper"
  141844. */
  141845. getClassName(): string;
  141846. }
  141847. }
  141848. declare module BABYLON {
  141849. /**
  141850. * Contains an array of blocks representing the octree
  141851. */
  141852. export interface IOctreeContainer<T> {
  141853. /**
  141854. * Blocks within the octree
  141855. */
  141856. blocks: Array<OctreeBlock<T>>;
  141857. }
  141858. /**
  141859. * Class used to store a cell in an octree
  141860. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141861. */
  141862. export class OctreeBlock<T> {
  141863. /**
  141864. * Gets the content of the current block
  141865. */
  141866. entries: T[];
  141867. /**
  141868. * Gets the list of block children
  141869. */
  141870. blocks: Array<OctreeBlock<T>>;
  141871. private _depth;
  141872. private _maxDepth;
  141873. private _capacity;
  141874. private _minPoint;
  141875. private _maxPoint;
  141876. private _boundingVectors;
  141877. private _creationFunc;
  141878. /**
  141879. * Creates a new block
  141880. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  141881. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  141882. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141883. * @param depth defines the current depth of this block in the octree
  141884. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  141885. * @param creationFunc defines a callback to call when an element is added to the block
  141886. */
  141887. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  141888. /**
  141889. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141890. */
  141891. get capacity(): number;
  141892. /**
  141893. * Gets the minimum vector (in world space) of the block's bounding box
  141894. */
  141895. get minPoint(): Vector3;
  141896. /**
  141897. * Gets the maximum vector (in world space) of the block's bounding box
  141898. */
  141899. get maxPoint(): Vector3;
  141900. /**
  141901. * Add a new element to this block
  141902. * @param entry defines the element to add
  141903. */
  141904. addEntry(entry: T): void;
  141905. /**
  141906. * Remove an element from this block
  141907. * @param entry defines the element to remove
  141908. */
  141909. removeEntry(entry: T): void;
  141910. /**
  141911. * Add an array of elements to this block
  141912. * @param entries defines the array of elements to add
  141913. */
  141914. addEntries(entries: T[]): void;
  141915. /**
  141916. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  141917. * @param frustumPlanes defines the frustum planes to test
  141918. * @param selection defines the array to store current content if selection is positive
  141919. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141920. */
  141921. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141922. /**
  141923. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  141924. * @param sphereCenter defines the bounding sphere center
  141925. * @param sphereRadius defines the bounding sphere radius
  141926. * @param selection defines the array to store current content if selection is positive
  141927. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141928. */
  141929. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141930. /**
  141931. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  141932. * @param ray defines the ray to test with
  141933. * @param selection defines the array to store current content if selection is positive
  141934. */
  141935. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  141936. /**
  141937. * Subdivide the content into child blocks (this block will then be empty)
  141938. */
  141939. createInnerBlocks(): void;
  141940. /**
  141941. * @hidden
  141942. */
  141943. static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  141944. }
  141945. }
  141946. declare module BABYLON {
  141947. /**
  141948. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  141949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141950. */
  141951. export class Octree<T> {
  141952. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  141953. maxDepth: number;
  141954. /**
  141955. * Blocks within the octree containing objects
  141956. */
  141957. blocks: Array<OctreeBlock<T>>;
  141958. /**
  141959. * Content stored in the octree
  141960. */
  141961. dynamicContent: T[];
  141962. private _maxBlockCapacity;
  141963. private _selectionContent;
  141964. private _creationFunc;
  141965. /**
  141966. * Creates a octree
  141967. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141968. * @param creationFunc function to be used to instatiate the octree
  141969. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  141970. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  141971. */
  141972. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  141973. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  141974. maxDepth?: number);
  141975. /**
  141976. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  141977. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  141978. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  141979. * @param entries meshes to be added to the octree blocks
  141980. */
  141981. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  141982. /**
  141983. * Adds a mesh to the octree
  141984. * @param entry Mesh to add to the octree
  141985. */
  141986. addMesh(entry: T): void;
  141987. /**
  141988. * Remove an element from the octree
  141989. * @param entry defines the element to remove
  141990. */
  141991. removeMesh(entry: T): void;
  141992. /**
  141993. * Selects an array of meshes within the frustum
  141994. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  141995. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  141996. * @returns array of meshes within the frustum
  141997. */
  141998. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  141999. /**
  142000. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  142001. * @param sphereCenter defines the bounding sphere center
  142002. * @param sphereRadius defines the bounding sphere radius
  142003. * @param allowDuplicate defines if the selection array can contains duplicated entries
  142004. * @returns an array of objects that intersect the sphere
  142005. */
  142006. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  142007. /**
  142008. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  142009. * @param ray defines the ray to test with
  142010. * @returns array of intersected objects
  142011. */
  142012. intersectsRay(ray: Ray): SmartArray<T>;
  142013. /**
  142014. * Adds a mesh into the octree block if it intersects the block
  142015. */
  142016. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  142017. /**
  142018. * Adds a submesh into the octree block if it intersects the block
  142019. */
  142020. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  142021. }
  142022. }
  142023. declare module BABYLON {
  142024. interface Scene {
  142025. /**
  142026. * @hidden
  142027. * Backing Filed
  142028. */
  142029. _selectionOctree: Octree<AbstractMesh>;
  142030. /**
  142031. * Gets the octree used to boost mesh selection (picking)
  142032. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142033. */
  142034. selectionOctree: Octree<AbstractMesh>;
  142035. /**
  142036. * Creates or updates the octree used to boost selection (picking)
  142037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142038. * @param maxCapacity defines the maximum capacity per leaf
  142039. * @param maxDepth defines the maximum depth of the octree
  142040. * @returns an octree of AbstractMesh
  142041. */
  142042. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  142043. }
  142044. interface AbstractMesh {
  142045. /**
  142046. * @hidden
  142047. * Backing Field
  142048. */
  142049. _submeshesOctree: Octree<SubMesh>;
  142050. /**
  142051. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  142052. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  142053. * @param maxCapacity defines the maximum size of each block (64 by default)
  142054. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  142055. * @returns the new octree
  142056. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  142057. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142058. */
  142059. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  142060. }
  142061. /**
  142062. * Defines the octree scene component responsible to manage any octrees
  142063. * in a given scene.
  142064. */
  142065. export class OctreeSceneComponent {
  142066. /**
  142067. * The component name help to identify the component in the list of scene components.
  142068. */
  142069. readonly name: string;
  142070. /**
  142071. * The scene the component belongs to.
  142072. */
  142073. scene: Scene;
  142074. /**
  142075. * Indicates if the meshes have been checked to make sure they are isEnabled()
  142076. */
  142077. readonly checksIsEnabled: boolean;
  142078. /**
  142079. * Creates a new instance of the component for the given scene
  142080. * @param scene Defines the scene to register the component in
  142081. */
  142082. constructor(scene: Scene);
  142083. /**
  142084. * Registers the component in a given scene
  142085. */
  142086. register(): void;
  142087. /**
  142088. * Return the list of active meshes
  142089. * @returns the list of active meshes
  142090. */
  142091. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  142092. /**
  142093. * Return the list of active sub meshes
  142094. * @param mesh The mesh to get the candidates sub meshes from
  142095. * @returns the list of active sub meshes
  142096. */
  142097. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  142098. private _tempRay;
  142099. /**
  142100. * Return the list of sub meshes intersecting with a given local ray
  142101. * @param mesh defines the mesh to find the submesh for
  142102. * @param localRay defines the ray in local space
  142103. * @returns the list of intersecting sub meshes
  142104. */
  142105. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  142106. /**
  142107. * Return the list of sub meshes colliding with a collider
  142108. * @param mesh defines the mesh to find the submesh for
  142109. * @param collider defines the collider to evaluate the collision against
  142110. * @returns the list of colliding sub meshes
  142111. */
  142112. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  142113. /**
  142114. * Rebuilds the elements related to this component in case of
  142115. * context lost for instance.
  142116. */
  142117. rebuild(): void;
  142118. /**
  142119. * Disposes the component and the associated ressources.
  142120. */
  142121. dispose(): void;
  142122. }
  142123. }
  142124. declare module BABYLON {
  142125. /**
  142126. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  142127. */
  142128. export interface GizmoAxisCache {
  142129. /** Mesh used to runder the Gizmo */
  142130. gizmoMeshes: Mesh[];
  142131. /** Mesh used to detect user interaction with Gizmo */
  142132. colliderMeshes: Mesh[];
  142133. /** Material used to inicate color of gizmo mesh */
  142134. material: StandardMaterial;
  142135. /** Material used to inicate hover state of the Gizmo */
  142136. hoverMaterial: StandardMaterial;
  142137. /** Material used to inicate disabled state of the Gizmo */
  142138. disableMaterial: StandardMaterial;
  142139. /** Used to indicate Active state of the Gizmo */
  142140. active: boolean;
  142141. }
  142142. /**
  142143. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  142144. */
  142145. export class Gizmo implements IDisposable {
  142146. /** The utility layer the gizmo will be added to */
  142147. gizmoLayer: UtilityLayerRenderer;
  142148. /**
  142149. * The root mesh of the gizmo
  142150. */
  142151. _rootMesh: Mesh;
  142152. private _attachedMesh;
  142153. private _attachedNode;
  142154. /**
  142155. * Ratio for the scale of the gizmo (Default: 1)
  142156. */
  142157. protected _scaleRatio: number;
  142158. /**
  142159. * boolean updated by pointermove when a gizmo mesh is hovered
  142160. */
  142161. protected _isHovered: boolean;
  142162. /**
  142163. * Ratio for the scale of the gizmo (Default: 1)
  142164. */
  142165. set scaleRatio(value: number);
  142166. get scaleRatio(): number;
  142167. /**
  142168. * True when the mouse pointer is hovered a gizmo mesh
  142169. */
  142170. get isHovered(): boolean;
  142171. /**
  142172. * If a custom mesh has been set (Default: false)
  142173. */
  142174. protected _customMeshSet: boolean;
  142175. /**
  142176. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  142177. * * When set, interactions will be enabled
  142178. */
  142179. get attachedMesh(): Nullable<AbstractMesh>;
  142180. set attachedMesh(value: Nullable<AbstractMesh>);
  142181. /**
  142182. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  142183. * * When set, interactions will be enabled
  142184. */
  142185. get attachedNode(): Nullable<Node>;
  142186. set attachedNode(value: Nullable<Node>);
  142187. /**
  142188. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  142189. * @param mesh The mesh to replace the default mesh of the gizmo
  142190. */
  142191. setCustomMesh(mesh: Mesh): void;
  142192. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  142193. /**
  142194. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  142195. */
  142196. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142197. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142198. /**
  142199. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  142200. */
  142201. updateGizmoPositionToMatchAttachedMesh: boolean;
  142202. /**
  142203. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  142204. */
  142205. updateScale: boolean;
  142206. protected _interactionsEnabled: boolean;
  142207. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142208. private _beforeRenderObserver;
  142209. private _tempQuaternion;
  142210. private _tempVector;
  142211. private _tempVector2;
  142212. private _tempMatrix1;
  142213. private _tempMatrix2;
  142214. private _rightHandtoLeftHandMatrix;
  142215. /**
  142216. * Creates a gizmo
  142217. * @param gizmoLayer The utility layer the gizmo will be added to
  142218. */
  142219. constructor(
  142220. /** The utility layer the gizmo will be added to */
  142221. gizmoLayer?: UtilityLayerRenderer);
  142222. /**
  142223. * Updates the gizmo to match the attached mesh's position/rotation
  142224. */
  142225. protected _update(): void;
  142226. /**
  142227. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  142228. * @param value Node, TransformNode or mesh
  142229. */
  142230. protected _matrixChanged(): void;
  142231. /**
  142232. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  142233. * @param gizmoLayer The utility layer the gizmo will be added to
  142234. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  142235. * @returns {Observer<PointerInfo>} pointerObserver
  142236. */
  142237. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  142238. /**
  142239. * Disposes of the gizmo
  142240. */
  142241. dispose(): void;
  142242. }
  142243. }
  142244. declare module BABYLON {
  142245. /**
  142246. * Single plane drag gizmo
  142247. */
  142248. export class PlaneDragGizmo extends Gizmo {
  142249. /**
  142250. * Drag behavior responsible for the gizmos dragging interactions
  142251. */
  142252. dragBehavior: PointerDragBehavior;
  142253. private _pointerObserver;
  142254. /**
  142255. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142256. */
  142257. snapDistance: number;
  142258. /**
  142259. * Event that fires each time the gizmo snaps to a new location.
  142260. * * snapDistance is the the change in distance
  142261. */
  142262. onSnapObservable: Observable<{
  142263. snapDistance: number;
  142264. }>;
  142265. private _gizmoMesh;
  142266. private _coloredMaterial;
  142267. private _hoverMaterial;
  142268. private _disableMaterial;
  142269. private _isEnabled;
  142270. private _parent;
  142271. private _dragging;
  142272. /** @hidden */
  142273. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  142274. /**
  142275. * Creates a PlaneDragGizmo
  142276. * @param gizmoLayer The utility layer the gizmo will be added to
  142277. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  142278. * @param color The color of the gizmo
  142279. */
  142280. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  142281. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142282. /**
  142283. * If the gizmo is enabled
  142284. */
  142285. set isEnabled(value: boolean);
  142286. get isEnabled(): boolean;
  142287. /**
  142288. * Disposes of the gizmo
  142289. */
  142290. dispose(): void;
  142291. }
  142292. }
  142293. declare module BABYLON {
  142294. /**
  142295. * Single plane rotation gizmo
  142296. */
  142297. export class PlaneRotationGizmo extends Gizmo {
  142298. /**
  142299. * Drag behavior responsible for the gizmos dragging interactions
  142300. */
  142301. dragBehavior: PointerDragBehavior;
  142302. private _pointerObserver;
  142303. /**
  142304. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  142305. */
  142306. snapDistance: number;
  142307. /**
  142308. * Event that fires each time the gizmo snaps to a new location.
  142309. * * snapDistance is the the change in distance
  142310. */
  142311. onSnapObservable: Observable<{
  142312. snapDistance: number;
  142313. }>;
  142314. private _isEnabled;
  142315. private _parent;
  142316. private _coloredMaterial;
  142317. private _hoverMaterial;
  142318. private _disableMaterial;
  142319. private _gizmoMesh;
  142320. private _rotationCircle;
  142321. private _dragging;
  142322. private static _CircleConstants;
  142323. /**
  142324. * Creates a PlaneRotationGizmo
  142325. * @param gizmoLayer The utility layer the gizmo will be added to
  142326. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  142327. * @param color The color of the gizmo
  142328. * @param tessellation Amount of tessellation to be used when creating rotation circles
  142329. * @param useEulerRotation Use and update Euler angle instead of quaternion
  142330. * @param thickness display gizmo axis thickness
  142331. */
  142332. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  142333. /** Create Geometry for Gizmo */
  142334. private _createGizmoMesh;
  142335. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142336. private setupRotationCircle;
  142337. private updateRotationPath;
  142338. private updateRotationCircle;
  142339. /**
  142340. * If the gizmo is enabled
  142341. */
  142342. set isEnabled(value: boolean);
  142343. get isEnabled(): boolean;
  142344. /**
  142345. * Disposes of the gizmo
  142346. */
  142347. dispose(): void;
  142348. }
  142349. }
  142350. declare module BABYLON {
  142351. /**
  142352. * Gizmo that enables rotating a mesh along 3 axis
  142353. */
  142354. export class RotationGizmo extends Gizmo {
  142355. /**
  142356. * Internal gizmo used for interactions on the x axis
  142357. */
  142358. xGizmo: PlaneRotationGizmo;
  142359. /**
  142360. * Internal gizmo used for interactions on the y axis
  142361. */
  142362. yGizmo: PlaneRotationGizmo;
  142363. /**
  142364. * Internal gizmo used for interactions on the z axis
  142365. */
  142366. zGizmo: PlaneRotationGizmo;
  142367. /** Fires an event when any of it's sub gizmos are dragged */
  142368. onDragStartObservable: Observable<unknown>;
  142369. /** Fires an event when any of it's sub gizmos are released from dragging */
  142370. onDragEndObservable: Observable<unknown>;
  142371. private _meshAttached;
  142372. private _nodeAttached;
  142373. private _observables;
  142374. /** Node Caching for quick lookup */
  142375. private _gizmoAxisCache;
  142376. get attachedMesh(): Nullable<AbstractMesh>;
  142377. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142378. get attachedNode(): Nullable<Node>;
  142379. set attachedNode(node: Nullable<Node>);
  142380. protected _checkBillboardTransform(): void;
  142381. /**
  142382. * True when the mouse pointer is hovering a gizmo mesh
  142383. */
  142384. get isHovered(): boolean;
  142385. /**
  142386. * Creates a RotationGizmo
  142387. * @param gizmoLayer The utility layer the gizmo will be added to
  142388. * @param tessellation Amount of tessellation to be used when creating rotation circles
  142389. * @param useEulerRotation Use and update Euler angle instead of quaternion
  142390. * @param thickness display gizmo axis thickness
  142391. */
  142392. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  142393. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142394. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142395. /**
  142396. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142397. */
  142398. set snapDistance(value: number);
  142399. get snapDistance(): number;
  142400. /**
  142401. * Ratio for the scale of the gizmo (Default: 1)
  142402. */
  142403. set scaleRatio(value: number);
  142404. get scaleRatio(): number;
  142405. /**
  142406. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142407. * @param mesh Axis gizmo mesh
  142408. * @param cache Gizmo axis definition used for reactive gizmo UI
  142409. */
  142410. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142411. /**
  142412. * Disposes of the gizmo
  142413. */
  142414. dispose(): void;
  142415. /**
  142416. * CustomMeshes are not supported by this gizmo
  142417. * @param mesh The mesh to replace the default mesh of the gizmo
  142418. */
  142419. setCustomMesh(mesh: Mesh): void;
  142420. }
  142421. }
  142422. declare module BABYLON {
  142423. /**
  142424. * Class containing static functions to help procedurally build meshes
  142425. */
  142426. export class PolyhedronBuilder {
  142427. /**
  142428. * Creates a polyhedron mesh
  142429. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  142430. * * The parameter `size` (positive float, default 1) sets the polygon size
  142431. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142432. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  142433. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  142434. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  142435. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142436. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  142437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142440. * @param name defines the name of the mesh
  142441. * @param options defines the options used to create the mesh
  142442. * @param scene defines the hosting scene
  142443. * @returns the polyhedron mesh
  142444. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142445. */
  142446. static CreatePolyhedron(name: string, options: {
  142447. type?: number;
  142448. size?: number;
  142449. sizeX?: number;
  142450. sizeY?: number;
  142451. sizeZ?: number;
  142452. custom?: any;
  142453. faceUV?: Vector4[];
  142454. faceColors?: Color4[];
  142455. flat?: boolean;
  142456. updatable?: boolean;
  142457. sideOrientation?: number;
  142458. frontUVs?: Vector4;
  142459. backUVs?: Vector4;
  142460. }, scene?: Nullable<Scene>): Mesh;
  142461. }
  142462. }
  142463. declare module BABYLON {
  142464. /**
  142465. * Class containing static functions to help procedurally build meshes
  142466. */
  142467. export class BoxBuilder {
  142468. /**
  142469. * Creates a box mesh
  142470. * * The parameter `size` sets the size (float) of each box side (default 1)
  142471. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142472. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  142473. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142477. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142478. * @param name defines the name of the mesh
  142479. * @param options defines the options used to create the mesh
  142480. * @param scene defines the hosting scene
  142481. * @returns the box mesh
  142482. */
  142483. static CreateBox(name: string, options: {
  142484. size?: number;
  142485. width?: number;
  142486. height?: number;
  142487. depth?: number;
  142488. faceUV?: Vector4[];
  142489. faceColors?: Color4[];
  142490. sideOrientation?: number;
  142491. frontUVs?: Vector4;
  142492. backUVs?: Vector4;
  142493. wrap?: boolean;
  142494. topBaseAt?: number;
  142495. bottomBaseAt?: number;
  142496. updatable?: boolean;
  142497. }, scene?: Nullable<Scene>): Mesh;
  142498. }
  142499. }
  142500. declare module BABYLON {
  142501. /**
  142502. * Single axis scale gizmo
  142503. */
  142504. export class AxisScaleGizmo extends Gizmo {
  142505. /**
  142506. * Drag behavior responsible for the gizmos dragging interactions
  142507. */
  142508. dragBehavior: PointerDragBehavior;
  142509. private _pointerObserver;
  142510. /**
  142511. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142512. */
  142513. snapDistance: number;
  142514. /**
  142515. * Event that fires each time the gizmo snaps to a new location.
  142516. * * snapDistance is the the change in distance
  142517. */
  142518. onSnapObservable: Observable<{
  142519. snapDistance: number;
  142520. }>;
  142521. /**
  142522. * If the scaling operation should be done on all axis (default: false)
  142523. */
  142524. uniformScaling: boolean;
  142525. /**
  142526. * Custom sensitivity value for the drag strength
  142527. */
  142528. sensitivity: number;
  142529. private _isEnabled;
  142530. private _parent;
  142531. private _gizmoMesh;
  142532. private _coloredMaterial;
  142533. private _hoverMaterial;
  142534. private _disableMaterial;
  142535. private _dragging;
  142536. private _tmpVector;
  142537. private _tmpMatrix;
  142538. private _tmpMatrix2;
  142539. /**
  142540. * Creates an AxisScaleGizmo
  142541. * @param gizmoLayer The utility layer the gizmo will be added to
  142542. * @param dragAxis The axis which the gizmo will be able to scale on
  142543. * @param color The color of the gizmo
  142544. * @param thickness display gizmo axis thickness
  142545. */
  142546. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  142547. /** Create Geometry for Gizmo */
  142548. private _createGizmoMesh;
  142549. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142550. /**
  142551. * If the gizmo is enabled
  142552. */
  142553. set isEnabled(value: boolean);
  142554. get isEnabled(): boolean;
  142555. /**
  142556. * Disposes of the gizmo
  142557. */
  142558. dispose(): void;
  142559. /**
  142560. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  142561. * @param mesh The mesh to replace the default mesh of the gizmo
  142562. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  142563. */
  142564. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  142565. }
  142566. }
  142567. declare module BABYLON {
  142568. /**
  142569. * Gizmo that enables scaling a mesh along 3 axis
  142570. */
  142571. export class ScaleGizmo extends Gizmo {
  142572. /**
  142573. * Internal gizmo used for interactions on the x axis
  142574. */
  142575. xGizmo: AxisScaleGizmo;
  142576. /**
  142577. * Internal gizmo used for interactions on the y axis
  142578. */
  142579. yGizmo: AxisScaleGizmo;
  142580. /**
  142581. * Internal gizmo used for interactions on the z axis
  142582. */
  142583. zGizmo: AxisScaleGizmo;
  142584. /**
  142585. * Internal gizmo used to scale all axis equally
  142586. */
  142587. uniformScaleGizmo: AxisScaleGizmo;
  142588. private _meshAttached;
  142589. private _nodeAttached;
  142590. private _snapDistance;
  142591. private _uniformScalingMesh;
  142592. private _octahedron;
  142593. private _sensitivity;
  142594. private _coloredMaterial;
  142595. private _hoverMaterial;
  142596. private _disableMaterial;
  142597. private _observables;
  142598. /** Node Caching for quick lookup */
  142599. private _gizmoAxisCache;
  142600. /** Fires an event when any of it's sub gizmos are dragged */
  142601. onDragStartObservable: Observable<unknown>;
  142602. /** Fires an event when any of it's sub gizmos are released from dragging */
  142603. onDragEndObservable: Observable<unknown>;
  142604. get attachedMesh(): Nullable<AbstractMesh>;
  142605. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142606. get attachedNode(): Nullable<Node>;
  142607. set attachedNode(node: Nullable<Node>);
  142608. /**
  142609. * True when the mouse pointer is hovering a gizmo mesh
  142610. */
  142611. get isHovered(): boolean;
  142612. /**
  142613. * Creates a ScaleGizmo
  142614. * @param gizmoLayer The utility layer the gizmo will be added to
  142615. * @param thickness display gizmo axis thickness
  142616. */
  142617. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  142618. /** Create Geometry for Gizmo */
  142619. private _createUniformScaleMesh;
  142620. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142621. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142622. /**
  142623. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142624. */
  142625. set snapDistance(value: number);
  142626. get snapDistance(): number;
  142627. /**
  142628. * Ratio for the scale of the gizmo (Default: 1)
  142629. */
  142630. set scaleRatio(value: number);
  142631. get scaleRatio(): number;
  142632. /**
  142633. * Sensitivity factor for dragging (Default: 1)
  142634. */
  142635. set sensitivity(value: number);
  142636. get sensitivity(): number;
  142637. /**
  142638. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142639. * @param mesh Axis gizmo mesh
  142640. * @param cache Gizmo axis definition used for reactive gizmo UI
  142641. */
  142642. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142643. /**
  142644. * Disposes of the gizmo
  142645. */
  142646. dispose(): void;
  142647. }
  142648. }
  142649. declare module BABYLON {
  142650. /**
  142651. * Bounding box gizmo
  142652. */
  142653. export class BoundingBoxGizmo extends Gizmo {
  142654. private _lineBoundingBox;
  142655. private _rotateSpheresParent;
  142656. private _scaleBoxesParent;
  142657. private _boundingDimensions;
  142658. private _renderObserver;
  142659. private _pointerObserver;
  142660. private _scaleDragSpeed;
  142661. private _tmpQuaternion;
  142662. private _tmpVector;
  142663. private _tmpRotationMatrix;
  142664. /**
  142665. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  142666. */
  142667. ignoreChildren: boolean;
  142668. /**
  142669. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  142670. */
  142671. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  142672. /**
  142673. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  142674. */
  142675. rotationSphereSize: number;
  142676. /**
  142677. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  142678. */
  142679. scaleBoxSize: number;
  142680. /**
  142681. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  142682. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  142683. */
  142684. fixedDragMeshScreenSize: boolean;
  142685. /**
  142686. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  142687. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  142688. */
  142689. fixedDragMeshBoundsSize: boolean;
  142690. /**
  142691. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  142692. */
  142693. fixedDragMeshScreenSizeDistanceFactor: number;
  142694. /**
  142695. * Fired when a rotation sphere or scale box is dragged
  142696. */
  142697. onDragStartObservable: Observable<{}>;
  142698. /**
  142699. * Fired when a scale box is dragged
  142700. */
  142701. onScaleBoxDragObservable: Observable<{}>;
  142702. /**
  142703. * Fired when a scale box drag is ended
  142704. */
  142705. onScaleBoxDragEndObservable: Observable<{}>;
  142706. /**
  142707. * Fired when a rotation sphere is dragged
  142708. */
  142709. onRotationSphereDragObservable: Observable<{}>;
  142710. /**
  142711. * Fired when a rotation sphere drag is ended
  142712. */
  142713. onRotationSphereDragEndObservable: Observable<{}>;
  142714. /**
  142715. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  142716. */
  142717. scalePivot: Nullable<Vector3>;
  142718. /**
  142719. * Mesh used as a pivot to rotate the attached node
  142720. */
  142721. private _anchorMesh;
  142722. private _existingMeshScale;
  142723. private _dragMesh;
  142724. private pointerDragBehavior;
  142725. private coloredMaterial;
  142726. private hoverColoredMaterial;
  142727. /**
  142728. * Sets the color of the bounding box gizmo
  142729. * @param color the color to set
  142730. */
  142731. setColor(color: Color3): void;
  142732. /**
  142733. * Creates an BoundingBoxGizmo
  142734. * @param gizmoLayer The utility layer the gizmo will be added to
  142735. * @param color The color of the gizmo
  142736. */
  142737. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  142738. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  142739. private _selectNode;
  142740. /**
  142741. * Updates the bounding box information for the Gizmo
  142742. */
  142743. updateBoundingBox(): void;
  142744. private _updateRotationSpheres;
  142745. private _updateScaleBoxes;
  142746. /**
  142747. * Enables rotation on the specified axis and disables rotation on the others
  142748. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  142749. */
  142750. setEnabledRotationAxis(axis: string): void;
  142751. /**
  142752. * Enables/disables scaling
  142753. * @param enable if scaling should be enabled
  142754. * @param homogeneousScaling defines if scaling should only be homogeneous
  142755. */
  142756. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  142757. private _updateDummy;
  142758. /**
  142759. * Enables a pointer drag behavior on the bounding box of the gizmo
  142760. */
  142761. enableDragBehavior(): void;
  142762. /**
  142763. * Disposes of the gizmo
  142764. */
  142765. dispose(): void;
  142766. /**
  142767. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  142768. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  142769. * @returns the bounding box mesh with the passed in mesh as a child
  142770. */
  142771. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  142772. /**
  142773. * CustomMeshes are not supported by this gizmo
  142774. * @param mesh The mesh to replace the default mesh of the gizmo
  142775. */
  142776. setCustomMesh(mesh: Mesh): void;
  142777. }
  142778. }
  142779. declare module BABYLON {
  142780. /**
  142781. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  142782. */
  142783. export class GizmoManager implements IDisposable {
  142784. private scene;
  142785. /**
  142786. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  142787. */
  142788. gizmos: {
  142789. positionGizmo: Nullable<PositionGizmo>;
  142790. rotationGizmo: Nullable<RotationGizmo>;
  142791. scaleGizmo: Nullable<ScaleGizmo>;
  142792. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  142793. };
  142794. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  142795. clearGizmoOnEmptyPointerEvent: boolean;
  142796. /** Fires an event when the manager is attached to a mesh */
  142797. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  142798. /** Fires an event when the manager is attached to a node */
  142799. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  142800. private _gizmosEnabled;
  142801. private _pointerObservers;
  142802. private _attachedMesh;
  142803. private _attachedNode;
  142804. private _boundingBoxColor;
  142805. private _defaultUtilityLayer;
  142806. private _defaultKeepDepthUtilityLayer;
  142807. private _thickness;
  142808. /** Node Caching for quick lookup */
  142809. private _gizmoAxisCache;
  142810. /**
  142811. * When bounding box gizmo is enabled, this can be used to track drag/end events
  142812. */
  142813. boundingBoxDragBehavior: SixDofDragBehavior;
  142814. /**
  142815. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  142816. */
  142817. attachableMeshes: Nullable<Array<AbstractMesh>>;
  142818. /**
  142819. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  142820. */
  142821. attachableNodes: Nullable<Array<Node>>;
  142822. /**
  142823. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  142824. */
  142825. usePointerToAttachGizmos: boolean;
  142826. /**
  142827. * Utility layer that the bounding box gizmo belongs to
  142828. */
  142829. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  142830. /**
  142831. * Utility layer that all gizmos besides bounding box belong to
  142832. */
  142833. get utilityLayer(): UtilityLayerRenderer;
  142834. /**
  142835. * True when the mouse pointer is hovering a gizmo mesh
  142836. */
  142837. get isHovered(): boolean;
  142838. /**
  142839. * Instatiates a gizmo manager
  142840. * @param scene the scene to overlay the gizmos on top of
  142841. * @param thickness display gizmo axis thickness
  142842. * @param utilityLayer the layer where gizmos are rendered
  142843. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  142844. */
  142845. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  142846. /**
  142847. * Subscribes to pointer down events, for attaching and detaching mesh
  142848. * @param scene The sceme layer the observer will be added to
  142849. */
  142850. private _attachToMeshPointerObserver;
  142851. /**
  142852. * Attaches a set of gizmos to the specified mesh
  142853. * @param mesh The mesh the gizmo's should be attached to
  142854. */
  142855. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142856. /**
  142857. * Attaches a set of gizmos to the specified node
  142858. * @param node The node the gizmo's should be attached to
  142859. */
  142860. attachToNode(node: Nullable<Node>): void;
  142861. /**
  142862. * If the position gizmo is enabled
  142863. */
  142864. set positionGizmoEnabled(value: boolean);
  142865. get positionGizmoEnabled(): boolean;
  142866. /**
  142867. * If the rotation gizmo is enabled
  142868. */
  142869. set rotationGizmoEnabled(value: boolean);
  142870. get rotationGizmoEnabled(): boolean;
  142871. /**
  142872. * If the scale gizmo is enabled
  142873. */
  142874. set scaleGizmoEnabled(value: boolean);
  142875. get scaleGizmoEnabled(): boolean;
  142876. /**
  142877. * If the boundingBox gizmo is enabled
  142878. */
  142879. set boundingBoxGizmoEnabled(value: boolean);
  142880. get boundingBoxGizmoEnabled(): boolean;
  142881. /**
  142882. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142883. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  142884. */
  142885. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  142886. /**
  142887. * Disposes of the gizmo manager
  142888. */
  142889. dispose(): void;
  142890. }
  142891. }
  142892. declare module BABYLON {
  142893. /**
  142894. * Gizmo that enables dragging a mesh along 3 axis
  142895. */
  142896. export class PositionGizmo extends Gizmo {
  142897. /**
  142898. * Internal gizmo used for interactions on the x axis
  142899. */
  142900. xGizmo: AxisDragGizmo;
  142901. /**
  142902. * Internal gizmo used for interactions on the y axis
  142903. */
  142904. yGizmo: AxisDragGizmo;
  142905. /**
  142906. * Internal gizmo used for interactions on the z axis
  142907. */
  142908. zGizmo: AxisDragGizmo;
  142909. /**
  142910. * Internal gizmo used for interactions on the yz plane
  142911. */
  142912. xPlaneGizmo: PlaneDragGizmo;
  142913. /**
  142914. * Internal gizmo used for interactions on the xz plane
  142915. */
  142916. yPlaneGizmo: PlaneDragGizmo;
  142917. /**
  142918. * Internal gizmo used for interactions on the xy plane
  142919. */
  142920. zPlaneGizmo: PlaneDragGizmo;
  142921. /**
  142922. * private variables
  142923. */
  142924. private _meshAttached;
  142925. private _nodeAttached;
  142926. private _snapDistance;
  142927. private _observables;
  142928. /** Node Caching for quick lookup */
  142929. private _gizmoAxisCache;
  142930. /** Fires an event when any of it's sub gizmos are dragged */
  142931. onDragStartObservable: Observable<unknown>;
  142932. /** Fires an event when any of it's sub gizmos are released from dragging */
  142933. onDragEndObservable: Observable<unknown>;
  142934. /**
  142935. * If set to true, planar drag is enabled
  142936. */
  142937. private _planarGizmoEnabled;
  142938. get attachedMesh(): Nullable<AbstractMesh>;
  142939. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142940. get attachedNode(): Nullable<Node>;
  142941. set attachedNode(node: Nullable<Node>);
  142942. /**
  142943. * True when the mouse pointer is hovering a gizmo mesh
  142944. */
  142945. get isHovered(): boolean;
  142946. /**
  142947. * Creates a PositionGizmo
  142948. * @param gizmoLayer The utility layer the gizmo will be added to
  142949. @param thickness display gizmo axis thickness
  142950. */
  142951. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  142952. /**
  142953. * If the planar drag gizmo is enabled
  142954. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  142955. */
  142956. set planarGizmoEnabled(value: boolean);
  142957. get planarGizmoEnabled(): boolean;
  142958. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142959. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142960. /**
  142961. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142962. */
  142963. set snapDistance(value: number);
  142964. get snapDistance(): number;
  142965. /**
  142966. * Ratio for the scale of the gizmo (Default: 1)
  142967. */
  142968. set scaleRatio(value: number);
  142969. get scaleRatio(): number;
  142970. /**
  142971. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142972. * @param mesh Axis gizmo mesh
  142973. * @param cache Gizmo axis definition used for reactive gizmo UI
  142974. */
  142975. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142976. /**
  142977. * Disposes of the gizmo
  142978. */
  142979. dispose(): void;
  142980. /**
  142981. * CustomMeshes are not supported by this gizmo
  142982. * @param mesh The mesh to replace the default mesh of the gizmo
  142983. */
  142984. setCustomMesh(mesh: Mesh): void;
  142985. }
  142986. }
  142987. declare module BABYLON {
  142988. /**
  142989. * Single axis drag gizmo
  142990. */
  142991. export class AxisDragGizmo extends Gizmo {
  142992. /**
  142993. * Drag behavior responsible for the gizmos dragging interactions
  142994. */
  142995. dragBehavior: PointerDragBehavior;
  142996. private _pointerObserver;
  142997. /**
  142998. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142999. */
  143000. snapDistance: number;
  143001. /**
  143002. * Event that fires each time the gizmo snaps to a new location.
  143003. * * snapDistance is the the change in distance
  143004. */
  143005. onSnapObservable: Observable<{
  143006. snapDistance: number;
  143007. }>;
  143008. private _isEnabled;
  143009. private _parent;
  143010. private _gizmoMesh;
  143011. private _coloredMaterial;
  143012. private _hoverMaterial;
  143013. private _disableMaterial;
  143014. private _dragging;
  143015. /** @hidden */
  143016. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  143017. /** @hidden */
  143018. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  143019. /**
  143020. * Creates an AxisDragGizmo
  143021. * @param gizmoLayer The utility layer the gizmo will be added to
  143022. * @param dragAxis The axis which the gizmo will be able to drag on
  143023. * @param color The color of the gizmo
  143024. * @param thickness display gizmo axis thickness
  143025. */
  143026. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  143027. protected _attachedNodeChanged(value: Nullable<Node>): void;
  143028. /**
  143029. * If the gizmo is enabled
  143030. */
  143031. set isEnabled(value: boolean);
  143032. get isEnabled(): boolean;
  143033. /**
  143034. * Disposes of the gizmo
  143035. */
  143036. dispose(): void;
  143037. }
  143038. }
  143039. declare module BABYLON.Debug {
  143040. /**
  143041. * The Axes viewer will show 3 axes in a specific point in space
  143042. */
  143043. export class AxesViewer {
  143044. private _xAxis;
  143045. private _yAxis;
  143046. private _zAxis;
  143047. private _scaleLinesFactor;
  143048. private _instanced;
  143049. /**
  143050. * Gets the hosting scene
  143051. */
  143052. scene: Nullable<Scene>;
  143053. /**
  143054. * Gets or sets a number used to scale line length
  143055. */
  143056. scaleLines: number;
  143057. /** Gets the node hierarchy used to render x-axis */
  143058. get xAxis(): TransformNode;
  143059. /** Gets the node hierarchy used to render y-axis */
  143060. get yAxis(): TransformNode;
  143061. /** Gets the node hierarchy used to render z-axis */
  143062. get zAxis(): TransformNode;
  143063. /**
  143064. * Creates a new AxesViewer
  143065. * @param scene defines the hosting scene
  143066. * @param scaleLines defines a number used to scale line length (1 by default)
  143067. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  143068. * @param xAxis defines the node hierarchy used to render the x-axis
  143069. * @param yAxis defines the node hierarchy used to render the y-axis
  143070. * @param zAxis defines the node hierarchy used to render the z-axis
  143071. */
  143072. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  143073. /**
  143074. * Force the viewer to update
  143075. * @param position defines the position of the viewer
  143076. * @param xaxis defines the x axis of the viewer
  143077. * @param yaxis defines the y axis of the viewer
  143078. * @param zaxis defines the z axis of the viewer
  143079. */
  143080. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  143081. /**
  143082. * Creates an instance of this axes viewer.
  143083. * @returns a new axes viewer with instanced meshes
  143084. */
  143085. createInstance(): AxesViewer;
  143086. /** Releases resources */
  143087. dispose(): void;
  143088. private static _SetRenderingGroupId;
  143089. }
  143090. }
  143091. declare module BABYLON.Debug {
  143092. /**
  143093. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  143094. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  143095. */
  143096. export class BoneAxesViewer extends AxesViewer {
  143097. /**
  143098. * Gets or sets the target mesh where to display the axes viewer
  143099. */
  143100. mesh: Nullable<Mesh>;
  143101. /**
  143102. * Gets or sets the target bone where to display the axes viewer
  143103. */
  143104. bone: Nullable<Bone>;
  143105. /** Gets current position */
  143106. pos: Vector3;
  143107. /** Gets direction of X axis */
  143108. xaxis: Vector3;
  143109. /** Gets direction of Y axis */
  143110. yaxis: Vector3;
  143111. /** Gets direction of Z axis */
  143112. zaxis: Vector3;
  143113. /**
  143114. * Creates a new BoneAxesViewer
  143115. * @param scene defines the hosting scene
  143116. * @param bone defines the target bone
  143117. * @param mesh defines the target mesh
  143118. * @param scaleLines defines a scaling factor for line length (1 by default)
  143119. */
  143120. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  143121. /**
  143122. * Force the viewer to update
  143123. */
  143124. update(): void;
  143125. /** Releases resources */
  143126. dispose(): void;
  143127. }
  143128. }
  143129. declare module BABYLON {
  143130. /**
  143131. * Interface used to define scene explorer extensibility option
  143132. */
  143133. export interface IExplorerExtensibilityOption {
  143134. /**
  143135. * Define the option label
  143136. */
  143137. label: string;
  143138. /**
  143139. * Defines the action to execute on click
  143140. */
  143141. action: (entity: any) => void;
  143142. }
  143143. /**
  143144. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  143145. */
  143146. export interface IExplorerExtensibilityGroup {
  143147. /**
  143148. * Defines a predicate to test if a given type mut be extended
  143149. */
  143150. predicate: (entity: any) => boolean;
  143151. /**
  143152. * Gets the list of options added to a type
  143153. */
  143154. entries: IExplorerExtensibilityOption[];
  143155. }
  143156. /**
  143157. * Interface used to define the options to use to create the Inspector
  143158. */
  143159. export interface IInspectorOptions {
  143160. /**
  143161. * Display in overlay mode (default: false)
  143162. */
  143163. overlay?: boolean;
  143164. /**
  143165. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  143166. */
  143167. globalRoot?: HTMLElement;
  143168. /**
  143169. * Display the Scene explorer
  143170. */
  143171. showExplorer?: boolean;
  143172. /**
  143173. * Display the property inspector
  143174. */
  143175. showInspector?: boolean;
  143176. /**
  143177. * Display in embed mode (both panes on the right)
  143178. */
  143179. embedMode?: boolean;
  143180. /**
  143181. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  143182. */
  143183. handleResize?: boolean;
  143184. /**
  143185. * Allow the panes to popup (default: true)
  143186. */
  143187. enablePopup?: boolean;
  143188. /**
  143189. * Allow the panes to be closed by users (default: true)
  143190. */
  143191. enableClose?: boolean;
  143192. /**
  143193. * Optional list of extensibility entries
  143194. */
  143195. explorerExtensibility?: IExplorerExtensibilityGroup[];
  143196. /**
  143197. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  143198. */
  143199. inspectorURL?: string;
  143200. /**
  143201. * Optional initial tab (default to DebugLayerTab.Properties)
  143202. */
  143203. initialTab?: DebugLayerTab;
  143204. }
  143205. interface Scene {
  143206. /**
  143207. * @hidden
  143208. * Backing field
  143209. */
  143210. _debugLayer: DebugLayer;
  143211. /**
  143212. * Gets the debug layer (aka Inspector) associated with the scene
  143213. * @see https://doc.babylonjs.com/features/playground_debuglayer
  143214. */
  143215. debugLayer: DebugLayer;
  143216. }
  143217. /**
  143218. * Enum of inspector action tab
  143219. */
  143220. export enum DebugLayerTab {
  143221. /**
  143222. * Properties tag (default)
  143223. */
  143224. Properties = 0,
  143225. /**
  143226. * Debug tab
  143227. */
  143228. Debug = 1,
  143229. /**
  143230. * Statistics tab
  143231. */
  143232. Statistics = 2,
  143233. /**
  143234. * Tools tab
  143235. */
  143236. Tools = 3,
  143237. /**
  143238. * Settings tab
  143239. */
  143240. Settings = 4
  143241. }
  143242. /**
  143243. * The debug layer (aka Inspector) is the go to tool in order to better understand
  143244. * what is happening in your scene
  143245. * @see https://doc.babylonjs.com/features/playground_debuglayer
  143246. */
  143247. export class DebugLayer {
  143248. /**
  143249. * Define the url to get the inspector script from.
  143250. * By default it uses the babylonjs CDN.
  143251. * @ignoreNaming
  143252. */
  143253. static InspectorURL: string;
  143254. private _scene;
  143255. private BJSINSPECTOR;
  143256. private _onPropertyChangedObservable?;
  143257. /**
  143258. * Observable triggered when a property is changed through the inspector.
  143259. */
  143260. get onPropertyChangedObservable(): any;
  143261. /**
  143262. * Instantiates a new debug layer.
  143263. * The debug layer (aka Inspector) is the go to tool in order to better understand
  143264. * what is happening in your scene
  143265. * @see https://doc.babylonjs.com/features/playground_debuglayer
  143266. * @param scene Defines the scene to inspect
  143267. */
  143268. constructor(scene: Scene);
  143269. /** Creates the inspector window. */
  143270. private _createInspector;
  143271. /**
  143272. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  143273. * @param entity defines the entity to select
  143274. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  143275. */
  143276. select(entity: any, lineContainerTitles?: string | string[]): void;
  143277. /** Get the inspector from bundle or global */
  143278. private _getGlobalInspector;
  143279. /**
  143280. * Get if the inspector is visible or not.
  143281. * @returns true if visible otherwise, false
  143282. */
  143283. isVisible(): boolean;
  143284. /**
  143285. * Hide the inspector and close its window.
  143286. */
  143287. hide(): void;
  143288. /**
  143289. * Update the scene in the inspector
  143290. */
  143291. setAsActiveScene(): void;
  143292. /**
  143293. * Launch the debugLayer.
  143294. * @param config Define the configuration of the inspector
  143295. * @return a promise fulfilled when the debug layer is visible
  143296. */
  143297. show(config?: IInspectorOptions): Promise<DebugLayer>;
  143298. }
  143299. }
  143300. declare module BABYLON.Debug {
  143301. /**
  143302. * Used to show the physics impostor around the specific mesh
  143303. */
  143304. export class PhysicsViewer {
  143305. /** @hidden */
  143306. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  143307. /** @hidden */
  143308. protected _meshes: Array<Nullable<AbstractMesh>>;
  143309. /** @hidden */
  143310. protected _scene: Nullable<Scene>;
  143311. /** @hidden */
  143312. protected _numMeshes: number;
  143313. /** @hidden */
  143314. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  143315. private _renderFunction;
  143316. private _utilityLayer;
  143317. private _debugBoxMesh;
  143318. private _debugSphereMesh;
  143319. private _debugCylinderMesh;
  143320. private _debugMaterial;
  143321. private _debugMeshMeshes;
  143322. /**
  143323. * Creates a new PhysicsViewer
  143324. * @param scene defines the hosting scene
  143325. */
  143326. constructor(scene: Scene);
  143327. /** @hidden */
  143328. protected _updateDebugMeshes(): void;
  143329. /**
  143330. * Renders a specified physic impostor
  143331. * @param impostor defines the impostor to render
  143332. * @param targetMesh defines the mesh represented by the impostor
  143333. * @returns the new debug mesh used to render the impostor
  143334. */
  143335. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  143336. /**
  143337. * Hides a specified physic impostor
  143338. * @param impostor defines the impostor to hide
  143339. */
  143340. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  143341. private _getDebugMaterial;
  143342. private _getDebugBoxMesh;
  143343. private _getDebugSphereMesh;
  143344. private _getDebugCylinderMesh;
  143345. private _getDebugMeshMesh;
  143346. private _getDebugMesh;
  143347. /** Releases all resources */
  143348. dispose(): void;
  143349. }
  143350. }
  143351. declare module BABYLON {
  143352. /**
  143353. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  143354. * in order to better appreciate the issue one might have.
  143355. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  143356. */
  143357. export class RayHelper {
  143358. /**
  143359. * Defines the ray we are currently tryin to visualize.
  143360. */
  143361. ray: Nullable<Ray>;
  143362. private _renderPoints;
  143363. private _renderLine;
  143364. private _renderFunction;
  143365. private _scene;
  143366. private _onAfterRenderObserver;
  143367. private _onAfterStepObserver;
  143368. private _attachedToMesh;
  143369. private _meshSpaceDirection;
  143370. private _meshSpaceOrigin;
  143371. /**
  143372. * Helper function to create a colored helper in a scene in one line.
  143373. * @param ray Defines the ray we are currently tryin to visualize
  143374. * @param scene Defines the scene the ray is used in
  143375. * @param color Defines the color we want to see the ray in
  143376. * @returns The newly created ray helper.
  143377. */
  143378. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  143379. /**
  143380. * Instantiate a new ray helper.
  143381. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  143382. * in order to better appreciate the issue one might have.
  143383. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  143384. * @param ray Defines the ray we are currently tryin to visualize
  143385. */
  143386. constructor(ray: Ray);
  143387. /**
  143388. * Shows the ray we are willing to debug.
  143389. * @param scene Defines the scene the ray needs to be rendered in
  143390. * @param color Defines the color the ray needs to be rendered in
  143391. */
  143392. show(scene: Scene, color?: Color3): void;
  143393. /**
  143394. * Hides the ray we are debugging.
  143395. */
  143396. hide(): void;
  143397. private _render;
  143398. /**
  143399. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  143400. * @param mesh Defines the mesh we want the helper attached to
  143401. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  143402. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  143403. * @param length Defines the length of the ray
  143404. */
  143405. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  143406. /**
  143407. * Detach the ray helper from the mesh it has previously been attached to.
  143408. */
  143409. detachFromMesh(): void;
  143410. private _updateToMesh;
  143411. /**
  143412. * Dispose the helper and release its associated resources.
  143413. */
  143414. dispose(): void;
  143415. }
  143416. }
  143417. declare module BABYLON {
  143418. /**
  143419. * Defines the options associated with the creation of a SkeletonViewer.
  143420. */
  143421. export interface ISkeletonViewerOptions {
  143422. /** Should the system pause animations before building the Viewer? */
  143423. pauseAnimations: boolean;
  143424. /** Should the system return the skeleton to rest before building? */
  143425. returnToRest: boolean;
  143426. /** public Display Mode of the Viewer */
  143427. displayMode: number;
  143428. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  143429. displayOptions: ISkeletonViewerDisplayOptions;
  143430. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  143431. computeBonesUsingShaders: boolean;
  143432. /** Flag ignore non weighted bones */
  143433. useAllBones: boolean;
  143434. }
  143435. /**
  143436. * Defines how to display the various bone meshes for the viewer.
  143437. */
  143438. export interface ISkeletonViewerDisplayOptions {
  143439. /** How far down to start tapering the bone spurs */
  143440. midStep?: number;
  143441. /** How big is the midStep? */
  143442. midStepFactor?: number;
  143443. /** Base for the Sphere Size */
  143444. sphereBaseSize?: number;
  143445. /** The ratio of the sphere to the longest bone in units */
  143446. sphereScaleUnit?: number;
  143447. /** Ratio for the Sphere Size */
  143448. sphereFactor?: number;
  143449. /** Whether a spur should attach its far end to the child bone position */
  143450. spurFollowsChild?: boolean;
  143451. /** Whether to show local axes or not */
  143452. showLocalAxes?: boolean;
  143453. /** Length of each local axis */
  143454. localAxesSize?: number;
  143455. }
  143456. /**
  143457. * Defines the constructor options for the BoneWeight Shader.
  143458. */
  143459. export interface IBoneWeightShaderOptions {
  143460. /** Skeleton to Map */
  143461. skeleton: Skeleton;
  143462. /** Colors for Uninfluenced bones */
  143463. colorBase?: Color3;
  143464. /** Colors for 0.0-0.25 Weight bones */
  143465. colorZero?: Color3;
  143466. /** Color for 0.25-0.5 Weight Influence */
  143467. colorQuarter?: Color3;
  143468. /** Color for 0.5-0.75 Weight Influence */
  143469. colorHalf?: Color3;
  143470. /** Color for 0.75-1 Weight Influence */
  143471. colorFull?: Color3;
  143472. /** Color for Zero Weight Influence */
  143473. targetBoneIndex?: number;
  143474. }
  143475. /**
  143476. * Simple structure of the gradient steps for the Color Map.
  143477. */
  143478. export interface ISkeletonMapShaderColorMapKnot {
  143479. /** Color of the Knot */
  143480. color: Color3;
  143481. /** Location of the Knot */
  143482. location: number;
  143483. }
  143484. /**
  143485. * Defines the constructor options for the SkeletonMap Shader.
  143486. */
  143487. export interface ISkeletonMapShaderOptions {
  143488. /** Skeleton to Map */
  143489. skeleton: Skeleton;
  143490. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  143491. colorMap?: ISkeletonMapShaderColorMapKnot[];
  143492. }
  143493. }
  143494. declare module BABYLON {
  143495. /**
  143496. * Class containing static functions to help procedurally build meshes
  143497. */
  143498. export class RibbonBuilder {
  143499. /**
  143500. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143501. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143502. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143503. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143504. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  143505. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  143506. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  143507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143509. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143510. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  143511. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143512. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  143513. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143515. * @param name defines the name of the mesh
  143516. * @param options defines the options used to create the mesh
  143517. * @param scene defines the hosting scene
  143518. * @returns the ribbon mesh
  143519. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143520. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143521. */
  143522. static CreateRibbon(name: string, options: {
  143523. pathArray: Vector3[][];
  143524. closeArray?: boolean;
  143525. closePath?: boolean;
  143526. offset?: number;
  143527. updatable?: boolean;
  143528. sideOrientation?: number;
  143529. frontUVs?: Vector4;
  143530. backUVs?: Vector4;
  143531. instance?: Mesh;
  143532. invertUV?: boolean;
  143533. uvs?: Vector2[];
  143534. colors?: Color4[];
  143535. }, scene?: Nullable<Scene>): Mesh;
  143536. }
  143537. }
  143538. declare module BABYLON {
  143539. /**
  143540. * Class containing static functions to help procedurally build meshes
  143541. */
  143542. export class ShapeBuilder {
  143543. /**
  143544. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143545. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  143546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143547. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  143548. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143549. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  143550. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  143551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143556. * @param name defines the name of the mesh
  143557. * @param options defines the options used to create the mesh
  143558. * @param scene defines the hosting scene
  143559. * @returns the extruded shape mesh
  143560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143562. */
  143563. static ExtrudeShape(name: string, options: {
  143564. shape: Vector3[];
  143565. path: Vector3[];
  143566. scale?: number;
  143567. rotation?: number;
  143568. cap?: number;
  143569. updatable?: boolean;
  143570. sideOrientation?: number;
  143571. frontUVs?: Vector4;
  143572. backUVs?: Vector4;
  143573. instance?: Mesh;
  143574. invertUV?: boolean;
  143575. }, scene?: Nullable<Scene>): Mesh;
  143576. /**
  143577. * Creates an custom extruded shape mesh.
  143578. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143579. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  143580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143581. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  143582. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143583. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  143584. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143585. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143586. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143587. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  143588. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  143589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143594. * @param name defines the name of the mesh
  143595. * @param options defines the options used to create the mesh
  143596. * @param scene defines the hosting scene
  143597. * @returns the custom extruded shape mesh
  143598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143601. */
  143602. static ExtrudeShapeCustom(name: string, options: {
  143603. shape: Vector3[];
  143604. path: Vector3[];
  143605. scaleFunction?: any;
  143606. rotationFunction?: any;
  143607. ribbonCloseArray?: boolean;
  143608. ribbonClosePath?: boolean;
  143609. cap?: number;
  143610. updatable?: boolean;
  143611. sideOrientation?: number;
  143612. frontUVs?: Vector4;
  143613. backUVs?: Vector4;
  143614. instance?: Mesh;
  143615. invertUV?: boolean;
  143616. }, scene?: Nullable<Scene>): Mesh;
  143617. private static _ExtrudeShapeGeneric;
  143618. }
  143619. }
  143620. declare module BABYLON.Debug {
  143621. /**
  143622. * Class used to render a debug view of a given skeleton
  143623. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  143624. */
  143625. export class SkeletonViewer {
  143626. /** defines the skeleton to render */
  143627. skeleton: Skeleton;
  143628. /** defines the mesh attached to the skeleton */
  143629. mesh: AbstractMesh;
  143630. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  143631. autoUpdateBonesMatrices: boolean;
  143632. /** defines the rendering group id to use with the viewer */
  143633. renderingGroupId: number;
  143634. /** is the options for the viewer */
  143635. options: Partial<ISkeletonViewerOptions>;
  143636. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  143637. static readonly DISPLAY_LINES: number;
  143638. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  143639. static readonly DISPLAY_SPHERES: number;
  143640. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  143641. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  143642. /** public static method to create a BoneWeight Shader
  143643. * @param options The constructor options
  143644. * @param scene The scene that the shader is scoped to
  143645. * @returns The created ShaderMaterial
  143646. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  143647. */
  143648. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  143649. /** public static method to create a BoneWeight Shader
  143650. * @param options The constructor options
  143651. * @param scene The scene that the shader is scoped to
  143652. * @returns The created ShaderMaterial
  143653. */
  143654. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  143655. /** private static method to create a BoneWeight Shader
  143656. * @param size The size of the buffer to create (usually the bone count)
  143657. * @param colorMap The gradient data to generate
  143658. * @param scene The scene that the shader is scoped to
  143659. * @returns an Array of floats from the color gradient values
  143660. */
  143661. private static _CreateBoneMapColorBuffer;
  143662. /** If SkeletonViewer scene scope. */
  143663. private _scene;
  143664. /** Gets or sets the color used to render the skeleton */
  143665. color: Color3;
  143666. /** Array of the points of the skeleton fo the line view. */
  143667. private _debugLines;
  143668. /** The SkeletonViewers Mesh. */
  143669. private _debugMesh;
  143670. /** The local axes Meshes. */
  143671. private _localAxes;
  143672. /** If SkeletonViewer is enabled. */
  143673. private _isEnabled;
  143674. /** If SkeletonViewer is ready. */
  143675. private _ready;
  143676. /** SkeletonViewer render observable. */
  143677. private _obs;
  143678. /** The Utility Layer to render the gizmos in. */
  143679. private _utilityLayer;
  143680. private _boneIndices;
  143681. /** Gets the Scene. */
  143682. get scene(): Scene;
  143683. /** Gets the utilityLayer. */
  143684. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  143685. /** Checks Ready Status. */
  143686. get isReady(): Boolean;
  143687. /** Sets Ready Status. */
  143688. set ready(value: boolean);
  143689. /** Gets the debugMesh */
  143690. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  143691. /** Sets the debugMesh */
  143692. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  143693. /** Gets the displayMode */
  143694. get displayMode(): number;
  143695. /** Sets the displayMode */
  143696. set displayMode(value: number);
  143697. /**
  143698. * Creates a new SkeletonViewer
  143699. * @param skeleton defines the skeleton to render
  143700. * @param mesh defines the mesh attached to the skeleton
  143701. * @param scene defines the hosting scene
  143702. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  143703. * @param renderingGroupId defines the rendering group id to use with the viewer
  143704. * @param options All of the extra constructor options for the SkeletonViewer
  143705. */
  143706. constructor(
  143707. /** defines the skeleton to render */
  143708. skeleton: Skeleton,
  143709. /** defines the mesh attached to the skeleton */
  143710. mesh: AbstractMesh,
  143711. /** The Scene scope*/
  143712. scene: Scene,
  143713. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  143714. autoUpdateBonesMatrices?: boolean,
  143715. /** defines the rendering group id to use with the viewer */
  143716. renderingGroupId?: number,
  143717. /** is the options for the viewer */
  143718. options?: Partial<ISkeletonViewerOptions>);
  143719. /** The Dynamic bindings for the update functions */
  143720. private _bindObs;
  143721. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  143722. update(): void;
  143723. /** Gets or sets a boolean indicating if the viewer is enabled */
  143724. set isEnabled(value: boolean);
  143725. get isEnabled(): boolean;
  143726. private _getBonePosition;
  143727. private _getLinesForBonesWithLength;
  143728. private _getLinesForBonesNoLength;
  143729. /** function to revert the mesh and scene back to the initial state. */
  143730. private _revert;
  143731. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  143732. private _getAbsoluteBindPoseToRef;
  143733. /** function to build and bind sphere joint points and spur bone representations. */
  143734. private _buildSpheresAndSpurs;
  143735. private _buildLocalAxes;
  143736. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  143737. private _displayLinesUpdate;
  143738. /** Changes the displayMode of the skeleton viewer
  143739. * @param mode The displayMode numerical value
  143740. */
  143741. changeDisplayMode(mode: number): void;
  143742. /** Sets a display option of the skeleton viewer
  143743. *
  143744. * | Option | Type | Default | Description |
  143745. * | ---------------- | ------- | ------- | ----------- |
  143746. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  143747. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  143748. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  143749. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  143750. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  143751. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  143752. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  143753. *
  143754. * @param option String of the option name
  143755. * @param value The numerical option value
  143756. */
  143757. changeDisplayOptions(option: string, value: number): void;
  143758. /** Release associated resources */
  143759. dispose(): void;
  143760. }
  143761. }
  143762. declare module BABYLON {
  143763. /**
  143764. * Enum for Device Types
  143765. */
  143766. export enum DeviceType {
  143767. /** Generic */
  143768. Generic = 0,
  143769. /** Keyboard */
  143770. Keyboard = 1,
  143771. /** Mouse */
  143772. Mouse = 2,
  143773. /** Touch Pointers */
  143774. Touch = 3,
  143775. /** PS4 Dual Shock */
  143776. DualShock = 4,
  143777. /** Xbox */
  143778. Xbox = 5,
  143779. /** Switch Controller */
  143780. Switch = 6
  143781. }
  143782. /**
  143783. * Enum for All Pointers (Touch/Mouse)
  143784. */
  143785. export enum PointerInput {
  143786. /** Horizontal Axis */
  143787. Horizontal = 0,
  143788. /** Vertical Axis */
  143789. Vertical = 1,
  143790. /** Left Click or Touch */
  143791. LeftClick = 2,
  143792. /** Middle Click */
  143793. MiddleClick = 3,
  143794. /** Right Click */
  143795. RightClick = 4,
  143796. /** Browser Back */
  143797. BrowserBack = 5,
  143798. /** Browser Forward */
  143799. BrowserForward = 6
  143800. }
  143801. /**
  143802. * Enum for Dual Shock Gamepad
  143803. */
  143804. export enum DualShockInput {
  143805. /** Cross */
  143806. Cross = 0,
  143807. /** Circle */
  143808. Circle = 1,
  143809. /** Square */
  143810. Square = 2,
  143811. /** Triangle */
  143812. Triangle = 3,
  143813. /** L1 */
  143814. L1 = 4,
  143815. /** R1 */
  143816. R1 = 5,
  143817. /** L2 */
  143818. L2 = 6,
  143819. /** R2 */
  143820. R2 = 7,
  143821. /** Share */
  143822. Share = 8,
  143823. /** Options */
  143824. Options = 9,
  143825. /** L3 */
  143826. L3 = 10,
  143827. /** R3 */
  143828. R3 = 11,
  143829. /** DPadUp */
  143830. DPadUp = 12,
  143831. /** DPadDown */
  143832. DPadDown = 13,
  143833. /** DPadLeft */
  143834. DPadLeft = 14,
  143835. /** DRight */
  143836. DPadRight = 15,
  143837. /** Home */
  143838. Home = 16,
  143839. /** TouchPad */
  143840. TouchPad = 17,
  143841. /** LStickXAxis */
  143842. LStickXAxis = 18,
  143843. /** LStickYAxis */
  143844. LStickYAxis = 19,
  143845. /** RStickXAxis */
  143846. RStickXAxis = 20,
  143847. /** RStickYAxis */
  143848. RStickYAxis = 21
  143849. }
  143850. /**
  143851. * Enum for Xbox Gamepad
  143852. */
  143853. export enum XboxInput {
  143854. /** A */
  143855. A = 0,
  143856. /** B */
  143857. B = 1,
  143858. /** X */
  143859. X = 2,
  143860. /** Y */
  143861. Y = 3,
  143862. /** LB */
  143863. LB = 4,
  143864. /** RB */
  143865. RB = 5,
  143866. /** LT */
  143867. LT = 6,
  143868. /** RT */
  143869. RT = 7,
  143870. /** Back */
  143871. Back = 8,
  143872. /** Start */
  143873. Start = 9,
  143874. /** LS */
  143875. LS = 10,
  143876. /** RS */
  143877. RS = 11,
  143878. /** DPadUp */
  143879. DPadUp = 12,
  143880. /** DPadDown */
  143881. DPadDown = 13,
  143882. /** DPadLeft */
  143883. DPadLeft = 14,
  143884. /** DRight */
  143885. DPadRight = 15,
  143886. /** Home */
  143887. Home = 16,
  143888. /** LStickXAxis */
  143889. LStickXAxis = 17,
  143890. /** LStickYAxis */
  143891. LStickYAxis = 18,
  143892. /** RStickXAxis */
  143893. RStickXAxis = 19,
  143894. /** RStickYAxis */
  143895. RStickYAxis = 20
  143896. }
  143897. /**
  143898. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  143899. */
  143900. export enum SwitchInput {
  143901. /** B */
  143902. B = 0,
  143903. /** A */
  143904. A = 1,
  143905. /** Y */
  143906. Y = 2,
  143907. /** X */
  143908. X = 3,
  143909. /** L */
  143910. L = 4,
  143911. /** R */
  143912. R = 5,
  143913. /** ZL */
  143914. ZL = 6,
  143915. /** ZR */
  143916. ZR = 7,
  143917. /** Minus */
  143918. Minus = 8,
  143919. /** Plus */
  143920. Plus = 9,
  143921. /** LS */
  143922. LS = 10,
  143923. /** RS */
  143924. RS = 11,
  143925. /** DPadUp */
  143926. DPadUp = 12,
  143927. /** DPadDown */
  143928. DPadDown = 13,
  143929. /** DPadLeft */
  143930. DPadLeft = 14,
  143931. /** DRight */
  143932. DPadRight = 15,
  143933. /** Home */
  143934. Home = 16,
  143935. /** Capture */
  143936. Capture = 17,
  143937. /** LStickXAxis */
  143938. LStickXAxis = 18,
  143939. /** LStickYAxis */
  143940. LStickYAxis = 19,
  143941. /** RStickXAxis */
  143942. RStickXAxis = 20,
  143943. /** RStickYAxis */
  143944. RStickYAxis = 21
  143945. }
  143946. }
  143947. declare module BABYLON {
  143948. /**
  143949. * This class will take all inputs from Keyboard, Pointer, and
  143950. * any Gamepads and provide a polling system that all devices
  143951. * will use. This class assumes that there will only be one
  143952. * pointer device and one keyboard.
  143953. */
  143954. export class DeviceInputSystem implements IDisposable {
  143955. /**
  143956. * Returns onDeviceConnected callback property
  143957. * @returns Callback with function to execute when a device is connected
  143958. */
  143959. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  143960. /**
  143961. * Sets callback function when a device is connected and executes against all connected devices
  143962. * @param callback Function to execute when a device is connected
  143963. */
  143964. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  143965. /**
  143966. * Callback to be triggered when a device is disconnected
  143967. */
  143968. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  143969. /**
  143970. * Callback to be triggered when event driven input is updated
  143971. */
  143972. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  143973. private _inputs;
  143974. private _gamepads;
  143975. private _keyboardActive;
  143976. private _pointerActive;
  143977. private _elementToAttachTo;
  143978. private _keyboardDownEvent;
  143979. private _keyboardUpEvent;
  143980. private _pointerMoveEvent;
  143981. private _pointerDownEvent;
  143982. private _pointerUpEvent;
  143983. private _gamepadConnectedEvent;
  143984. private _gamepadDisconnectedEvent;
  143985. private _onDeviceConnected;
  143986. private static _MAX_KEYCODES;
  143987. private static _MAX_POINTER_INPUTS;
  143988. private constructor();
  143989. /**
  143990. * Creates a new DeviceInputSystem instance
  143991. * @param engine Engine to pull input element from
  143992. * @returns The new instance
  143993. */
  143994. static Create(engine: Engine): DeviceInputSystem;
  143995. /**
  143996. * Checks for current device input value, given an id and input index
  143997. * @param deviceName Id of connected device
  143998. * @param inputIndex Index of device input
  143999. * @returns Current value of input
  144000. */
  144001. /**
  144002. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  144003. * @param deviceType Enum specifiying device type
  144004. * @param deviceSlot "Slot" or index that device is referenced in
  144005. * @param inputIndex Id of input to be checked
  144006. * @returns Current value of input
  144007. */
  144008. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  144009. /**
  144010. * Dispose of all the eventlisteners
  144011. */
  144012. dispose(): void;
  144013. /**
  144014. * Checks for existing connections to devices and register them, if necessary
  144015. * Currently handles gamepads and mouse
  144016. */
  144017. private _checkForConnectedDevices;
  144018. /**
  144019. * Add a gamepad to the DeviceInputSystem
  144020. * @param gamepad A single DOM Gamepad object
  144021. */
  144022. private _addGamePad;
  144023. /**
  144024. * Add pointer device to DeviceInputSystem
  144025. * @param deviceType Type of Pointer to add
  144026. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  144027. * @param currentX Current X at point of adding
  144028. * @param currentY Current Y at point of adding
  144029. */
  144030. private _addPointerDevice;
  144031. /**
  144032. * Add device and inputs to device array
  144033. * @param deviceType Enum specifiying device type
  144034. * @param deviceSlot "Slot" or index that device is referenced in
  144035. * @param numberOfInputs Number of input entries to create for given device
  144036. */
  144037. private _registerDevice;
  144038. /**
  144039. * Given a specific device name, remove that device from the device map
  144040. * @param deviceType Enum specifiying device type
  144041. * @param deviceSlot "Slot" or index that device is referenced in
  144042. */
  144043. private _unregisterDevice;
  144044. /**
  144045. * Handle all actions that come from keyboard interaction
  144046. */
  144047. private _handleKeyActions;
  144048. /**
  144049. * Handle all actions that come from pointer interaction
  144050. */
  144051. private _handlePointerActions;
  144052. /**
  144053. * Handle all actions that come from gamepad interaction
  144054. */
  144055. private _handleGamepadActions;
  144056. /**
  144057. * Update all non-event based devices with each frame
  144058. * @param deviceType Enum specifiying device type
  144059. * @param deviceSlot "Slot" or index that device is referenced in
  144060. * @param inputIndex Id of input to be checked
  144061. */
  144062. private _updateDevice;
  144063. /**
  144064. * Gets DeviceType from the device name
  144065. * @param deviceName Name of Device from DeviceInputSystem
  144066. * @returns DeviceType enum value
  144067. */
  144068. private _getGamepadDeviceType;
  144069. }
  144070. }
  144071. declare module BABYLON {
  144072. /**
  144073. * Type to handle enforcement of inputs
  144074. */
  144075. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  144076. }
  144077. declare module BABYLON {
  144078. /**
  144079. * Class that handles all input for a specific device
  144080. */
  144081. export class DeviceSource<T extends DeviceType> {
  144082. /** Type of device */
  144083. readonly deviceType: DeviceType;
  144084. /** "Slot" or index that device is referenced in */
  144085. readonly deviceSlot: number;
  144086. /**
  144087. * Observable to handle device input changes per device
  144088. */
  144089. readonly onInputChangedObservable: Observable<{
  144090. inputIndex: DeviceInput<T>;
  144091. previousState: Nullable<number>;
  144092. currentState: Nullable<number>;
  144093. }>;
  144094. private readonly _deviceInputSystem;
  144095. /**
  144096. * Default Constructor
  144097. * @param deviceInputSystem Reference to DeviceInputSystem
  144098. * @param deviceType Type of device
  144099. * @param deviceSlot "Slot" or index that device is referenced in
  144100. */
  144101. constructor(deviceInputSystem: DeviceInputSystem,
  144102. /** Type of device */
  144103. deviceType: DeviceType,
  144104. /** "Slot" or index that device is referenced in */
  144105. deviceSlot?: number);
  144106. /**
  144107. * Get input for specific input
  144108. * @param inputIndex index of specific input on device
  144109. * @returns Input value from DeviceInputSystem
  144110. */
  144111. getInput(inputIndex: DeviceInput<T>): number;
  144112. }
  144113. /**
  144114. * Class to keep track of devices
  144115. */
  144116. export class DeviceSourceManager implements IDisposable {
  144117. /**
  144118. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  144119. */
  144120. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  144121. /**
  144122. * Observable to be triggered when after a device is disconnected
  144123. */
  144124. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  144125. private readonly _devices;
  144126. private readonly _firstDevice;
  144127. private readonly _deviceInputSystem;
  144128. /**
  144129. * Default Constructor
  144130. * @param engine engine to pull input element from
  144131. */
  144132. constructor(engine: Engine);
  144133. /**
  144134. * Gets a DeviceSource, given a type and slot
  144135. * @param deviceType Enum specifying device type
  144136. * @param deviceSlot "Slot" or index that device is referenced in
  144137. * @returns DeviceSource object
  144138. */
  144139. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  144140. /**
  144141. * Gets an array of DeviceSource objects for a given device type
  144142. * @param deviceType Enum specifying device type
  144143. * @returns Array of DeviceSource objects
  144144. */
  144145. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  144146. /**
  144147. * Returns a read-only list of all available devices
  144148. * @returns Read-only array with active devices
  144149. */
  144150. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  144151. /**
  144152. * Dispose of DeviceInputSystem and other parts
  144153. */
  144154. dispose(): void;
  144155. /**
  144156. * Function to add device name to device list
  144157. * @param deviceType Enum specifying device type
  144158. * @param deviceSlot "Slot" or index that device is referenced in
  144159. */
  144160. private _addDevice;
  144161. /**
  144162. * Function to remove device name to device list
  144163. * @param deviceType Enum specifying device type
  144164. * @param deviceSlot "Slot" or index that device is referenced in
  144165. */
  144166. private _removeDevice;
  144167. /**
  144168. * Updates array storing first connected device of each type
  144169. * @param type Type of Device
  144170. */
  144171. private _updateFirstDevices;
  144172. }
  144173. }
  144174. declare module BABYLON {
  144175. /**
  144176. * Options to create the null engine
  144177. */
  144178. export class NullEngineOptions {
  144179. /**
  144180. * Render width (Default: 512)
  144181. */
  144182. renderWidth: number;
  144183. /**
  144184. * Render height (Default: 256)
  144185. */
  144186. renderHeight: number;
  144187. /**
  144188. * Texture size (Default: 512)
  144189. */
  144190. textureSize: number;
  144191. /**
  144192. * If delta time between frames should be constant
  144193. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  144194. */
  144195. deterministicLockstep: boolean;
  144196. /**
  144197. * Maximum about of steps between frames (Default: 4)
  144198. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  144199. */
  144200. lockstepMaxSteps: number;
  144201. /**
  144202. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  144203. */
  144204. useHighPrecisionMatrix?: boolean;
  144205. }
  144206. /**
  144207. * The null engine class provides support for headless version of babylon.js.
  144208. * This can be used in server side scenario or for testing purposes
  144209. */
  144210. export class NullEngine extends Engine {
  144211. private _options;
  144212. /**
  144213. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  144214. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  144215. * @returns true if engine is in deterministic lock step mode
  144216. */
  144217. isDeterministicLockStep(): boolean;
  144218. /**
  144219. * Gets the max steps when engine is running in deterministic lock step
  144220. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  144221. * @returns the max steps
  144222. */
  144223. getLockstepMaxSteps(): number;
  144224. /**
  144225. * Gets the current hardware scaling level.
  144226. * By default the hardware scaling level is computed from the window device ratio.
  144227. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  144228. * @returns a number indicating the current hardware scaling level
  144229. */
  144230. getHardwareScalingLevel(): number;
  144231. constructor(options?: NullEngineOptions);
  144232. /**
  144233. * Creates a vertex buffer
  144234. * @param vertices the data for the vertex buffer
  144235. * @returns the new WebGL static buffer
  144236. */
  144237. createVertexBuffer(vertices: FloatArray): DataBuffer;
  144238. /**
  144239. * Creates a new index buffer
  144240. * @param indices defines the content of the index buffer
  144241. * @param updatable defines if the index buffer must be updatable
  144242. * @returns a new webGL buffer
  144243. */
  144244. createIndexBuffer(indices: IndicesArray): DataBuffer;
  144245. /**
  144246. * Clear the current render buffer or the current render target (if any is set up)
  144247. * @param color defines the color to use
  144248. * @param backBuffer defines if the back buffer must be cleared
  144249. * @param depth defines if the depth buffer must be cleared
  144250. * @param stencil defines if the stencil buffer must be cleared
  144251. */
  144252. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  144253. /**
  144254. * Gets the current render width
  144255. * @param useScreen defines if screen size must be used (or the current render target if any)
  144256. * @returns a number defining the current render width
  144257. */
  144258. getRenderWidth(useScreen?: boolean): number;
  144259. /**
  144260. * Gets the current render height
  144261. * @param useScreen defines if screen size must be used (or the current render target if any)
  144262. * @returns a number defining the current render height
  144263. */
  144264. getRenderHeight(useScreen?: boolean): number;
  144265. /**
  144266. * Set the WebGL's viewport
  144267. * @param viewport defines the viewport element to be used
  144268. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  144269. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  144270. */
  144271. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  144272. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  144273. /**
  144274. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  144275. * @param pipelineContext defines the pipeline context to use
  144276. * @param uniformsNames defines the list of uniform names
  144277. * @returns an array of webGL uniform locations
  144278. */
  144279. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  144280. /**
  144281. * Gets the lsit of active attributes for a given webGL program
  144282. * @param pipelineContext defines the pipeline context to use
  144283. * @param attributesNames defines the list of attribute names to get
  144284. * @returns an array of indices indicating the offset of each attribute
  144285. */
  144286. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  144287. /**
  144288. * Binds an effect to the webGL context
  144289. * @param effect defines the effect to bind
  144290. */
  144291. bindSamplers(effect: Effect): void;
  144292. /**
  144293. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  144294. * @param effect defines the effect to activate
  144295. */
  144296. enableEffect(effect: Effect): void;
  144297. /**
  144298. * Set various states to the webGL context
  144299. * @param culling defines backface culling state
  144300. * @param zOffset defines the value to apply to zOffset (0 by default)
  144301. * @param force defines if states must be applied even if cache is up to date
  144302. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  144303. */
  144304. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  144305. /**
  144306. * Set the value of an uniform to an array of int32
  144307. * @param uniform defines the webGL uniform location where to store the value
  144308. * @param array defines the array of int32 to store
  144309. * @returns true if value was set
  144310. */
  144311. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144312. /**
  144313. * Set the value of an uniform to an array of int32 (stored as vec2)
  144314. * @param uniform defines the webGL uniform location where to store the value
  144315. * @param array defines the array of int32 to store
  144316. * @returns true if value was set
  144317. */
  144318. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144319. /**
  144320. * Set the value of an uniform to an array of int32 (stored as vec3)
  144321. * @param uniform defines the webGL uniform location where to store the value
  144322. * @param array defines the array of int32 to store
  144323. * @returns true if value was set
  144324. */
  144325. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144326. /**
  144327. * Set the value of an uniform to an array of int32 (stored as vec4)
  144328. * @param uniform defines the webGL uniform location where to store the value
  144329. * @param array defines the array of int32 to store
  144330. * @returns true if value was set
  144331. */
  144332. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144333. /**
  144334. * Set the value of an uniform to an array of float32
  144335. * @param uniform defines the webGL uniform location where to store the value
  144336. * @param array defines the array of float32 to store
  144337. * @returns true if value was set
  144338. */
  144339. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144340. /**
  144341. * Set the value of an uniform to an array of float32 (stored as vec2)
  144342. * @param uniform defines the webGL uniform location where to store the value
  144343. * @param array defines the array of float32 to store
  144344. * @returns true if value was set
  144345. */
  144346. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144347. /**
  144348. * Set the value of an uniform to an array of float32 (stored as vec3)
  144349. * @param uniform defines the webGL uniform location where to store the value
  144350. * @param array defines the array of float32 to store
  144351. * @returns true if value was set
  144352. */
  144353. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144354. /**
  144355. * Set the value of an uniform to an array of float32 (stored as vec4)
  144356. * @param uniform defines the webGL uniform location where to store the value
  144357. * @param array defines the array of float32 to store
  144358. * @returns true if value was set
  144359. */
  144360. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144361. /**
  144362. * Set the value of an uniform to an array of number
  144363. * @param uniform defines the webGL uniform location where to store the value
  144364. * @param array defines the array of number to store
  144365. * @returns true if value was set
  144366. */
  144367. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  144368. /**
  144369. * Set the value of an uniform to an array of number (stored as vec2)
  144370. * @param uniform defines the webGL uniform location where to store the value
  144371. * @param array defines the array of number to store
  144372. * @returns true if value was set
  144373. */
  144374. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  144375. /**
  144376. * Set the value of an uniform to an array of number (stored as vec3)
  144377. * @param uniform defines the webGL uniform location where to store the value
  144378. * @param array defines the array of number to store
  144379. * @returns true if value was set
  144380. */
  144381. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  144382. /**
  144383. * Set the value of an uniform to an array of number (stored as vec4)
  144384. * @param uniform defines the webGL uniform location where to store the value
  144385. * @param array defines the array of number to store
  144386. * @returns true if value was set
  144387. */
  144388. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  144389. /**
  144390. * Set the value of an uniform to an array of float32 (stored as matrices)
  144391. * @param uniform defines the webGL uniform location where to store the value
  144392. * @param matrices defines the array of float32 to store
  144393. * @returns true if value was set
  144394. */
  144395. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  144396. /**
  144397. * Set the value of an uniform to a matrix (3x3)
  144398. * @param uniform defines the webGL uniform location where to store the value
  144399. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  144400. * @returns true if value was set
  144401. */
  144402. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144403. /**
  144404. * Set the value of an uniform to a matrix (2x2)
  144405. * @param uniform defines the webGL uniform location where to store the value
  144406. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  144407. * @returns true if value was set
  144408. */
  144409. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144410. /**
  144411. * Set the value of an uniform to a number (float)
  144412. * @param uniform defines the webGL uniform location where to store the value
  144413. * @param value defines the float number to store
  144414. * @returns true if value was set
  144415. */
  144416. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  144417. /**
  144418. * Set the value of an uniform to a vec2
  144419. * @param uniform defines the webGL uniform location where to store the value
  144420. * @param x defines the 1st component of the value
  144421. * @param y defines the 2nd component of the value
  144422. * @returns true if value was set
  144423. */
  144424. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  144425. /**
  144426. * Set the value of an uniform to a vec3
  144427. * @param uniform defines the webGL uniform location where to store the value
  144428. * @param x defines the 1st component of the value
  144429. * @param y defines the 2nd component of the value
  144430. * @param z defines the 3rd component of the value
  144431. * @returns true if value was set
  144432. */
  144433. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  144434. /**
  144435. * Set the value of an uniform to a boolean
  144436. * @param uniform defines the webGL uniform location where to store the value
  144437. * @param bool defines the boolean to store
  144438. * @returns true if value was set
  144439. */
  144440. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  144441. /**
  144442. * Set the value of an uniform to a vec4
  144443. * @param uniform defines the webGL uniform location where to store the value
  144444. * @param x defines the 1st component of the value
  144445. * @param y defines the 2nd component of the value
  144446. * @param z defines the 3rd component of the value
  144447. * @param w defines the 4th component of the value
  144448. * @returns true if value was set
  144449. */
  144450. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  144451. /**
  144452. * Sets the current alpha mode
  144453. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  144454. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  144455. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144456. */
  144457. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  144458. /**
  144459. * Bind webGl buffers directly to the webGL context
  144460. * @param vertexBuffers defines the vertex buffer to bind
  144461. * @param indexBuffer defines the index buffer to bind
  144462. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  144463. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  144464. * @param effect defines the effect associated with the vertex buffer
  144465. */
  144466. bindBuffers(vertexBuffers: {
  144467. [key: string]: VertexBuffer;
  144468. }, indexBuffer: DataBuffer, effect: Effect): void;
  144469. /**
  144470. * Force the entire cache to be cleared
  144471. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  144472. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  144473. */
  144474. wipeCaches(bruteForce?: boolean): void;
  144475. /**
  144476. * Send a draw order
  144477. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  144478. * @param indexStart defines the starting index
  144479. * @param indexCount defines the number of index to draw
  144480. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144481. */
  144482. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  144483. /**
  144484. * Draw a list of indexed primitives
  144485. * @param fillMode defines the primitive to use
  144486. * @param indexStart defines the starting index
  144487. * @param indexCount defines the number of index to draw
  144488. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144489. */
  144490. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  144491. /**
  144492. * Draw a list of unindexed primitives
  144493. * @param fillMode defines the primitive to use
  144494. * @param verticesStart defines the index of first vertex to draw
  144495. * @param verticesCount defines the count of vertices to draw
  144496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144497. */
  144498. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  144499. /** @hidden */
  144500. protected _createTexture(): WebGLTexture;
  144501. /** @hidden */
  144502. _releaseTexture(texture: InternalTexture): void;
  144503. /**
  144504. * Usually called from Texture.ts.
  144505. * Passed information to create a WebGLTexture
  144506. * @param urlArg defines a value which contains one of the following:
  144507. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  144508. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  144509. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  144510. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  144511. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  144512. * @param scene needed for loading to the correct scene
  144513. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  144514. * @param onLoad optional callback to be called upon successful completion
  144515. * @param onError optional callback to be called upon failure
  144516. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  144517. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  144518. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  144519. * @param forcedExtension defines the extension to use to pick the right loader
  144520. * @param mimeType defines an optional mime type
  144521. * @returns a InternalTexture for assignment back into BABYLON.Texture
  144522. */
  144523. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  144524. /**
  144525. * Creates a new render target texture
  144526. * @param size defines the size of the texture
  144527. * @param options defines the options used to create the texture
  144528. * @returns a new render target texture stored in an InternalTexture
  144529. */
  144530. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  144531. /**
  144532. * Update the sampling mode of a given texture
  144533. * @param samplingMode defines the required sampling mode
  144534. * @param texture defines the texture to update
  144535. */
  144536. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  144537. /**
  144538. * Binds the frame buffer to the specified texture.
  144539. * @param texture The texture to render to or null for the default canvas
  144540. * @param faceIndex The face of the texture to render to in case of cube texture
  144541. * @param requiredWidth The width of the target to render to
  144542. * @param requiredHeight The height of the target to render to
  144543. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  144544. * @param lodLevel defines le lod level to bind to the frame buffer
  144545. */
  144546. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  144547. /**
  144548. * Unbind the current render target texture from the webGL context
  144549. * @param texture defines the render target texture to unbind
  144550. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  144551. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  144552. */
  144553. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  144554. /**
  144555. * Creates a dynamic vertex buffer
  144556. * @param vertices the data for the dynamic vertex buffer
  144557. * @returns the new WebGL dynamic buffer
  144558. */
  144559. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  144560. /**
  144561. * Update the content of a dynamic texture
  144562. * @param texture defines the texture to update
  144563. * @param canvas defines the canvas containing the source
  144564. * @param invertY defines if data must be stored with Y axis inverted
  144565. * @param premulAlpha defines if alpha is stored as premultiplied
  144566. * @param format defines the format of the data
  144567. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  144568. */
  144569. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  144570. /**
  144571. * Gets a boolean indicating if all created effects are ready
  144572. * @returns true if all effects are ready
  144573. */
  144574. areAllEffectsReady(): boolean;
  144575. /**
  144576. * @hidden
  144577. * Get the current error code of the webGL context
  144578. * @returns the error code
  144579. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  144580. */
  144581. getError(): number;
  144582. /** @hidden */
  144583. _getUnpackAlignement(): number;
  144584. /** @hidden */
  144585. _unpackFlipY(value: boolean): void;
  144586. /**
  144587. * Update a dynamic index buffer
  144588. * @param indexBuffer defines the target index buffer
  144589. * @param indices defines the data to update
  144590. * @param offset defines the offset in the target index buffer where update should start
  144591. */
  144592. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  144593. /**
  144594. * Updates a dynamic vertex buffer.
  144595. * @param vertexBuffer the vertex buffer to update
  144596. * @param vertices the data used to update the vertex buffer
  144597. * @param byteOffset the byte offset of the data (optional)
  144598. * @param byteLength the byte length of the data (optional)
  144599. */
  144600. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  144601. /** @hidden */
  144602. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  144603. /** @hidden */
  144604. _bindTexture(channel: number, texture: InternalTexture): void;
  144605. protected _deleteBuffer(buffer: WebGLBuffer): void;
  144606. /**
  144607. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  144608. */
  144609. releaseEffects(): void;
  144610. displayLoadingUI(): void;
  144611. hideLoadingUI(): void;
  144612. /** @hidden */
  144613. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144614. /** @hidden */
  144615. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144616. /** @hidden */
  144617. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144618. /** @hidden */
  144619. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  144620. }
  144621. }
  144622. declare module BABYLON {
  144623. /** @hidden */
  144624. export class _OcclusionDataStorage {
  144625. /** @hidden */
  144626. occlusionInternalRetryCounter: number;
  144627. /** @hidden */
  144628. isOcclusionQueryInProgress: boolean;
  144629. /** @hidden */
  144630. isOccluded: boolean;
  144631. /** @hidden */
  144632. occlusionRetryCount: number;
  144633. /** @hidden */
  144634. occlusionType: number;
  144635. /** @hidden */
  144636. occlusionQueryAlgorithmType: number;
  144637. }
  144638. interface Engine {
  144639. /**
  144640. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  144641. * @return the new query
  144642. */
  144643. createQuery(): WebGLQuery;
  144644. /**
  144645. * Delete and release a webGL query
  144646. * @param query defines the query to delete
  144647. * @return the current engine
  144648. */
  144649. deleteQuery(query: WebGLQuery): Engine;
  144650. /**
  144651. * Check if a given query has resolved and got its value
  144652. * @param query defines the query to check
  144653. * @returns true if the query got its value
  144654. */
  144655. isQueryResultAvailable(query: WebGLQuery): boolean;
  144656. /**
  144657. * Gets the value of a given query
  144658. * @param query defines the query to check
  144659. * @returns the value of the query
  144660. */
  144661. getQueryResult(query: WebGLQuery): number;
  144662. /**
  144663. * Initiates an occlusion query
  144664. * @param algorithmType defines the algorithm to use
  144665. * @param query defines the query to use
  144666. * @returns the current engine
  144667. * @see https://doc.babylonjs.com/features/occlusionquery
  144668. */
  144669. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  144670. /**
  144671. * Ends an occlusion query
  144672. * @see https://doc.babylonjs.com/features/occlusionquery
  144673. * @param algorithmType defines the algorithm to use
  144674. * @returns the current engine
  144675. */
  144676. endOcclusionQuery(algorithmType: number): Engine;
  144677. /**
  144678. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  144679. * Please note that only one query can be issued at a time
  144680. * @returns a time token used to track the time span
  144681. */
  144682. startTimeQuery(): Nullable<_TimeToken>;
  144683. /**
  144684. * Ends a time query
  144685. * @param token defines the token used to measure the time span
  144686. * @returns the time spent (in ns)
  144687. */
  144688. endTimeQuery(token: _TimeToken): int;
  144689. /** @hidden */
  144690. _currentNonTimestampToken: Nullable<_TimeToken>;
  144691. /** @hidden */
  144692. _createTimeQuery(): WebGLQuery;
  144693. /** @hidden */
  144694. _deleteTimeQuery(query: WebGLQuery): void;
  144695. /** @hidden */
  144696. _getGlAlgorithmType(algorithmType: number): number;
  144697. /** @hidden */
  144698. _getTimeQueryResult(query: WebGLQuery): any;
  144699. /** @hidden */
  144700. _getTimeQueryAvailability(query: WebGLQuery): any;
  144701. }
  144702. interface AbstractMesh {
  144703. /**
  144704. * Backing filed
  144705. * @hidden
  144706. */
  144707. __occlusionDataStorage: _OcclusionDataStorage;
  144708. /**
  144709. * Access property
  144710. * @hidden
  144711. */
  144712. _occlusionDataStorage: _OcclusionDataStorage;
  144713. /**
  144714. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  144715. * The default value is -1 which means don't break the query and wait till the result
  144716. * @see https://doc.babylonjs.com/features/occlusionquery
  144717. */
  144718. occlusionRetryCount: number;
  144719. /**
  144720. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  144721. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  144722. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  144723. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  144724. * @see https://doc.babylonjs.com/features/occlusionquery
  144725. */
  144726. occlusionType: number;
  144727. /**
  144728. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  144729. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  144730. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  144731. * @see https://doc.babylonjs.com/features/occlusionquery
  144732. */
  144733. occlusionQueryAlgorithmType: number;
  144734. /**
  144735. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  144736. * @see https://doc.babylonjs.com/features/occlusionquery
  144737. */
  144738. isOccluded: boolean;
  144739. /**
  144740. * Flag to check the progress status of the query
  144741. * @see https://doc.babylonjs.com/features/occlusionquery
  144742. */
  144743. isOcclusionQueryInProgress: boolean;
  144744. }
  144745. }
  144746. declare module BABYLON {
  144747. /** @hidden */
  144748. export var _forceTransformFeedbackToBundle: boolean;
  144749. interface Engine {
  144750. /**
  144751. * Creates a webGL transform feedback object
  144752. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  144753. * @returns the webGL transform feedback object
  144754. */
  144755. createTransformFeedback(): WebGLTransformFeedback;
  144756. /**
  144757. * Delete a webGL transform feedback object
  144758. * @param value defines the webGL transform feedback object to delete
  144759. */
  144760. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  144761. /**
  144762. * Bind a webGL transform feedback object to the webgl context
  144763. * @param value defines the webGL transform feedback object to bind
  144764. */
  144765. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  144766. /**
  144767. * Begins a transform feedback operation
  144768. * @param usePoints defines if points or triangles must be used
  144769. */
  144770. beginTransformFeedback(usePoints: boolean): void;
  144771. /**
  144772. * Ends a transform feedback operation
  144773. */
  144774. endTransformFeedback(): void;
  144775. /**
  144776. * Specify the varyings to use with transform feedback
  144777. * @param program defines the associated webGL program
  144778. * @param value defines the list of strings representing the varying names
  144779. */
  144780. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  144781. /**
  144782. * Bind a webGL buffer for a transform feedback operation
  144783. * @param value defines the webGL buffer to bind
  144784. */
  144785. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  144786. }
  144787. }
  144788. declare module BABYLON {
  144789. /**
  144790. * Class used to define an additional view for the engine
  144791. * @see https://doc.babylonjs.com/how_to/multi_canvases
  144792. */
  144793. export class EngineView {
  144794. /** Defines the canvas where to render the view */
  144795. target: HTMLCanvasElement;
  144796. /** Defines an optional camera used to render the view (will use active camera else) */
  144797. camera?: Camera;
  144798. }
  144799. interface Engine {
  144800. /**
  144801. * Gets or sets the HTML element to use for attaching events
  144802. */
  144803. inputElement: Nullable<HTMLElement>;
  144804. /**
  144805. * Gets the current engine view
  144806. * @see https://doc.babylonjs.com/how_to/multi_canvases
  144807. */
  144808. activeView: Nullable<EngineView>;
  144809. /** Gets or sets the list of views */
  144810. views: EngineView[];
  144811. /**
  144812. * Register a new child canvas
  144813. * @param canvas defines the canvas to register
  144814. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  144815. * @returns the associated view
  144816. */
  144817. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  144818. /**
  144819. * Remove a registered child canvas
  144820. * @param canvas defines the canvas to remove
  144821. * @returns the current engine
  144822. */
  144823. unRegisterView(canvas: HTMLCanvasElement): Engine;
  144824. }
  144825. }
  144826. declare module BABYLON {
  144827. interface Engine {
  144828. /** @hidden */
  144829. _excludedCompressedTextures: string[];
  144830. /** @hidden */
  144831. _textureFormatInUse: string;
  144832. /**
  144833. * Gets the list of texture formats supported
  144834. */
  144835. readonly texturesSupported: Array<string>;
  144836. /**
  144837. * Gets the texture format in use
  144838. */
  144839. readonly textureFormatInUse: Nullable<string>;
  144840. /**
  144841. * Set the compressed texture extensions or file names to skip.
  144842. *
  144843. * @param skippedFiles defines the list of those texture files you want to skip
  144844. * Example: [".dds", ".env", "myfile.png"]
  144845. */
  144846. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  144847. /**
  144848. * Set the compressed texture format to use, based on the formats you have, and the formats
  144849. * supported by the hardware / browser.
  144850. *
  144851. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  144852. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  144853. * to API arguments needed to compressed textures. This puts the burden on the container
  144854. * generator to house the arcane code for determining these for current & future formats.
  144855. *
  144856. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  144857. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  144858. *
  144859. * Note: The result of this call is not taken into account when a texture is base64.
  144860. *
  144861. * @param formatsAvailable defines the list of those format families you have created
  144862. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  144863. *
  144864. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  144865. * @returns The extension selected.
  144866. */
  144867. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  144868. }
  144869. }
  144870. declare module BABYLON {
  144871. /** @hidden */
  144872. export var rgbdEncodePixelShader: {
  144873. name: string;
  144874. shader: string;
  144875. };
  144876. }
  144877. declare module BABYLON {
  144878. /**
  144879. * Raw texture data and descriptor sufficient for WebGL texture upload
  144880. */
  144881. export interface EnvironmentTextureInfo {
  144882. /**
  144883. * Version of the environment map
  144884. */
  144885. version: number;
  144886. /**
  144887. * Width of image
  144888. */
  144889. width: number;
  144890. /**
  144891. * Irradiance information stored in the file.
  144892. */
  144893. irradiance: any;
  144894. /**
  144895. * Specular information stored in the file.
  144896. */
  144897. specular: any;
  144898. }
  144899. /**
  144900. * Defines One Image in the file. It requires only the position in the file
  144901. * as well as the length.
  144902. */
  144903. interface BufferImageData {
  144904. /**
  144905. * Length of the image data.
  144906. */
  144907. length: number;
  144908. /**
  144909. * Position of the data from the null terminator delimiting the end of the JSON.
  144910. */
  144911. position: number;
  144912. }
  144913. /**
  144914. * Defines the specular data enclosed in the file.
  144915. * This corresponds to the version 1 of the data.
  144916. */
  144917. export interface EnvironmentTextureSpecularInfoV1 {
  144918. /**
  144919. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  144920. */
  144921. specularDataPosition?: number;
  144922. /**
  144923. * This contains all the images data needed to reconstruct the cubemap.
  144924. */
  144925. mipmaps: Array<BufferImageData>;
  144926. /**
  144927. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  144928. */
  144929. lodGenerationScale: number;
  144930. }
  144931. /**
  144932. * Sets of helpers addressing the serialization and deserialization of environment texture
  144933. * stored in a BabylonJS env file.
  144934. * Those files are usually stored as .env files.
  144935. */
  144936. export class EnvironmentTextureTools {
  144937. /**
  144938. * Magic number identifying the env file.
  144939. */
  144940. private static _MagicBytes;
  144941. /**
  144942. * Gets the environment info from an env file.
  144943. * @param data The array buffer containing the .env bytes.
  144944. * @returns the environment file info (the json header) if successfully parsed.
  144945. */
  144946. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  144947. /**
  144948. * Creates an environment texture from a loaded cube texture.
  144949. * @param texture defines the cube texture to convert in env file
  144950. * @return a promise containing the environment data if succesfull.
  144951. */
  144952. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  144953. /**
  144954. * Creates a JSON representation of the spherical data.
  144955. * @param texture defines the texture containing the polynomials
  144956. * @return the JSON representation of the spherical info
  144957. */
  144958. private static _CreateEnvTextureIrradiance;
  144959. /**
  144960. * Creates the ArrayBufferViews used for initializing environment texture image data.
  144961. * @param data the image data
  144962. * @param info parameters that determine what views will be created for accessing the underlying buffer
  144963. * @return the views described by info providing access to the underlying buffer
  144964. */
  144965. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  144966. /**
  144967. * Uploads the texture info contained in the env file to the GPU.
  144968. * @param texture defines the internal texture to upload to
  144969. * @param data defines the data to load
  144970. * @param info defines the texture info retrieved through the GetEnvInfo method
  144971. * @returns a promise
  144972. */
  144973. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  144974. private static _OnImageReadyAsync;
  144975. /**
  144976. * Uploads the levels of image data to the GPU.
  144977. * @param texture defines the internal texture to upload to
  144978. * @param imageData defines the array buffer views of image data [mipmap][face]
  144979. * @returns a promise
  144980. */
  144981. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  144982. /**
  144983. * Uploads spherical polynomials information to the texture.
  144984. * @param texture defines the texture we are trying to upload the information to
  144985. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  144986. */
  144987. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  144988. /** @hidden */
  144989. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144990. }
  144991. }
  144992. declare module BABYLON {
  144993. /**
  144994. * Container for accessors for natively-stored mesh data buffers.
  144995. */
  144996. class NativeDataBuffer extends DataBuffer {
  144997. /**
  144998. * Accessor value used to identify/retrieve a natively-stored index buffer.
  144999. */
  145000. nativeIndexBuffer?: any;
  145001. /**
  145002. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  145003. */
  145004. nativeVertexBuffer?: any;
  145005. }
  145006. /** @hidden */
  145007. class NativeTexture extends InternalTexture {
  145008. getInternalTexture(): InternalTexture;
  145009. getViewCount(): number;
  145010. }
  145011. /** @hidden */
  145012. export class NativeEngine extends Engine {
  145013. private readonly _native;
  145014. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  145015. private readonly INVALID_HANDLE;
  145016. private _boundBuffersVertexArray;
  145017. private _currentDepthTest;
  145018. getHardwareScalingLevel(): number;
  145019. constructor();
  145020. dispose(): void;
  145021. /**
  145022. * Can be used to override the current requestAnimationFrame requester.
  145023. * @hidden
  145024. */
  145025. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  145026. /**
  145027. * Override default engine behavior.
  145028. * @param color
  145029. * @param backBuffer
  145030. * @param depth
  145031. * @param stencil
  145032. */
  145033. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  145034. /**
  145035. * Gets host document
  145036. * @returns the host document object
  145037. */
  145038. getHostDocument(): Nullable<Document>;
  145039. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  145040. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  145041. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  145042. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  145043. [key: string]: VertexBuffer;
  145044. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  145045. bindBuffers(vertexBuffers: {
  145046. [key: string]: VertexBuffer;
  145047. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  145048. recordVertexArrayObject(vertexBuffers: {
  145049. [key: string]: VertexBuffer;
  145050. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  145051. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  145052. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  145053. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  145054. /**
  145055. * Draw a list of indexed primitives
  145056. * @param fillMode defines the primitive to use
  145057. * @param indexStart defines the starting index
  145058. * @param indexCount defines the number of index to draw
  145059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  145060. */
  145061. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  145062. /**
  145063. * Draw a list of unindexed primitives
  145064. * @param fillMode defines the primitive to use
  145065. * @param verticesStart defines the index of first vertex to draw
  145066. * @param verticesCount defines the count of vertices to draw
  145067. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  145068. */
  145069. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  145070. createPipelineContext(): IPipelineContext;
  145071. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  145072. /** @hidden */
  145073. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  145074. /** @hidden */
  145075. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  145076. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  145077. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  145078. protected _setProgram(program: WebGLProgram): void;
  145079. _releaseEffect(effect: Effect): void;
  145080. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  145081. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  145082. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  145083. bindSamplers(effect: Effect): void;
  145084. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  145085. getRenderWidth(useScreen?: boolean): number;
  145086. getRenderHeight(useScreen?: boolean): number;
  145087. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  145088. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  145089. /**
  145090. * Set the z offset to apply to current rendering
  145091. * @param value defines the offset to apply
  145092. */
  145093. setZOffset(value: number): void;
  145094. /**
  145095. * Gets the current value of the zOffset
  145096. * @returns the current zOffset state
  145097. */
  145098. getZOffset(): number;
  145099. /**
  145100. * Enable or disable depth buffering
  145101. * @param enable defines the state to set
  145102. */
  145103. setDepthBuffer(enable: boolean): void;
  145104. /**
  145105. * Gets a boolean indicating if depth writing is enabled
  145106. * @returns the current depth writing state
  145107. */
  145108. getDepthWrite(): boolean;
  145109. setDepthFunctionToGreater(): void;
  145110. setDepthFunctionToGreaterOrEqual(): void;
  145111. setDepthFunctionToLess(): void;
  145112. setDepthFunctionToLessOrEqual(): void;
  145113. /**
  145114. * Enable or disable depth writing
  145115. * @param enable defines the state to set
  145116. */
  145117. setDepthWrite(enable: boolean): void;
  145118. /**
  145119. * Enable or disable color writing
  145120. * @param enable defines the state to set
  145121. */
  145122. setColorWrite(enable: boolean): void;
  145123. /**
  145124. * Gets a boolean indicating if color writing is enabled
  145125. * @returns the current color writing state
  145126. */
  145127. getColorWrite(): boolean;
  145128. /**
  145129. * Sets alpha constants used by some alpha blending modes
  145130. * @param r defines the red component
  145131. * @param g defines the green component
  145132. * @param b defines the blue component
  145133. * @param a defines the alpha component
  145134. */
  145135. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  145136. /**
  145137. * Sets the current alpha mode
  145138. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  145139. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  145140. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  145141. */
  145142. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  145143. /**
  145144. * Gets the current alpha mode
  145145. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  145146. * @returns the current alpha mode
  145147. */
  145148. getAlphaMode(): number;
  145149. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  145150. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145151. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145152. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145153. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145154. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145155. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145156. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145157. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145158. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  145159. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  145160. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  145161. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  145162. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  145163. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  145164. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  145165. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  145166. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  145167. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  145168. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  145169. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  145170. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  145171. wipeCaches(bruteForce?: boolean): void;
  145172. protected _createTexture(): WebGLTexture;
  145173. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  145174. /**
  145175. * Update the content of a dynamic texture
  145176. * @param texture defines the texture to update
  145177. * @param canvas defines the canvas containing the source
  145178. * @param invertY defines if data must be stored with Y axis inverted
  145179. * @param premulAlpha defines if alpha is stored as premultiplied
  145180. * @param format defines the format of the data
  145181. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  145182. */
  145183. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  145184. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  145185. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  145186. /**
  145187. * Usually called from Texture.ts.
  145188. * Passed information to create a WebGLTexture
  145189. * @param url defines a value which contains one of the following:
  145190. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  145191. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  145192. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  145193. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  145194. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  145195. * @param scene needed for loading to the correct scene
  145196. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  145197. * @param onLoad optional callback to be called upon successful completion
  145198. * @param onError optional callback to be called upon failure
  145199. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  145200. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  145201. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  145202. * @param forcedExtension defines the extension to use to pick the right loader
  145203. * @param mimeType defines an optional mime type
  145204. * @param loaderOptions options to be passed to the loader
  145205. * @returns a InternalTexture for assignment back into BABYLON.Texture
  145206. */
  145207. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  145208. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  145209. _releaseFramebufferObjects(texture: InternalTexture): void;
  145210. /**
  145211. * Creates a cube texture
  145212. * @param rootUrl defines the url where the files to load is located
  145213. * @param scene defines the current scene
  145214. * @param files defines the list of files to load (1 per face)
  145215. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  145216. * @param onLoad defines an optional callback raised when the texture is loaded
  145217. * @param onError defines an optional callback raised if there is an issue to load the texture
  145218. * @param format defines the format of the data
  145219. * @param forcedExtension defines the extension to use to pick the right loader
  145220. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  145221. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  145222. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  145223. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  145224. * @returns the cube texture as an InternalTexture
  145225. */
  145226. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  145227. createRenderTargetTexture(size: number | {
  145228. width: number;
  145229. height: number;
  145230. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  145231. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  145232. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  145233. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  145234. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  145235. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  145236. /**
  145237. * Updates a dynamic vertex buffer.
  145238. * @param vertexBuffer the vertex buffer to update
  145239. * @param data the data used to update the vertex buffer
  145240. * @param byteOffset the byte offset of the data (optional)
  145241. * @param byteLength the byte length of the data (optional)
  145242. */
  145243. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  145244. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  145245. private _updateAnisotropicLevel;
  145246. private _getAddressMode;
  145247. /** @hidden */
  145248. _bindTexture(channel: number, texture: InternalTexture): void;
  145249. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  145250. releaseEffects(): void;
  145251. /** @hidden */
  145252. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145253. /** @hidden */
  145254. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145255. /** @hidden */
  145256. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145257. /** @hidden */
  145258. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  145259. private _getNativeSamplingMode;
  145260. private _getNativeTextureFormat;
  145261. private _getNativeAlphaMode;
  145262. private _getNativeAttribType;
  145263. }
  145264. }
  145265. declare module BABYLON {
  145266. /**
  145267. * Helper class to create the best engine depending on the current hardware
  145268. */
  145269. export class EngineFactory {
  145270. /**
  145271. * Creates an engine based on the capabilities of the underlying hardware
  145272. * @param canvas Defines the canvas to use to display the result
  145273. * @param options Defines the options passed to the engine to create the context dependencies
  145274. * @returns a promise that resolves with the created engine
  145275. */
  145276. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  145277. }
  145278. }
  145279. declare module BABYLON {
  145280. /**
  145281. * Gather the list of clipboard event types as constants.
  145282. */
  145283. export class ClipboardEventTypes {
  145284. /**
  145285. * The clipboard event is fired when a copy command is active (pressed).
  145286. */
  145287. static readonly COPY: number;
  145288. /**
  145289. * The clipboard event is fired when a cut command is active (pressed).
  145290. */
  145291. static readonly CUT: number;
  145292. /**
  145293. * The clipboard event is fired when a paste command is active (pressed).
  145294. */
  145295. static readonly PASTE: number;
  145296. }
  145297. /**
  145298. * This class is used to store clipboard related info for the onClipboardObservable event.
  145299. */
  145300. export class ClipboardInfo {
  145301. /**
  145302. * Defines the type of event (BABYLON.ClipboardEventTypes)
  145303. */
  145304. type: number;
  145305. /**
  145306. * Defines the related dom event
  145307. */
  145308. event: ClipboardEvent;
  145309. /**
  145310. *Creates an instance of ClipboardInfo.
  145311. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  145312. * @param event Defines the related dom event
  145313. */
  145314. constructor(
  145315. /**
  145316. * Defines the type of event (BABYLON.ClipboardEventTypes)
  145317. */
  145318. type: number,
  145319. /**
  145320. * Defines the related dom event
  145321. */
  145322. event: ClipboardEvent);
  145323. /**
  145324. * Get the clipboard event's type from the keycode.
  145325. * @param keyCode Defines the keyCode for the current keyboard event.
  145326. * @return {number}
  145327. */
  145328. static GetTypeFromCharacter(keyCode: number): number;
  145329. }
  145330. }
  145331. declare module BABYLON {
  145332. /**
  145333. * Google Daydream controller
  145334. */
  145335. export class DaydreamController extends WebVRController {
  145336. /**
  145337. * Base Url for the controller model.
  145338. */
  145339. static MODEL_BASE_URL: string;
  145340. /**
  145341. * File name for the controller model.
  145342. */
  145343. static MODEL_FILENAME: string;
  145344. /**
  145345. * Gamepad Id prefix used to identify Daydream Controller.
  145346. */
  145347. static readonly GAMEPAD_ID_PREFIX: string;
  145348. /**
  145349. * Creates a new DaydreamController from a gamepad
  145350. * @param vrGamepad the gamepad that the controller should be created from
  145351. */
  145352. constructor(vrGamepad: any);
  145353. /**
  145354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145355. * @param scene scene in which to add meshes
  145356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145357. */
  145358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145359. /**
  145360. * Called once for each button that changed state since the last frame
  145361. * @param buttonIdx Which button index changed
  145362. * @param state New state of the button
  145363. * @param changes Which properties on the state changed since last frame
  145364. */
  145365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145366. }
  145367. }
  145368. declare module BABYLON {
  145369. /**
  145370. * Gear VR Controller
  145371. */
  145372. export class GearVRController extends WebVRController {
  145373. /**
  145374. * Base Url for the controller model.
  145375. */
  145376. static MODEL_BASE_URL: string;
  145377. /**
  145378. * File name for the controller model.
  145379. */
  145380. static MODEL_FILENAME: string;
  145381. /**
  145382. * Gamepad Id prefix used to identify this controller.
  145383. */
  145384. static readonly GAMEPAD_ID_PREFIX: string;
  145385. private readonly _buttonIndexToObservableNameMap;
  145386. /**
  145387. * Creates a new GearVRController from a gamepad
  145388. * @param vrGamepad the gamepad that the controller should be created from
  145389. */
  145390. constructor(vrGamepad: any);
  145391. /**
  145392. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145393. * @param scene scene in which to add meshes
  145394. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145395. */
  145396. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145397. /**
  145398. * Called once for each button that changed state since the last frame
  145399. * @param buttonIdx Which button index changed
  145400. * @param state New state of the button
  145401. * @param changes Which properties on the state changed since last frame
  145402. */
  145403. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145404. }
  145405. }
  145406. declare module BABYLON {
  145407. /**
  145408. * Generic Controller
  145409. */
  145410. export class GenericController extends WebVRController {
  145411. /**
  145412. * Base Url for the controller model.
  145413. */
  145414. static readonly MODEL_BASE_URL: string;
  145415. /**
  145416. * File name for the controller model.
  145417. */
  145418. static readonly MODEL_FILENAME: string;
  145419. /**
  145420. * Creates a new GenericController from a gamepad
  145421. * @param vrGamepad the gamepad that the controller should be created from
  145422. */
  145423. constructor(vrGamepad: any);
  145424. /**
  145425. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145426. * @param scene scene in which to add meshes
  145427. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145428. */
  145429. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145430. /**
  145431. * Called once for each button that changed state since the last frame
  145432. * @param buttonIdx Which button index changed
  145433. * @param state New state of the button
  145434. * @param changes Which properties on the state changed since last frame
  145435. */
  145436. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145437. }
  145438. }
  145439. declare module BABYLON {
  145440. /**
  145441. * Oculus Touch Controller
  145442. */
  145443. export class OculusTouchController extends WebVRController {
  145444. /**
  145445. * Base Url for the controller model.
  145446. */
  145447. static MODEL_BASE_URL: string;
  145448. /**
  145449. * File name for the left controller model.
  145450. */
  145451. static MODEL_LEFT_FILENAME: string;
  145452. /**
  145453. * File name for the right controller model.
  145454. */
  145455. static MODEL_RIGHT_FILENAME: string;
  145456. /**
  145457. * Base Url for the Quest controller model.
  145458. */
  145459. static QUEST_MODEL_BASE_URL: string;
  145460. /**
  145461. * @hidden
  145462. * If the controllers are running on a device that needs the updated Quest controller models
  145463. */
  145464. static _IsQuest: boolean;
  145465. /**
  145466. * Fired when the secondary trigger on this controller is modified
  145467. */
  145468. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  145469. /**
  145470. * Fired when the thumb rest on this controller is modified
  145471. */
  145472. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  145473. /**
  145474. * Creates a new OculusTouchController from a gamepad
  145475. * @param vrGamepad the gamepad that the controller should be created from
  145476. */
  145477. constructor(vrGamepad: any);
  145478. /**
  145479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145480. * @param scene scene in which to add meshes
  145481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145482. */
  145483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145484. /**
  145485. * Fired when the A button on this controller is modified
  145486. */
  145487. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145488. /**
  145489. * Fired when the B button on this controller is modified
  145490. */
  145491. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145492. /**
  145493. * Fired when the X button on this controller is modified
  145494. */
  145495. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145496. /**
  145497. * Fired when the Y button on this controller is modified
  145498. */
  145499. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145500. /**
  145501. * Called once for each button that changed state since the last frame
  145502. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  145503. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  145504. * 2) secondary trigger (same)
  145505. * 3) A (right) X (left), touch, pressed = value
  145506. * 4) B / Y
  145507. * 5) thumb rest
  145508. * @param buttonIdx Which button index changed
  145509. * @param state New state of the button
  145510. * @param changes Which properties on the state changed since last frame
  145511. */
  145512. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145513. }
  145514. }
  145515. declare module BABYLON {
  145516. /**
  145517. * Vive Controller
  145518. */
  145519. export class ViveController extends WebVRController {
  145520. /**
  145521. * Base Url for the controller model.
  145522. */
  145523. static MODEL_BASE_URL: string;
  145524. /**
  145525. * File name for the controller model.
  145526. */
  145527. static MODEL_FILENAME: string;
  145528. /**
  145529. * Creates a new ViveController from a gamepad
  145530. * @param vrGamepad the gamepad that the controller should be created from
  145531. */
  145532. constructor(vrGamepad: any);
  145533. /**
  145534. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145535. * @param scene scene in which to add meshes
  145536. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145537. */
  145538. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  145539. /**
  145540. * Fired when the left button on this controller is modified
  145541. */
  145542. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145543. /**
  145544. * Fired when the right button on this controller is modified
  145545. */
  145546. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145547. /**
  145548. * Fired when the menu button on this controller is modified
  145549. */
  145550. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145551. /**
  145552. * Called once for each button that changed state since the last frame
  145553. * Vive mapping:
  145554. * 0: touchpad
  145555. * 1: trigger
  145556. * 2: left AND right buttons
  145557. * 3: menu button
  145558. * @param buttonIdx Which button index changed
  145559. * @param state New state of the button
  145560. * @param changes Which properties on the state changed since last frame
  145561. */
  145562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145563. }
  145564. }
  145565. declare module BABYLON {
  145566. /**
  145567. * Defines the WindowsMotionController object that the state of the windows motion controller
  145568. */
  145569. export class WindowsMotionController extends WebVRController {
  145570. /**
  145571. * The base url used to load the left and right controller models
  145572. */
  145573. static MODEL_BASE_URL: string;
  145574. /**
  145575. * The name of the left controller model file
  145576. */
  145577. static MODEL_LEFT_FILENAME: string;
  145578. /**
  145579. * The name of the right controller model file
  145580. */
  145581. static MODEL_RIGHT_FILENAME: string;
  145582. /**
  145583. * The controller name prefix for this controller type
  145584. */
  145585. static readonly GAMEPAD_ID_PREFIX: string;
  145586. /**
  145587. * The controller id pattern for this controller type
  145588. */
  145589. private static readonly GAMEPAD_ID_PATTERN;
  145590. private _loadedMeshInfo;
  145591. protected readonly _mapping: {
  145592. buttons: string[];
  145593. buttonMeshNames: {
  145594. trigger: string;
  145595. menu: string;
  145596. grip: string;
  145597. thumbstick: string;
  145598. trackpad: string;
  145599. };
  145600. buttonObservableNames: {
  145601. trigger: string;
  145602. menu: string;
  145603. grip: string;
  145604. thumbstick: string;
  145605. trackpad: string;
  145606. };
  145607. axisMeshNames: string[];
  145608. pointingPoseMeshName: string;
  145609. };
  145610. /**
  145611. * Fired when the trackpad on this controller is clicked
  145612. */
  145613. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  145614. /**
  145615. * Fired when the trackpad on this controller is modified
  145616. */
  145617. onTrackpadValuesChangedObservable: Observable<StickValues>;
  145618. /**
  145619. * The current x and y values of this controller's trackpad
  145620. */
  145621. trackpad: StickValues;
  145622. /**
  145623. * Creates a new WindowsMotionController from a gamepad
  145624. * @param vrGamepad the gamepad that the controller should be created from
  145625. */
  145626. constructor(vrGamepad: any);
  145627. /**
  145628. * Fired when the trigger on this controller is modified
  145629. */
  145630. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145631. /**
  145632. * Fired when the menu button on this controller is modified
  145633. */
  145634. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145635. /**
  145636. * Fired when the grip button on this controller is modified
  145637. */
  145638. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145639. /**
  145640. * Fired when the thumbstick button on this controller is modified
  145641. */
  145642. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145643. /**
  145644. * Fired when the touchpad button on this controller is modified
  145645. */
  145646. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145647. /**
  145648. * Fired when the touchpad values on this controller are modified
  145649. */
  145650. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  145651. protected _updateTrackpad(): void;
  145652. /**
  145653. * Called once per frame by the engine.
  145654. */
  145655. update(): void;
  145656. /**
  145657. * Called once for each button that changed state since the last frame
  145658. * @param buttonIdx Which button index changed
  145659. * @param state New state of the button
  145660. * @param changes Which properties on the state changed since last frame
  145661. */
  145662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  145663. /**
  145664. * Moves the buttons on the controller mesh based on their current state
  145665. * @param buttonName the name of the button to move
  145666. * @param buttonValue the value of the button which determines the buttons new position
  145667. */
  145668. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  145669. /**
  145670. * Moves the axis on the controller mesh based on its current state
  145671. * @param axis the index of the axis
  145672. * @param axisValue the value of the axis which determines the meshes new position
  145673. * @hidden
  145674. */
  145675. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  145676. /**
  145677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  145678. * @param scene scene in which to add meshes
  145679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  145680. */
  145681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  145682. /**
  145683. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  145684. * can be transformed by button presses and axes values, based on this._mapping.
  145685. *
  145686. * @param scene scene in which the meshes exist
  145687. * @param meshes list of meshes that make up the controller model to process
  145688. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  145689. */
  145690. private processModel;
  145691. private createMeshInfo;
  145692. /**
  145693. * Gets the ray of the controller in the direction the controller is pointing
  145694. * @param length the length the resulting ray should be
  145695. * @returns a ray in the direction the controller is pointing
  145696. */
  145697. getForwardRay(length?: number): Ray;
  145698. /**
  145699. * Disposes of the controller
  145700. */
  145701. dispose(): void;
  145702. }
  145703. /**
  145704. * This class represents a new windows motion controller in XR.
  145705. */
  145706. export class XRWindowsMotionController extends WindowsMotionController {
  145707. /**
  145708. * Changing the original WIndowsMotionController mapping to fir the new mapping
  145709. */
  145710. protected readonly _mapping: {
  145711. buttons: string[];
  145712. buttonMeshNames: {
  145713. trigger: string;
  145714. menu: string;
  145715. grip: string;
  145716. thumbstick: string;
  145717. trackpad: string;
  145718. };
  145719. buttonObservableNames: {
  145720. trigger: string;
  145721. menu: string;
  145722. grip: string;
  145723. thumbstick: string;
  145724. trackpad: string;
  145725. };
  145726. axisMeshNames: string[];
  145727. pointingPoseMeshName: string;
  145728. };
  145729. /**
  145730. * Construct a new XR-Based windows motion controller
  145731. *
  145732. * @param gamepadInfo the gamepad object from the browser
  145733. */
  145734. constructor(gamepadInfo: any);
  145735. /**
  145736. * holds the thumbstick values (X,Y)
  145737. */
  145738. thumbstickValues: StickValues;
  145739. /**
  145740. * Fired when the thumbstick on this controller is clicked
  145741. */
  145742. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  145743. /**
  145744. * Fired when the thumbstick on this controller is modified
  145745. */
  145746. onThumbstickValuesChangedObservable: Observable<StickValues>;
  145747. /**
  145748. * Fired when the touchpad button on this controller is modified
  145749. */
  145750. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  145751. /**
  145752. * Fired when the touchpad values on this controller are modified
  145753. */
  145754. onTrackpadValuesChangedObservable: Observable<StickValues>;
  145755. /**
  145756. * Fired when the thumbstick button on this controller is modified
  145757. * here to prevent breaking changes
  145758. */
  145759. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  145760. /**
  145761. * updating the thumbstick(!) and not the trackpad.
  145762. * This is named this way due to the difference between WebVR and XR and to avoid
  145763. * changing the parent class.
  145764. */
  145765. protected _updateTrackpad(): void;
  145766. /**
  145767. * Disposes the class with joy
  145768. */
  145769. dispose(): void;
  145770. }
  145771. }
  145772. declare module BABYLON {
  145773. /**
  145774. * A directional light is defined by a direction (what a surprise!).
  145775. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  145776. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  145777. * Documentation: https://doc.babylonjs.com/babylon101/lights
  145778. */
  145779. export class DirectionalLight extends ShadowLight {
  145780. private _shadowFrustumSize;
  145781. /**
  145782. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  145783. */
  145784. get shadowFrustumSize(): number;
  145785. /**
  145786. * Specifies a fix frustum size for the shadow generation.
  145787. */
  145788. set shadowFrustumSize(value: number);
  145789. private _shadowOrthoScale;
  145790. /**
  145791. * Gets the shadow projection scale against the optimal computed one.
  145792. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  145793. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  145794. */
  145795. get shadowOrthoScale(): number;
  145796. /**
  145797. * Sets the shadow projection scale against the optimal computed one.
  145798. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  145799. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  145800. */
  145801. set shadowOrthoScale(value: number);
  145802. /**
  145803. * Automatically compute the projection matrix to best fit (including all the casters)
  145804. * on each frame.
  145805. */
  145806. autoUpdateExtends: boolean;
  145807. /**
  145808. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  145809. * on each frame. autoUpdateExtends must be set to true for this to work
  145810. */
  145811. autoCalcShadowZBounds: boolean;
  145812. private _orthoLeft;
  145813. private _orthoRight;
  145814. private _orthoTop;
  145815. private _orthoBottom;
  145816. /**
  145817. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  145818. * The directional light is emitted from everywhere in the given direction.
  145819. * It can cast shadows.
  145820. * Documentation : https://doc.babylonjs.com/babylon101/lights
  145821. * @param name The friendly name of the light
  145822. * @param direction The direction of the light
  145823. * @param scene The scene the light belongs to
  145824. */
  145825. constructor(name: string, direction: Vector3, scene: Scene);
  145826. /**
  145827. * Returns the string "DirectionalLight".
  145828. * @return The class name
  145829. */
  145830. getClassName(): string;
  145831. /**
  145832. * Returns the integer 1.
  145833. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  145834. */
  145835. getTypeID(): number;
  145836. /**
  145837. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  145838. * Returns the DirectionalLight Shadow projection matrix.
  145839. */
  145840. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  145841. /**
  145842. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  145843. * Returns the DirectionalLight Shadow projection matrix.
  145844. */
  145845. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  145846. /**
  145847. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  145848. * Returns the DirectionalLight Shadow projection matrix.
  145849. */
  145850. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  145851. protected _buildUniformLayout(): void;
  145852. /**
  145853. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  145854. * @param effect The effect to update
  145855. * @param lightIndex The index of the light in the effect to update
  145856. * @returns The directional light
  145857. */
  145858. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  145859. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  145860. /**
  145861. * Gets the minZ used for shadow according to both the scene and the light.
  145862. *
  145863. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  145864. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  145865. * @param activeCamera The camera we are returning the min for
  145866. * @returns the depth min z
  145867. */
  145868. getDepthMinZ(activeCamera: Camera): number;
  145869. /**
  145870. * Gets the maxZ used for shadow according to both the scene and the light.
  145871. *
  145872. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  145873. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  145874. * @param activeCamera The camera we are returning the max for
  145875. * @returns the depth max z
  145876. */
  145877. getDepthMaxZ(activeCamera: Camera): number;
  145878. /**
  145879. * Prepares the list of defines specific to the light type.
  145880. * @param defines the list of defines
  145881. * @param lightIndex defines the index of the light for the effect
  145882. */
  145883. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  145884. }
  145885. }
  145886. declare module BABYLON {
  145887. /**
  145888. * Class containing static functions to help procedurally build meshes
  145889. */
  145890. export class HemisphereBuilder {
  145891. /**
  145892. * Creates a hemisphere mesh
  145893. * @param name defines the name of the mesh
  145894. * @param options defines the options used to create the mesh
  145895. * @param scene defines the hosting scene
  145896. * @returns the hemisphere mesh
  145897. */
  145898. static CreateHemisphere(name: string, options: {
  145899. segments?: number;
  145900. diameter?: number;
  145901. sideOrientation?: number;
  145902. }, scene: any): Mesh;
  145903. }
  145904. }
  145905. declare module BABYLON {
  145906. /**
  145907. * A spot light is defined by a position, a direction, an angle, and an exponent.
  145908. * These values define a cone of light starting from the position, emitting toward the direction.
  145909. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  145910. * and the exponent defines the speed of the decay of the light with distance (reach).
  145911. * Documentation: https://doc.babylonjs.com/babylon101/lights
  145912. */
  145913. export class SpotLight extends ShadowLight {
  145914. private _angle;
  145915. private _innerAngle;
  145916. private _cosHalfAngle;
  145917. private _lightAngleScale;
  145918. private _lightAngleOffset;
  145919. /**
  145920. * Gets the cone angle of the spot light in Radians.
  145921. */
  145922. get angle(): number;
  145923. /**
  145924. * Sets the cone angle of the spot light in Radians.
  145925. */
  145926. set angle(value: number);
  145927. /**
  145928. * Only used in gltf falloff mode, this defines the angle where
  145929. * the directional falloff will start before cutting at angle which could be seen
  145930. * as outer angle.
  145931. */
  145932. get innerAngle(): number;
  145933. /**
  145934. * Only used in gltf falloff mode, this defines the angle where
  145935. * the directional falloff will start before cutting at angle which could be seen
  145936. * as outer angle.
  145937. */
  145938. set innerAngle(value: number);
  145939. private _shadowAngleScale;
  145940. /**
  145941. * Allows scaling the angle of the light for shadow generation only.
  145942. */
  145943. get shadowAngleScale(): number;
  145944. /**
  145945. * Allows scaling the angle of the light for shadow generation only.
  145946. */
  145947. set shadowAngleScale(value: number);
  145948. /**
  145949. * The light decay speed with the distance from the emission spot.
  145950. */
  145951. exponent: number;
  145952. private _projectionTextureMatrix;
  145953. /**
  145954. * Allows reading the projecton texture
  145955. */
  145956. get projectionTextureMatrix(): Matrix;
  145957. protected _projectionTextureLightNear: number;
  145958. /**
  145959. * Gets the near clip of the Spotlight for texture projection.
  145960. */
  145961. get projectionTextureLightNear(): number;
  145962. /**
  145963. * Sets the near clip of the Spotlight for texture projection.
  145964. */
  145965. set projectionTextureLightNear(value: number);
  145966. protected _projectionTextureLightFar: number;
  145967. /**
  145968. * Gets the far clip of the Spotlight for texture projection.
  145969. */
  145970. get projectionTextureLightFar(): number;
  145971. /**
  145972. * Sets the far clip of the Spotlight for texture projection.
  145973. */
  145974. set projectionTextureLightFar(value: number);
  145975. protected _projectionTextureUpDirection: Vector3;
  145976. /**
  145977. * Gets the Up vector of the Spotlight for texture projection.
  145978. */
  145979. get projectionTextureUpDirection(): Vector3;
  145980. /**
  145981. * Sets the Up vector of the Spotlight for texture projection.
  145982. */
  145983. set projectionTextureUpDirection(value: Vector3);
  145984. private _projectionTexture;
  145985. /**
  145986. * Gets the projection texture of the light.
  145987. */
  145988. get projectionTexture(): Nullable<BaseTexture>;
  145989. /**
  145990. * Sets the projection texture of the light.
  145991. */
  145992. set projectionTexture(value: Nullable<BaseTexture>);
  145993. private static _IsProceduralTexture;
  145994. private static _IsTexture;
  145995. private _projectionTextureViewLightDirty;
  145996. private _projectionTextureProjectionLightDirty;
  145997. private _projectionTextureDirty;
  145998. private _projectionTextureViewTargetVector;
  145999. private _projectionTextureViewLightMatrix;
  146000. private _projectionTextureProjectionLightMatrix;
  146001. private _projectionTextureScalingMatrix;
  146002. /**
  146003. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  146004. * It can cast shadows.
  146005. * Documentation : https://doc.babylonjs.com/babylon101/lights
  146006. * @param name The light friendly name
  146007. * @param position The position of the spot light in the scene
  146008. * @param direction The direction of the light in the scene
  146009. * @param angle The cone angle of the light in Radians
  146010. * @param exponent The light decay speed with the distance from the emission spot
  146011. * @param scene The scene the lights belongs to
  146012. */
  146013. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  146014. /**
  146015. * Returns the string "SpotLight".
  146016. * @returns the class name
  146017. */
  146018. getClassName(): string;
  146019. /**
  146020. * Returns the integer 2.
  146021. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  146022. */
  146023. getTypeID(): number;
  146024. /**
  146025. * Overrides the direction setter to recompute the projection texture view light Matrix.
  146026. */
  146027. protected _setDirection(value: Vector3): void;
  146028. /**
  146029. * Overrides the position setter to recompute the projection texture view light Matrix.
  146030. */
  146031. protected _setPosition(value: Vector3): void;
  146032. /**
  146033. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  146034. * Returns the SpotLight.
  146035. */
  146036. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  146037. protected _computeProjectionTextureViewLightMatrix(): void;
  146038. protected _computeProjectionTextureProjectionLightMatrix(): void;
  146039. /**
  146040. * Main function for light texture projection matrix computing.
  146041. */
  146042. protected _computeProjectionTextureMatrix(): void;
  146043. protected _buildUniformLayout(): void;
  146044. private _computeAngleValues;
  146045. /**
  146046. * Sets the passed Effect "effect" with the Light textures.
  146047. * @param effect The effect to update
  146048. * @param lightIndex The index of the light in the effect to update
  146049. * @returns The light
  146050. */
  146051. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  146052. /**
  146053. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  146054. * @param effect The effect to update
  146055. * @param lightIndex The index of the light in the effect to update
  146056. * @returns The spot light
  146057. */
  146058. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  146059. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  146060. /**
  146061. * Disposes the light and the associated resources.
  146062. */
  146063. dispose(): void;
  146064. /**
  146065. * Prepares the list of defines specific to the light type.
  146066. * @param defines the list of defines
  146067. * @param lightIndex defines the index of the light for the effect
  146068. */
  146069. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  146070. }
  146071. }
  146072. declare module BABYLON {
  146073. /**
  146074. * Gizmo that enables viewing a light
  146075. */
  146076. export class LightGizmo extends Gizmo {
  146077. private _lightMesh;
  146078. private _material;
  146079. private _cachedPosition;
  146080. private _cachedForward;
  146081. private _attachedMeshParent;
  146082. private _pointerObserver;
  146083. /**
  146084. * Event that fires each time the gizmo is clicked
  146085. */
  146086. onClickedObservable: Observable<Light>;
  146087. /**
  146088. * Creates a LightGizmo
  146089. * @param gizmoLayer The utility layer the gizmo will be added to
  146090. */
  146091. constructor(gizmoLayer?: UtilityLayerRenderer);
  146092. private _light;
  146093. /**
  146094. * The light that the gizmo is attached to
  146095. */
  146096. set light(light: Nullable<Light>);
  146097. get light(): Nullable<Light>;
  146098. /**
  146099. * Gets the material used to render the light gizmo
  146100. */
  146101. get material(): StandardMaterial;
  146102. /**
  146103. * @hidden
  146104. * Updates the gizmo to match the attached mesh's position/rotation
  146105. */
  146106. protected _update(): void;
  146107. private static _Scale;
  146108. /**
  146109. * Creates the lines for a light mesh
  146110. */
  146111. private static _CreateLightLines;
  146112. /**
  146113. * Disposes of the light gizmo
  146114. */
  146115. dispose(): void;
  146116. private static _CreateHemisphericLightMesh;
  146117. private static _CreatePointLightMesh;
  146118. private static _CreateSpotLightMesh;
  146119. private static _CreateDirectionalLightMesh;
  146120. }
  146121. }
  146122. declare module BABYLON {
  146123. /**
  146124. * Gizmo that enables viewing a camera
  146125. */
  146126. export class CameraGizmo extends Gizmo {
  146127. private _cameraMesh;
  146128. private _cameraLinesMesh;
  146129. private _material;
  146130. private _pointerObserver;
  146131. /**
  146132. * Event that fires each time the gizmo is clicked
  146133. */
  146134. onClickedObservable: Observable<Camera>;
  146135. /**
  146136. * Creates a CameraGizmo
  146137. * @param gizmoLayer The utility layer the gizmo will be added to
  146138. */
  146139. constructor(gizmoLayer?: UtilityLayerRenderer);
  146140. private _camera;
  146141. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  146142. get displayFrustum(): boolean;
  146143. set displayFrustum(value: boolean);
  146144. /**
  146145. * The camera that the gizmo is attached to
  146146. */
  146147. set camera(camera: Nullable<Camera>);
  146148. get camera(): Nullable<Camera>;
  146149. /**
  146150. * Gets the material used to render the camera gizmo
  146151. */
  146152. get material(): StandardMaterial;
  146153. /**
  146154. * @hidden
  146155. * Updates the gizmo to match the attached mesh's position/rotation
  146156. */
  146157. protected _update(): void;
  146158. private static _Scale;
  146159. private _invProjection;
  146160. /**
  146161. * Disposes of the camera gizmo
  146162. */
  146163. dispose(): void;
  146164. private static _CreateCameraMesh;
  146165. private static _CreateCameraFrustum;
  146166. }
  146167. }
  146168. declare module BABYLON {
  146169. /** @hidden */
  146170. export var backgroundFragmentDeclaration: {
  146171. name: string;
  146172. shader: string;
  146173. };
  146174. }
  146175. declare module BABYLON {
  146176. /** @hidden */
  146177. export var backgroundUboDeclaration: {
  146178. name: string;
  146179. shader: string;
  146180. };
  146181. }
  146182. declare module BABYLON {
  146183. /** @hidden */
  146184. export var backgroundPixelShader: {
  146185. name: string;
  146186. shader: string;
  146187. };
  146188. }
  146189. declare module BABYLON {
  146190. /** @hidden */
  146191. export var backgroundVertexDeclaration: {
  146192. name: string;
  146193. shader: string;
  146194. };
  146195. }
  146196. declare module BABYLON {
  146197. /** @hidden */
  146198. export var backgroundVertexShader: {
  146199. name: string;
  146200. shader: string;
  146201. };
  146202. }
  146203. declare module BABYLON {
  146204. /**
  146205. * Background material used to create an efficient environement around your scene.
  146206. */
  146207. export class BackgroundMaterial extends PushMaterial {
  146208. /**
  146209. * Standard reflectance value at parallel view angle.
  146210. */
  146211. static StandardReflectance0: number;
  146212. /**
  146213. * Standard reflectance value at grazing angle.
  146214. */
  146215. static StandardReflectance90: number;
  146216. protected _primaryColor: Color3;
  146217. /**
  146218. * Key light Color (multiply against the environement texture)
  146219. */
  146220. primaryColor: Color3;
  146221. protected __perceptualColor: Nullable<Color3>;
  146222. /**
  146223. * Experimental Internal Use Only.
  146224. *
  146225. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  146226. * This acts as a helper to set the primary color to a more "human friendly" value.
  146227. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  146228. * output color as close as possible from the chosen value.
  146229. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  146230. * part of lighting setup.)
  146231. */
  146232. get _perceptualColor(): Nullable<Color3>;
  146233. set _perceptualColor(value: Nullable<Color3>);
  146234. protected _primaryColorShadowLevel: float;
  146235. /**
  146236. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  146237. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  146238. */
  146239. get primaryColorShadowLevel(): float;
  146240. set primaryColorShadowLevel(value: float);
  146241. protected _primaryColorHighlightLevel: float;
  146242. /**
  146243. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  146244. * The primary color is used at the level chosen to define what the white area would look.
  146245. */
  146246. get primaryColorHighlightLevel(): float;
  146247. set primaryColorHighlightLevel(value: float);
  146248. protected _reflectionTexture: Nullable<BaseTexture>;
  146249. /**
  146250. * Reflection Texture used in the material.
  146251. * Should be author in a specific way for the best result (refer to the documentation).
  146252. */
  146253. reflectionTexture: Nullable<BaseTexture>;
  146254. protected _reflectionBlur: float;
  146255. /**
  146256. * Reflection Texture level of blur.
  146257. *
  146258. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  146259. * texture twice.
  146260. */
  146261. reflectionBlur: float;
  146262. protected _diffuseTexture: Nullable<BaseTexture>;
  146263. /**
  146264. * Diffuse Texture used in the material.
  146265. * Should be author in a specific way for the best result (refer to the documentation).
  146266. */
  146267. diffuseTexture: Nullable<BaseTexture>;
  146268. protected _shadowLights: Nullable<IShadowLight[]>;
  146269. /**
  146270. * Specify the list of lights casting shadow on the material.
  146271. * All scene shadow lights will be included if null.
  146272. */
  146273. shadowLights: Nullable<IShadowLight[]>;
  146274. protected _shadowLevel: float;
  146275. /**
  146276. * Helps adjusting the shadow to a softer level if required.
  146277. * 0 means black shadows and 1 means no shadows.
  146278. */
  146279. shadowLevel: float;
  146280. protected _sceneCenter: Vector3;
  146281. /**
  146282. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  146283. * It is usually zero but might be interesting to modify according to your setup.
  146284. */
  146285. sceneCenter: Vector3;
  146286. protected _opacityFresnel: boolean;
  146287. /**
  146288. * This helps specifying that the material is falling off to the sky box at grazing angle.
  146289. * This helps ensuring a nice transition when the camera goes under the ground.
  146290. */
  146291. opacityFresnel: boolean;
  146292. protected _reflectionFresnel: boolean;
  146293. /**
  146294. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  146295. * This helps adding a mirror texture on the ground.
  146296. */
  146297. reflectionFresnel: boolean;
  146298. protected _reflectionFalloffDistance: number;
  146299. /**
  146300. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  146301. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  146302. */
  146303. reflectionFalloffDistance: number;
  146304. protected _reflectionAmount: number;
  146305. /**
  146306. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  146307. */
  146308. reflectionAmount: number;
  146309. protected _reflectionReflectance0: number;
  146310. /**
  146311. * This specifies the weight of the reflection at grazing angle.
  146312. */
  146313. reflectionReflectance0: number;
  146314. protected _reflectionReflectance90: number;
  146315. /**
  146316. * This specifies the weight of the reflection at a perpendicular point of view.
  146317. */
  146318. reflectionReflectance90: number;
  146319. /**
  146320. * Sets the reflection reflectance fresnel values according to the default standard
  146321. * empirically know to work well :-)
  146322. */
  146323. set reflectionStandardFresnelWeight(value: number);
  146324. protected _useRGBColor: boolean;
  146325. /**
  146326. * Helps to directly use the maps channels instead of their level.
  146327. */
  146328. useRGBColor: boolean;
  146329. protected _enableNoise: boolean;
  146330. /**
  146331. * This helps reducing the banding effect that could occur on the background.
  146332. */
  146333. enableNoise: boolean;
  146334. /**
  146335. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  146336. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  146337. * Recommended to be keep at 1.0 except for special cases.
  146338. */
  146339. get fovMultiplier(): number;
  146340. set fovMultiplier(value: number);
  146341. private _fovMultiplier;
  146342. /**
  146343. * Enable the FOV adjustment feature controlled by fovMultiplier.
  146344. */
  146345. useEquirectangularFOV: boolean;
  146346. private _maxSimultaneousLights;
  146347. /**
  146348. * Number of Simultaneous lights allowed on the material.
  146349. */
  146350. maxSimultaneousLights: int;
  146351. private _shadowOnly;
  146352. /**
  146353. * Make the material only render shadows
  146354. */
  146355. shadowOnly: boolean;
  146356. /**
  146357. * Default configuration related to image processing available in the Background Material.
  146358. */
  146359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  146360. /**
  146361. * Keep track of the image processing observer to allow dispose and replace.
  146362. */
  146363. private _imageProcessingObserver;
  146364. /**
  146365. * Attaches a new image processing configuration to the PBR Material.
  146366. * @param configuration (if null the scene configuration will be use)
  146367. */
  146368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  146369. /**
  146370. * Gets the image processing configuration used either in this material.
  146371. */
  146372. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  146373. /**
  146374. * Sets the Default image processing configuration used either in the this material.
  146375. *
  146376. * If sets to null, the scene one is in use.
  146377. */
  146378. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  146379. /**
  146380. * Gets wether the color curves effect is enabled.
  146381. */
  146382. get cameraColorCurvesEnabled(): boolean;
  146383. /**
  146384. * Sets wether the color curves effect is enabled.
  146385. */
  146386. set cameraColorCurvesEnabled(value: boolean);
  146387. /**
  146388. * Gets wether the color grading effect is enabled.
  146389. */
  146390. get cameraColorGradingEnabled(): boolean;
  146391. /**
  146392. * Gets wether the color grading effect is enabled.
  146393. */
  146394. set cameraColorGradingEnabled(value: boolean);
  146395. /**
  146396. * Gets wether tonemapping is enabled or not.
  146397. */
  146398. get cameraToneMappingEnabled(): boolean;
  146399. /**
  146400. * Sets wether tonemapping is enabled or not
  146401. */
  146402. set cameraToneMappingEnabled(value: boolean);
  146403. /**
  146404. * The camera exposure used on this material.
  146405. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  146406. * This corresponds to a photographic exposure.
  146407. */
  146408. get cameraExposure(): float;
  146409. /**
  146410. * The camera exposure used on this material.
  146411. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  146412. * This corresponds to a photographic exposure.
  146413. */
  146414. set cameraExposure(value: float);
  146415. /**
  146416. * Gets The camera contrast used on this material.
  146417. */
  146418. get cameraContrast(): float;
  146419. /**
  146420. * Sets The camera contrast used on this material.
  146421. */
  146422. set cameraContrast(value: float);
  146423. /**
  146424. * Gets the Color Grading 2D Lookup Texture.
  146425. */
  146426. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  146427. /**
  146428. * Sets the Color Grading 2D Lookup Texture.
  146429. */
  146430. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  146431. /**
  146432. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  146433. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  146434. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  146435. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  146436. */
  146437. get cameraColorCurves(): Nullable<ColorCurves>;
  146438. /**
  146439. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  146440. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  146441. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  146442. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  146443. */
  146444. set cameraColorCurves(value: Nullable<ColorCurves>);
  146445. /**
  146446. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  146447. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  146448. */
  146449. switchToBGR: boolean;
  146450. private _renderTargets;
  146451. private _reflectionControls;
  146452. private _white;
  146453. private _primaryShadowColor;
  146454. private _primaryHighlightColor;
  146455. /**
  146456. * Instantiates a Background Material in the given scene
  146457. * @param name The friendly name of the material
  146458. * @param scene The scene to add the material to
  146459. */
  146460. constructor(name: string, scene: Scene);
  146461. /**
  146462. * Gets a boolean indicating that current material needs to register RTT
  146463. */
  146464. get hasRenderTargetTextures(): boolean;
  146465. /**
  146466. * The entire material has been created in order to prevent overdraw.
  146467. * @returns false
  146468. */
  146469. needAlphaTesting(): boolean;
  146470. /**
  146471. * The entire material has been created in order to prevent overdraw.
  146472. * @returns true if blending is enable
  146473. */
  146474. needAlphaBlending(): boolean;
  146475. /**
  146476. * Checks wether the material is ready to be rendered for a given mesh.
  146477. * @param mesh The mesh to render
  146478. * @param subMesh The submesh to check against
  146479. * @param useInstances Specify wether or not the material is used with instances
  146480. * @returns true if all the dependencies are ready (Textures, Effects...)
  146481. */
  146482. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  146483. /**
  146484. * Compute the primary color according to the chosen perceptual color.
  146485. */
  146486. private _computePrimaryColorFromPerceptualColor;
  146487. /**
  146488. * Compute the highlights and shadow colors according to their chosen levels.
  146489. */
  146490. private _computePrimaryColors;
  146491. /**
  146492. * Build the uniform buffer used in the material.
  146493. */
  146494. buildUniformLayout(): void;
  146495. /**
  146496. * Unbind the material.
  146497. */
  146498. unbind(): void;
  146499. /**
  146500. * Bind only the world matrix to the material.
  146501. * @param world The world matrix to bind.
  146502. */
  146503. bindOnlyWorldMatrix(world: Matrix): void;
  146504. /**
  146505. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  146506. * @param world The world matrix to bind.
  146507. * @param subMesh The submesh to bind for.
  146508. */
  146509. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  146510. /**
  146511. * Checks to see if a texture is used in the material.
  146512. * @param texture - Base texture to use.
  146513. * @returns - Boolean specifying if a texture is used in the material.
  146514. */
  146515. hasTexture(texture: BaseTexture): boolean;
  146516. /**
  146517. * Dispose the material.
  146518. * @param forceDisposeEffect Force disposal of the associated effect.
  146519. * @param forceDisposeTextures Force disposal of the associated textures.
  146520. */
  146521. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  146522. /**
  146523. * Clones the material.
  146524. * @param name The cloned name.
  146525. * @returns The cloned material.
  146526. */
  146527. clone(name: string): BackgroundMaterial;
  146528. /**
  146529. * Serializes the current material to its JSON representation.
  146530. * @returns The JSON representation.
  146531. */
  146532. serialize(): any;
  146533. /**
  146534. * Gets the class name of the material
  146535. * @returns "BackgroundMaterial"
  146536. */
  146537. getClassName(): string;
  146538. /**
  146539. * Parse a JSON input to create back a background material.
  146540. * @param source The JSON data to parse
  146541. * @param scene The scene to create the parsed material in
  146542. * @param rootUrl The root url of the assets the material depends upon
  146543. * @returns the instantiated BackgroundMaterial.
  146544. */
  146545. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  146546. }
  146547. }
  146548. declare module BABYLON {
  146549. /**
  146550. * Represents the different options available during the creation of
  146551. * a Environment helper.
  146552. *
  146553. * This can control the default ground, skybox and image processing setup of your scene.
  146554. */
  146555. export interface IEnvironmentHelperOptions {
  146556. /**
  146557. * Specifies whether or not to create a ground.
  146558. * True by default.
  146559. */
  146560. createGround: boolean;
  146561. /**
  146562. * Specifies the ground size.
  146563. * 15 by default.
  146564. */
  146565. groundSize: number;
  146566. /**
  146567. * The texture used on the ground for the main color.
  146568. * Comes from the BabylonJS CDN by default.
  146569. *
  146570. * Remarks: Can be either a texture or a url.
  146571. */
  146572. groundTexture: string | BaseTexture;
  146573. /**
  146574. * The color mixed in the ground texture by default.
  146575. * BabylonJS clearColor by default.
  146576. */
  146577. groundColor: Color3;
  146578. /**
  146579. * Specifies the ground opacity.
  146580. * 1 by default.
  146581. */
  146582. groundOpacity: number;
  146583. /**
  146584. * Enables the ground to receive shadows.
  146585. * True by default.
  146586. */
  146587. enableGroundShadow: boolean;
  146588. /**
  146589. * Helps preventing the shadow to be fully black on the ground.
  146590. * 0.5 by default.
  146591. */
  146592. groundShadowLevel: number;
  146593. /**
  146594. * Creates a mirror texture attach to the ground.
  146595. * false by default.
  146596. */
  146597. enableGroundMirror: boolean;
  146598. /**
  146599. * Specifies the ground mirror size ratio.
  146600. * 0.3 by default as the default kernel is 64.
  146601. */
  146602. groundMirrorSizeRatio: number;
  146603. /**
  146604. * Specifies the ground mirror blur kernel size.
  146605. * 64 by default.
  146606. */
  146607. groundMirrorBlurKernel: number;
  146608. /**
  146609. * Specifies the ground mirror visibility amount.
  146610. * 1 by default
  146611. */
  146612. groundMirrorAmount: number;
  146613. /**
  146614. * Specifies the ground mirror reflectance weight.
  146615. * This uses the standard weight of the background material to setup the fresnel effect
  146616. * of the mirror.
  146617. * 1 by default.
  146618. */
  146619. groundMirrorFresnelWeight: number;
  146620. /**
  146621. * Specifies the ground mirror Falloff distance.
  146622. * This can helps reducing the size of the reflection.
  146623. * 0 by Default.
  146624. */
  146625. groundMirrorFallOffDistance: number;
  146626. /**
  146627. * Specifies the ground mirror texture type.
  146628. * Unsigned Int by Default.
  146629. */
  146630. groundMirrorTextureType: number;
  146631. /**
  146632. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  146633. * the shown objects.
  146634. */
  146635. groundYBias: number;
  146636. /**
  146637. * Specifies whether or not to create a skybox.
  146638. * True by default.
  146639. */
  146640. createSkybox: boolean;
  146641. /**
  146642. * Specifies the skybox size.
  146643. * 20 by default.
  146644. */
  146645. skyboxSize: number;
  146646. /**
  146647. * The texture used on the skybox for the main color.
  146648. * Comes from the BabylonJS CDN by default.
  146649. *
  146650. * Remarks: Can be either a texture or a url.
  146651. */
  146652. skyboxTexture: string | BaseTexture;
  146653. /**
  146654. * The color mixed in the skybox texture by default.
  146655. * BabylonJS clearColor by default.
  146656. */
  146657. skyboxColor: Color3;
  146658. /**
  146659. * The background rotation around the Y axis of the scene.
  146660. * This helps aligning the key lights of your scene with the background.
  146661. * 0 by default.
  146662. */
  146663. backgroundYRotation: number;
  146664. /**
  146665. * Compute automatically the size of the elements to best fit with the scene.
  146666. */
  146667. sizeAuto: boolean;
  146668. /**
  146669. * Default position of the rootMesh if autoSize is not true.
  146670. */
  146671. rootPosition: Vector3;
  146672. /**
  146673. * Sets up the image processing in the scene.
  146674. * true by default.
  146675. */
  146676. setupImageProcessing: boolean;
  146677. /**
  146678. * The texture used as your environment texture in the scene.
  146679. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  146680. *
  146681. * Remarks: Can be either a texture or a url.
  146682. */
  146683. environmentTexture: string | BaseTexture;
  146684. /**
  146685. * The value of the exposure to apply to the scene.
  146686. * 0.6 by default if setupImageProcessing is true.
  146687. */
  146688. cameraExposure: number;
  146689. /**
  146690. * The value of the contrast to apply to the scene.
  146691. * 1.6 by default if setupImageProcessing is true.
  146692. */
  146693. cameraContrast: number;
  146694. /**
  146695. * Specifies whether or not tonemapping should be enabled in the scene.
  146696. * true by default if setupImageProcessing is true.
  146697. */
  146698. toneMappingEnabled: boolean;
  146699. }
  146700. /**
  146701. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  146702. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  146703. * It also helps with the default setup of your imageProcessing configuration.
  146704. */
  146705. export class EnvironmentHelper {
  146706. /**
  146707. * Default ground texture URL.
  146708. */
  146709. private static _groundTextureCDNUrl;
  146710. /**
  146711. * Default skybox texture URL.
  146712. */
  146713. private static _skyboxTextureCDNUrl;
  146714. /**
  146715. * Default environment texture URL.
  146716. */
  146717. private static _environmentTextureCDNUrl;
  146718. /**
  146719. * Creates the default options for the helper.
  146720. */
  146721. private static _getDefaultOptions;
  146722. private _rootMesh;
  146723. /**
  146724. * Gets the root mesh created by the helper.
  146725. */
  146726. get rootMesh(): Mesh;
  146727. private _skybox;
  146728. /**
  146729. * Gets the skybox created by the helper.
  146730. */
  146731. get skybox(): Nullable<Mesh>;
  146732. private _skyboxTexture;
  146733. /**
  146734. * Gets the skybox texture created by the helper.
  146735. */
  146736. get skyboxTexture(): Nullable<BaseTexture>;
  146737. private _skyboxMaterial;
  146738. /**
  146739. * Gets the skybox material created by the helper.
  146740. */
  146741. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  146742. private _ground;
  146743. /**
  146744. * Gets the ground mesh created by the helper.
  146745. */
  146746. get ground(): Nullable<Mesh>;
  146747. private _groundTexture;
  146748. /**
  146749. * Gets the ground texture created by the helper.
  146750. */
  146751. get groundTexture(): Nullable<BaseTexture>;
  146752. private _groundMirror;
  146753. /**
  146754. * Gets the ground mirror created by the helper.
  146755. */
  146756. get groundMirror(): Nullable<MirrorTexture>;
  146757. /**
  146758. * Gets the ground mirror render list to helps pushing the meshes
  146759. * you wish in the ground reflection.
  146760. */
  146761. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  146762. private _groundMaterial;
  146763. /**
  146764. * Gets the ground material created by the helper.
  146765. */
  146766. get groundMaterial(): Nullable<BackgroundMaterial>;
  146767. /**
  146768. * Stores the creation options.
  146769. */
  146770. private readonly _scene;
  146771. private _options;
  146772. /**
  146773. * This observable will be notified with any error during the creation of the environment,
  146774. * mainly texture creation errors.
  146775. */
  146776. onErrorObservable: Observable<{
  146777. message?: string;
  146778. exception?: any;
  146779. }>;
  146780. /**
  146781. * constructor
  146782. * @param options Defines the options we want to customize the helper
  146783. * @param scene The scene to add the material to
  146784. */
  146785. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  146786. /**
  146787. * Updates the background according to the new options
  146788. * @param options
  146789. */
  146790. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  146791. /**
  146792. * Sets the primary color of all the available elements.
  146793. * @param color the main color to affect to the ground and the background
  146794. */
  146795. setMainColor(color: Color3): void;
  146796. /**
  146797. * Setup the image processing according to the specified options.
  146798. */
  146799. private _setupImageProcessing;
  146800. /**
  146801. * Setup the environment texture according to the specified options.
  146802. */
  146803. private _setupEnvironmentTexture;
  146804. /**
  146805. * Setup the background according to the specified options.
  146806. */
  146807. private _setupBackground;
  146808. /**
  146809. * Get the scene sizes according to the setup.
  146810. */
  146811. private _getSceneSize;
  146812. /**
  146813. * Setup the ground according to the specified options.
  146814. */
  146815. private _setupGround;
  146816. /**
  146817. * Setup the ground material according to the specified options.
  146818. */
  146819. private _setupGroundMaterial;
  146820. /**
  146821. * Setup the ground diffuse texture according to the specified options.
  146822. */
  146823. private _setupGroundDiffuseTexture;
  146824. /**
  146825. * Setup the ground mirror texture according to the specified options.
  146826. */
  146827. private _setupGroundMirrorTexture;
  146828. /**
  146829. * Setup the ground to receive the mirror texture.
  146830. */
  146831. private _setupMirrorInGroundMaterial;
  146832. /**
  146833. * Setup the skybox according to the specified options.
  146834. */
  146835. private _setupSkybox;
  146836. /**
  146837. * Setup the skybox material according to the specified options.
  146838. */
  146839. private _setupSkyboxMaterial;
  146840. /**
  146841. * Setup the skybox reflection texture according to the specified options.
  146842. */
  146843. private _setupSkyboxReflectionTexture;
  146844. private _errorHandler;
  146845. /**
  146846. * Dispose all the elements created by the Helper.
  146847. */
  146848. dispose(): void;
  146849. }
  146850. }
  146851. declare module BABYLON {
  146852. /**
  146853. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  146854. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  146855. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  146856. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146857. */
  146858. export abstract class TextureDome<T extends Texture> extends TransformNode {
  146859. protected onError: Nullable<(message?: string, exception?: any) => void>;
  146860. /**
  146861. * Define the source as a Monoscopic panoramic 360/180.
  146862. */
  146863. static readonly MODE_MONOSCOPIC: number;
  146864. /**
  146865. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  146866. */
  146867. static readonly MODE_TOPBOTTOM: number;
  146868. /**
  146869. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  146870. */
  146871. static readonly MODE_SIDEBYSIDE: number;
  146872. private _halfDome;
  146873. private _crossEye;
  146874. protected _useDirectMapping: boolean;
  146875. /**
  146876. * The texture being displayed on the sphere
  146877. */
  146878. protected _texture: T;
  146879. /**
  146880. * Gets the texture being displayed on the sphere
  146881. */
  146882. get texture(): T;
  146883. /**
  146884. * Sets the texture being displayed on the sphere
  146885. */
  146886. set texture(newTexture: T);
  146887. /**
  146888. * The skybox material
  146889. */
  146890. protected _material: BackgroundMaterial;
  146891. /**
  146892. * The surface used for the dome
  146893. */
  146894. protected _mesh: Mesh;
  146895. /**
  146896. * Gets the mesh used for the dome.
  146897. */
  146898. get mesh(): Mesh;
  146899. /**
  146900. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  146901. */
  146902. private _halfDomeMask;
  146903. /**
  146904. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  146905. * Also see the options.resolution property.
  146906. */
  146907. get fovMultiplier(): number;
  146908. set fovMultiplier(value: number);
  146909. protected _textureMode: number;
  146910. /**
  146911. * Gets or set the current texture mode for the texture. It can be:
  146912. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146913. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146914. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146915. */
  146916. get textureMode(): number;
  146917. /**
  146918. * Sets the current texture mode for the texture. It can be:
  146919. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146920. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146921. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146922. */
  146923. set textureMode(value: number);
  146924. /**
  146925. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  146926. */
  146927. get halfDome(): boolean;
  146928. /**
  146929. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  146930. */
  146931. set halfDome(enabled: boolean);
  146932. /**
  146933. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  146934. */
  146935. set crossEye(enabled: boolean);
  146936. /**
  146937. * Is it a cross-eye texture?
  146938. */
  146939. get crossEye(): boolean;
  146940. /**
  146941. * The background material of this dome.
  146942. */
  146943. get material(): BackgroundMaterial;
  146944. /**
  146945. * Oberserver used in Stereoscopic VR Mode.
  146946. */
  146947. private _onBeforeCameraRenderObserver;
  146948. /**
  146949. * Observable raised when an error occured while loading the 360 image
  146950. */
  146951. onLoadErrorObservable: Observable<string>;
  146952. /**
  146953. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  146954. * @param name Element's name, child elements will append suffixes for their own names.
  146955. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  146956. * @param options An object containing optional or exposed sub element properties
  146957. */
  146958. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  146959. resolution?: number;
  146960. clickToPlay?: boolean;
  146961. autoPlay?: boolean;
  146962. loop?: boolean;
  146963. size?: number;
  146964. poster?: string;
  146965. faceForward?: boolean;
  146966. useDirectMapping?: boolean;
  146967. halfDomeMode?: boolean;
  146968. crossEyeMode?: boolean;
  146969. generateMipMaps?: boolean;
  146970. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  146971. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  146972. protected _changeTextureMode(value: number): void;
  146973. /**
  146974. * Releases resources associated with this node.
  146975. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  146976. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  146977. */
  146978. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  146979. }
  146980. }
  146981. declare module BABYLON {
  146982. /**
  146983. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  146984. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  146985. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  146986. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146987. */
  146988. export class PhotoDome extends TextureDome<Texture> {
  146989. /**
  146990. * Define the image as a Monoscopic panoramic 360 image.
  146991. */
  146992. static readonly MODE_MONOSCOPIC: number;
  146993. /**
  146994. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  146995. */
  146996. static readonly MODE_TOPBOTTOM: number;
  146997. /**
  146998. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  146999. */
  147000. static readonly MODE_SIDEBYSIDE: number;
  147001. /**
  147002. * Gets or sets the texture being displayed on the sphere
  147003. */
  147004. get photoTexture(): Texture;
  147005. /**
  147006. * sets the texture being displayed on the sphere
  147007. */
  147008. set photoTexture(value: Texture);
  147009. /**
  147010. * Gets the current video mode for the video. It can be:
  147011. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  147012. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  147013. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  147014. */
  147015. get imageMode(): number;
  147016. /**
  147017. * Sets the current video mode for the video. It can be:
  147018. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  147019. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  147020. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  147021. */
  147022. set imageMode(value: number);
  147023. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  147024. }
  147025. }
  147026. declare module BABYLON {
  147027. /**
  147028. * Direct draw surface info
  147029. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  147030. */
  147031. export interface DDSInfo {
  147032. /**
  147033. * Width of the texture
  147034. */
  147035. width: number;
  147036. /**
  147037. * Width of the texture
  147038. */
  147039. height: number;
  147040. /**
  147041. * Number of Mipmaps for the texture
  147042. * @see https://en.wikipedia.org/wiki/Mipmap
  147043. */
  147044. mipmapCount: number;
  147045. /**
  147046. * If the textures format is a known fourCC format
  147047. * @see https://www.fourcc.org/
  147048. */
  147049. isFourCC: boolean;
  147050. /**
  147051. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  147052. */
  147053. isRGB: boolean;
  147054. /**
  147055. * If the texture is a lumincance format
  147056. */
  147057. isLuminance: boolean;
  147058. /**
  147059. * If this is a cube texture
  147060. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  147061. */
  147062. isCube: boolean;
  147063. /**
  147064. * If the texture is a compressed format eg. FOURCC_DXT1
  147065. */
  147066. isCompressed: boolean;
  147067. /**
  147068. * The dxgiFormat of the texture
  147069. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  147070. */
  147071. dxgiFormat: number;
  147072. /**
  147073. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  147074. */
  147075. textureType: number;
  147076. /**
  147077. * Sphericle polynomial created for the dds texture
  147078. */
  147079. sphericalPolynomial?: SphericalPolynomial;
  147080. }
  147081. /**
  147082. * Class used to provide DDS decompression tools
  147083. */
  147084. export class DDSTools {
  147085. /**
  147086. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  147087. */
  147088. static StoreLODInAlphaChannel: boolean;
  147089. /**
  147090. * Gets DDS information from an array buffer
  147091. * @param data defines the array buffer view to read data from
  147092. * @returns the DDS information
  147093. */
  147094. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  147095. private static _FloatView;
  147096. private static _Int32View;
  147097. private static _ToHalfFloat;
  147098. private static _FromHalfFloat;
  147099. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  147100. private static _GetHalfFloatRGBAArrayBuffer;
  147101. private static _GetFloatRGBAArrayBuffer;
  147102. private static _GetFloatAsUIntRGBAArrayBuffer;
  147103. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  147104. private static _GetRGBAArrayBuffer;
  147105. private static _ExtractLongWordOrder;
  147106. private static _GetRGBArrayBuffer;
  147107. private static _GetLuminanceArrayBuffer;
  147108. /**
  147109. * Uploads DDS Levels to a Babylon Texture
  147110. * @hidden
  147111. */
  147112. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  147113. }
  147114. interface ThinEngine {
  147115. /**
  147116. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  147117. * @param rootUrl defines the url where the file to load is located
  147118. * @param scene defines the current scene
  147119. * @param lodScale defines scale to apply to the mip map selection
  147120. * @param lodOffset defines offset to apply to the mip map selection
  147121. * @param onLoad defines an optional callback raised when the texture is loaded
  147122. * @param onError defines an optional callback raised if there is an issue to load the texture
  147123. * @param format defines the format of the data
  147124. * @param forcedExtension defines the extension to use to pick the right loader
  147125. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  147126. * @returns the cube texture as an InternalTexture
  147127. */
  147128. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  147129. }
  147130. }
  147131. declare module BABYLON {
  147132. /**
  147133. * Implementation of the DDS Texture Loader.
  147134. * @hidden
  147135. */
  147136. export class _DDSTextureLoader implements IInternalTextureLoader {
  147137. /**
  147138. * Defines wether the loader supports cascade loading the different faces.
  147139. */
  147140. readonly supportCascades: boolean;
  147141. /**
  147142. * This returns if the loader support the current file information.
  147143. * @param extension defines the file extension of the file being loaded
  147144. * @returns true if the loader can load the specified file
  147145. */
  147146. canLoad(extension: string): boolean;
  147147. /**
  147148. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  147149. * @param data contains the texture data
  147150. * @param texture defines the BabylonJS internal texture
  147151. * @param createPolynomials will be true if polynomials have been requested
  147152. * @param onLoad defines the callback to trigger once the texture is ready
  147153. * @param onError defines the callback to trigger in case of error
  147154. */
  147155. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  147156. /**
  147157. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  147158. * @param data contains the texture data
  147159. * @param texture defines the BabylonJS internal texture
  147160. * @param callback defines the method to call once ready to upload
  147161. */
  147162. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  147163. }
  147164. }
  147165. declare module BABYLON {
  147166. /**
  147167. * Implementation of the ENV Texture Loader.
  147168. * @hidden
  147169. */
  147170. export class _ENVTextureLoader implements IInternalTextureLoader {
  147171. /**
  147172. * Defines wether the loader supports cascade loading the different faces.
  147173. */
  147174. readonly supportCascades: boolean;
  147175. /**
  147176. * This returns if the loader support the current file information.
  147177. * @param extension defines the file extension of the file being loaded
  147178. * @returns true if the loader can load the specified file
  147179. */
  147180. canLoad(extension: string): boolean;
  147181. /**
  147182. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  147183. * @param data contains the texture data
  147184. * @param texture defines the BabylonJS internal texture
  147185. * @param createPolynomials will be true if polynomials have been requested
  147186. * @param onLoad defines the callback to trigger once the texture is ready
  147187. * @param onError defines the callback to trigger in case of error
  147188. */
  147189. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  147190. /**
  147191. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  147192. * @param data contains the texture data
  147193. * @param texture defines the BabylonJS internal texture
  147194. * @param callback defines the method to call once ready to upload
  147195. */
  147196. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  147197. }
  147198. }
  147199. declare module BABYLON {
  147200. /**
  147201. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  147202. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  147203. */
  147204. export class KhronosTextureContainer {
  147205. /** contents of the KTX container file */
  147206. data: ArrayBufferView;
  147207. private static HEADER_LEN;
  147208. private static COMPRESSED_2D;
  147209. private static COMPRESSED_3D;
  147210. private static TEX_2D;
  147211. private static TEX_3D;
  147212. /**
  147213. * Gets the openGL type
  147214. */
  147215. glType: number;
  147216. /**
  147217. * Gets the openGL type size
  147218. */
  147219. glTypeSize: number;
  147220. /**
  147221. * Gets the openGL format
  147222. */
  147223. glFormat: number;
  147224. /**
  147225. * Gets the openGL internal format
  147226. */
  147227. glInternalFormat: number;
  147228. /**
  147229. * Gets the base internal format
  147230. */
  147231. glBaseInternalFormat: number;
  147232. /**
  147233. * Gets image width in pixel
  147234. */
  147235. pixelWidth: number;
  147236. /**
  147237. * Gets image height in pixel
  147238. */
  147239. pixelHeight: number;
  147240. /**
  147241. * Gets image depth in pixels
  147242. */
  147243. pixelDepth: number;
  147244. /**
  147245. * Gets the number of array elements
  147246. */
  147247. numberOfArrayElements: number;
  147248. /**
  147249. * Gets the number of faces
  147250. */
  147251. numberOfFaces: number;
  147252. /**
  147253. * Gets the number of mipmap levels
  147254. */
  147255. numberOfMipmapLevels: number;
  147256. /**
  147257. * Gets the bytes of key value data
  147258. */
  147259. bytesOfKeyValueData: number;
  147260. /**
  147261. * Gets the load type
  147262. */
  147263. loadType: number;
  147264. /**
  147265. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  147266. */
  147267. isInvalid: boolean;
  147268. /**
  147269. * Creates a new KhronosTextureContainer
  147270. * @param data contents of the KTX container file
  147271. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  147272. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  147273. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  147274. */
  147275. constructor(
  147276. /** contents of the KTX container file */
  147277. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  147278. /**
  147279. * Uploads KTX content to a Babylon Texture.
  147280. * It is assumed that the texture has already been created & is currently bound
  147281. * @hidden
  147282. */
  147283. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  147284. private _upload2DCompressedLevels;
  147285. /**
  147286. * Checks if the given data starts with a KTX file identifier.
  147287. * @param data the data to check
  147288. * @returns true if the data is a KTX file or false otherwise
  147289. */
  147290. static IsValid(data: ArrayBufferView): boolean;
  147291. }
  147292. }
  147293. declare module BABYLON {
  147294. /**
  147295. * Helper class to push actions to a pool of workers.
  147296. */
  147297. export class WorkerPool implements IDisposable {
  147298. private _workerInfos;
  147299. private _pendingActions;
  147300. /**
  147301. * Constructor
  147302. * @param workers Array of workers to use for actions
  147303. */
  147304. constructor(workers: Array<Worker>);
  147305. /**
  147306. * Terminates all workers and clears any pending actions.
  147307. */
  147308. dispose(): void;
  147309. /**
  147310. * Pushes an action to the worker pool. If all the workers are active, the action will be
  147311. * pended until a worker has completed its action.
  147312. * @param action The action to perform. Call onComplete when the action is complete.
  147313. */
  147314. push(action: (worker: Worker, onComplete: () => void) => void): void;
  147315. private _execute;
  147316. }
  147317. }
  147318. declare module BABYLON {
  147319. /**
  147320. * Class for loading KTX2 files
  147321. */
  147322. export class KhronosTextureContainer2 {
  147323. private static _WorkerPoolPromise?;
  147324. private static _Initialized;
  147325. private static _Ktx2Decoder;
  147326. /**
  147327. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  147328. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  147329. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  147330. * Urls you can change:
  147331. * URLConfig.jsDecoderModule
  147332. * URLConfig.wasmUASTCToASTC
  147333. * URLConfig.wasmUASTCToBC7
  147334. * URLConfig.wasmUASTCToRGBA_UNORM
  147335. * URLConfig.wasmUASTCToRGBA_SRGB
  147336. * URLConfig.jsMSCTranscoder
  147337. * URLConfig.wasmMSCTranscoder
  147338. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  147339. */
  147340. static URLConfig: {
  147341. jsDecoderModule: string;
  147342. wasmUASTCToASTC: null;
  147343. wasmUASTCToBC7: null;
  147344. wasmUASTCToRGBA_UNORM: null;
  147345. wasmUASTCToRGBA_SRGB: null;
  147346. jsMSCTranscoder: null;
  147347. wasmMSCTranscoder: null;
  147348. };
  147349. /**
  147350. * Default number of workers used to handle data decoding
  147351. */
  147352. static DefaultNumWorkers: number;
  147353. private static GetDefaultNumWorkers;
  147354. private _engine;
  147355. private static _CreateWorkerPool;
  147356. /**
  147357. * Constructor
  147358. * @param engine The engine to use
  147359. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147360. */
  147361. constructor(engine: ThinEngine, numWorkers?: number);
  147362. /** @hidden */
  147363. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  147364. /**
  147365. * Stop all async operations and release resources.
  147366. */
  147367. dispose(): void;
  147368. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  147369. /**
  147370. * Checks if the given data starts with a KTX2 file identifier.
  147371. * @param data the data to check
  147372. * @returns true if the data is a KTX2 file or false otherwise
  147373. */
  147374. static IsValid(data: ArrayBufferView): boolean;
  147375. }
  147376. }
  147377. declare module BABYLON {
  147378. /**
  147379. * Implementation of the KTX Texture Loader.
  147380. * @hidden
  147381. */
  147382. export class _KTXTextureLoader implements IInternalTextureLoader {
  147383. /**
  147384. * Defines wether the loader supports cascade loading the different faces.
  147385. */
  147386. readonly supportCascades: boolean;
  147387. /**
  147388. * This returns if the loader support the current file information.
  147389. * @param extension defines the file extension of the file being loaded
  147390. * @param mimeType defines the optional mime type of the file being loaded
  147391. * @returns true if the loader can load the specified file
  147392. */
  147393. canLoad(extension: string, mimeType?: string): boolean;
  147394. /**
  147395. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  147396. * @param data contains the texture data
  147397. * @param texture defines the BabylonJS internal texture
  147398. * @param createPolynomials will be true if polynomials have been requested
  147399. * @param onLoad defines the callback to trigger once the texture is ready
  147400. * @param onError defines the callback to trigger in case of error
  147401. */
  147402. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  147403. /**
  147404. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  147405. * @param data contains the texture data
  147406. * @param texture defines the BabylonJS internal texture
  147407. * @param callback defines the method to call once ready to upload
  147408. */
  147409. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  147410. }
  147411. }
  147412. declare module BABYLON {
  147413. /** @hidden */
  147414. export var _forceSceneHelpersToBundle: boolean;
  147415. interface Scene {
  147416. /**
  147417. * Creates a default light for the scene.
  147418. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  147419. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  147420. */
  147421. createDefaultLight(replace?: boolean): void;
  147422. /**
  147423. * Creates a default camera for the scene.
  147424. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  147425. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  147426. * @param replace has default false, when true replaces the active camera in the scene
  147427. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  147428. */
  147429. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  147430. /**
  147431. * Creates a default camera and a default light.
  147432. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  147433. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  147434. * @param replace has the default false, when true replaces the active camera/light in the scene
  147435. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  147436. */
  147437. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  147438. /**
  147439. * Creates a new sky box
  147440. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  147441. * @param environmentTexture defines the texture to use as environment texture
  147442. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  147443. * @param scale defines the overall scale of the skybox
  147444. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  147445. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  147446. * @returns a new mesh holding the sky box
  147447. */
  147448. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  147449. /**
  147450. * Creates a new environment
  147451. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  147452. * @param options defines the options you can use to configure the environment
  147453. * @returns the new EnvironmentHelper
  147454. */
  147455. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  147456. /**
  147457. * Creates a new VREXperienceHelper
  147458. * @see https://doc.babylonjs.com/how_to/webvr_helper
  147459. * @param webVROptions defines the options used to create the new VREXperienceHelper
  147460. * @returns a new VREXperienceHelper
  147461. */
  147462. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  147463. /**
  147464. * Creates a new WebXRDefaultExperience
  147465. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  147466. * @param options experience options
  147467. * @returns a promise for a new WebXRDefaultExperience
  147468. */
  147469. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  147470. }
  147471. }
  147472. declare module BABYLON {
  147473. /**
  147474. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  147475. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  147476. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  147477. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  147478. */
  147479. export class VideoDome extends TextureDome<VideoTexture> {
  147480. /**
  147481. * Define the video source as a Monoscopic panoramic 360 video.
  147482. */
  147483. static readonly MODE_MONOSCOPIC: number;
  147484. /**
  147485. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  147486. */
  147487. static readonly MODE_TOPBOTTOM: number;
  147488. /**
  147489. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  147490. */
  147491. static readonly MODE_SIDEBYSIDE: number;
  147492. /**
  147493. * Get the video texture associated with this video dome
  147494. */
  147495. get videoTexture(): VideoTexture;
  147496. /**
  147497. * Get the video mode of this dome
  147498. */
  147499. get videoMode(): number;
  147500. /**
  147501. * Set the video mode of this dome.
  147502. * @see textureMode
  147503. */
  147504. set videoMode(value: number);
  147505. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  147506. }
  147507. }
  147508. declare module BABYLON {
  147509. /**
  147510. * This class can be used to get instrumentation data from a Babylon engine
  147511. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  147512. */
  147513. export class EngineInstrumentation implements IDisposable {
  147514. /**
  147515. * Define the instrumented engine.
  147516. */
  147517. engine: Engine;
  147518. private _captureGPUFrameTime;
  147519. private _gpuFrameTimeToken;
  147520. private _gpuFrameTime;
  147521. private _captureShaderCompilationTime;
  147522. private _shaderCompilationTime;
  147523. private _onBeginFrameObserver;
  147524. private _onEndFrameObserver;
  147525. private _onBeforeShaderCompilationObserver;
  147526. private _onAfterShaderCompilationObserver;
  147527. /**
  147528. * Gets the perf counter used for GPU frame time
  147529. */
  147530. get gpuFrameTimeCounter(): PerfCounter;
  147531. /**
  147532. * Gets the GPU frame time capture status
  147533. */
  147534. get captureGPUFrameTime(): boolean;
  147535. /**
  147536. * Enable or disable the GPU frame time capture
  147537. */
  147538. set captureGPUFrameTime(value: boolean);
  147539. /**
  147540. * Gets the perf counter used for shader compilation time
  147541. */
  147542. get shaderCompilationTimeCounter(): PerfCounter;
  147543. /**
  147544. * Gets the shader compilation time capture status
  147545. */
  147546. get captureShaderCompilationTime(): boolean;
  147547. /**
  147548. * Enable or disable the shader compilation time capture
  147549. */
  147550. set captureShaderCompilationTime(value: boolean);
  147551. /**
  147552. * Instantiates a new engine instrumentation.
  147553. * This class can be used to get instrumentation data from a Babylon engine
  147554. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  147555. * @param engine Defines the engine to instrument
  147556. */
  147557. constructor(
  147558. /**
  147559. * Define the instrumented engine.
  147560. */
  147561. engine: Engine);
  147562. /**
  147563. * Dispose and release associated resources.
  147564. */
  147565. dispose(): void;
  147566. }
  147567. }
  147568. declare module BABYLON {
  147569. /**
  147570. * This class can be used to get instrumentation data from a Babylon engine
  147571. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  147572. */
  147573. export class SceneInstrumentation implements IDisposable {
  147574. /**
  147575. * Defines the scene to instrument
  147576. */
  147577. scene: Scene;
  147578. private _captureActiveMeshesEvaluationTime;
  147579. private _activeMeshesEvaluationTime;
  147580. private _captureRenderTargetsRenderTime;
  147581. private _renderTargetsRenderTime;
  147582. private _captureFrameTime;
  147583. private _frameTime;
  147584. private _captureRenderTime;
  147585. private _renderTime;
  147586. private _captureInterFrameTime;
  147587. private _interFrameTime;
  147588. private _captureParticlesRenderTime;
  147589. private _particlesRenderTime;
  147590. private _captureSpritesRenderTime;
  147591. private _spritesRenderTime;
  147592. private _capturePhysicsTime;
  147593. private _physicsTime;
  147594. private _captureAnimationsTime;
  147595. private _animationsTime;
  147596. private _captureCameraRenderTime;
  147597. private _cameraRenderTime;
  147598. private _onBeforeActiveMeshesEvaluationObserver;
  147599. private _onAfterActiveMeshesEvaluationObserver;
  147600. private _onBeforeRenderTargetsRenderObserver;
  147601. private _onAfterRenderTargetsRenderObserver;
  147602. private _onAfterRenderObserver;
  147603. private _onBeforeDrawPhaseObserver;
  147604. private _onAfterDrawPhaseObserver;
  147605. private _onBeforeAnimationsObserver;
  147606. private _onBeforeParticlesRenderingObserver;
  147607. private _onAfterParticlesRenderingObserver;
  147608. private _onBeforeSpritesRenderingObserver;
  147609. private _onAfterSpritesRenderingObserver;
  147610. private _onBeforePhysicsObserver;
  147611. private _onAfterPhysicsObserver;
  147612. private _onAfterAnimationsObserver;
  147613. private _onBeforeCameraRenderObserver;
  147614. private _onAfterCameraRenderObserver;
  147615. /**
  147616. * Gets the perf counter used for active meshes evaluation time
  147617. */
  147618. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  147619. /**
  147620. * Gets the active meshes evaluation time capture status
  147621. */
  147622. get captureActiveMeshesEvaluationTime(): boolean;
  147623. /**
  147624. * Enable or disable the active meshes evaluation time capture
  147625. */
  147626. set captureActiveMeshesEvaluationTime(value: boolean);
  147627. /**
  147628. * Gets the perf counter used for render targets render time
  147629. */
  147630. get renderTargetsRenderTimeCounter(): PerfCounter;
  147631. /**
  147632. * Gets the render targets render time capture status
  147633. */
  147634. get captureRenderTargetsRenderTime(): boolean;
  147635. /**
  147636. * Enable or disable the render targets render time capture
  147637. */
  147638. set captureRenderTargetsRenderTime(value: boolean);
  147639. /**
  147640. * Gets the perf counter used for particles render time
  147641. */
  147642. get particlesRenderTimeCounter(): PerfCounter;
  147643. /**
  147644. * Gets the particles render time capture status
  147645. */
  147646. get captureParticlesRenderTime(): boolean;
  147647. /**
  147648. * Enable or disable the particles render time capture
  147649. */
  147650. set captureParticlesRenderTime(value: boolean);
  147651. /**
  147652. * Gets the perf counter used for sprites render time
  147653. */
  147654. get spritesRenderTimeCounter(): PerfCounter;
  147655. /**
  147656. * Gets the sprites render time capture status
  147657. */
  147658. get captureSpritesRenderTime(): boolean;
  147659. /**
  147660. * Enable or disable the sprites render time capture
  147661. */
  147662. set captureSpritesRenderTime(value: boolean);
  147663. /**
  147664. * Gets the perf counter used for physics time
  147665. */
  147666. get physicsTimeCounter(): PerfCounter;
  147667. /**
  147668. * Gets the physics time capture status
  147669. */
  147670. get capturePhysicsTime(): boolean;
  147671. /**
  147672. * Enable or disable the physics time capture
  147673. */
  147674. set capturePhysicsTime(value: boolean);
  147675. /**
  147676. * Gets the perf counter used for animations time
  147677. */
  147678. get animationsTimeCounter(): PerfCounter;
  147679. /**
  147680. * Gets the animations time capture status
  147681. */
  147682. get captureAnimationsTime(): boolean;
  147683. /**
  147684. * Enable or disable the animations time capture
  147685. */
  147686. set captureAnimationsTime(value: boolean);
  147687. /**
  147688. * Gets the perf counter used for frame time capture
  147689. */
  147690. get frameTimeCounter(): PerfCounter;
  147691. /**
  147692. * Gets the frame time capture status
  147693. */
  147694. get captureFrameTime(): boolean;
  147695. /**
  147696. * Enable or disable the frame time capture
  147697. */
  147698. set captureFrameTime(value: boolean);
  147699. /**
  147700. * Gets the perf counter used for inter-frames time capture
  147701. */
  147702. get interFrameTimeCounter(): PerfCounter;
  147703. /**
  147704. * Gets the inter-frames time capture status
  147705. */
  147706. get captureInterFrameTime(): boolean;
  147707. /**
  147708. * Enable or disable the inter-frames time capture
  147709. */
  147710. set captureInterFrameTime(value: boolean);
  147711. /**
  147712. * Gets the perf counter used for render time capture
  147713. */
  147714. get renderTimeCounter(): PerfCounter;
  147715. /**
  147716. * Gets the render time capture status
  147717. */
  147718. get captureRenderTime(): boolean;
  147719. /**
  147720. * Enable or disable the render time capture
  147721. */
  147722. set captureRenderTime(value: boolean);
  147723. /**
  147724. * Gets the perf counter used for camera render time capture
  147725. */
  147726. get cameraRenderTimeCounter(): PerfCounter;
  147727. /**
  147728. * Gets the camera render time capture status
  147729. */
  147730. get captureCameraRenderTime(): boolean;
  147731. /**
  147732. * Enable or disable the camera render time capture
  147733. */
  147734. set captureCameraRenderTime(value: boolean);
  147735. /**
  147736. * Gets the perf counter used for draw calls
  147737. */
  147738. get drawCallsCounter(): PerfCounter;
  147739. /**
  147740. * Instantiates a new scene instrumentation.
  147741. * This class can be used to get instrumentation data from a Babylon engine
  147742. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  147743. * @param scene Defines the scene to instrument
  147744. */
  147745. constructor(
  147746. /**
  147747. * Defines the scene to instrument
  147748. */
  147749. scene: Scene);
  147750. /**
  147751. * Dispose and release associated resources.
  147752. */
  147753. dispose(): void;
  147754. }
  147755. }
  147756. declare module BABYLON {
  147757. /** @hidden */
  147758. export var glowMapGenerationPixelShader: {
  147759. name: string;
  147760. shader: string;
  147761. };
  147762. }
  147763. declare module BABYLON {
  147764. /** @hidden */
  147765. export var glowMapGenerationVertexShader: {
  147766. name: string;
  147767. shader: string;
  147768. };
  147769. }
  147770. declare module BABYLON {
  147771. /**
  147772. * Effect layer options. This helps customizing the behaviour
  147773. * of the effect layer.
  147774. */
  147775. export interface IEffectLayerOptions {
  147776. /**
  147777. * Multiplication factor apply to the canvas size to compute the render target size
  147778. * used to generated the objects (the smaller the faster).
  147779. */
  147780. mainTextureRatio: number;
  147781. /**
  147782. * Enforces a fixed size texture to ensure effect stability across devices.
  147783. */
  147784. mainTextureFixedSize?: number;
  147785. /**
  147786. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  147787. */
  147788. alphaBlendingMode: number;
  147789. /**
  147790. * The camera attached to the layer.
  147791. */
  147792. camera: Nullable<Camera>;
  147793. /**
  147794. * The rendering group to draw the layer in.
  147795. */
  147796. renderingGroupId: number;
  147797. }
  147798. /**
  147799. * The effect layer Helps adding post process effect blended with the main pass.
  147800. *
  147801. * This can be for instance use to generate glow or higlight effects on the scene.
  147802. *
  147803. * The effect layer class can not be used directly and is intented to inherited from to be
  147804. * customized per effects.
  147805. */
  147806. export abstract class EffectLayer {
  147807. private _vertexBuffers;
  147808. private _indexBuffer;
  147809. private _cachedDefines;
  147810. private _effectLayerMapGenerationEffect;
  147811. private _effectLayerOptions;
  147812. private _mergeEffect;
  147813. protected _scene: Scene;
  147814. protected _engine: Engine;
  147815. protected _maxSize: number;
  147816. protected _mainTextureDesiredSize: ISize;
  147817. protected _mainTexture: RenderTargetTexture;
  147818. protected _shouldRender: boolean;
  147819. protected _postProcesses: PostProcess[];
  147820. protected _textures: BaseTexture[];
  147821. protected _emissiveTextureAndColor: {
  147822. texture: Nullable<BaseTexture>;
  147823. color: Color4;
  147824. };
  147825. /**
  147826. * The name of the layer
  147827. */
  147828. name: string;
  147829. /**
  147830. * The clear color of the texture used to generate the glow map.
  147831. */
  147832. neutralColor: Color4;
  147833. /**
  147834. * Specifies whether the highlight layer is enabled or not.
  147835. */
  147836. isEnabled: boolean;
  147837. /**
  147838. * Gets the camera attached to the layer.
  147839. */
  147840. get camera(): Nullable<Camera>;
  147841. /**
  147842. * Gets the rendering group id the layer should render in.
  147843. */
  147844. get renderingGroupId(): number;
  147845. set renderingGroupId(renderingGroupId: number);
  147846. /**
  147847. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  147848. */
  147849. disableBoundingBoxesFromEffectLayer: boolean;
  147850. /**
  147851. * An event triggered when the effect layer has been disposed.
  147852. */
  147853. onDisposeObservable: Observable<EffectLayer>;
  147854. /**
  147855. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  147856. */
  147857. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  147858. /**
  147859. * An event triggered when the generated texture is being merged in the scene.
  147860. */
  147861. onBeforeComposeObservable: Observable<EffectLayer>;
  147862. /**
  147863. * An event triggered when the mesh is rendered into the effect render target.
  147864. */
  147865. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  147866. /**
  147867. * An event triggered after the mesh has been rendered into the effect render target.
  147868. */
  147869. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  147870. /**
  147871. * An event triggered when the generated texture has been merged in the scene.
  147872. */
  147873. onAfterComposeObservable: Observable<EffectLayer>;
  147874. /**
  147875. * An event triggered when the efffect layer changes its size.
  147876. */
  147877. onSizeChangedObservable: Observable<EffectLayer>;
  147878. /** @hidden */
  147879. static _SceneComponentInitialization: (scene: Scene) => void;
  147880. /**
  147881. * Instantiates a new effect Layer and references it in the scene.
  147882. * @param name The name of the layer
  147883. * @param scene The scene to use the layer in
  147884. */
  147885. constructor(
  147886. /** The Friendly of the effect in the scene */
  147887. name: string, scene: Scene);
  147888. /**
  147889. * Get the effect name of the layer.
  147890. * @return The effect name
  147891. */
  147892. abstract getEffectName(): string;
  147893. /**
  147894. * Checks for the readiness of the element composing the layer.
  147895. * @param subMesh the mesh to check for
  147896. * @param useInstances specify whether or not to use instances to render the mesh
  147897. * @return true if ready otherwise, false
  147898. */
  147899. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147900. /**
  147901. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  147902. * @returns true if the effect requires stencil during the main canvas render pass.
  147903. */
  147904. abstract needStencil(): boolean;
  147905. /**
  147906. * Create the merge effect. This is the shader use to blit the information back
  147907. * to the main canvas at the end of the scene rendering.
  147908. * @returns The effect containing the shader used to merge the effect on the main canvas
  147909. */
  147910. protected abstract _createMergeEffect(): Effect;
  147911. /**
  147912. * Creates the render target textures and post processes used in the effect layer.
  147913. */
  147914. protected abstract _createTextureAndPostProcesses(): void;
  147915. /**
  147916. * Implementation specific of rendering the generating effect on the main canvas.
  147917. * @param effect The effect used to render through
  147918. */
  147919. protected abstract _internalRender(effect: Effect): void;
  147920. /**
  147921. * Sets the required values for both the emissive texture and and the main color.
  147922. */
  147923. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147924. /**
  147925. * Free any resources and references associated to a mesh.
  147926. * Internal use
  147927. * @param mesh The mesh to free.
  147928. */
  147929. abstract _disposeMesh(mesh: Mesh): void;
  147930. /**
  147931. * Serializes this layer (Glow or Highlight for example)
  147932. * @returns a serialized layer object
  147933. */
  147934. abstract serialize?(): any;
  147935. /**
  147936. * Initializes the effect layer with the required options.
  147937. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  147938. */
  147939. protected _init(options: Partial<IEffectLayerOptions>): void;
  147940. /**
  147941. * Generates the index buffer of the full screen quad blending to the main canvas.
  147942. */
  147943. private _generateIndexBuffer;
  147944. /**
  147945. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  147946. */
  147947. private _generateVertexBuffer;
  147948. /**
  147949. * Sets the main texture desired size which is the closest power of two
  147950. * of the engine canvas size.
  147951. */
  147952. private _setMainTextureSize;
  147953. /**
  147954. * Creates the main texture for the effect layer.
  147955. */
  147956. protected _createMainTexture(): void;
  147957. /**
  147958. * Adds specific effects defines.
  147959. * @param defines The defines to add specifics to.
  147960. */
  147961. protected _addCustomEffectDefines(defines: string[]): void;
  147962. /**
  147963. * Checks for the readiness of the element composing the layer.
  147964. * @param subMesh the mesh to check for
  147965. * @param useInstances specify whether or not to use instances to render the mesh
  147966. * @param emissiveTexture the associated emissive texture used to generate the glow
  147967. * @return true if ready otherwise, false
  147968. */
  147969. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  147970. /**
  147971. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  147972. */
  147973. render(): void;
  147974. /**
  147975. * Determine if a given mesh will be used in the current effect.
  147976. * @param mesh mesh to test
  147977. * @returns true if the mesh will be used
  147978. */
  147979. hasMesh(mesh: AbstractMesh): boolean;
  147980. /**
  147981. * Returns true if the layer contains information to display, otherwise false.
  147982. * @returns true if the glow layer should be rendered
  147983. */
  147984. shouldRender(): boolean;
  147985. /**
  147986. * Returns true if the mesh should render, otherwise false.
  147987. * @param mesh The mesh to render
  147988. * @returns true if it should render otherwise false
  147989. */
  147990. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  147991. /**
  147992. * Returns true if the mesh can be rendered, otherwise false.
  147993. * @param mesh The mesh to render
  147994. * @param material The material used on the mesh
  147995. * @returns true if it can be rendered otherwise false
  147996. */
  147997. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147998. /**
  147999. * Returns true if the mesh should render, otherwise false.
  148000. * @param mesh The mesh to render
  148001. * @returns true if it should render otherwise false
  148002. */
  148003. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  148004. /**
  148005. * Renders the submesh passed in parameter to the generation map.
  148006. */
  148007. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  148008. /**
  148009. * Defines whether the current material of the mesh should be use to render the effect.
  148010. * @param mesh defines the current mesh to render
  148011. */
  148012. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  148013. /**
  148014. * Rebuild the required buffers.
  148015. * @hidden Internal use only.
  148016. */
  148017. _rebuild(): void;
  148018. /**
  148019. * Dispose only the render target textures and post process.
  148020. */
  148021. private _disposeTextureAndPostProcesses;
  148022. /**
  148023. * Dispose the highlight layer and free resources.
  148024. */
  148025. dispose(): void;
  148026. /**
  148027. * Gets the class name of the effect layer
  148028. * @returns the string with the class name of the effect layer
  148029. */
  148030. getClassName(): string;
  148031. /**
  148032. * Creates an effect layer from parsed effect layer data
  148033. * @param parsedEffectLayer defines effect layer data
  148034. * @param scene defines the current scene
  148035. * @param rootUrl defines the root URL containing the effect layer information
  148036. * @returns a parsed effect Layer
  148037. */
  148038. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  148039. }
  148040. }
  148041. declare module BABYLON {
  148042. interface AbstractScene {
  148043. /**
  148044. * The list of effect layers (highlights/glow) added to the scene
  148045. * @see https://doc.babylonjs.com/how_to/highlight_layer
  148046. * @see https://doc.babylonjs.com/how_to/glow_layer
  148047. */
  148048. effectLayers: Array<EffectLayer>;
  148049. /**
  148050. * Removes the given effect layer from this scene.
  148051. * @param toRemove defines the effect layer to remove
  148052. * @returns the index of the removed effect layer
  148053. */
  148054. removeEffectLayer(toRemove: EffectLayer): number;
  148055. /**
  148056. * Adds the given effect layer to this scene
  148057. * @param newEffectLayer defines the effect layer to add
  148058. */
  148059. addEffectLayer(newEffectLayer: EffectLayer): void;
  148060. }
  148061. /**
  148062. * Defines the layer scene component responsible to manage any effect layers
  148063. * in a given scene.
  148064. */
  148065. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  148066. /**
  148067. * The component name helpfull to identify the component in the list of scene components.
  148068. */
  148069. readonly name: string;
  148070. /**
  148071. * The scene the component belongs to.
  148072. */
  148073. scene: Scene;
  148074. private _engine;
  148075. private _renderEffects;
  148076. private _needStencil;
  148077. private _previousStencilState;
  148078. /**
  148079. * Creates a new instance of the component for the given scene
  148080. * @param scene Defines the scene to register the component in
  148081. */
  148082. constructor(scene: Scene);
  148083. /**
  148084. * Registers the component in a given scene
  148085. */
  148086. register(): void;
  148087. /**
  148088. * Rebuilds the elements related to this component in case of
  148089. * context lost for instance.
  148090. */
  148091. rebuild(): void;
  148092. /**
  148093. * Serializes the component data to the specified json object
  148094. * @param serializationObject The object to serialize to
  148095. */
  148096. serialize(serializationObject: any): void;
  148097. /**
  148098. * Adds all the elements from the container to the scene
  148099. * @param container the container holding the elements
  148100. */
  148101. addFromContainer(container: AbstractScene): void;
  148102. /**
  148103. * Removes all the elements in the container from the scene
  148104. * @param container contains the elements to remove
  148105. * @param dispose if the removed element should be disposed (default: false)
  148106. */
  148107. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148108. /**
  148109. * Disposes the component and the associated ressources.
  148110. */
  148111. dispose(): void;
  148112. private _isReadyForMesh;
  148113. private _renderMainTexture;
  148114. private _setStencil;
  148115. private _setStencilBack;
  148116. private _draw;
  148117. private _drawCamera;
  148118. private _drawRenderingGroup;
  148119. }
  148120. }
  148121. declare module BABYLON {
  148122. /** @hidden */
  148123. export var glowMapMergePixelShader: {
  148124. name: string;
  148125. shader: string;
  148126. };
  148127. }
  148128. declare module BABYLON {
  148129. /** @hidden */
  148130. export var glowMapMergeVertexShader: {
  148131. name: string;
  148132. shader: string;
  148133. };
  148134. }
  148135. declare module BABYLON {
  148136. interface AbstractScene {
  148137. /**
  148138. * Return a the first highlight layer of the scene with a given name.
  148139. * @param name The name of the highlight layer to look for.
  148140. * @return The highlight layer if found otherwise null.
  148141. */
  148142. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  148143. }
  148144. /**
  148145. * Glow layer options. This helps customizing the behaviour
  148146. * of the glow layer.
  148147. */
  148148. export interface IGlowLayerOptions {
  148149. /**
  148150. * Multiplication factor apply to the canvas size to compute the render target size
  148151. * used to generated the glowing objects (the smaller the faster).
  148152. */
  148153. mainTextureRatio: number;
  148154. /**
  148155. * Enforces a fixed size texture to ensure resize independant blur.
  148156. */
  148157. mainTextureFixedSize?: number;
  148158. /**
  148159. * How big is the kernel of the blur texture.
  148160. */
  148161. blurKernelSize: number;
  148162. /**
  148163. * The camera attached to the layer.
  148164. */
  148165. camera: Nullable<Camera>;
  148166. /**
  148167. * Enable MSAA by chosing the number of samples.
  148168. */
  148169. mainTextureSamples?: number;
  148170. /**
  148171. * The rendering group to draw the layer in.
  148172. */
  148173. renderingGroupId: number;
  148174. }
  148175. /**
  148176. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  148177. *
  148178. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  148179. *
  148180. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  148181. */
  148182. export class GlowLayer extends EffectLayer {
  148183. /**
  148184. * Effect Name of the layer.
  148185. */
  148186. static readonly EffectName: string;
  148187. /**
  148188. * The default blur kernel size used for the glow.
  148189. */
  148190. static DefaultBlurKernelSize: number;
  148191. /**
  148192. * The default texture size ratio used for the glow.
  148193. */
  148194. static DefaultTextureRatio: number;
  148195. /**
  148196. * Sets the kernel size of the blur.
  148197. */
  148198. set blurKernelSize(value: number);
  148199. /**
  148200. * Gets the kernel size of the blur.
  148201. */
  148202. get blurKernelSize(): number;
  148203. /**
  148204. * Sets the glow intensity.
  148205. */
  148206. set intensity(value: number);
  148207. /**
  148208. * Gets the glow intensity.
  148209. */
  148210. get intensity(): number;
  148211. private _options;
  148212. private _intensity;
  148213. private _horizontalBlurPostprocess1;
  148214. private _verticalBlurPostprocess1;
  148215. private _horizontalBlurPostprocess2;
  148216. private _verticalBlurPostprocess2;
  148217. private _blurTexture1;
  148218. private _blurTexture2;
  148219. private _postProcesses1;
  148220. private _postProcesses2;
  148221. private _includedOnlyMeshes;
  148222. private _excludedMeshes;
  148223. private _meshesUsingTheirOwnMaterials;
  148224. /**
  148225. * Callback used to let the user override the color selection on a per mesh basis
  148226. */
  148227. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  148228. /**
  148229. * Callback used to let the user override the texture selection on a per mesh basis
  148230. */
  148231. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  148232. /**
  148233. * Instantiates a new glow Layer and references it to the scene.
  148234. * @param name The name of the layer
  148235. * @param scene The scene to use the layer in
  148236. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  148237. */
  148238. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  148239. /**
  148240. * Get the effect name of the layer.
  148241. * @return The effect name
  148242. */
  148243. getEffectName(): string;
  148244. /**
  148245. * Create the merge effect. This is the shader use to blit the information back
  148246. * to the main canvas at the end of the scene rendering.
  148247. */
  148248. protected _createMergeEffect(): Effect;
  148249. /**
  148250. * Creates the render target textures and post processes used in the glow layer.
  148251. */
  148252. protected _createTextureAndPostProcesses(): void;
  148253. /**
  148254. * Checks for the readiness of the element composing the layer.
  148255. * @param subMesh the mesh to check for
  148256. * @param useInstances specify wether or not to use instances to render the mesh
  148257. * @param emissiveTexture the associated emissive texture used to generate the glow
  148258. * @return true if ready otherwise, false
  148259. */
  148260. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148261. /**
  148262. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  148263. */
  148264. needStencil(): boolean;
  148265. /**
  148266. * Returns true if the mesh can be rendered, otherwise false.
  148267. * @param mesh The mesh to render
  148268. * @param material The material used on the mesh
  148269. * @returns true if it can be rendered otherwise false
  148270. */
  148271. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  148272. /**
  148273. * Implementation specific of rendering the generating effect on the main canvas.
  148274. * @param effect The effect used to render through
  148275. */
  148276. protected _internalRender(effect: Effect): void;
  148277. /**
  148278. * Sets the required values for both the emissive texture and and the main color.
  148279. */
  148280. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  148281. /**
  148282. * Returns true if the mesh should render, otherwise false.
  148283. * @param mesh The mesh to render
  148284. * @returns true if it should render otherwise false
  148285. */
  148286. protected _shouldRenderMesh(mesh: Mesh): boolean;
  148287. /**
  148288. * Adds specific effects defines.
  148289. * @param defines The defines to add specifics to.
  148290. */
  148291. protected _addCustomEffectDefines(defines: string[]): void;
  148292. /**
  148293. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  148294. * @param mesh The mesh to exclude from the glow layer
  148295. */
  148296. addExcludedMesh(mesh: Mesh): void;
  148297. /**
  148298. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  148299. * @param mesh The mesh to remove
  148300. */
  148301. removeExcludedMesh(mesh: Mesh): void;
  148302. /**
  148303. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  148304. * @param mesh The mesh to include in the glow layer
  148305. */
  148306. addIncludedOnlyMesh(mesh: Mesh): void;
  148307. /**
  148308. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  148309. * @param mesh The mesh to remove
  148310. */
  148311. removeIncludedOnlyMesh(mesh: Mesh): void;
  148312. /**
  148313. * Determine if a given mesh will be used in the glow layer
  148314. * @param mesh The mesh to test
  148315. * @returns true if the mesh will be highlighted by the current glow layer
  148316. */
  148317. hasMesh(mesh: AbstractMesh): boolean;
  148318. /**
  148319. * Defines whether the current material of the mesh should be use to render the effect.
  148320. * @param mesh defines the current mesh to render
  148321. */
  148322. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  148323. /**
  148324. * Add a mesh to be rendered through its own material and not with emissive only.
  148325. * @param mesh The mesh for which we need to use its material
  148326. */
  148327. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  148328. /**
  148329. * Remove a mesh from being rendered through its own material and not with emissive only.
  148330. * @param mesh The mesh for which we need to not use its material
  148331. */
  148332. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  148333. /**
  148334. * Free any resources and references associated to a mesh.
  148335. * Internal use
  148336. * @param mesh The mesh to free.
  148337. * @hidden
  148338. */
  148339. _disposeMesh(mesh: Mesh): void;
  148340. /**
  148341. * Gets the class name of the effect layer
  148342. * @returns the string with the class name of the effect layer
  148343. */
  148344. getClassName(): string;
  148345. /**
  148346. * Serializes this glow layer
  148347. * @returns a serialized glow layer object
  148348. */
  148349. serialize(): any;
  148350. /**
  148351. * Creates a Glow Layer from parsed glow layer data
  148352. * @param parsedGlowLayer defines glow layer data
  148353. * @param scene defines the current scene
  148354. * @param rootUrl defines the root URL containing the glow layer information
  148355. * @returns a parsed Glow Layer
  148356. */
  148357. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  148358. }
  148359. }
  148360. declare module BABYLON {
  148361. /** @hidden */
  148362. export var glowBlurPostProcessPixelShader: {
  148363. name: string;
  148364. shader: string;
  148365. };
  148366. }
  148367. declare module BABYLON {
  148368. interface AbstractScene {
  148369. /**
  148370. * Return a the first highlight layer of the scene with a given name.
  148371. * @param name The name of the highlight layer to look for.
  148372. * @return The highlight layer if found otherwise null.
  148373. */
  148374. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  148375. }
  148376. /**
  148377. * Highlight layer options. This helps customizing the behaviour
  148378. * of the highlight layer.
  148379. */
  148380. export interface IHighlightLayerOptions {
  148381. /**
  148382. * Multiplication factor apply to the canvas size to compute the render target size
  148383. * used to generated the glowing objects (the smaller the faster).
  148384. */
  148385. mainTextureRatio: number;
  148386. /**
  148387. * Enforces a fixed size texture to ensure resize independant blur.
  148388. */
  148389. mainTextureFixedSize?: number;
  148390. /**
  148391. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  148392. * of the picture to blur (the smaller the faster).
  148393. */
  148394. blurTextureSizeRatio: number;
  148395. /**
  148396. * How big in texel of the blur texture is the vertical blur.
  148397. */
  148398. blurVerticalSize: number;
  148399. /**
  148400. * How big in texel of the blur texture is the horizontal blur.
  148401. */
  148402. blurHorizontalSize: number;
  148403. /**
  148404. * Alpha blending mode used to apply the blur. Default is combine.
  148405. */
  148406. alphaBlendingMode: number;
  148407. /**
  148408. * The camera attached to the layer.
  148409. */
  148410. camera: Nullable<Camera>;
  148411. /**
  148412. * Should we display highlight as a solid stroke?
  148413. */
  148414. isStroke?: boolean;
  148415. /**
  148416. * The rendering group to draw the layer in.
  148417. */
  148418. renderingGroupId: number;
  148419. }
  148420. /**
  148421. * The highlight layer Helps adding a glow effect around a mesh.
  148422. *
  148423. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  148424. * glowy meshes to your scene.
  148425. *
  148426. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  148427. */
  148428. export class HighlightLayer extends EffectLayer {
  148429. name: string;
  148430. /**
  148431. * Effect Name of the highlight layer.
  148432. */
  148433. static readonly EffectName: string;
  148434. /**
  148435. * The neutral color used during the preparation of the glow effect.
  148436. * This is black by default as the blend operation is a blend operation.
  148437. */
  148438. static NeutralColor: Color4;
  148439. /**
  148440. * Stencil value used for glowing meshes.
  148441. */
  148442. static GlowingMeshStencilReference: number;
  148443. /**
  148444. * Stencil value used for the other meshes in the scene.
  148445. */
  148446. static NormalMeshStencilReference: number;
  148447. /**
  148448. * Specifies whether or not the inner glow is ACTIVE in the layer.
  148449. */
  148450. innerGlow: boolean;
  148451. /**
  148452. * Specifies whether or not the outer glow is ACTIVE in the layer.
  148453. */
  148454. outerGlow: boolean;
  148455. /**
  148456. * Specifies the horizontal size of the blur.
  148457. */
  148458. set blurHorizontalSize(value: number);
  148459. /**
  148460. * Specifies the vertical size of the blur.
  148461. */
  148462. set blurVerticalSize(value: number);
  148463. /**
  148464. * Gets the horizontal size of the blur.
  148465. */
  148466. get blurHorizontalSize(): number;
  148467. /**
  148468. * Gets the vertical size of the blur.
  148469. */
  148470. get blurVerticalSize(): number;
  148471. /**
  148472. * An event triggered when the highlight layer is being blurred.
  148473. */
  148474. onBeforeBlurObservable: Observable<HighlightLayer>;
  148475. /**
  148476. * An event triggered when the highlight layer has been blurred.
  148477. */
  148478. onAfterBlurObservable: Observable<HighlightLayer>;
  148479. private _instanceGlowingMeshStencilReference;
  148480. private _options;
  148481. private _downSamplePostprocess;
  148482. private _horizontalBlurPostprocess;
  148483. private _verticalBlurPostprocess;
  148484. private _blurTexture;
  148485. private _meshes;
  148486. private _excludedMeshes;
  148487. /**
  148488. * Instantiates a new highlight Layer and references it to the scene..
  148489. * @param name The name of the layer
  148490. * @param scene The scene to use the layer in
  148491. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  148492. */
  148493. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  148494. /**
  148495. * Get the effect name of the layer.
  148496. * @return The effect name
  148497. */
  148498. getEffectName(): string;
  148499. /**
  148500. * Create the merge effect. This is the shader use to blit the information back
  148501. * to the main canvas at the end of the scene rendering.
  148502. */
  148503. protected _createMergeEffect(): Effect;
  148504. /**
  148505. * Creates the render target textures and post processes used in the highlight layer.
  148506. */
  148507. protected _createTextureAndPostProcesses(): void;
  148508. /**
  148509. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  148510. */
  148511. needStencil(): boolean;
  148512. /**
  148513. * Checks for the readiness of the element composing the layer.
  148514. * @param subMesh the mesh to check for
  148515. * @param useInstances specify wether or not to use instances to render the mesh
  148516. * @param emissiveTexture the associated emissive texture used to generate the glow
  148517. * @return true if ready otherwise, false
  148518. */
  148519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148520. /**
  148521. * Implementation specific of rendering the generating effect on the main canvas.
  148522. * @param effect The effect used to render through
  148523. */
  148524. protected _internalRender(effect: Effect): void;
  148525. /**
  148526. * Returns true if the layer contains information to display, otherwise false.
  148527. */
  148528. shouldRender(): boolean;
  148529. /**
  148530. * Returns true if the mesh should render, otherwise false.
  148531. * @param mesh The mesh to render
  148532. * @returns true if it should render otherwise false
  148533. */
  148534. protected _shouldRenderMesh(mesh: Mesh): boolean;
  148535. /**
  148536. * Returns true if the mesh can be rendered, otherwise false.
  148537. * @param mesh The mesh to render
  148538. * @param material The material used on the mesh
  148539. * @returns true if it can be rendered otherwise false
  148540. */
  148541. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  148542. /**
  148543. * Adds specific effects defines.
  148544. * @param defines The defines to add specifics to.
  148545. */
  148546. protected _addCustomEffectDefines(defines: string[]): void;
  148547. /**
  148548. * Sets the required values for both the emissive texture and and the main color.
  148549. */
  148550. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  148551. /**
  148552. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  148553. * @param mesh The mesh to exclude from the highlight layer
  148554. */
  148555. addExcludedMesh(mesh: Mesh): void;
  148556. /**
  148557. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  148558. * @param mesh The mesh to highlight
  148559. */
  148560. removeExcludedMesh(mesh: Mesh): void;
  148561. /**
  148562. * Determine if a given mesh will be highlighted by the current HighlightLayer
  148563. * @param mesh mesh to test
  148564. * @returns true if the mesh will be highlighted by the current HighlightLayer
  148565. */
  148566. hasMesh(mesh: AbstractMesh): boolean;
  148567. /**
  148568. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  148569. * @param mesh The mesh to highlight
  148570. * @param color The color of the highlight
  148571. * @param glowEmissiveOnly Extract the glow from the emissive texture
  148572. */
  148573. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  148574. /**
  148575. * Remove a mesh from the highlight layer in order to make it stop glowing.
  148576. * @param mesh The mesh to highlight
  148577. */
  148578. removeMesh(mesh: Mesh): void;
  148579. /**
  148580. * Remove all the meshes currently referenced in the highlight layer
  148581. */
  148582. removeAllMeshes(): void;
  148583. /**
  148584. * Force the stencil to the normal expected value for none glowing parts
  148585. */
  148586. private _defaultStencilReference;
  148587. /**
  148588. * Free any resources and references associated to a mesh.
  148589. * Internal use
  148590. * @param mesh The mesh to free.
  148591. * @hidden
  148592. */
  148593. _disposeMesh(mesh: Mesh): void;
  148594. /**
  148595. * Dispose the highlight layer and free resources.
  148596. */
  148597. dispose(): void;
  148598. /**
  148599. * Gets the class name of the effect layer
  148600. * @returns the string with the class name of the effect layer
  148601. */
  148602. getClassName(): string;
  148603. /**
  148604. * Serializes this Highlight layer
  148605. * @returns a serialized Highlight layer object
  148606. */
  148607. serialize(): any;
  148608. /**
  148609. * Creates a Highlight layer from parsed Highlight layer data
  148610. * @param parsedHightlightLayer defines the Highlight layer data
  148611. * @param scene defines the current scene
  148612. * @param rootUrl defines the root URL containing the Highlight layer information
  148613. * @returns a parsed Highlight layer
  148614. */
  148615. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  148616. }
  148617. }
  148618. declare module BABYLON {
  148619. interface AbstractScene {
  148620. /**
  148621. * The list of layers (background and foreground) of the scene
  148622. */
  148623. layers: Array<Layer>;
  148624. }
  148625. /**
  148626. * Defines the layer scene component responsible to manage any layers
  148627. * in a given scene.
  148628. */
  148629. export class LayerSceneComponent implements ISceneComponent {
  148630. /**
  148631. * The component name helpfull to identify the component in the list of scene components.
  148632. */
  148633. readonly name: string;
  148634. /**
  148635. * The scene the component belongs to.
  148636. */
  148637. scene: Scene;
  148638. private _engine;
  148639. /**
  148640. * Creates a new instance of the component for the given scene
  148641. * @param scene Defines the scene to register the component in
  148642. */
  148643. constructor(scene: Scene);
  148644. /**
  148645. * Registers the component in a given scene
  148646. */
  148647. register(): void;
  148648. /**
  148649. * Rebuilds the elements related to this component in case of
  148650. * context lost for instance.
  148651. */
  148652. rebuild(): void;
  148653. /**
  148654. * Disposes the component and the associated ressources.
  148655. */
  148656. dispose(): void;
  148657. private _draw;
  148658. private _drawCameraPredicate;
  148659. private _drawCameraBackground;
  148660. private _drawCameraForeground;
  148661. private _drawRenderTargetPredicate;
  148662. private _drawRenderTargetBackground;
  148663. private _drawRenderTargetForeground;
  148664. /**
  148665. * Adds all the elements from the container to the scene
  148666. * @param container the container holding the elements
  148667. */
  148668. addFromContainer(container: AbstractScene): void;
  148669. /**
  148670. * Removes all the elements in the container from the scene
  148671. * @param container contains the elements to remove
  148672. * @param dispose if the removed element should be disposed (default: false)
  148673. */
  148674. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148675. }
  148676. }
  148677. declare module BABYLON {
  148678. /** @hidden */
  148679. export var layerPixelShader: {
  148680. name: string;
  148681. shader: string;
  148682. };
  148683. }
  148684. declare module BABYLON {
  148685. /** @hidden */
  148686. export var layerVertexShader: {
  148687. name: string;
  148688. shader: string;
  148689. };
  148690. }
  148691. declare module BABYLON {
  148692. /**
  148693. * This represents a full screen 2d layer.
  148694. * This can be useful to display a picture in the background of your scene for instance.
  148695. * @see https://www.babylonjs-playground.com/#08A2BS#1
  148696. */
  148697. export class Layer {
  148698. /**
  148699. * Define the name of the layer.
  148700. */
  148701. name: string;
  148702. /**
  148703. * Define the texture the layer should display.
  148704. */
  148705. texture: Nullable<Texture>;
  148706. /**
  148707. * Is the layer in background or foreground.
  148708. */
  148709. isBackground: boolean;
  148710. /**
  148711. * Define the color of the layer (instead of texture).
  148712. */
  148713. color: Color4;
  148714. /**
  148715. * Define the scale of the layer in order to zoom in out of the texture.
  148716. */
  148717. scale: Vector2;
  148718. /**
  148719. * Define an offset for the layer in order to shift the texture.
  148720. */
  148721. offset: Vector2;
  148722. /**
  148723. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  148724. */
  148725. alphaBlendingMode: number;
  148726. /**
  148727. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  148728. * Alpha test will not mix with the background color in case of transparency.
  148729. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  148730. */
  148731. alphaTest: boolean;
  148732. /**
  148733. * Define a mask to restrict the layer to only some of the scene cameras.
  148734. */
  148735. layerMask: number;
  148736. /**
  148737. * Define the list of render target the layer is visible into.
  148738. */
  148739. renderTargetTextures: RenderTargetTexture[];
  148740. /**
  148741. * Define if the layer is only used in renderTarget or if it also
  148742. * renders in the main frame buffer of the canvas.
  148743. */
  148744. renderOnlyInRenderTargetTextures: boolean;
  148745. private _scene;
  148746. private _vertexBuffers;
  148747. private _indexBuffer;
  148748. private _effect;
  148749. private _previousDefines;
  148750. /**
  148751. * An event triggered when the layer is disposed.
  148752. */
  148753. onDisposeObservable: Observable<Layer>;
  148754. private _onDisposeObserver;
  148755. /**
  148756. * Back compatibility with callback before the onDisposeObservable existed.
  148757. * The set callback will be triggered when the layer has been disposed.
  148758. */
  148759. set onDispose(callback: () => void);
  148760. /**
  148761. * An event triggered before rendering the scene
  148762. */
  148763. onBeforeRenderObservable: Observable<Layer>;
  148764. private _onBeforeRenderObserver;
  148765. /**
  148766. * Back compatibility with callback before the onBeforeRenderObservable existed.
  148767. * The set callback will be triggered just before rendering the layer.
  148768. */
  148769. set onBeforeRender(callback: () => void);
  148770. /**
  148771. * An event triggered after rendering the scene
  148772. */
  148773. onAfterRenderObservable: Observable<Layer>;
  148774. private _onAfterRenderObserver;
  148775. /**
  148776. * Back compatibility with callback before the onAfterRenderObservable existed.
  148777. * The set callback will be triggered just after rendering the layer.
  148778. */
  148779. set onAfterRender(callback: () => void);
  148780. /**
  148781. * Instantiates a new layer.
  148782. * This represents a full screen 2d layer.
  148783. * This can be useful to display a picture in the background of your scene for instance.
  148784. * @see https://www.babylonjs-playground.com/#08A2BS#1
  148785. * @param name Define the name of the layer in the scene
  148786. * @param imgUrl Define the url of the texture to display in the layer
  148787. * @param scene Define the scene the layer belongs to
  148788. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  148789. * @param color Defines a color for the layer
  148790. */
  148791. constructor(
  148792. /**
  148793. * Define the name of the layer.
  148794. */
  148795. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  148796. private _createIndexBuffer;
  148797. /** @hidden */
  148798. _rebuild(): void;
  148799. /**
  148800. * Renders the layer in the scene.
  148801. */
  148802. render(): void;
  148803. /**
  148804. * Disposes and releases the associated ressources.
  148805. */
  148806. dispose(): void;
  148807. }
  148808. }
  148809. declare module BABYLON {
  148810. /** @hidden */
  148811. export var lensFlarePixelShader: {
  148812. name: string;
  148813. shader: string;
  148814. };
  148815. }
  148816. declare module BABYLON {
  148817. /** @hidden */
  148818. export var lensFlareVertexShader: {
  148819. name: string;
  148820. shader: string;
  148821. };
  148822. }
  148823. declare module BABYLON {
  148824. /**
  148825. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  148826. * It is usually composed of several `lensFlare`.
  148827. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148828. */
  148829. export class LensFlareSystem {
  148830. /**
  148831. * Define the name of the lens flare system
  148832. */
  148833. name: string;
  148834. /**
  148835. * List of lens flares used in this system.
  148836. */
  148837. lensFlares: LensFlare[];
  148838. /**
  148839. * Define a limit from the border the lens flare can be visible.
  148840. */
  148841. borderLimit: number;
  148842. /**
  148843. * Define a viewport border we do not want to see the lens flare in.
  148844. */
  148845. viewportBorder: number;
  148846. /**
  148847. * Define a predicate which could limit the list of meshes able to occlude the effect.
  148848. */
  148849. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  148850. /**
  148851. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  148852. */
  148853. layerMask: number;
  148854. /**
  148855. * Define the id of the lens flare system in the scene.
  148856. * (equal to name by default)
  148857. */
  148858. id: string;
  148859. private _scene;
  148860. private _emitter;
  148861. private _vertexBuffers;
  148862. private _indexBuffer;
  148863. private _effect;
  148864. private _positionX;
  148865. private _positionY;
  148866. private _isEnabled;
  148867. /** @hidden */
  148868. static _SceneComponentInitialization: (scene: Scene) => void;
  148869. /**
  148870. * Instantiates a lens flare system.
  148871. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  148872. * It is usually composed of several `lensFlare`.
  148873. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148874. * @param name Define the name of the lens flare system in the scene
  148875. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  148876. * @param scene Define the scene the lens flare system belongs to
  148877. */
  148878. constructor(
  148879. /**
  148880. * Define the name of the lens flare system
  148881. */
  148882. name: string, emitter: any, scene: Scene);
  148883. /**
  148884. * Define if the lens flare system is enabled.
  148885. */
  148886. get isEnabled(): boolean;
  148887. set isEnabled(value: boolean);
  148888. /**
  148889. * Get the scene the effects belongs to.
  148890. * @returns the scene holding the lens flare system
  148891. */
  148892. getScene(): Scene;
  148893. /**
  148894. * Get the emitter of the lens flare system.
  148895. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148896. * @returns the emitter of the lens flare system
  148897. */
  148898. getEmitter(): any;
  148899. /**
  148900. * Set the emitter of the lens flare system.
  148901. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148902. * @param newEmitter Define the new emitter of the system
  148903. */
  148904. setEmitter(newEmitter: any): void;
  148905. /**
  148906. * Get the lens flare system emitter position.
  148907. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  148908. * @returns the position
  148909. */
  148910. getEmitterPosition(): Vector3;
  148911. /**
  148912. * @hidden
  148913. */
  148914. computeEffectivePosition(globalViewport: Viewport): boolean;
  148915. /** @hidden */
  148916. _isVisible(): boolean;
  148917. /**
  148918. * @hidden
  148919. */
  148920. render(): boolean;
  148921. /**
  148922. * Dispose and release the lens flare with its associated resources.
  148923. */
  148924. dispose(): void;
  148925. /**
  148926. * Parse a lens flare system from a JSON repressentation
  148927. * @param parsedLensFlareSystem Define the JSON to parse
  148928. * @param scene Define the scene the parsed system should be instantiated in
  148929. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  148930. * @returns the parsed system
  148931. */
  148932. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  148933. /**
  148934. * Serialize the current Lens Flare System into a JSON representation.
  148935. * @returns the serialized JSON
  148936. */
  148937. serialize(): any;
  148938. }
  148939. }
  148940. declare module BABYLON {
  148941. /**
  148942. * This represents one of the lens effect in a `lensFlareSystem`.
  148943. * It controls one of the indiviual texture used in the effect.
  148944. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148945. */
  148946. export class LensFlare {
  148947. /**
  148948. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148949. */
  148950. size: number;
  148951. /**
  148952. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  148953. */
  148954. position: number;
  148955. /**
  148956. * Define the lens color.
  148957. */
  148958. color: Color3;
  148959. /**
  148960. * Define the lens texture.
  148961. */
  148962. texture: Nullable<Texture>;
  148963. /**
  148964. * Define the alpha mode to render this particular lens.
  148965. */
  148966. alphaMode: number;
  148967. private _system;
  148968. /**
  148969. * Creates a new Lens Flare.
  148970. * This represents one of the lens effect in a `lensFlareSystem`.
  148971. * It controls one of the indiviual texture used in the effect.
  148972. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148973. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  148974. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  148975. * @param color Define the lens color
  148976. * @param imgUrl Define the lens texture url
  148977. * @param system Define the `lensFlareSystem` this flare is part of
  148978. * @returns The newly created Lens Flare
  148979. */
  148980. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  148981. /**
  148982. * Instantiates a new Lens Flare.
  148983. * This represents one of the lens effect in a `lensFlareSystem`.
  148984. * It controls one of the indiviual texture used in the effect.
  148985. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148986. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  148987. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  148988. * @param color Define the lens color
  148989. * @param imgUrl Define the lens texture url
  148990. * @param system Define the `lensFlareSystem` this flare is part of
  148991. */
  148992. constructor(
  148993. /**
  148994. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148995. */
  148996. size: number,
  148997. /**
  148998. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  148999. */
  149000. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  149001. /**
  149002. * Dispose and release the lens flare with its associated resources.
  149003. */
  149004. dispose(): void;
  149005. }
  149006. }
  149007. declare module BABYLON {
  149008. interface AbstractScene {
  149009. /**
  149010. * The list of lens flare system added to the scene
  149011. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  149012. */
  149013. lensFlareSystems: Array<LensFlareSystem>;
  149014. /**
  149015. * Removes the given lens flare system from this scene.
  149016. * @param toRemove The lens flare system to remove
  149017. * @returns The index of the removed lens flare system
  149018. */
  149019. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  149020. /**
  149021. * Adds the given lens flare system to this scene
  149022. * @param newLensFlareSystem The lens flare system to add
  149023. */
  149024. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  149025. /**
  149026. * Gets a lens flare system using its name
  149027. * @param name defines the name to look for
  149028. * @returns the lens flare system or null if not found
  149029. */
  149030. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  149031. /**
  149032. * Gets a lens flare system using its id
  149033. * @param id defines the id to look for
  149034. * @returns the lens flare system or null if not found
  149035. */
  149036. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  149037. }
  149038. /**
  149039. * Defines the lens flare scene component responsible to manage any lens flares
  149040. * in a given scene.
  149041. */
  149042. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  149043. /**
  149044. * The component name helpfull to identify the component in the list of scene components.
  149045. */
  149046. readonly name: string;
  149047. /**
  149048. * The scene the component belongs to.
  149049. */
  149050. scene: Scene;
  149051. /**
  149052. * Creates a new instance of the component for the given scene
  149053. * @param scene Defines the scene to register the component in
  149054. */
  149055. constructor(scene: Scene);
  149056. /**
  149057. * Registers the component in a given scene
  149058. */
  149059. register(): void;
  149060. /**
  149061. * Rebuilds the elements related to this component in case of
  149062. * context lost for instance.
  149063. */
  149064. rebuild(): void;
  149065. /**
  149066. * Adds all the elements from the container to the scene
  149067. * @param container the container holding the elements
  149068. */
  149069. addFromContainer(container: AbstractScene): void;
  149070. /**
  149071. * Removes all the elements in the container from the scene
  149072. * @param container contains the elements to remove
  149073. * @param dispose if the removed element should be disposed (default: false)
  149074. */
  149075. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149076. /**
  149077. * Serializes the component data to the specified json object
  149078. * @param serializationObject The object to serialize to
  149079. */
  149080. serialize(serializationObject: any): void;
  149081. /**
  149082. * Disposes the component and the associated ressources.
  149083. */
  149084. dispose(): void;
  149085. private _draw;
  149086. }
  149087. }
  149088. declare module BABYLON {
  149089. /** @hidden */
  149090. export var depthPixelShader: {
  149091. name: string;
  149092. shader: string;
  149093. };
  149094. }
  149095. declare module BABYLON {
  149096. /** @hidden */
  149097. export var depthVertexShader: {
  149098. name: string;
  149099. shader: string;
  149100. };
  149101. }
  149102. declare module BABYLON {
  149103. /**
  149104. * This represents a depth renderer in Babylon.
  149105. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  149106. */
  149107. export class DepthRenderer {
  149108. private _scene;
  149109. private _depthMap;
  149110. private _effect;
  149111. private readonly _storeNonLinearDepth;
  149112. private readonly _clearColor;
  149113. /** Get if the depth renderer is using packed depth or not */
  149114. readonly isPacked: boolean;
  149115. private _cachedDefines;
  149116. private _camera;
  149117. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  149118. enabled: boolean;
  149119. /**
  149120. * Specifiess that the depth renderer will only be used within
  149121. * the camera it is created for.
  149122. * This can help forcing its rendering during the camera processing.
  149123. */
  149124. useOnlyInActiveCamera: boolean;
  149125. /** @hidden */
  149126. static _SceneComponentInitialization: (scene: Scene) => void;
  149127. /**
  149128. * Instantiates a depth renderer
  149129. * @param scene The scene the renderer belongs to
  149130. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  149131. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  149132. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  149133. */
  149134. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  149135. /**
  149136. * Creates the depth rendering effect and checks if the effect is ready.
  149137. * @param subMesh The submesh to be used to render the depth map of
  149138. * @param useInstances If multiple world instances should be used
  149139. * @returns if the depth renderer is ready to render the depth map
  149140. */
  149141. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149142. /**
  149143. * Gets the texture which the depth map will be written to.
  149144. * @returns The depth map texture
  149145. */
  149146. getDepthMap(): RenderTargetTexture;
  149147. /**
  149148. * Disposes of the depth renderer.
  149149. */
  149150. dispose(): void;
  149151. }
  149152. }
  149153. declare module BABYLON {
  149154. /** @hidden */
  149155. export var minmaxReduxPixelShader: {
  149156. name: string;
  149157. shader: string;
  149158. };
  149159. }
  149160. declare module BABYLON {
  149161. /**
  149162. * This class computes a min/max reduction from a texture: it means it computes the minimum
  149163. * and maximum values from all values of the texture.
  149164. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  149165. * The source values are read from the red channel of the texture.
  149166. */
  149167. export class MinMaxReducer {
  149168. /**
  149169. * Observable triggered when the computation has been performed
  149170. */
  149171. onAfterReductionPerformed: Observable<{
  149172. min: number;
  149173. max: number;
  149174. }>;
  149175. protected _camera: Camera;
  149176. protected _sourceTexture: Nullable<RenderTargetTexture>;
  149177. protected _reductionSteps: Nullable<Array<PostProcess>>;
  149178. protected _postProcessManager: PostProcessManager;
  149179. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  149180. protected _forceFullscreenViewport: boolean;
  149181. /**
  149182. * Creates a min/max reducer
  149183. * @param camera The camera to use for the post processes
  149184. */
  149185. constructor(camera: Camera);
  149186. /**
  149187. * Gets the texture used to read the values from.
  149188. */
  149189. get sourceTexture(): Nullable<RenderTargetTexture>;
  149190. /**
  149191. * Sets the source texture to read the values from.
  149192. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  149193. * because in such textures '1' value must not be taken into account to compute the maximum
  149194. * as this value is used to clear the texture.
  149195. * Note that the computation is not activated by calling this function, you must call activate() for that!
  149196. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  149197. * @param depthRedux Indicates if the texture is a depth texture or not
  149198. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  149199. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  149200. */
  149201. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  149202. /**
  149203. * Defines the refresh rate of the computation.
  149204. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  149205. */
  149206. get refreshRate(): number;
  149207. set refreshRate(value: number);
  149208. protected _activated: boolean;
  149209. /**
  149210. * Gets the activation status of the reducer
  149211. */
  149212. get activated(): boolean;
  149213. /**
  149214. * Activates the reduction computation.
  149215. * When activated, the observers registered in onAfterReductionPerformed are
  149216. * called after the compuation is performed
  149217. */
  149218. activate(): void;
  149219. /**
  149220. * Deactivates the reduction computation.
  149221. */
  149222. deactivate(): void;
  149223. /**
  149224. * Disposes the min/max reducer
  149225. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  149226. */
  149227. dispose(disposeAll?: boolean): void;
  149228. }
  149229. }
  149230. declare module BABYLON {
  149231. /**
  149232. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  149233. */
  149234. export class DepthReducer extends MinMaxReducer {
  149235. private _depthRenderer;
  149236. private _depthRendererId;
  149237. /**
  149238. * Gets the depth renderer used for the computation.
  149239. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  149240. */
  149241. get depthRenderer(): Nullable<DepthRenderer>;
  149242. /**
  149243. * Creates a depth reducer
  149244. * @param camera The camera used to render the depth texture
  149245. */
  149246. constructor(camera: Camera);
  149247. /**
  149248. * Sets the depth renderer to use to generate the depth map
  149249. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  149250. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  149251. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  149252. */
  149253. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  149254. /** @hidden */
  149255. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  149256. /**
  149257. * Activates the reduction computation.
  149258. * When activated, the observers registered in onAfterReductionPerformed are
  149259. * called after the compuation is performed
  149260. */
  149261. activate(): void;
  149262. /**
  149263. * Deactivates the reduction computation.
  149264. */
  149265. deactivate(): void;
  149266. /**
  149267. * Disposes the depth reducer
  149268. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  149269. */
  149270. dispose(disposeAll?: boolean): void;
  149271. }
  149272. }
  149273. declare module BABYLON {
  149274. /**
  149275. * A CSM implementation allowing casting shadows on large scenes.
  149276. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  149277. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  149278. */
  149279. export class CascadedShadowGenerator extends ShadowGenerator {
  149280. private static readonly frustumCornersNDCSpace;
  149281. /**
  149282. * Name of the CSM class
  149283. */
  149284. static CLASSNAME: string;
  149285. /**
  149286. * Defines the default number of cascades used by the CSM.
  149287. */
  149288. static readonly DEFAULT_CASCADES_COUNT: number;
  149289. /**
  149290. * Defines the minimum number of cascades used by the CSM.
  149291. */
  149292. static readonly MIN_CASCADES_COUNT: number;
  149293. /**
  149294. * Defines the maximum number of cascades used by the CSM.
  149295. */
  149296. static readonly MAX_CASCADES_COUNT: number;
  149297. protected _validateFilter(filter: number): number;
  149298. /**
  149299. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  149300. */
  149301. penumbraDarkness: number;
  149302. private _numCascades;
  149303. /**
  149304. * Gets or set the number of cascades used by the CSM.
  149305. */
  149306. get numCascades(): number;
  149307. set numCascades(value: number);
  149308. /**
  149309. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  149310. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  149311. */
  149312. stabilizeCascades: boolean;
  149313. private _freezeShadowCastersBoundingInfo;
  149314. private _freezeShadowCastersBoundingInfoObservable;
  149315. /**
  149316. * Enables or disables the shadow casters bounding info computation.
  149317. * If your shadow casters don't move, you can disable this feature.
  149318. * If it is enabled, the bounding box computation is done every frame.
  149319. */
  149320. get freezeShadowCastersBoundingInfo(): boolean;
  149321. set freezeShadowCastersBoundingInfo(freeze: boolean);
  149322. private _scbiMin;
  149323. private _scbiMax;
  149324. protected _computeShadowCastersBoundingInfo(): void;
  149325. protected _shadowCastersBoundingInfo: BoundingInfo;
  149326. /**
  149327. * Gets or sets the shadow casters bounding info.
  149328. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  149329. * so that the system won't overwrite the bounds you provide
  149330. */
  149331. get shadowCastersBoundingInfo(): BoundingInfo;
  149332. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  149333. protected _breaksAreDirty: boolean;
  149334. protected _minDistance: number;
  149335. protected _maxDistance: number;
  149336. /**
  149337. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  149338. *
  149339. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  149340. * If you don't know these values, simply leave them to their defaults and don't call this function.
  149341. * @param min minimal distance for the breaks (default to 0.)
  149342. * @param max maximal distance for the breaks (default to 1.)
  149343. */
  149344. setMinMaxDistance(min: number, max: number): void;
  149345. /** Gets the minimal distance used in the cascade break computation */
  149346. get minDistance(): number;
  149347. /** Gets the maximal distance used in the cascade break computation */
  149348. get maxDistance(): number;
  149349. /**
  149350. * Gets the class name of that object
  149351. * @returns "CascadedShadowGenerator"
  149352. */
  149353. getClassName(): string;
  149354. private _cascadeMinExtents;
  149355. private _cascadeMaxExtents;
  149356. /**
  149357. * Gets a cascade minimum extents
  149358. * @param cascadeIndex index of the cascade
  149359. * @returns the minimum cascade extents
  149360. */
  149361. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  149362. /**
  149363. * Gets a cascade maximum extents
  149364. * @param cascadeIndex index of the cascade
  149365. * @returns the maximum cascade extents
  149366. */
  149367. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  149368. private _cascades;
  149369. private _currentLayer;
  149370. private _viewSpaceFrustumsZ;
  149371. private _viewMatrices;
  149372. private _projectionMatrices;
  149373. private _transformMatrices;
  149374. private _transformMatricesAsArray;
  149375. private _frustumLengths;
  149376. private _lightSizeUVCorrection;
  149377. private _depthCorrection;
  149378. private _frustumCornersWorldSpace;
  149379. private _frustumCenter;
  149380. private _shadowCameraPos;
  149381. private _shadowMaxZ;
  149382. /**
  149383. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  149384. * It defaults to camera.maxZ
  149385. */
  149386. get shadowMaxZ(): number;
  149387. /**
  149388. * Sets the shadow max z distance.
  149389. */
  149390. set shadowMaxZ(value: number);
  149391. protected _debug: boolean;
  149392. /**
  149393. * Gets or sets the debug flag.
  149394. * When enabled, the cascades are materialized by different colors on the screen.
  149395. */
  149396. get debug(): boolean;
  149397. set debug(dbg: boolean);
  149398. private _depthClamp;
  149399. /**
  149400. * Gets or sets the depth clamping value.
  149401. *
  149402. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  149403. * to account for the shadow casters far away.
  149404. *
  149405. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  149406. */
  149407. get depthClamp(): boolean;
  149408. set depthClamp(value: boolean);
  149409. private _cascadeBlendPercentage;
  149410. /**
  149411. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  149412. * It defaults to 0.1 (10% blending).
  149413. */
  149414. get cascadeBlendPercentage(): number;
  149415. set cascadeBlendPercentage(value: number);
  149416. private _lambda;
  149417. /**
  149418. * Gets or set the lambda parameter.
  149419. * This parameter is used to split the camera frustum and create the cascades.
  149420. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  149421. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  149422. */
  149423. get lambda(): number;
  149424. set lambda(value: number);
  149425. /**
  149426. * Gets the view matrix corresponding to a given cascade
  149427. * @param cascadeNum cascade to retrieve the view matrix from
  149428. * @returns the cascade view matrix
  149429. */
  149430. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  149431. /**
  149432. * Gets the projection matrix corresponding to a given cascade
  149433. * @param cascadeNum cascade to retrieve the projection matrix from
  149434. * @returns the cascade projection matrix
  149435. */
  149436. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  149437. /**
  149438. * Gets the transformation matrix corresponding to a given cascade
  149439. * @param cascadeNum cascade to retrieve the transformation matrix from
  149440. * @returns the cascade transformation matrix
  149441. */
  149442. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  149443. private _depthRenderer;
  149444. /**
  149445. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  149446. *
  149447. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  149448. *
  149449. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  149450. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  149451. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  149452. */
  149453. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  149454. private _depthReducer;
  149455. private _autoCalcDepthBounds;
  149456. /**
  149457. * Gets or sets the autoCalcDepthBounds property.
  149458. *
  149459. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  149460. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  149461. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  149462. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  149463. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  149464. */
  149465. get autoCalcDepthBounds(): boolean;
  149466. set autoCalcDepthBounds(value: boolean);
  149467. /**
  149468. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  149469. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  149470. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  149471. * for setting the refresh rate on the renderer yourself!
  149472. */
  149473. get autoCalcDepthBoundsRefreshRate(): number;
  149474. set autoCalcDepthBoundsRefreshRate(value: number);
  149475. /**
  149476. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  149477. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  149478. * you change the camera near/far planes!
  149479. */
  149480. splitFrustum(): void;
  149481. private _splitFrustum;
  149482. private _computeMatrices;
  149483. private _computeFrustumInWorldSpace;
  149484. private _computeCascadeFrustum;
  149485. /**
  149486. * Support test.
  149487. */
  149488. static get IsSupported(): boolean;
  149489. /** @hidden */
  149490. static _SceneComponentInitialization: (scene: Scene) => void;
  149491. /**
  149492. * Creates a Cascaded Shadow Generator object.
  149493. * A ShadowGenerator is the required tool to use the shadows.
  149494. * Each directional light casting shadows needs to use its own ShadowGenerator.
  149495. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  149496. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  149497. * @param light The directional light object generating the shadows.
  149498. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  149499. */
  149500. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  149501. protected _initializeGenerator(): void;
  149502. protected _createTargetRenderTexture(): void;
  149503. protected _initializeShadowMap(): void;
  149504. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  149505. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  149506. /**
  149507. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  149508. * @param defines Defines of the material we want to update
  149509. * @param lightIndex Index of the light in the enabled light list of the material
  149510. */
  149511. prepareDefines(defines: any, lightIndex: number): void;
  149512. /**
  149513. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  149514. * defined in the generator but impacting the effect).
  149515. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  149516. * @param effect The effect we are binfing the information for
  149517. */
  149518. bindShadowLight(lightIndex: string, effect: Effect): void;
  149519. /**
  149520. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  149521. * (eq to view projection * shadow projection matrices)
  149522. * @returns The transform matrix used to create the shadow map
  149523. */
  149524. getTransformMatrix(): Matrix;
  149525. /**
  149526. * Disposes the ShadowGenerator.
  149527. * Returns nothing.
  149528. */
  149529. dispose(): void;
  149530. /**
  149531. * Serializes the shadow generator setup to a json object.
  149532. * @returns The serialized JSON object
  149533. */
  149534. serialize(): any;
  149535. /**
  149536. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  149537. * @param parsedShadowGenerator The JSON object to parse
  149538. * @param scene The scene to create the shadow map for
  149539. * @returns The parsed shadow generator
  149540. */
  149541. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  149542. }
  149543. }
  149544. declare module BABYLON {
  149545. /**
  149546. * Defines the shadow generator component responsible to manage any shadow generators
  149547. * in a given scene.
  149548. */
  149549. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  149550. /**
  149551. * The component name helpfull to identify the component in the list of scene components.
  149552. */
  149553. readonly name: string;
  149554. /**
  149555. * The scene the component belongs to.
  149556. */
  149557. scene: Scene;
  149558. /**
  149559. * Creates a new instance of the component for the given scene
  149560. * @param scene Defines the scene to register the component in
  149561. */
  149562. constructor(scene: Scene);
  149563. /**
  149564. * Registers the component in a given scene
  149565. */
  149566. register(): void;
  149567. /**
  149568. * Rebuilds the elements related to this component in case of
  149569. * context lost for instance.
  149570. */
  149571. rebuild(): void;
  149572. /**
  149573. * Serializes the component data to the specified json object
  149574. * @param serializationObject The object to serialize to
  149575. */
  149576. serialize(serializationObject: any): void;
  149577. /**
  149578. * Adds all the elements from the container to the scene
  149579. * @param container the container holding the elements
  149580. */
  149581. addFromContainer(container: AbstractScene): void;
  149582. /**
  149583. * Removes all the elements in the container from the scene
  149584. * @param container contains the elements to remove
  149585. * @param dispose if the removed element should be disposed (default: false)
  149586. */
  149587. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149588. /**
  149589. * Rebuilds the elements related to this component in case of
  149590. * context lost for instance.
  149591. */
  149592. dispose(): void;
  149593. private _gatherRenderTargets;
  149594. }
  149595. }
  149596. declare module BABYLON {
  149597. /**
  149598. * A point light is a light defined by an unique point in world space.
  149599. * The light is emitted in every direction from this point.
  149600. * A good example of a point light is a standard light bulb.
  149601. * Documentation: https://doc.babylonjs.com/babylon101/lights
  149602. */
  149603. export class PointLight extends ShadowLight {
  149604. private _shadowAngle;
  149605. /**
  149606. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149607. * This specifies what angle the shadow will use to be created.
  149608. *
  149609. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  149610. */
  149611. get shadowAngle(): number;
  149612. /**
  149613. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149614. * This specifies what angle the shadow will use to be created.
  149615. *
  149616. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  149617. */
  149618. set shadowAngle(value: number);
  149619. /**
  149620. * Gets the direction if it has been set.
  149621. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149622. */
  149623. get direction(): Vector3;
  149624. /**
  149625. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  149626. */
  149627. set direction(value: Vector3);
  149628. /**
  149629. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  149630. * A PointLight emits the light in every direction.
  149631. * It can cast shadows.
  149632. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  149633. * ```javascript
  149634. * var pointLight = new PointLight("pl", camera.position, scene);
  149635. * ```
  149636. * Documentation : https://doc.babylonjs.com/babylon101/lights
  149637. * @param name The light friendly name
  149638. * @param position The position of the point light in the scene
  149639. * @param scene The scene the lights belongs to
  149640. */
  149641. constructor(name: string, position: Vector3, scene: Scene);
  149642. /**
  149643. * Returns the string "PointLight"
  149644. * @returns the class name
  149645. */
  149646. getClassName(): string;
  149647. /**
  149648. * Returns the integer 0.
  149649. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  149650. */
  149651. getTypeID(): number;
  149652. /**
  149653. * Specifies wether or not the shadowmap should be a cube texture.
  149654. * @returns true if the shadowmap needs to be a cube texture.
  149655. */
  149656. needCube(): boolean;
  149657. /**
  149658. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  149659. * @param faceIndex The index of the face we are computed the direction to generate shadow
  149660. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  149661. */
  149662. getShadowDirection(faceIndex?: number): Vector3;
  149663. /**
  149664. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  149665. * - fov = PI / 2
  149666. * - aspect ratio : 1.0
  149667. * - z-near and far equal to the active camera minZ and maxZ.
  149668. * Returns the PointLight.
  149669. */
  149670. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  149671. protected _buildUniformLayout(): void;
  149672. /**
  149673. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  149674. * @param effect The effect to update
  149675. * @param lightIndex The index of the light in the effect to update
  149676. * @returns The point light
  149677. */
  149678. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  149679. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  149680. /**
  149681. * Prepares the list of defines specific to the light type.
  149682. * @param defines the list of defines
  149683. * @param lightIndex defines the index of the light for the effect
  149684. */
  149685. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  149686. }
  149687. }
  149688. declare module BABYLON {
  149689. /**
  149690. * Header information of HDR texture files.
  149691. */
  149692. export interface HDRInfo {
  149693. /**
  149694. * The height of the texture in pixels.
  149695. */
  149696. height: number;
  149697. /**
  149698. * The width of the texture in pixels.
  149699. */
  149700. width: number;
  149701. /**
  149702. * The index of the beginning of the data in the binary file.
  149703. */
  149704. dataPosition: number;
  149705. }
  149706. /**
  149707. * This groups tools to convert HDR texture to native colors array.
  149708. */
  149709. export class HDRTools {
  149710. private static Ldexp;
  149711. private static Rgbe2float;
  149712. private static readStringLine;
  149713. /**
  149714. * Reads header information from an RGBE texture stored in a native array.
  149715. * More information on this format are available here:
  149716. * https://en.wikipedia.org/wiki/RGBE_image_format
  149717. *
  149718. * @param uint8array The binary file stored in native array.
  149719. * @return The header information.
  149720. */
  149721. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  149722. /**
  149723. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  149724. * This RGBE texture needs to store the information as a panorama.
  149725. *
  149726. * More information on this format are available here:
  149727. * https://en.wikipedia.org/wiki/RGBE_image_format
  149728. *
  149729. * @param buffer The binary file stored in an array buffer.
  149730. * @param size The expected size of the extracted cubemap.
  149731. * @return The Cube Map information.
  149732. */
  149733. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  149734. /**
  149735. * Returns the pixels data extracted from an RGBE texture.
  149736. * This pixels will be stored left to right up to down in the R G B order in one array.
  149737. *
  149738. * More information on this format are available here:
  149739. * https://en.wikipedia.org/wiki/RGBE_image_format
  149740. *
  149741. * @param uint8array The binary file stored in an array buffer.
  149742. * @param hdrInfo The header information of the file.
  149743. * @return The pixels data in RGB right to left up to down order.
  149744. */
  149745. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  149746. private static RGBE_ReadPixels_RLE;
  149747. private static RGBE_ReadPixels_NOT_RLE;
  149748. }
  149749. }
  149750. declare module BABYLON {
  149751. /**
  149752. * Effect Render Options
  149753. */
  149754. export interface IEffectRendererOptions {
  149755. /**
  149756. * Defines the vertices positions.
  149757. */
  149758. positions?: number[];
  149759. /**
  149760. * Defines the indices.
  149761. */
  149762. indices?: number[];
  149763. }
  149764. /**
  149765. * Helper class to render one or more effects.
  149766. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  149767. */
  149768. export class EffectRenderer {
  149769. private engine;
  149770. private static _DefaultOptions;
  149771. private _vertexBuffers;
  149772. private _indexBuffer;
  149773. private _fullscreenViewport;
  149774. /**
  149775. * Creates an effect renderer
  149776. * @param engine the engine to use for rendering
  149777. * @param options defines the options of the effect renderer
  149778. */
  149779. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  149780. /**
  149781. * Sets the current viewport in normalized coordinates 0-1
  149782. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  149783. */
  149784. setViewport(viewport?: Viewport): void;
  149785. /**
  149786. * Binds the embedded attributes buffer to the effect.
  149787. * @param effect Defines the effect to bind the attributes for
  149788. */
  149789. bindBuffers(effect: Effect): void;
  149790. /**
  149791. * Sets the current effect wrapper to use during draw.
  149792. * The effect needs to be ready before calling this api.
  149793. * This also sets the default full screen position attribute.
  149794. * @param effectWrapper Defines the effect to draw with
  149795. */
  149796. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  149797. /**
  149798. * Restores engine states
  149799. */
  149800. restoreStates(): void;
  149801. /**
  149802. * Draws a full screen quad.
  149803. */
  149804. draw(): void;
  149805. private isRenderTargetTexture;
  149806. /**
  149807. * renders one or more effects to a specified texture
  149808. * @param effectWrapper the effect to renderer
  149809. * @param outputTexture texture to draw to, if null it will render to the screen.
  149810. */
  149811. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  149812. /**
  149813. * Disposes of the effect renderer
  149814. */
  149815. dispose(): void;
  149816. }
  149817. /**
  149818. * Options to create an EffectWrapper
  149819. */
  149820. interface EffectWrapperCreationOptions {
  149821. /**
  149822. * Engine to use to create the effect
  149823. */
  149824. engine: ThinEngine;
  149825. /**
  149826. * Fragment shader for the effect
  149827. */
  149828. fragmentShader: string;
  149829. /**
  149830. * Use the shader store instead of direct source code
  149831. */
  149832. useShaderStore?: boolean;
  149833. /**
  149834. * Vertex shader for the effect
  149835. */
  149836. vertexShader?: string;
  149837. /**
  149838. * Attributes to use in the shader
  149839. */
  149840. attributeNames?: Array<string>;
  149841. /**
  149842. * Uniforms to use in the shader
  149843. */
  149844. uniformNames?: Array<string>;
  149845. /**
  149846. * Texture sampler names to use in the shader
  149847. */
  149848. samplerNames?: Array<string>;
  149849. /**
  149850. * Defines to use in the shader
  149851. */
  149852. defines?: Array<string>;
  149853. /**
  149854. * Callback when effect is compiled
  149855. */
  149856. onCompiled?: Nullable<(effect: Effect) => void>;
  149857. /**
  149858. * The friendly name of the effect displayed in Spector.
  149859. */
  149860. name?: string;
  149861. }
  149862. /**
  149863. * Wraps an effect to be used for rendering
  149864. */
  149865. export class EffectWrapper {
  149866. /**
  149867. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  149868. */
  149869. onApplyObservable: Observable<{}>;
  149870. /**
  149871. * The underlying effect
  149872. */
  149873. effect: Effect;
  149874. /**
  149875. * Creates an effect to be renderer
  149876. * @param creationOptions options to create the effect
  149877. */
  149878. constructor(creationOptions: EffectWrapperCreationOptions);
  149879. /**
  149880. * Disposes of the effect wrapper
  149881. */
  149882. dispose(): void;
  149883. }
  149884. }
  149885. declare module BABYLON {
  149886. /** @hidden */
  149887. export var hdrFilteringVertexShader: {
  149888. name: string;
  149889. shader: string;
  149890. };
  149891. }
  149892. declare module BABYLON {
  149893. /** @hidden */
  149894. export var hdrFilteringPixelShader: {
  149895. name: string;
  149896. shader: string;
  149897. };
  149898. }
  149899. declare module BABYLON {
  149900. /**
  149901. * Options for texture filtering
  149902. */
  149903. interface IHDRFilteringOptions {
  149904. /**
  149905. * Scales pixel intensity for the input HDR map.
  149906. */
  149907. hdrScale?: number;
  149908. /**
  149909. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  149910. */
  149911. quality?: number;
  149912. }
  149913. /**
  149914. * Filters HDR maps to get correct renderings of PBR reflections
  149915. */
  149916. export class HDRFiltering {
  149917. private _engine;
  149918. private _effectRenderer;
  149919. private _effectWrapper;
  149920. private _lodGenerationOffset;
  149921. private _lodGenerationScale;
  149922. /**
  149923. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  149924. * you care about baking speed.
  149925. */
  149926. quality: number;
  149927. /**
  149928. * Scales pixel intensity for the input HDR map.
  149929. */
  149930. hdrScale: number;
  149931. /**
  149932. * Instantiates HDR filter for reflection maps
  149933. *
  149934. * @param engine Thin engine
  149935. * @param options Options
  149936. */
  149937. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  149938. private _createRenderTarget;
  149939. private _prefilterInternal;
  149940. private _createEffect;
  149941. /**
  149942. * Get a value indicating if the filter is ready to be used
  149943. * @param texture Texture to filter
  149944. * @returns true if the filter is ready
  149945. */
  149946. isReady(texture: BaseTexture): boolean;
  149947. /**
  149948. * Prefilters a cube texture to have mipmap levels representing roughness values.
  149949. * Prefiltering will be invoked at the end of next rendering pass.
  149950. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  149951. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  149952. * @param texture Texture to filter
  149953. * @param onFinished Callback when filtering is done
  149954. * @return Promise called when prefiltering is done
  149955. */
  149956. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  149957. }
  149958. }
  149959. declare module BABYLON {
  149960. /**
  149961. * This represents a texture coming from an HDR input.
  149962. *
  149963. * The only supported format is currently panorama picture stored in RGBE format.
  149964. * Example of such files can be found on HDRLib: http://hdrlib.com/
  149965. */
  149966. export class HDRCubeTexture extends BaseTexture {
  149967. private static _facesMapping;
  149968. private _generateHarmonics;
  149969. private _noMipmap;
  149970. private _prefilterOnLoad;
  149971. private _textureMatrix;
  149972. private _size;
  149973. private _onLoad;
  149974. private _onError;
  149975. /**
  149976. * The texture URL.
  149977. */
  149978. url: string;
  149979. protected _isBlocking: boolean;
  149980. /**
  149981. * Sets wether or not the texture is blocking during loading.
  149982. */
  149983. set isBlocking(value: boolean);
  149984. /**
  149985. * Gets wether or not the texture is blocking during loading.
  149986. */
  149987. get isBlocking(): boolean;
  149988. protected _rotationY: number;
  149989. /**
  149990. * Sets texture matrix rotation angle around Y axis in radians.
  149991. */
  149992. set rotationY(value: number);
  149993. /**
  149994. * Gets texture matrix rotation angle around Y axis radians.
  149995. */
  149996. get rotationY(): number;
  149997. /**
  149998. * Gets or sets the center of the bounding box associated with the cube texture
  149999. * It must define where the camera used to render the texture was set
  150000. */
  150001. boundingBoxPosition: Vector3;
  150002. private _boundingBoxSize;
  150003. /**
  150004. * Gets or sets the size of the bounding box associated with the cube texture
  150005. * When defined, the cubemap will switch to local mode
  150006. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  150007. * @example https://www.babylonjs-playground.com/#RNASML
  150008. */
  150009. set boundingBoxSize(value: Vector3);
  150010. get boundingBoxSize(): Vector3;
  150011. /**
  150012. * Instantiates an HDRTexture from the following parameters.
  150013. *
  150014. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  150015. * @param sceneOrEngine The scene or engine the texture will be used in
  150016. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  150017. * @param noMipmap Forces to not generate the mipmap if true
  150018. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  150019. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150020. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  150021. */
  150022. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  150023. /**
  150024. * Get the current class name of the texture useful for serialization or dynamic coding.
  150025. * @returns "HDRCubeTexture"
  150026. */
  150027. getClassName(): string;
  150028. /**
  150029. * Occurs when the file is raw .hdr file.
  150030. */
  150031. private loadTexture;
  150032. clone(): HDRCubeTexture;
  150033. delayLoad(): void;
  150034. /**
  150035. * Get the texture reflection matrix used to rotate/transform the reflection.
  150036. * @returns the reflection matrix
  150037. */
  150038. getReflectionTextureMatrix(): Matrix;
  150039. /**
  150040. * Set the texture reflection matrix used to rotate/transform the reflection.
  150041. * @param value Define the reflection matrix to set
  150042. */
  150043. setReflectionTextureMatrix(value: Matrix): void;
  150044. /**
  150045. * Parses a JSON representation of an HDR Texture in order to create the texture
  150046. * @param parsedTexture Define the JSON representation
  150047. * @param scene Define the scene the texture should be created in
  150048. * @param rootUrl Define the root url in case we need to load relative dependencies
  150049. * @returns the newly created texture after parsing
  150050. */
  150051. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  150052. serialize(): any;
  150053. }
  150054. }
  150055. declare module BABYLON {
  150056. /**
  150057. * Class used to control physics engine
  150058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150059. */
  150060. export class PhysicsEngine implements IPhysicsEngine {
  150061. private _physicsPlugin;
  150062. /**
  150063. * Global value used to control the smallest number supported by the simulation
  150064. */
  150065. static Epsilon: number;
  150066. private _impostors;
  150067. private _joints;
  150068. private _subTimeStep;
  150069. /**
  150070. * Gets the gravity vector used by the simulation
  150071. */
  150072. gravity: Vector3;
  150073. /**
  150074. * Factory used to create the default physics plugin.
  150075. * @returns The default physics plugin
  150076. */
  150077. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  150078. /**
  150079. * Creates a new Physics Engine
  150080. * @param gravity defines the gravity vector used by the simulation
  150081. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  150082. */
  150083. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  150084. /**
  150085. * Sets the gravity vector used by the simulation
  150086. * @param gravity defines the gravity vector to use
  150087. */
  150088. setGravity(gravity: Vector3): void;
  150089. /**
  150090. * Set the time step of the physics engine.
  150091. * Default is 1/60.
  150092. * To slow it down, enter 1/600 for example.
  150093. * To speed it up, 1/30
  150094. * @param newTimeStep defines the new timestep to apply to this world.
  150095. */
  150096. setTimeStep(newTimeStep?: number): void;
  150097. /**
  150098. * Get the time step of the physics engine.
  150099. * @returns the current time step
  150100. */
  150101. getTimeStep(): number;
  150102. /**
  150103. * Set the sub time step of the physics engine.
  150104. * Default is 0 meaning there is no sub steps
  150105. * To increase physics resolution precision, set a small value (like 1 ms)
  150106. * @param subTimeStep defines the new sub timestep used for physics resolution.
  150107. */
  150108. setSubTimeStep(subTimeStep?: number): void;
  150109. /**
  150110. * Get the sub time step of the physics engine.
  150111. * @returns the current sub time step
  150112. */
  150113. getSubTimeStep(): number;
  150114. /**
  150115. * Release all resources
  150116. */
  150117. dispose(): void;
  150118. /**
  150119. * Gets the name of the current physics plugin
  150120. * @returns the name of the plugin
  150121. */
  150122. getPhysicsPluginName(): string;
  150123. /**
  150124. * Adding a new impostor for the impostor tracking.
  150125. * This will be done by the impostor itself.
  150126. * @param impostor the impostor to add
  150127. */
  150128. addImpostor(impostor: PhysicsImpostor): void;
  150129. /**
  150130. * Remove an impostor from the engine.
  150131. * This impostor and its mesh will not longer be updated by the physics engine.
  150132. * @param impostor the impostor to remove
  150133. */
  150134. removeImpostor(impostor: PhysicsImpostor): void;
  150135. /**
  150136. * Add a joint to the physics engine
  150137. * @param mainImpostor defines the main impostor to which the joint is added.
  150138. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  150139. * @param joint defines the joint that will connect both impostors.
  150140. */
  150141. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  150142. /**
  150143. * Removes a joint from the simulation
  150144. * @param mainImpostor defines the impostor used with the joint
  150145. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  150146. * @param joint defines the joint to remove
  150147. */
  150148. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  150149. /**
  150150. * Called by the scene. No need to call it.
  150151. * @param delta defines the timespam between frames
  150152. */
  150153. _step(delta: number): void;
  150154. /**
  150155. * Gets the current plugin used to run the simulation
  150156. * @returns current plugin
  150157. */
  150158. getPhysicsPlugin(): IPhysicsEnginePlugin;
  150159. /**
  150160. * Gets the list of physic impostors
  150161. * @returns an array of PhysicsImpostor
  150162. */
  150163. getImpostors(): Array<PhysicsImpostor>;
  150164. /**
  150165. * Gets the impostor for a physics enabled object
  150166. * @param object defines the object impersonated by the impostor
  150167. * @returns the PhysicsImpostor or null if not found
  150168. */
  150169. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  150170. /**
  150171. * Gets the impostor for a physics body object
  150172. * @param body defines physics body used by the impostor
  150173. * @returns the PhysicsImpostor or null if not found
  150174. */
  150175. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  150176. /**
  150177. * Does a raycast in the physics world
  150178. * @param from when should the ray start?
  150179. * @param to when should the ray end?
  150180. * @returns PhysicsRaycastResult
  150181. */
  150182. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  150183. }
  150184. }
  150185. declare module BABYLON {
  150186. /** @hidden */
  150187. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  150188. private _useDeltaForWorldStep;
  150189. world: any;
  150190. name: string;
  150191. private _physicsMaterials;
  150192. private _fixedTimeStep;
  150193. private _cannonRaycastResult;
  150194. private _raycastResult;
  150195. private _physicsBodysToRemoveAfterStep;
  150196. private _firstFrame;
  150197. BJSCANNON: any;
  150198. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  150199. setGravity(gravity: Vector3): void;
  150200. setTimeStep(timeStep: number): void;
  150201. getTimeStep(): number;
  150202. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  150203. private _removeMarkedPhysicsBodiesFromWorld;
  150204. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150205. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150206. generatePhysicsBody(impostor: PhysicsImpostor): void;
  150207. private _processChildMeshes;
  150208. removePhysicsBody(impostor: PhysicsImpostor): void;
  150209. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  150210. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  150211. private _addMaterial;
  150212. private _checkWithEpsilon;
  150213. private _createShape;
  150214. private _createHeightmap;
  150215. private _minus90X;
  150216. private _plus90X;
  150217. private _tmpPosition;
  150218. private _tmpDeltaPosition;
  150219. private _tmpUnityRotation;
  150220. private _updatePhysicsBodyTransformation;
  150221. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  150222. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  150223. isSupported(): boolean;
  150224. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150225. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150226. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150227. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150228. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  150229. getBodyMass(impostor: PhysicsImpostor): number;
  150230. getBodyFriction(impostor: PhysicsImpostor): number;
  150231. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  150232. getBodyRestitution(impostor: PhysicsImpostor): number;
  150233. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  150234. sleepBody(impostor: PhysicsImpostor): void;
  150235. wakeUpBody(impostor: PhysicsImpostor): void;
  150236. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  150237. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  150238. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  150239. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  150240. getRadius(impostor: PhysicsImpostor): number;
  150241. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  150242. dispose(): void;
  150243. private _extendNamespace;
  150244. /**
  150245. * Does a raycast in the physics world
  150246. * @param from when should the ray start?
  150247. * @param to when should the ray end?
  150248. * @returns PhysicsRaycastResult
  150249. */
  150250. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  150251. }
  150252. }
  150253. declare module BABYLON {
  150254. /** @hidden */
  150255. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  150256. private _useDeltaForWorldStep;
  150257. world: any;
  150258. name: string;
  150259. BJSOIMO: any;
  150260. private _raycastResult;
  150261. private _fixedTimeStep;
  150262. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  150263. setGravity(gravity: Vector3): void;
  150264. setTimeStep(timeStep: number): void;
  150265. getTimeStep(): number;
  150266. private _tmpImpostorsArray;
  150267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  150268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  150271. private _tmpPositionVector;
  150272. removePhysicsBody(impostor: PhysicsImpostor): void;
  150273. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  150274. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  150275. isSupported(): boolean;
  150276. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  150277. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  150278. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150279. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150280. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150281. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150282. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  150283. getBodyMass(impostor: PhysicsImpostor): number;
  150284. getBodyFriction(impostor: PhysicsImpostor): number;
  150285. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  150286. getBodyRestitution(impostor: PhysicsImpostor): number;
  150287. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  150288. sleepBody(impostor: PhysicsImpostor): void;
  150289. wakeUpBody(impostor: PhysicsImpostor): void;
  150290. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  150291. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  150292. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  150293. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  150294. getRadius(impostor: PhysicsImpostor): number;
  150295. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  150296. dispose(): void;
  150297. /**
  150298. * Does a raycast in the physics world
  150299. * @param from when should the ray start?
  150300. * @param to when should the ray end?
  150301. * @returns PhysicsRaycastResult
  150302. */
  150303. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  150304. }
  150305. }
  150306. declare module BABYLON {
  150307. /**
  150308. * AmmoJS Physics plugin
  150309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150310. * @see https://github.com/kripken/ammo.js/
  150311. */
  150312. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  150313. private _useDeltaForWorldStep;
  150314. /**
  150315. * Reference to the Ammo library
  150316. */
  150317. bjsAMMO: any;
  150318. /**
  150319. * Created ammoJS world which physics bodies are added to
  150320. */
  150321. world: any;
  150322. /**
  150323. * Name of the plugin
  150324. */
  150325. name: string;
  150326. private _timeStep;
  150327. private _fixedTimeStep;
  150328. private _maxSteps;
  150329. private _tmpQuaternion;
  150330. private _tmpAmmoTransform;
  150331. private _tmpAmmoQuaternion;
  150332. private _tmpAmmoConcreteContactResultCallback;
  150333. private _collisionConfiguration;
  150334. private _dispatcher;
  150335. private _overlappingPairCache;
  150336. private _solver;
  150337. private _softBodySolver;
  150338. private _tmpAmmoVectorA;
  150339. private _tmpAmmoVectorB;
  150340. private _tmpAmmoVectorC;
  150341. private _tmpAmmoVectorD;
  150342. private _tmpContactCallbackResult;
  150343. private _tmpAmmoVectorRCA;
  150344. private _tmpAmmoVectorRCB;
  150345. private _raycastResult;
  150346. private _tmpContactPoint;
  150347. private static readonly DISABLE_COLLISION_FLAG;
  150348. private static readonly KINEMATIC_FLAG;
  150349. private static readonly DISABLE_DEACTIVATION_FLAG;
  150350. /**
  150351. * Initializes the ammoJS plugin
  150352. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  150353. * @param ammoInjection can be used to inject your own ammo reference
  150354. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  150355. */
  150356. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  150357. /**
  150358. * Sets the gravity of the physics world (m/(s^2))
  150359. * @param gravity Gravity to set
  150360. */
  150361. setGravity(gravity: Vector3): void;
  150362. /**
  150363. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  150364. * @param timeStep timestep to use in seconds
  150365. */
  150366. setTimeStep(timeStep: number): void;
  150367. /**
  150368. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  150369. * @param fixedTimeStep fixedTimeStep to use in seconds
  150370. */
  150371. setFixedTimeStep(fixedTimeStep: number): void;
  150372. /**
  150373. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  150374. * @param maxSteps the maximum number of steps by the physics engine per frame
  150375. */
  150376. setMaxSteps(maxSteps: number): void;
  150377. /**
  150378. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  150379. * @returns the current timestep in seconds
  150380. */
  150381. getTimeStep(): number;
  150382. /**
  150383. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  150384. */
  150385. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  150386. private _isImpostorInContact;
  150387. private _isImpostorPairInContact;
  150388. private _stepSimulation;
  150389. /**
  150390. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  150391. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  150392. * After the step the babylon meshes are set to the position of the physics imposters
  150393. * @param delta amount of time to step forward
  150394. * @param impostors array of imposters to update before/after the step
  150395. */
  150396. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  150397. /**
  150398. * Update babylon mesh to match physics world object
  150399. * @param impostor imposter to match
  150400. */
  150401. private _afterSoftStep;
  150402. /**
  150403. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  150404. * @param impostor imposter to match
  150405. */
  150406. private _ropeStep;
  150407. /**
  150408. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  150409. * @param impostor imposter to match
  150410. */
  150411. private _softbodyOrClothStep;
  150412. private _tmpMatrix;
  150413. /**
  150414. * Applies an impulse on the imposter
  150415. * @param impostor imposter to apply impulse to
  150416. * @param force amount of force to be applied to the imposter
  150417. * @param contactPoint the location to apply the impulse on the imposter
  150418. */
  150419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150420. /**
  150421. * Applies a force on the imposter
  150422. * @param impostor imposter to apply force
  150423. * @param force amount of force to be applied to the imposter
  150424. * @param contactPoint the location to apply the force on the imposter
  150425. */
  150426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  150427. /**
  150428. * Creates a physics body using the plugin
  150429. * @param impostor the imposter to create the physics body on
  150430. */
  150431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  150432. /**
  150433. * Removes the physics body from the imposter and disposes of the body's memory
  150434. * @param impostor imposter to remove the physics body from
  150435. */
  150436. removePhysicsBody(impostor: PhysicsImpostor): void;
  150437. /**
  150438. * Generates a joint
  150439. * @param impostorJoint the imposter joint to create the joint with
  150440. */
  150441. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  150442. /**
  150443. * Removes a joint
  150444. * @param impostorJoint the imposter joint to remove the joint from
  150445. */
  150446. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  150447. private _addMeshVerts;
  150448. /**
  150449. * Initialise the soft body vertices to match its object's (mesh) vertices
  150450. * Softbody vertices (nodes) are in world space and to match this
  150451. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  150452. * @param impostor to create the softbody for
  150453. */
  150454. private _softVertexData;
  150455. /**
  150456. * Create an impostor's soft body
  150457. * @param impostor to create the softbody for
  150458. */
  150459. private _createSoftbody;
  150460. /**
  150461. * Create cloth for an impostor
  150462. * @param impostor to create the softbody for
  150463. */
  150464. private _createCloth;
  150465. /**
  150466. * Create rope for an impostor
  150467. * @param impostor to create the softbody for
  150468. */
  150469. private _createRope;
  150470. /**
  150471. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  150472. * @param impostor to create the custom physics shape for
  150473. */
  150474. private _createCustom;
  150475. private _addHullVerts;
  150476. private _createShape;
  150477. /**
  150478. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  150479. * @param impostor imposter containing the physics body and babylon object
  150480. */
  150481. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  150482. /**
  150483. * Sets the babylon object's position/rotation from the physics body's position/rotation
  150484. * @param impostor imposter containing the physics body and babylon object
  150485. * @param newPosition new position
  150486. * @param newRotation new rotation
  150487. */
  150488. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  150489. /**
  150490. * If this plugin is supported
  150491. * @returns true if its supported
  150492. */
  150493. isSupported(): boolean;
  150494. /**
  150495. * Sets the linear velocity of the physics body
  150496. * @param impostor imposter to set the velocity on
  150497. * @param velocity velocity to set
  150498. */
  150499. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150500. /**
  150501. * Sets the angular velocity of the physics body
  150502. * @param impostor imposter to set the velocity on
  150503. * @param velocity velocity to set
  150504. */
  150505. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  150506. /**
  150507. * gets the linear velocity
  150508. * @param impostor imposter to get linear velocity from
  150509. * @returns linear velocity
  150510. */
  150511. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150512. /**
  150513. * gets the angular velocity
  150514. * @param impostor imposter to get angular velocity from
  150515. * @returns angular velocity
  150516. */
  150517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  150518. /**
  150519. * Sets the mass of physics body
  150520. * @param impostor imposter to set the mass on
  150521. * @param mass mass to set
  150522. */
  150523. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  150524. /**
  150525. * Gets the mass of the physics body
  150526. * @param impostor imposter to get the mass from
  150527. * @returns mass
  150528. */
  150529. getBodyMass(impostor: PhysicsImpostor): number;
  150530. /**
  150531. * Gets friction of the impostor
  150532. * @param impostor impostor to get friction from
  150533. * @returns friction value
  150534. */
  150535. getBodyFriction(impostor: PhysicsImpostor): number;
  150536. /**
  150537. * Sets friction of the impostor
  150538. * @param impostor impostor to set friction on
  150539. * @param friction friction value
  150540. */
  150541. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  150542. /**
  150543. * Gets restitution of the impostor
  150544. * @param impostor impostor to get restitution from
  150545. * @returns restitution value
  150546. */
  150547. getBodyRestitution(impostor: PhysicsImpostor): number;
  150548. /**
  150549. * Sets resitution of the impostor
  150550. * @param impostor impostor to set resitution on
  150551. * @param restitution resitution value
  150552. */
  150553. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  150554. /**
  150555. * Gets pressure inside the impostor
  150556. * @param impostor impostor to get pressure from
  150557. * @returns pressure value
  150558. */
  150559. getBodyPressure(impostor: PhysicsImpostor): number;
  150560. /**
  150561. * Sets pressure inside a soft body impostor
  150562. * Cloth and rope must remain 0 pressure
  150563. * @param impostor impostor to set pressure on
  150564. * @param pressure pressure value
  150565. */
  150566. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  150567. /**
  150568. * Gets stiffness of the impostor
  150569. * @param impostor impostor to get stiffness from
  150570. * @returns pressure value
  150571. */
  150572. getBodyStiffness(impostor: PhysicsImpostor): number;
  150573. /**
  150574. * Sets stiffness of the impostor
  150575. * @param impostor impostor to set stiffness on
  150576. * @param stiffness stiffness value from 0 to 1
  150577. */
  150578. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  150579. /**
  150580. * Gets velocityIterations of the impostor
  150581. * @param impostor impostor to get velocity iterations from
  150582. * @returns velocityIterations value
  150583. */
  150584. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  150585. /**
  150586. * Sets velocityIterations of the impostor
  150587. * @param impostor impostor to set velocity iterations on
  150588. * @param velocityIterations velocityIterations value
  150589. */
  150590. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  150591. /**
  150592. * Gets positionIterations of the impostor
  150593. * @param impostor impostor to get position iterations from
  150594. * @returns positionIterations value
  150595. */
  150596. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  150597. /**
  150598. * Sets positionIterations of the impostor
  150599. * @param impostor impostor to set position on
  150600. * @param positionIterations positionIterations value
  150601. */
  150602. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  150603. /**
  150604. * Append an anchor to a cloth object
  150605. * @param impostor is the cloth impostor to add anchor to
  150606. * @param otherImpostor is the rigid impostor to anchor to
  150607. * @param width ratio across width from 0 to 1
  150608. * @param height ratio up height from 0 to 1
  150609. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  150610. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  150611. */
  150612. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  150613. /**
  150614. * Append an hook to a rope object
  150615. * @param impostor is the rope impostor to add hook to
  150616. * @param otherImpostor is the rigid impostor to hook to
  150617. * @param length ratio along the rope from 0 to 1
  150618. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  150619. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  150620. */
  150621. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  150622. /**
  150623. * Sleeps the physics body and stops it from being active
  150624. * @param impostor impostor to sleep
  150625. */
  150626. sleepBody(impostor: PhysicsImpostor): void;
  150627. /**
  150628. * Activates the physics body
  150629. * @param impostor impostor to activate
  150630. */
  150631. wakeUpBody(impostor: PhysicsImpostor): void;
  150632. /**
  150633. * Updates the distance parameters of the joint
  150634. * @param joint joint to update
  150635. * @param maxDistance maximum distance of the joint
  150636. * @param minDistance minimum distance of the joint
  150637. */
  150638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  150639. /**
  150640. * Sets a motor on the joint
  150641. * @param joint joint to set motor on
  150642. * @param speed speed of the motor
  150643. * @param maxForce maximum force of the motor
  150644. * @param motorIndex index of the motor
  150645. */
  150646. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  150647. /**
  150648. * Sets the motors limit
  150649. * @param joint joint to set limit on
  150650. * @param upperLimit upper limit
  150651. * @param lowerLimit lower limit
  150652. */
  150653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  150654. /**
  150655. * Syncs the position and rotation of a mesh with the impostor
  150656. * @param mesh mesh to sync
  150657. * @param impostor impostor to update the mesh with
  150658. */
  150659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  150660. /**
  150661. * Gets the radius of the impostor
  150662. * @param impostor impostor to get radius from
  150663. * @returns the radius
  150664. */
  150665. getRadius(impostor: PhysicsImpostor): number;
  150666. /**
  150667. * Gets the box size of the impostor
  150668. * @param impostor impostor to get box size from
  150669. * @param result the resulting box size
  150670. */
  150671. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  150672. /**
  150673. * Disposes of the impostor
  150674. */
  150675. dispose(): void;
  150676. /**
  150677. * Does a raycast in the physics world
  150678. * @param from when should the ray start?
  150679. * @param to when should the ray end?
  150680. * @returns PhysicsRaycastResult
  150681. */
  150682. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  150683. }
  150684. }
  150685. declare module BABYLON {
  150686. interface AbstractScene {
  150687. /**
  150688. * The list of reflection probes added to the scene
  150689. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  150690. */
  150691. reflectionProbes: Array<ReflectionProbe>;
  150692. /**
  150693. * Removes the given reflection probe from this scene.
  150694. * @param toRemove The reflection probe to remove
  150695. * @returns The index of the removed reflection probe
  150696. */
  150697. removeReflectionProbe(toRemove: ReflectionProbe): number;
  150698. /**
  150699. * Adds the given reflection probe to this scene.
  150700. * @param newReflectionProbe The reflection probe to add
  150701. */
  150702. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  150703. }
  150704. /**
  150705. * Class used to generate realtime reflection / refraction cube textures
  150706. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  150707. */
  150708. export class ReflectionProbe {
  150709. /** defines the name of the probe */
  150710. name: string;
  150711. private _scene;
  150712. private _renderTargetTexture;
  150713. private _projectionMatrix;
  150714. private _viewMatrix;
  150715. private _target;
  150716. private _add;
  150717. private _attachedMesh;
  150718. private _invertYAxis;
  150719. /** Gets or sets probe position (center of the cube map) */
  150720. position: Vector3;
  150721. /**
  150722. * Creates a new reflection probe
  150723. * @param name defines the name of the probe
  150724. * @param size defines the texture resolution (for each face)
  150725. * @param scene defines the hosting scene
  150726. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  150727. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  150728. */
  150729. constructor(
  150730. /** defines the name of the probe */
  150731. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  150732. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  150733. get samples(): number;
  150734. set samples(value: number);
  150735. /** Gets or sets the refresh rate to use (on every frame by default) */
  150736. get refreshRate(): number;
  150737. set refreshRate(value: number);
  150738. /**
  150739. * Gets the hosting scene
  150740. * @returns a Scene
  150741. */
  150742. getScene(): Scene;
  150743. /** Gets the internal CubeTexture used to render to */
  150744. get cubeTexture(): RenderTargetTexture;
  150745. /** Gets the list of meshes to render */
  150746. get renderList(): Nullable<AbstractMesh[]>;
  150747. /**
  150748. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  150749. * @param mesh defines the mesh to attach to
  150750. */
  150751. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  150752. /**
  150753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  150754. * @param renderingGroupId The rendering group id corresponding to its index
  150755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  150756. */
  150757. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  150758. /**
  150759. * Clean all associated resources
  150760. */
  150761. dispose(): void;
  150762. /**
  150763. * Converts the reflection probe information to a readable string for debug purpose.
  150764. * @param fullDetails Supports for multiple levels of logging within scene loading
  150765. * @returns the human readable reflection probe info
  150766. */
  150767. toString(fullDetails?: boolean): string;
  150768. /**
  150769. * Get the class name of the relfection probe.
  150770. * @returns "ReflectionProbe"
  150771. */
  150772. getClassName(): string;
  150773. /**
  150774. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  150775. * @returns The JSON representation of the texture
  150776. */
  150777. serialize(): any;
  150778. /**
  150779. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  150780. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  150781. * @param scene Define the scene the parsed reflection probe should be instantiated in
  150782. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  150783. * @returns The parsed reflection probe if successful
  150784. */
  150785. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  150786. }
  150787. }
  150788. declare module BABYLON {
  150789. /** @hidden */
  150790. export var _BabylonLoaderRegistered: boolean;
  150791. /**
  150792. * Helps setting up some configuration for the babylon file loader.
  150793. */
  150794. export class BabylonFileLoaderConfiguration {
  150795. /**
  150796. * The loader does not allow injecting custom physix engine into the plugins.
  150797. * Unfortunately in ES6, we need to manually inject them into the plugin.
  150798. * So you could set this variable to your engine import to make it work.
  150799. */
  150800. static LoaderInjectedPhysicsEngine: any;
  150801. }
  150802. }
  150803. declare module BABYLON {
  150804. /**
  150805. * A material to use for fast depth-only rendering.
  150806. */
  150807. export class OcclusionMaterial extends ShaderMaterial {
  150808. constructor(name: string, scene: Scene);
  150809. }
  150810. }
  150811. declare module BABYLON {
  150812. /**
  150813. * The Physically based simple base material of BJS.
  150814. *
  150815. * This enables better naming and convention enforcements on top of the pbrMaterial.
  150816. * It is used as the base class for both the specGloss and metalRough conventions.
  150817. */
  150818. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  150819. /**
  150820. * Number of Simultaneous lights allowed on the material.
  150821. */
  150822. maxSimultaneousLights: number;
  150823. /**
  150824. * If sets to true, disables all the lights affecting the material.
  150825. */
  150826. disableLighting: boolean;
  150827. /**
  150828. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  150829. */
  150830. environmentTexture: BaseTexture;
  150831. /**
  150832. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  150833. */
  150834. invertNormalMapX: boolean;
  150835. /**
  150836. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  150837. */
  150838. invertNormalMapY: boolean;
  150839. /**
  150840. * Normal map used in the model.
  150841. */
  150842. normalTexture: BaseTexture;
  150843. /**
  150844. * Emissivie color used to self-illuminate the model.
  150845. */
  150846. emissiveColor: Color3;
  150847. /**
  150848. * Emissivie texture used to self-illuminate the model.
  150849. */
  150850. emissiveTexture: BaseTexture;
  150851. /**
  150852. * Occlusion Channel Strenght.
  150853. */
  150854. occlusionStrength: number;
  150855. /**
  150856. * Occlusion Texture of the material (adding extra occlusion effects).
  150857. */
  150858. occlusionTexture: BaseTexture;
  150859. /**
  150860. * Defines the alpha limits in alpha test mode.
  150861. */
  150862. alphaCutOff: number;
  150863. /**
  150864. * Gets the current double sided mode.
  150865. */
  150866. get doubleSided(): boolean;
  150867. /**
  150868. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  150869. */
  150870. set doubleSided(value: boolean);
  150871. /**
  150872. * Stores the pre-calculated light information of a mesh in a texture.
  150873. */
  150874. lightmapTexture: BaseTexture;
  150875. /**
  150876. * If true, the light map contains occlusion information instead of lighting info.
  150877. */
  150878. useLightmapAsShadowmap: boolean;
  150879. /**
  150880. * Instantiates a new PBRMaterial instance.
  150881. *
  150882. * @param name The material name
  150883. * @param scene The scene the material will be use in.
  150884. */
  150885. constructor(name: string, scene: Scene);
  150886. getClassName(): string;
  150887. }
  150888. }
  150889. declare module BABYLON {
  150890. /**
  150891. * The PBR material of BJS following the metal roughness convention.
  150892. *
  150893. * This fits to the PBR convention in the GLTF definition:
  150894. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  150895. */
  150896. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  150897. /**
  150898. * The base color has two different interpretations depending on the value of metalness.
  150899. * When the material is a metal, the base color is the specific measured reflectance value
  150900. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  150901. * of the material.
  150902. */
  150903. baseColor: Color3;
  150904. /**
  150905. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  150906. * well as opacity information in the alpha channel.
  150907. */
  150908. baseTexture: BaseTexture;
  150909. /**
  150910. * Specifies the metallic scalar value of the material.
  150911. * Can also be used to scale the metalness values of the metallic texture.
  150912. */
  150913. metallic: number;
  150914. /**
  150915. * Specifies the roughness scalar value of the material.
  150916. * Can also be used to scale the roughness values of the metallic texture.
  150917. */
  150918. roughness: number;
  150919. /**
  150920. * Texture containing both the metallic value in the B channel and the
  150921. * roughness value in the G channel to keep better precision.
  150922. */
  150923. metallicRoughnessTexture: BaseTexture;
  150924. /**
  150925. * Instantiates a new PBRMetalRoughnessMaterial instance.
  150926. *
  150927. * @param name The material name
  150928. * @param scene The scene the material will be use in.
  150929. */
  150930. constructor(name: string, scene: Scene);
  150931. /**
  150932. * Return the currrent class name of the material.
  150933. */
  150934. getClassName(): string;
  150935. /**
  150936. * Makes a duplicate of the current material.
  150937. * @param name - name to use for the new material.
  150938. */
  150939. clone(name: string): PBRMetallicRoughnessMaterial;
  150940. /**
  150941. * Serialize the material to a parsable JSON object.
  150942. */
  150943. serialize(): any;
  150944. /**
  150945. * Parses a JSON object correponding to the serialize function.
  150946. */
  150947. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  150948. }
  150949. }
  150950. declare module BABYLON {
  150951. /**
  150952. * The PBR material of BJS following the specular glossiness convention.
  150953. *
  150954. * This fits to the PBR convention in the GLTF definition:
  150955. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  150956. */
  150957. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  150958. /**
  150959. * Specifies the diffuse color of the material.
  150960. */
  150961. diffuseColor: Color3;
  150962. /**
  150963. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  150964. * channel.
  150965. */
  150966. diffuseTexture: BaseTexture;
  150967. /**
  150968. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  150969. */
  150970. specularColor: Color3;
  150971. /**
  150972. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  150973. */
  150974. glossiness: number;
  150975. /**
  150976. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  150977. */
  150978. specularGlossinessTexture: BaseTexture;
  150979. /**
  150980. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  150981. */
  150982. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  150983. /**
  150984. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  150985. *
  150986. * @param name The material name
  150987. * @param scene The scene the material will be use in.
  150988. */
  150989. constructor(name: string, scene: Scene);
  150990. /**
  150991. * Return the currrent class name of the material.
  150992. */
  150993. getClassName(): string;
  150994. /**
  150995. * Makes a duplicate of the current material.
  150996. * @param name - name to use for the new material.
  150997. */
  150998. clone(name: string): PBRSpecularGlossinessMaterial;
  150999. /**
  151000. * Serialize the material to a parsable JSON object.
  151001. */
  151002. serialize(): any;
  151003. /**
  151004. * Parses a JSON object correponding to the serialize function.
  151005. */
  151006. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  151007. }
  151008. }
  151009. declare module BABYLON {
  151010. /**
  151011. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  151012. * It can help converting any input color in a desired output one. This can then be used to create effects
  151013. * from sepia, black and white to sixties or futuristic rendering...
  151014. *
  151015. * The only supported format is currently 3dl.
  151016. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  151017. */
  151018. export class ColorGradingTexture extends BaseTexture {
  151019. /**
  151020. * The texture URL.
  151021. */
  151022. url: string;
  151023. /**
  151024. * Empty line regex stored for GC.
  151025. */
  151026. private static _noneEmptyLineRegex;
  151027. private _textureMatrix;
  151028. private _onLoad;
  151029. /**
  151030. * Instantiates a ColorGradingTexture from the following parameters.
  151031. *
  151032. * @param url The location of the color gradind data (currently only supporting 3dl)
  151033. * @param sceneOrEngine The scene or engine the texture will be used in
  151034. * @param onLoad defines a callback triggered when the texture has been loaded
  151035. */
  151036. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  151037. /**
  151038. * Fires the onload event from the constructor if requested.
  151039. */
  151040. private _triggerOnLoad;
  151041. /**
  151042. * Returns the texture matrix used in most of the material.
  151043. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  151044. */
  151045. getTextureMatrix(): Matrix;
  151046. /**
  151047. * Occurs when the file being loaded is a .3dl LUT file.
  151048. */
  151049. private load3dlTexture;
  151050. /**
  151051. * Starts the loading process of the texture.
  151052. */
  151053. private loadTexture;
  151054. /**
  151055. * Clones the color gradind texture.
  151056. */
  151057. clone(): ColorGradingTexture;
  151058. /**
  151059. * Called during delayed load for textures.
  151060. */
  151061. delayLoad(): void;
  151062. /**
  151063. * Parses a color grading texture serialized by Babylon.
  151064. * @param parsedTexture The texture information being parsedTexture
  151065. * @param scene The scene to load the texture in
  151066. * @param rootUrl The root url of the data assets to load
  151067. * @return A color gradind texture
  151068. */
  151069. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  151070. /**
  151071. * Serializes the LUT texture to json format.
  151072. */
  151073. serialize(): any;
  151074. }
  151075. }
  151076. declare module BABYLON {
  151077. /**
  151078. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  151079. */
  151080. export class EquiRectangularCubeTexture extends BaseTexture {
  151081. /** The six faces of the cube. */
  151082. private static _FacesMapping;
  151083. private _noMipmap;
  151084. private _onLoad;
  151085. private _onError;
  151086. /** The size of the cubemap. */
  151087. private _size;
  151088. /** The buffer of the image. */
  151089. private _buffer;
  151090. /** The width of the input image. */
  151091. private _width;
  151092. /** The height of the input image. */
  151093. private _height;
  151094. /** The URL to the image. */
  151095. url: string;
  151096. /**
  151097. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  151098. * @param url The location of the image
  151099. * @param scene The scene the texture will be used in
  151100. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  151101. * @param noMipmap Forces to not generate the mipmap if true
  151102. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151103. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151104. * @param onLoad — defines a callback called when texture is loaded
  151105. * @param onError — defines a callback called if there is an error
  151106. */
  151107. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  151108. /**
  151109. * Load the image data, by putting the image on a canvas and extracting its buffer.
  151110. */
  151111. private loadImage;
  151112. /**
  151113. * Convert the image buffer into a cubemap and create a CubeTexture.
  151114. */
  151115. private loadTexture;
  151116. /**
  151117. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  151118. * @param buffer The ArrayBuffer that should be converted.
  151119. * @returns The buffer as Float32Array.
  151120. */
  151121. private getFloat32ArrayFromArrayBuffer;
  151122. /**
  151123. * Get the current class name of the texture useful for serialization or dynamic coding.
  151124. * @returns "EquiRectangularCubeTexture"
  151125. */
  151126. getClassName(): string;
  151127. /**
  151128. * Create a clone of the current EquiRectangularCubeTexture and return it.
  151129. * @returns A clone of the current EquiRectangularCubeTexture.
  151130. */
  151131. clone(): EquiRectangularCubeTexture;
  151132. }
  151133. }
  151134. declare module BABYLON {
  151135. /**
  151136. * Defines the options related to the creation of an HtmlElementTexture
  151137. */
  151138. export interface IHtmlElementTextureOptions {
  151139. /**
  151140. * Defines wether mip maps should be created or not.
  151141. */
  151142. generateMipMaps?: boolean;
  151143. /**
  151144. * Defines the sampling mode of the texture.
  151145. */
  151146. samplingMode?: number;
  151147. /**
  151148. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  151149. */
  151150. engine: Nullable<ThinEngine>;
  151151. /**
  151152. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  151153. */
  151154. scene: Nullable<Scene>;
  151155. }
  151156. /**
  151157. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  151158. * To be as efficient as possible depending on your constraints nothing aside the first upload
  151159. * is automatically managed.
  151160. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  151161. * in your application.
  151162. *
  151163. * As the update is not automatic, you need to call them manually.
  151164. */
  151165. export class HtmlElementTexture extends BaseTexture {
  151166. /**
  151167. * The texture URL.
  151168. */
  151169. element: HTMLVideoElement | HTMLCanvasElement;
  151170. private static readonly DefaultOptions;
  151171. private _textureMatrix;
  151172. private _isVideo;
  151173. private _generateMipMaps;
  151174. private _samplingMode;
  151175. /**
  151176. * Instantiates a HtmlElementTexture from the following parameters.
  151177. *
  151178. * @param name Defines the name of the texture
  151179. * @param element Defines the video or canvas the texture is filled with
  151180. * @param options Defines the other none mandatory texture creation options
  151181. */
  151182. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  151183. private _createInternalTexture;
  151184. /**
  151185. * Returns the texture matrix used in most of the material.
  151186. */
  151187. getTextureMatrix(): Matrix;
  151188. /**
  151189. * Updates the content of the texture.
  151190. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  151191. */
  151192. update(invertY?: Nullable<boolean>): void;
  151193. }
  151194. }
  151195. declare module BABYLON {
  151196. /**
  151197. * Based on jsTGALoader - Javascript loader for TGA file
  151198. * By Vincent Thibault
  151199. * @see http://blog.robrowser.com/javascript-tga-loader.html
  151200. */
  151201. export class TGATools {
  151202. private static _TYPE_INDEXED;
  151203. private static _TYPE_RGB;
  151204. private static _TYPE_GREY;
  151205. private static _TYPE_RLE_INDEXED;
  151206. private static _TYPE_RLE_RGB;
  151207. private static _TYPE_RLE_GREY;
  151208. private static _ORIGIN_MASK;
  151209. private static _ORIGIN_SHIFT;
  151210. private static _ORIGIN_BL;
  151211. private static _ORIGIN_BR;
  151212. private static _ORIGIN_UL;
  151213. private static _ORIGIN_UR;
  151214. /**
  151215. * Gets the header of a TGA file
  151216. * @param data defines the TGA data
  151217. * @returns the header
  151218. */
  151219. static GetTGAHeader(data: Uint8Array): any;
  151220. /**
  151221. * Uploads TGA content to a Babylon Texture
  151222. * @hidden
  151223. */
  151224. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  151225. /** @hidden */
  151226. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  151227. /** @hidden */
  151228. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  151229. /** @hidden */
  151230. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  151231. /** @hidden */
  151232. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  151233. /** @hidden */
  151234. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  151235. /** @hidden */
  151236. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  151237. }
  151238. }
  151239. declare module BABYLON {
  151240. /**
  151241. * Implementation of the TGA Texture Loader.
  151242. * @hidden
  151243. */
  151244. export class _TGATextureLoader implements IInternalTextureLoader {
  151245. /**
  151246. * Defines wether the loader supports cascade loading the different faces.
  151247. */
  151248. readonly supportCascades: boolean;
  151249. /**
  151250. * This returns if the loader support the current file information.
  151251. * @param extension defines the file extension of the file being loaded
  151252. * @returns true if the loader can load the specified file
  151253. */
  151254. canLoad(extension: string): boolean;
  151255. /**
  151256. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  151257. * @param data contains the texture data
  151258. * @param texture defines the BabylonJS internal texture
  151259. * @param createPolynomials will be true if polynomials have been requested
  151260. * @param onLoad defines the callback to trigger once the texture is ready
  151261. * @param onError defines the callback to trigger in case of error
  151262. */
  151263. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  151264. /**
  151265. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  151266. * @param data contains the texture data
  151267. * @param texture defines the BabylonJS internal texture
  151268. * @param callback defines the method to call once ready to upload
  151269. */
  151270. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  151271. }
  151272. }
  151273. declare module BABYLON {
  151274. /**
  151275. * Implementation of the HDR Texture Loader.
  151276. * @hidden
  151277. */
  151278. export class _HDRTextureLoader implements IInternalTextureLoader {
  151279. /**
  151280. * Defines wether the loader supports cascade loading the different faces.
  151281. */
  151282. readonly supportCascades: boolean;
  151283. /**
  151284. * This returns if the loader support the current file information.
  151285. * @param extension defines the file extension of the file being loaded
  151286. * @returns true if the loader can load the specified file
  151287. */
  151288. canLoad(extension: string): boolean;
  151289. /**
  151290. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  151291. * @param data contains the texture data
  151292. * @param texture defines the BabylonJS internal texture
  151293. * @param createPolynomials will be true if polynomials have been requested
  151294. * @param onLoad defines the callback to trigger once the texture is ready
  151295. * @param onError defines the callback to trigger in case of error
  151296. */
  151297. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  151298. /**
  151299. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  151300. * @param data contains the texture data
  151301. * @param texture defines the BabylonJS internal texture
  151302. * @param callback defines the method to call once ready to upload
  151303. */
  151304. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  151305. }
  151306. }
  151307. declare module BABYLON {
  151308. /**
  151309. * Info about the .basis files
  151310. */
  151311. class BasisFileInfo {
  151312. /**
  151313. * If the file has alpha
  151314. */
  151315. hasAlpha: boolean;
  151316. /**
  151317. * Info about each image of the basis file
  151318. */
  151319. images: Array<{
  151320. levels: Array<{
  151321. width: number;
  151322. height: number;
  151323. transcodedPixels: ArrayBufferView;
  151324. }>;
  151325. }>;
  151326. }
  151327. /**
  151328. * Result of transcoding a basis file
  151329. */
  151330. class TranscodeResult {
  151331. /**
  151332. * Info about the .basis file
  151333. */
  151334. fileInfo: BasisFileInfo;
  151335. /**
  151336. * Format to use when loading the file
  151337. */
  151338. format: number;
  151339. }
  151340. /**
  151341. * Configuration options for the Basis transcoder
  151342. */
  151343. export class BasisTranscodeConfiguration {
  151344. /**
  151345. * Supported compression formats used to determine the supported output format of the transcoder
  151346. */
  151347. supportedCompressionFormats?: {
  151348. /**
  151349. * etc1 compression format
  151350. */
  151351. etc1?: boolean;
  151352. /**
  151353. * s3tc compression format
  151354. */
  151355. s3tc?: boolean;
  151356. /**
  151357. * pvrtc compression format
  151358. */
  151359. pvrtc?: boolean;
  151360. /**
  151361. * etc2 compression format
  151362. */
  151363. etc2?: boolean;
  151364. };
  151365. /**
  151366. * If mipmap levels should be loaded for transcoded images (Default: true)
  151367. */
  151368. loadMipmapLevels?: boolean;
  151369. /**
  151370. * Index of a single image to load (Default: all images)
  151371. */
  151372. loadSingleImage?: number;
  151373. }
  151374. /**
  151375. * Used to load .Basis files
  151376. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  151377. */
  151378. export class BasisTools {
  151379. private static _IgnoreSupportedFormats;
  151380. /**
  151381. * URL to use when loading the basis transcoder
  151382. */
  151383. static JSModuleURL: string;
  151384. /**
  151385. * URL to use when loading the wasm module for the transcoder
  151386. */
  151387. static WasmModuleURL: string;
  151388. /**
  151389. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  151390. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  151391. * @returns internal format corresponding to the Basis format
  151392. */
  151393. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  151394. private static _WorkerPromise;
  151395. private static _Worker;
  151396. private static _actionId;
  151397. private static _CreateWorkerAsync;
  151398. /**
  151399. * Transcodes a loaded image file to compressed pixel data
  151400. * @param data image data to transcode
  151401. * @param config configuration options for the transcoding
  151402. * @returns a promise resulting in the transcoded image
  151403. */
  151404. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  151405. /**
  151406. * Loads a texture from the transcode result
  151407. * @param texture texture load to
  151408. * @param transcodeResult the result of transcoding the basis file to load from
  151409. */
  151410. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  151411. }
  151412. }
  151413. declare module BABYLON {
  151414. /**
  151415. * Loader for .basis file format
  151416. */
  151417. export class _BasisTextureLoader implements IInternalTextureLoader {
  151418. /**
  151419. * Defines whether the loader supports cascade loading the different faces.
  151420. */
  151421. readonly supportCascades: boolean;
  151422. /**
  151423. * This returns if the loader support the current file information.
  151424. * @param extension defines the file extension of the file being loaded
  151425. * @returns true if the loader can load the specified file
  151426. */
  151427. canLoad(extension: string): boolean;
  151428. /**
  151429. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  151430. * @param data contains the texture data
  151431. * @param texture defines the BabylonJS internal texture
  151432. * @param createPolynomials will be true if polynomials have been requested
  151433. * @param onLoad defines the callback to trigger once the texture is ready
  151434. * @param onError defines the callback to trigger in case of error
  151435. */
  151436. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  151437. /**
  151438. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  151439. * @param data contains the texture data
  151440. * @param texture defines the BabylonJS internal texture
  151441. * @param callback defines the method to call once ready to upload
  151442. */
  151443. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  151444. }
  151445. }
  151446. declare module BABYLON {
  151447. /**
  151448. * Defines the basic options interface of a TexturePacker Frame
  151449. */
  151450. export interface ITexturePackerFrame {
  151451. /**
  151452. * The frame ID
  151453. */
  151454. id: number;
  151455. /**
  151456. * The frames Scale
  151457. */
  151458. scale: Vector2;
  151459. /**
  151460. * The Frames offset
  151461. */
  151462. offset: Vector2;
  151463. }
  151464. /**
  151465. * This is a support class for frame Data on texture packer sets.
  151466. */
  151467. export class TexturePackerFrame implements ITexturePackerFrame {
  151468. /**
  151469. * The frame ID
  151470. */
  151471. id: number;
  151472. /**
  151473. * The frames Scale
  151474. */
  151475. scale: Vector2;
  151476. /**
  151477. * The Frames offset
  151478. */
  151479. offset: Vector2;
  151480. /**
  151481. * Initializes a texture package frame.
  151482. * @param id The numerical frame identifier
  151483. * @param scale Scalar Vector2 for UV frame
  151484. * @param offset Vector2 for the frame position in UV units.
  151485. * @returns TexturePackerFrame
  151486. */
  151487. constructor(id: number, scale: Vector2, offset: Vector2);
  151488. }
  151489. }
  151490. declare module BABYLON {
  151491. /**
  151492. * Defines the basic options interface of a TexturePacker
  151493. */
  151494. export interface ITexturePackerOptions {
  151495. /**
  151496. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  151497. */
  151498. map?: string[];
  151499. /**
  151500. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  151501. */
  151502. uvsIn?: string;
  151503. /**
  151504. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  151505. */
  151506. uvsOut?: string;
  151507. /**
  151508. * number representing the layout style. Defaults to LAYOUT_STRIP
  151509. */
  151510. layout?: number;
  151511. /**
  151512. * number of columns if using custom column count layout(2). This defaults to 4.
  151513. */
  151514. colnum?: number;
  151515. /**
  151516. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  151517. */
  151518. updateInputMeshes?: boolean;
  151519. /**
  151520. * boolean flag to dispose all the source textures. Defaults to true.
  151521. */
  151522. disposeSources?: boolean;
  151523. /**
  151524. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  151525. */
  151526. fillBlanks?: boolean;
  151527. /**
  151528. * string value representing the context fill style color. Defaults to 'black'.
  151529. */
  151530. customFillColor?: string;
  151531. /**
  151532. * Width and Height Value of each Frame in the TexturePacker Sets
  151533. */
  151534. frameSize?: number;
  151535. /**
  151536. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  151537. */
  151538. paddingRatio?: number;
  151539. /**
  151540. * Number that declares the fill method for the padding gutter.
  151541. */
  151542. paddingMode?: number;
  151543. /**
  151544. * If in SUBUV_COLOR padding mode what color to use.
  151545. */
  151546. paddingColor?: Color3 | Color4;
  151547. }
  151548. /**
  151549. * Defines the basic interface of a TexturePacker JSON File
  151550. */
  151551. export interface ITexturePackerJSON {
  151552. /**
  151553. * The frame ID
  151554. */
  151555. name: string;
  151556. /**
  151557. * The base64 channel data
  151558. */
  151559. sets: any;
  151560. /**
  151561. * The options of the Packer
  151562. */
  151563. options: ITexturePackerOptions;
  151564. /**
  151565. * The frame data of the Packer
  151566. */
  151567. frames: Array<number>;
  151568. }
  151569. /**
  151570. * This is a support class that generates a series of packed texture sets.
  151571. * @see https://doc.babylonjs.com/babylon101/materials
  151572. */
  151573. export class TexturePacker {
  151574. /** Packer Layout Constant 0 */
  151575. static readonly LAYOUT_STRIP: number;
  151576. /** Packer Layout Constant 1 */
  151577. static readonly LAYOUT_POWER2: number;
  151578. /** Packer Layout Constant 2 */
  151579. static readonly LAYOUT_COLNUM: number;
  151580. /** Packer Layout Constant 0 */
  151581. static readonly SUBUV_WRAP: number;
  151582. /** Packer Layout Constant 1 */
  151583. static readonly SUBUV_EXTEND: number;
  151584. /** Packer Layout Constant 2 */
  151585. static readonly SUBUV_COLOR: number;
  151586. /** The Name of the Texture Package */
  151587. name: string;
  151588. /** The scene scope of the TexturePacker */
  151589. scene: Scene;
  151590. /** The Meshes to target */
  151591. meshes: AbstractMesh[];
  151592. /** Arguments passed with the Constructor */
  151593. options: ITexturePackerOptions;
  151594. /** The promise that is started upon initialization */
  151595. promise: Nullable<Promise<TexturePacker | string>>;
  151596. /** The Container object for the channel sets that are generated */
  151597. sets: object;
  151598. /** The Container array for the frames that are generated */
  151599. frames: TexturePackerFrame[];
  151600. /** The expected number of textures the system is parsing. */
  151601. private _expecting;
  151602. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  151603. private _paddingValue;
  151604. /**
  151605. * Initializes a texture package series from an array of meshes or a single mesh.
  151606. * @param name The name of the package
  151607. * @param meshes The target meshes to compose the package from
  151608. * @param options The arguments that texture packer should follow while building.
  151609. * @param scene The scene which the textures are scoped to.
  151610. * @returns TexturePacker
  151611. */
  151612. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  151613. /**
  151614. * Starts the package process
  151615. * @param resolve The promises resolution function
  151616. * @returns TexturePacker
  151617. */
  151618. private _createFrames;
  151619. /**
  151620. * Calculates the Size of the Channel Sets
  151621. * @returns Vector2
  151622. */
  151623. private _calculateSize;
  151624. /**
  151625. * Calculates the UV data for the frames.
  151626. * @param baseSize the base frameSize
  151627. * @param padding the base frame padding
  151628. * @param dtSize size of the Dynamic Texture for that channel
  151629. * @param dtUnits is 1/dtSize
  151630. * @param update flag to update the input meshes
  151631. */
  151632. private _calculateMeshUVFrames;
  151633. /**
  151634. * Calculates the frames Offset.
  151635. * @param index of the frame
  151636. * @returns Vector2
  151637. */
  151638. private _getFrameOffset;
  151639. /**
  151640. * Updates a Mesh to the frame data
  151641. * @param mesh that is the target
  151642. * @param frameID or the frame index
  151643. */
  151644. private _updateMeshUV;
  151645. /**
  151646. * Updates a Meshes materials to use the texture packer channels
  151647. * @param m is the mesh to target
  151648. * @param force all channels on the packer to be set.
  151649. */
  151650. private _updateTextureReferences;
  151651. /**
  151652. * Public method to set a Mesh to a frame
  151653. * @param m that is the target
  151654. * @param frameID or the frame index
  151655. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  151656. */
  151657. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  151658. /**
  151659. * Starts the async promise to compile the texture packer.
  151660. * @returns Promise<void>
  151661. */
  151662. processAsync(): Promise<void>;
  151663. /**
  151664. * Disposes all textures associated with this packer
  151665. */
  151666. dispose(): void;
  151667. /**
  151668. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  151669. * @param imageType is the image type to use.
  151670. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  151671. */
  151672. download(imageType?: string, quality?: number): void;
  151673. /**
  151674. * Public method to load a texturePacker JSON file.
  151675. * @param data of the JSON file in string format.
  151676. */
  151677. updateFromJSON(data: string): void;
  151678. }
  151679. }
  151680. declare module BABYLON {
  151681. /**
  151682. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  151683. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  151684. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  151685. */
  151686. export class CustomProceduralTexture extends ProceduralTexture {
  151687. private _animate;
  151688. private _time;
  151689. private _config;
  151690. private _texturePath;
  151691. /**
  151692. * Instantiates a new Custom Procedural Texture.
  151693. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  151694. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  151695. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  151696. * @param name Define the name of the texture
  151697. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  151698. * @param size Define the size of the texture to create
  151699. * @param scene Define the scene the texture belongs to
  151700. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  151701. * @param generateMipMaps Define if the texture should creates mip maps or not
  151702. */
  151703. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  151704. private _loadJson;
  151705. /**
  151706. * Is the texture ready to be used ? (rendered at least once)
  151707. * @returns true if ready, otherwise, false.
  151708. */
  151709. isReady(): boolean;
  151710. /**
  151711. * Render the texture to its associated render target.
  151712. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  151713. */
  151714. render(useCameraPostProcess?: boolean): void;
  151715. /**
  151716. * Update the list of dependant textures samplers in the shader.
  151717. */
  151718. updateTextures(): void;
  151719. /**
  151720. * Update the uniform values of the procedural texture in the shader.
  151721. */
  151722. updateShaderUniforms(): void;
  151723. /**
  151724. * Define if the texture animates or not.
  151725. */
  151726. get animate(): boolean;
  151727. set animate(value: boolean);
  151728. }
  151729. }
  151730. declare module BABYLON {
  151731. /** @hidden */
  151732. export var noisePixelShader: {
  151733. name: string;
  151734. shader: string;
  151735. };
  151736. }
  151737. declare module BABYLON {
  151738. /**
  151739. * Class used to generate noise procedural textures
  151740. */
  151741. export class NoiseProceduralTexture extends ProceduralTexture {
  151742. /** Gets or sets the start time (default is 0) */
  151743. time: number;
  151744. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  151745. brightness: number;
  151746. /** Defines the number of octaves to process */
  151747. octaves: number;
  151748. /** Defines the level of persistence (0.8 by default) */
  151749. persistence: number;
  151750. /** Gets or sets animation speed factor (default is 1) */
  151751. animationSpeedFactor: number;
  151752. /**
  151753. * Creates a new NoiseProceduralTexture
  151754. * @param name defines the name fo the texture
  151755. * @param size defines the size of the texture (default is 256)
  151756. * @param scene defines the hosting scene
  151757. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  151758. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  151759. */
  151760. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  151761. private _updateShaderUniforms;
  151762. protected _getDefines(): string;
  151763. /** Generate the current state of the procedural texture */
  151764. render(useCameraPostProcess?: boolean): void;
  151765. /**
  151766. * Serializes this noise procedural texture
  151767. * @returns a serialized noise procedural texture object
  151768. */
  151769. serialize(): any;
  151770. /**
  151771. * Clone the texture.
  151772. * @returns the cloned texture
  151773. */
  151774. clone(): NoiseProceduralTexture;
  151775. /**
  151776. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  151777. * @param parsedTexture defines parsed texture data
  151778. * @param scene defines the current scene
  151779. * @param rootUrl defines the root URL containing noise procedural texture information
  151780. * @returns a parsed NoiseProceduralTexture
  151781. */
  151782. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  151783. }
  151784. }
  151785. declare module BABYLON {
  151786. /**
  151787. * Raw cube texture where the raw buffers are passed in
  151788. */
  151789. export class RawCubeTexture extends CubeTexture {
  151790. /**
  151791. * Creates a cube texture where the raw buffers are passed in.
  151792. * @param scene defines the scene the texture is attached to
  151793. * @param data defines the array of data to use to create each face
  151794. * @param size defines the size of the textures
  151795. * @param format defines the format of the data
  151796. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  151797. * @param generateMipMaps defines if the engine should generate the mip levels
  151798. * @param invertY defines if data must be stored with Y axis inverted
  151799. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  151800. * @param compression defines the compression used (null by default)
  151801. */
  151802. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  151803. /**
  151804. * Updates the raw cube texture.
  151805. * @param data defines the data to store
  151806. * @param format defines the data format
  151807. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151808. * @param invertY defines if data must be stored with Y axis inverted
  151809. * @param compression defines the compression used (null by default)
  151810. * @param level defines which level of the texture to update
  151811. */
  151812. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  151813. /**
  151814. * Updates a raw cube texture with RGBD encoded data.
  151815. * @param data defines the array of data [mipmap][face] to use to create each face
  151816. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  151817. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  151818. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  151819. * @returns a promsie that resolves when the operation is complete
  151820. */
  151821. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  151822. /**
  151823. * Clones the raw cube texture.
  151824. * @return a new cube texture
  151825. */
  151826. clone(): CubeTexture;
  151827. /** @hidden */
  151828. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  151829. }
  151830. }
  151831. declare module BABYLON {
  151832. /**
  151833. * Class used to store 2D array textures containing user data
  151834. */
  151835. export class RawTexture2DArray extends Texture {
  151836. /** Gets or sets the texture format to use */
  151837. format: number;
  151838. /**
  151839. * Create a new RawTexture2DArray
  151840. * @param data defines the data of the texture
  151841. * @param width defines the width of the texture
  151842. * @param height defines the height of the texture
  151843. * @param depth defines the number of layers of the texture
  151844. * @param format defines the texture format to use
  151845. * @param scene defines the hosting scene
  151846. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  151847. * @param invertY defines if texture must be stored with Y axis inverted
  151848. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151849. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  151850. */
  151851. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  151852. /** Gets or sets the texture format to use */
  151853. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  151854. /**
  151855. * Update the texture with new data
  151856. * @param data defines the data to store in the texture
  151857. */
  151858. update(data: ArrayBufferView): void;
  151859. }
  151860. }
  151861. declare module BABYLON {
  151862. /**
  151863. * Class used to store 3D textures containing user data
  151864. */
  151865. export class RawTexture3D extends Texture {
  151866. /** Gets or sets the texture format to use */
  151867. format: number;
  151868. /**
  151869. * Create a new RawTexture3D
  151870. * @param data defines the data of the texture
  151871. * @param width defines the width of the texture
  151872. * @param height defines the height of the texture
  151873. * @param depth defines the depth of the texture
  151874. * @param format defines the texture format to use
  151875. * @param scene defines the hosting scene
  151876. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  151877. * @param invertY defines if texture must be stored with Y axis inverted
  151878. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151879. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  151880. */
  151881. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  151882. /** Gets or sets the texture format to use */
  151883. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  151884. /**
  151885. * Update the texture with new data
  151886. * @param data defines the data to store in the texture
  151887. */
  151888. update(data: ArrayBufferView): void;
  151889. }
  151890. }
  151891. declare module BABYLON {
  151892. /**
  151893. * Creates a refraction texture used by refraction channel of the standard material.
  151894. * It is like a mirror but to see through a material.
  151895. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151896. */
  151897. export class RefractionTexture extends RenderTargetTexture {
  151898. /**
  151899. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  151900. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  151901. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151902. */
  151903. refractionPlane: Plane;
  151904. /**
  151905. * Define how deep under the surface we should see.
  151906. */
  151907. depth: number;
  151908. /**
  151909. * Creates a refraction texture used by refraction channel of the standard material.
  151910. * It is like a mirror but to see through a material.
  151911. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151912. * @param name Define the texture name
  151913. * @param size Define the size of the underlying texture
  151914. * @param scene Define the scene the refraction belongs to
  151915. * @param generateMipMaps Define if we need to generate mips level for the refraction
  151916. */
  151917. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  151918. /**
  151919. * Clone the refraction texture.
  151920. * @returns the cloned texture
  151921. */
  151922. clone(): RefractionTexture;
  151923. /**
  151924. * Serialize the texture to a JSON representation you could use in Parse later on
  151925. * @returns the serialized JSON representation
  151926. */
  151927. serialize(): any;
  151928. }
  151929. }
  151930. declare module BABYLON {
  151931. /**
  151932. * Block used to add support for vertex skinning (bones)
  151933. */
  151934. export class BonesBlock extends NodeMaterialBlock {
  151935. /**
  151936. * Creates a new BonesBlock
  151937. * @param name defines the block name
  151938. */
  151939. constructor(name: string);
  151940. /**
  151941. * Initialize the block and prepare the context for build
  151942. * @param state defines the state that will be used for the build
  151943. */
  151944. initialize(state: NodeMaterialBuildState): void;
  151945. /**
  151946. * Gets the current class name
  151947. * @returns the class name
  151948. */
  151949. getClassName(): string;
  151950. /**
  151951. * Gets the matrix indices input component
  151952. */
  151953. get matricesIndices(): NodeMaterialConnectionPoint;
  151954. /**
  151955. * Gets the matrix weights input component
  151956. */
  151957. get matricesWeights(): NodeMaterialConnectionPoint;
  151958. /**
  151959. * Gets the extra matrix indices input component
  151960. */
  151961. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  151962. /**
  151963. * Gets the extra matrix weights input component
  151964. */
  151965. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  151966. /**
  151967. * Gets the world input component
  151968. */
  151969. get world(): NodeMaterialConnectionPoint;
  151970. /**
  151971. * Gets the output component
  151972. */
  151973. get output(): NodeMaterialConnectionPoint;
  151974. autoConfigure(material: NodeMaterial): void;
  151975. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  151976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151978. protected _buildBlock(state: NodeMaterialBuildState): this;
  151979. }
  151980. }
  151981. declare module BABYLON {
  151982. /**
  151983. * Block used to add support for instances
  151984. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  151985. */
  151986. export class InstancesBlock extends NodeMaterialBlock {
  151987. /**
  151988. * Creates a new InstancesBlock
  151989. * @param name defines the block name
  151990. */
  151991. constructor(name: string);
  151992. /**
  151993. * Gets the current class name
  151994. * @returns the class name
  151995. */
  151996. getClassName(): string;
  151997. /**
  151998. * Gets the first world row input component
  151999. */
  152000. get world0(): NodeMaterialConnectionPoint;
  152001. /**
  152002. * Gets the second world row input component
  152003. */
  152004. get world1(): NodeMaterialConnectionPoint;
  152005. /**
  152006. * Gets the third world row input component
  152007. */
  152008. get world2(): NodeMaterialConnectionPoint;
  152009. /**
  152010. * Gets the forth world row input component
  152011. */
  152012. get world3(): NodeMaterialConnectionPoint;
  152013. /**
  152014. * Gets the world input component
  152015. */
  152016. get world(): NodeMaterialConnectionPoint;
  152017. /**
  152018. * Gets the output component
  152019. */
  152020. get output(): NodeMaterialConnectionPoint;
  152021. /**
  152022. * Gets the isntanceID component
  152023. */
  152024. get instanceID(): NodeMaterialConnectionPoint;
  152025. autoConfigure(material: NodeMaterial): void;
  152026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  152027. protected _buildBlock(state: NodeMaterialBuildState): this;
  152028. }
  152029. }
  152030. declare module BABYLON {
  152031. /**
  152032. * Block used to add morph targets support to vertex shader
  152033. */
  152034. export class MorphTargetsBlock extends NodeMaterialBlock {
  152035. private _repeatableContentAnchor;
  152036. /**
  152037. * Create a new MorphTargetsBlock
  152038. * @param name defines the block name
  152039. */
  152040. constructor(name: string);
  152041. /**
  152042. * Gets the current class name
  152043. * @returns the class name
  152044. */
  152045. getClassName(): string;
  152046. /**
  152047. * Gets the position input component
  152048. */
  152049. get position(): NodeMaterialConnectionPoint;
  152050. /**
  152051. * Gets the normal input component
  152052. */
  152053. get normal(): NodeMaterialConnectionPoint;
  152054. /**
  152055. * Gets the tangent input component
  152056. */
  152057. get tangent(): NodeMaterialConnectionPoint;
  152058. /**
  152059. * Gets the tangent input component
  152060. */
  152061. get uv(): NodeMaterialConnectionPoint;
  152062. /**
  152063. * Gets the position output component
  152064. */
  152065. get positionOutput(): NodeMaterialConnectionPoint;
  152066. /**
  152067. * Gets the normal output component
  152068. */
  152069. get normalOutput(): NodeMaterialConnectionPoint;
  152070. /**
  152071. * Gets the tangent output component
  152072. */
  152073. get tangentOutput(): NodeMaterialConnectionPoint;
  152074. /**
  152075. * Gets the tangent output component
  152076. */
  152077. get uvOutput(): NodeMaterialConnectionPoint;
  152078. initialize(state: NodeMaterialBuildState): void;
  152079. autoConfigure(material: NodeMaterial): void;
  152080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152081. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152082. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  152083. protected _buildBlock(state: NodeMaterialBuildState): this;
  152084. }
  152085. }
  152086. declare module BABYLON {
  152087. /**
  152088. * Block used to get data information from a light
  152089. */
  152090. export class LightInformationBlock extends NodeMaterialBlock {
  152091. private _lightDataUniformName;
  152092. private _lightColorUniformName;
  152093. private _lightTypeDefineName;
  152094. /**
  152095. * Gets or sets the light associated with this block
  152096. */
  152097. light: Nullable<Light>;
  152098. /**
  152099. * Creates a new LightInformationBlock
  152100. * @param name defines the block name
  152101. */
  152102. constructor(name: string);
  152103. /**
  152104. * Gets the current class name
  152105. * @returns the class name
  152106. */
  152107. getClassName(): string;
  152108. /**
  152109. * Gets the world position input component
  152110. */
  152111. get worldPosition(): NodeMaterialConnectionPoint;
  152112. /**
  152113. * Gets the direction output component
  152114. */
  152115. get direction(): NodeMaterialConnectionPoint;
  152116. /**
  152117. * Gets the direction output component
  152118. */
  152119. get color(): NodeMaterialConnectionPoint;
  152120. /**
  152121. * Gets the direction output component
  152122. */
  152123. get intensity(): NodeMaterialConnectionPoint;
  152124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152125. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152126. protected _buildBlock(state: NodeMaterialBuildState): this;
  152127. serialize(): any;
  152128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152129. }
  152130. }
  152131. declare module BABYLON {
  152132. /**
  152133. * Block used to add image processing support to fragment shader
  152134. */
  152135. export class ImageProcessingBlock extends NodeMaterialBlock {
  152136. /**
  152137. * Create a new ImageProcessingBlock
  152138. * @param name defines the block name
  152139. */
  152140. constructor(name: string);
  152141. /**
  152142. * Gets the current class name
  152143. * @returns the class name
  152144. */
  152145. getClassName(): string;
  152146. /**
  152147. * Gets the color input component
  152148. */
  152149. get color(): NodeMaterialConnectionPoint;
  152150. /**
  152151. * Gets the output component
  152152. */
  152153. get output(): NodeMaterialConnectionPoint;
  152154. /**
  152155. * Initialize the block and prepare the context for build
  152156. * @param state defines the state that will be used for the build
  152157. */
  152158. initialize(state: NodeMaterialBuildState): void;
  152159. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  152160. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152161. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152162. protected _buildBlock(state: NodeMaterialBuildState): this;
  152163. }
  152164. }
  152165. declare module BABYLON {
  152166. /**
  152167. * Block used to pertub normals based on a normal map
  152168. */
  152169. export class PerturbNormalBlock extends NodeMaterialBlock {
  152170. private _tangentSpaceParameterName;
  152171. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  152172. invertX: boolean;
  152173. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  152174. invertY: boolean;
  152175. /**
  152176. * Create a new PerturbNormalBlock
  152177. * @param name defines the block name
  152178. */
  152179. constructor(name: string);
  152180. /**
  152181. * Gets the current class name
  152182. * @returns the class name
  152183. */
  152184. getClassName(): string;
  152185. /**
  152186. * Gets the world position input component
  152187. */
  152188. get worldPosition(): NodeMaterialConnectionPoint;
  152189. /**
  152190. * Gets the world normal input component
  152191. */
  152192. get worldNormal(): NodeMaterialConnectionPoint;
  152193. /**
  152194. * Gets the world tangent input component
  152195. */
  152196. get worldTangent(): NodeMaterialConnectionPoint;
  152197. /**
  152198. * Gets the uv input component
  152199. */
  152200. get uv(): NodeMaterialConnectionPoint;
  152201. /**
  152202. * Gets the normal map color input component
  152203. */
  152204. get normalMapColor(): NodeMaterialConnectionPoint;
  152205. /**
  152206. * Gets the strength input component
  152207. */
  152208. get strength(): NodeMaterialConnectionPoint;
  152209. /**
  152210. * Gets the output component
  152211. */
  152212. get output(): NodeMaterialConnectionPoint;
  152213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152215. autoConfigure(material: NodeMaterial): void;
  152216. protected _buildBlock(state: NodeMaterialBuildState): this;
  152217. protected _dumpPropertiesCode(): string;
  152218. serialize(): any;
  152219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152220. }
  152221. }
  152222. declare module BABYLON {
  152223. /**
  152224. * Block used to discard a pixel if a value is smaller than a cutoff
  152225. */
  152226. export class DiscardBlock extends NodeMaterialBlock {
  152227. /**
  152228. * Create a new DiscardBlock
  152229. * @param name defines the block name
  152230. */
  152231. constructor(name: string);
  152232. /**
  152233. * Gets the current class name
  152234. * @returns the class name
  152235. */
  152236. getClassName(): string;
  152237. /**
  152238. * Gets the color input component
  152239. */
  152240. get value(): NodeMaterialConnectionPoint;
  152241. /**
  152242. * Gets the cutoff input component
  152243. */
  152244. get cutoff(): NodeMaterialConnectionPoint;
  152245. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152246. }
  152247. }
  152248. declare module BABYLON {
  152249. /**
  152250. * Block used to test if the fragment shader is front facing
  152251. */
  152252. export class FrontFacingBlock extends NodeMaterialBlock {
  152253. /**
  152254. * Creates a new FrontFacingBlock
  152255. * @param name defines the block name
  152256. */
  152257. constructor(name: string);
  152258. /**
  152259. * Gets the current class name
  152260. * @returns the class name
  152261. */
  152262. getClassName(): string;
  152263. /**
  152264. * Gets the output component
  152265. */
  152266. get output(): NodeMaterialConnectionPoint;
  152267. protected _buildBlock(state: NodeMaterialBuildState): this;
  152268. }
  152269. }
  152270. declare module BABYLON {
  152271. /**
  152272. * Block used to get the derivative value on x and y of a given input
  152273. */
  152274. export class DerivativeBlock extends NodeMaterialBlock {
  152275. /**
  152276. * Create a new DerivativeBlock
  152277. * @param name defines the block name
  152278. */
  152279. constructor(name: string);
  152280. /**
  152281. * Gets the current class name
  152282. * @returns the class name
  152283. */
  152284. getClassName(): string;
  152285. /**
  152286. * Gets the input component
  152287. */
  152288. get input(): NodeMaterialConnectionPoint;
  152289. /**
  152290. * Gets the derivative output on x
  152291. */
  152292. get dx(): NodeMaterialConnectionPoint;
  152293. /**
  152294. * Gets the derivative output on y
  152295. */
  152296. get dy(): NodeMaterialConnectionPoint;
  152297. protected _buildBlock(state: NodeMaterialBuildState): this;
  152298. }
  152299. }
  152300. declare module BABYLON {
  152301. /**
  152302. * Block used to make gl_FragCoord available
  152303. */
  152304. export class FragCoordBlock extends NodeMaterialBlock {
  152305. /**
  152306. * Creates a new FragCoordBlock
  152307. * @param name defines the block name
  152308. */
  152309. constructor(name: string);
  152310. /**
  152311. * Gets the current class name
  152312. * @returns the class name
  152313. */
  152314. getClassName(): string;
  152315. /**
  152316. * Gets the xy component
  152317. */
  152318. get xy(): NodeMaterialConnectionPoint;
  152319. /**
  152320. * Gets the xyz component
  152321. */
  152322. get xyz(): NodeMaterialConnectionPoint;
  152323. /**
  152324. * Gets the xyzw component
  152325. */
  152326. get xyzw(): NodeMaterialConnectionPoint;
  152327. /**
  152328. * Gets the x component
  152329. */
  152330. get x(): NodeMaterialConnectionPoint;
  152331. /**
  152332. * Gets the y component
  152333. */
  152334. get y(): NodeMaterialConnectionPoint;
  152335. /**
  152336. * Gets the z component
  152337. */
  152338. get z(): NodeMaterialConnectionPoint;
  152339. /**
  152340. * Gets the w component
  152341. */
  152342. get output(): NodeMaterialConnectionPoint;
  152343. protected writeOutputs(state: NodeMaterialBuildState): string;
  152344. protected _buildBlock(state: NodeMaterialBuildState): this;
  152345. }
  152346. }
  152347. declare module BABYLON {
  152348. /**
  152349. * Block used to get the screen sizes
  152350. */
  152351. export class ScreenSizeBlock extends NodeMaterialBlock {
  152352. private _varName;
  152353. private _scene;
  152354. /**
  152355. * Creates a new ScreenSizeBlock
  152356. * @param name defines the block name
  152357. */
  152358. constructor(name: string);
  152359. /**
  152360. * Gets the current class name
  152361. * @returns the class name
  152362. */
  152363. getClassName(): string;
  152364. /**
  152365. * Gets the xy component
  152366. */
  152367. get xy(): NodeMaterialConnectionPoint;
  152368. /**
  152369. * Gets the x component
  152370. */
  152371. get x(): NodeMaterialConnectionPoint;
  152372. /**
  152373. * Gets the y component
  152374. */
  152375. get y(): NodeMaterialConnectionPoint;
  152376. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152377. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  152378. protected _buildBlock(state: NodeMaterialBuildState): this;
  152379. }
  152380. }
  152381. declare module BABYLON {
  152382. /**
  152383. * Block used to add support for scene fog
  152384. */
  152385. export class FogBlock extends NodeMaterialBlock {
  152386. private _fogDistanceName;
  152387. private _fogParameters;
  152388. /**
  152389. * Create a new FogBlock
  152390. * @param name defines the block name
  152391. */
  152392. constructor(name: string);
  152393. /**
  152394. * Gets the current class name
  152395. * @returns the class name
  152396. */
  152397. getClassName(): string;
  152398. /**
  152399. * Gets the world position input component
  152400. */
  152401. get worldPosition(): NodeMaterialConnectionPoint;
  152402. /**
  152403. * Gets the view input component
  152404. */
  152405. get view(): NodeMaterialConnectionPoint;
  152406. /**
  152407. * Gets the color input component
  152408. */
  152409. get input(): NodeMaterialConnectionPoint;
  152410. /**
  152411. * Gets the fog color input component
  152412. */
  152413. get fogColor(): NodeMaterialConnectionPoint;
  152414. /**
  152415. * Gets the output component
  152416. */
  152417. get output(): NodeMaterialConnectionPoint;
  152418. autoConfigure(material: NodeMaterial): void;
  152419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152421. protected _buildBlock(state: NodeMaterialBuildState): this;
  152422. }
  152423. }
  152424. declare module BABYLON {
  152425. /**
  152426. * Block used to add light in the fragment shader
  152427. */
  152428. export class LightBlock extends NodeMaterialBlock {
  152429. private _lightId;
  152430. /**
  152431. * Gets or sets the light associated with this block
  152432. */
  152433. light: Nullable<Light>;
  152434. /**
  152435. * Create a new LightBlock
  152436. * @param name defines the block name
  152437. */
  152438. constructor(name: string);
  152439. /**
  152440. * Gets the current class name
  152441. * @returns the class name
  152442. */
  152443. getClassName(): string;
  152444. /**
  152445. * Gets the world position input component
  152446. */
  152447. get worldPosition(): NodeMaterialConnectionPoint;
  152448. /**
  152449. * Gets the world normal input component
  152450. */
  152451. get worldNormal(): NodeMaterialConnectionPoint;
  152452. /**
  152453. * Gets the camera (or eye) position component
  152454. */
  152455. get cameraPosition(): NodeMaterialConnectionPoint;
  152456. /**
  152457. * Gets the glossiness component
  152458. */
  152459. get glossiness(): NodeMaterialConnectionPoint;
  152460. /**
  152461. * Gets the glossinness power component
  152462. */
  152463. get glossPower(): NodeMaterialConnectionPoint;
  152464. /**
  152465. * Gets the diffuse color component
  152466. */
  152467. get diffuseColor(): NodeMaterialConnectionPoint;
  152468. /**
  152469. * Gets the specular color component
  152470. */
  152471. get specularColor(): NodeMaterialConnectionPoint;
  152472. /**
  152473. * Gets the view matrix component
  152474. */
  152475. get view(): NodeMaterialConnectionPoint;
  152476. /**
  152477. * Gets the diffuse output component
  152478. */
  152479. get diffuseOutput(): NodeMaterialConnectionPoint;
  152480. /**
  152481. * Gets the specular output component
  152482. */
  152483. get specularOutput(): NodeMaterialConnectionPoint;
  152484. /**
  152485. * Gets the shadow output component
  152486. */
  152487. get shadow(): NodeMaterialConnectionPoint;
  152488. autoConfigure(material: NodeMaterial): void;
  152489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152490. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  152491. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152492. private _injectVertexCode;
  152493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152494. serialize(): any;
  152495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152496. }
  152497. }
  152498. declare module BABYLON {
  152499. /**
  152500. * Block used to read a reflection texture from a sampler
  152501. */
  152502. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  152503. /**
  152504. * Create a new ReflectionTextureBlock
  152505. * @param name defines the block name
  152506. */
  152507. constructor(name: string);
  152508. /**
  152509. * Gets the current class name
  152510. * @returns the class name
  152511. */
  152512. getClassName(): string;
  152513. /**
  152514. * Gets the world position input component
  152515. */
  152516. get position(): NodeMaterialConnectionPoint;
  152517. /**
  152518. * Gets the world position input component
  152519. */
  152520. get worldPosition(): NodeMaterialConnectionPoint;
  152521. /**
  152522. * Gets the world normal input component
  152523. */
  152524. get worldNormal(): NodeMaterialConnectionPoint;
  152525. /**
  152526. * Gets the world input component
  152527. */
  152528. get world(): NodeMaterialConnectionPoint;
  152529. /**
  152530. * Gets the camera (or eye) position component
  152531. */
  152532. get cameraPosition(): NodeMaterialConnectionPoint;
  152533. /**
  152534. * Gets the view input component
  152535. */
  152536. get view(): NodeMaterialConnectionPoint;
  152537. /**
  152538. * Gets the rgb output component
  152539. */
  152540. get rgb(): NodeMaterialConnectionPoint;
  152541. /**
  152542. * Gets the rgba output component
  152543. */
  152544. get rgba(): NodeMaterialConnectionPoint;
  152545. /**
  152546. * Gets the r output component
  152547. */
  152548. get r(): NodeMaterialConnectionPoint;
  152549. /**
  152550. * Gets the g output component
  152551. */
  152552. get g(): NodeMaterialConnectionPoint;
  152553. /**
  152554. * Gets the b output component
  152555. */
  152556. get b(): NodeMaterialConnectionPoint;
  152557. /**
  152558. * Gets the a output component
  152559. */
  152560. get a(): NodeMaterialConnectionPoint;
  152561. autoConfigure(material: NodeMaterial): void;
  152562. protected _buildBlock(state: NodeMaterialBuildState): this;
  152563. }
  152564. }
  152565. declare module BABYLON {
  152566. /**
  152567. * Block used to add 2 vectors
  152568. */
  152569. export class AddBlock extends NodeMaterialBlock {
  152570. /**
  152571. * Creates a new AddBlock
  152572. * @param name defines the block name
  152573. */
  152574. constructor(name: string);
  152575. /**
  152576. * Gets the current class name
  152577. * @returns the class name
  152578. */
  152579. getClassName(): string;
  152580. /**
  152581. * Gets the left operand input component
  152582. */
  152583. get left(): NodeMaterialConnectionPoint;
  152584. /**
  152585. * Gets the right operand input component
  152586. */
  152587. get right(): NodeMaterialConnectionPoint;
  152588. /**
  152589. * Gets the output component
  152590. */
  152591. get output(): NodeMaterialConnectionPoint;
  152592. protected _buildBlock(state: NodeMaterialBuildState): this;
  152593. }
  152594. }
  152595. declare module BABYLON {
  152596. /**
  152597. * Block used to scale a vector by a float
  152598. */
  152599. export class ScaleBlock extends NodeMaterialBlock {
  152600. /**
  152601. * Creates a new ScaleBlock
  152602. * @param name defines the block name
  152603. */
  152604. constructor(name: string);
  152605. /**
  152606. * Gets the current class name
  152607. * @returns the class name
  152608. */
  152609. getClassName(): string;
  152610. /**
  152611. * Gets the input component
  152612. */
  152613. get input(): NodeMaterialConnectionPoint;
  152614. /**
  152615. * Gets the factor input component
  152616. */
  152617. get factor(): NodeMaterialConnectionPoint;
  152618. /**
  152619. * Gets the output component
  152620. */
  152621. get output(): NodeMaterialConnectionPoint;
  152622. protected _buildBlock(state: NodeMaterialBuildState): this;
  152623. }
  152624. }
  152625. declare module BABYLON {
  152626. /**
  152627. * Block used to clamp a float
  152628. */
  152629. export class ClampBlock extends NodeMaterialBlock {
  152630. /** Gets or sets the minimum range */
  152631. minimum: number;
  152632. /** Gets or sets the maximum range */
  152633. maximum: number;
  152634. /**
  152635. * Creates a new ClampBlock
  152636. * @param name defines the block name
  152637. */
  152638. constructor(name: string);
  152639. /**
  152640. * Gets the current class name
  152641. * @returns the class name
  152642. */
  152643. getClassName(): string;
  152644. /**
  152645. * Gets the value input component
  152646. */
  152647. get value(): NodeMaterialConnectionPoint;
  152648. /**
  152649. * Gets the output component
  152650. */
  152651. get output(): NodeMaterialConnectionPoint;
  152652. protected _buildBlock(state: NodeMaterialBuildState): this;
  152653. protected _dumpPropertiesCode(): string;
  152654. serialize(): any;
  152655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152656. }
  152657. }
  152658. declare module BABYLON {
  152659. /**
  152660. * Block used to apply a cross product between 2 vectors
  152661. */
  152662. export class CrossBlock extends NodeMaterialBlock {
  152663. /**
  152664. * Creates a new CrossBlock
  152665. * @param name defines the block name
  152666. */
  152667. constructor(name: string);
  152668. /**
  152669. * Gets the current class name
  152670. * @returns the class name
  152671. */
  152672. getClassName(): string;
  152673. /**
  152674. * Gets the left operand input component
  152675. */
  152676. get left(): NodeMaterialConnectionPoint;
  152677. /**
  152678. * Gets the right operand input component
  152679. */
  152680. get right(): NodeMaterialConnectionPoint;
  152681. /**
  152682. * Gets the output component
  152683. */
  152684. get output(): NodeMaterialConnectionPoint;
  152685. protected _buildBlock(state: NodeMaterialBuildState): this;
  152686. }
  152687. }
  152688. declare module BABYLON {
  152689. /**
  152690. * Block used to apply a dot product between 2 vectors
  152691. */
  152692. export class DotBlock extends NodeMaterialBlock {
  152693. /**
  152694. * Creates a new DotBlock
  152695. * @param name defines the block name
  152696. */
  152697. constructor(name: string);
  152698. /**
  152699. * Gets the current class name
  152700. * @returns the class name
  152701. */
  152702. getClassName(): string;
  152703. /**
  152704. * Gets the left operand input component
  152705. */
  152706. get left(): NodeMaterialConnectionPoint;
  152707. /**
  152708. * Gets the right operand input component
  152709. */
  152710. get right(): NodeMaterialConnectionPoint;
  152711. /**
  152712. * Gets the output component
  152713. */
  152714. get output(): NodeMaterialConnectionPoint;
  152715. protected _buildBlock(state: NodeMaterialBuildState): this;
  152716. }
  152717. }
  152718. declare module BABYLON {
  152719. /**
  152720. * Block used to normalize a vector
  152721. */
  152722. export class NormalizeBlock extends NodeMaterialBlock {
  152723. /**
  152724. * Creates a new NormalizeBlock
  152725. * @param name defines the block name
  152726. */
  152727. constructor(name: string);
  152728. /**
  152729. * Gets the current class name
  152730. * @returns the class name
  152731. */
  152732. getClassName(): string;
  152733. /**
  152734. * Gets the input component
  152735. */
  152736. get input(): NodeMaterialConnectionPoint;
  152737. /**
  152738. * Gets the output component
  152739. */
  152740. get output(): NodeMaterialConnectionPoint;
  152741. protected _buildBlock(state: NodeMaterialBuildState): this;
  152742. }
  152743. }
  152744. declare module BABYLON {
  152745. /**
  152746. * Block used to create a Color3/4 out of individual inputs (one for each component)
  152747. */
  152748. export class ColorMergerBlock extends NodeMaterialBlock {
  152749. /**
  152750. * Create a new ColorMergerBlock
  152751. * @param name defines the block name
  152752. */
  152753. constructor(name: string);
  152754. /**
  152755. * Gets the current class name
  152756. * @returns the class name
  152757. */
  152758. getClassName(): string;
  152759. /**
  152760. * Gets the rgb component (input)
  152761. */
  152762. get rgbIn(): NodeMaterialConnectionPoint;
  152763. /**
  152764. * Gets the r component (input)
  152765. */
  152766. get r(): NodeMaterialConnectionPoint;
  152767. /**
  152768. * Gets the g component (input)
  152769. */
  152770. get g(): NodeMaterialConnectionPoint;
  152771. /**
  152772. * Gets the b component (input)
  152773. */
  152774. get b(): NodeMaterialConnectionPoint;
  152775. /**
  152776. * Gets the a component (input)
  152777. */
  152778. get a(): NodeMaterialConnectionPoint;
  152779. /**
  152780. * Gets the rgba component (output)
  152781. */
  152782. get rgba(): NodeMaterialConnectionPoint;
  152783. /**
  152784. * Gets the rgb component (output)
  152785. */
  152786. get rgbOut(): NodeMaterialConnectionPoint;
  152787. /**
  152788. * Gets the rgb component (output)
  152789. * @deprecated Please use rgbOut instead.
  152790. */
  152791. get rgb(): NodeMaterialConnectionPoint;
  152792. protected _buildBlock(state: NodeMaterialBuildState): this;
  152793. }
  152794. }
  152795. declare module BABYLON {
  152796. /**
  152797. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  152798. */
  152799. export class VectorSplitterBlock extends NodeMaterialBlock {
  152800. /**
  152801. * Create a new VectorSplitterBlock
  152802. * @param name defines the block name
  152803. */
  152804. constructor(name: string);
  152805. /**
  152806. * Gets the current class name
  152807. * @returns the class name
  152808. */
  152809. getClassName(): string;
  152810. /**
  152811. * Gets the xyzw component (input)
  152812. */
  152813. get xyzw(): NodeMaterialConnectionPoint;
  152814. /**
  152815. * Gets the xyz component (input)
  152816. */
  152817. get xyzIn(): NodeMaterialConnectionPoint;
  152818. /**
  152819. * Gets the xy component (input)
  152820. */
  152821. get xyIn(): NodeMaterialConnectionPoint;
  152822. /**
  152823. * Gets the xyz component (output)
  152824. */
  152825. get xyzOut(): NodeMaterialConnectionPoint;
  152826. /**
  152827. * Gets the xy component (output)
  152828. */
  152829. get xyOut(): NodeMaterialConnectionPoint;
  152830. /**
  152831. * Gets the x component (output)
  152832. */
  152833. get x(): NodeMaterialConnectionPoint;
  152834. /**
  152835. * Gets the y component (output)
  152836. */
  152837. get y(): NodeMaterialConnectionPoint;
  152838. /**
  152839. * Gets the z component (output)
  152840. */
  152841. get z(): NodeMaterialConnectionPoint;
  152842. /**
  152843. * Gets the w component (output)
  152844. */
  152845. get w(): NodeMaterialConnectionPoint;
  152846. protected _inputRename(name: string): string;
  152847. protected _outputRename(name: string): string;
  152848. protected _buildBlock(state: NodeMaterialBuildState): this;
  152849. }
  152850. }
  152851. declare module BABYLON {
  152852. /**
  152853. * Block used to lerp between 2 values
  152854. */
  152855. export class LerpBlock extends NodeMaterialBlock {
  152856. /**
  152857. * Creates a new LerpBlock
  152858. * @param name defines the block name
  152859. */
  152860. constructor(name: string);
  152861. /**
  152862. * Gets the current class name
  152863. * @returns the class name
  152864. */
  152865. getClassName(): string;
  152866. /**
  152867. * Gets the left operand input component
  152868. */
  152869. get left(): NodeMaterialConnectionPoint;
  152870. /**
  152871. * Gets the right operand input component
  152872. */
  152873. get right(): NodeMaterialConnectionPoint;
  152874. /**
  152875. * Gets the gradient operand input component
  152876. */
  152877. get gradient(): NodeMaterialConnectionPoint;
  152878. /**
  152879. * Gets the output component
  152880. */
  152881. get output(): NodeMaterialConnectionPoint;
  152882. protected _buildBlock(state: NodeMaterialBuildState): this;
  152883. }
  152884. }
  152885. declare module BABYLON {
  152886. /**
  152887. * Block used to divide 2 vectors
  152888. */
  152889. export class DivideBlock extends NodeMaterialBlock {
  152890. /**
  152891. * Creates a new DivideBlock
  152892. * @param name defines the block name
  152893. */
  152894. constructor(name: string);
  152895. /**
  152896. * Gets the current class name
  152897. * @returns the class name
  152898. */
  152899. getClassName(): string;
  152900. /**
  152901. * Gets the left operand input component
  152902. */
  152903. get left(): NodeMaterialConnectionPoint;
  152904. /**
  152905. * Gets the right operand input component
  152906. */
  152907. get right(): NodeMaterialConnectionPoint;
  152908. /**
  152909. * Gets the output component
  152910. */
  152911. get output(): NodeMaterialConnectionPoint;
  152912. protected _buildBlock(state: NodeMaterialBuildState): this;
  152913. }
  152914. }
  152915. declare module BABYLON {
  152916. /**
  152917. * Block used to subtract 2 vectors
  152918. */
  152919. export class SubtractBlock extends NodeMaterialBlock {
  152920. /**
  152921. * Creates a new SubtractBlock
  152922. * @param name defines the block name
  152923. */
  152924. constructor(name: string);
  152925. /**
  152926. * Gets the current class name
  152927. * @returns the class name
  152928. */
  152929. getClassName(): string;
  152930. /**
  152931. * Gets the left operand input component
  152932. */
  152933. get left(): NodeMaterialConnectionPoint;
  152934. /**
  152935. * Gets the right operand input component
  152936. */
  152937. get right(): NodeMaterialConnectionPoint;
  152938. /**
  152939. * Gets the output component
  152940. */
  152941. get output(): NodeMaterialConnectionPoint;
  152942. protected _buildBlock(state: NodeMaterialBuildState): this;
  152943. }
  152944. }
  152945. declare module BABYLON {
  152946. /**
  152947. * Block used to step a value
  152948. */
  152949. export class StepBlock extends NodeMaterialBlock {
  152950. /**
  152951. * Creates a new StepBlock
  152952. * @param name defines the block name
  152953. */
  152954. constructor(name: string);
  152955. /**
  152956. * Gets the current class name
  152957. * @returns the class name
  152958. */
  152959. getClassName(): string;
  152960. /**
  152961. * Gets the value operand input component
  152962. */
  152963. get value(): NodeMaterialConnectionPoint;
  152964. /**
  152965. * Gets the edge operand input component
  152966. */
  152967. get edge(): NodeMaterialConnectionPoint;
  152968. /**
  152969. * Gets the output component
  152970. */
  152971. get output(): NodeMaterialConnectionPoint;
  152972. protected _buildBlock(state: NodeMaterialBuildState): this;
  152973. }
  152974. }
  152975. declare module BABYLON {
  152976. /**
  152977. * Block used to get the opposite (1 - x) of a value
  152978. */
  152979. export class OneMinusBlock extends NodeMaterialBlock {
  152980. /**
  152981. * Creates a new OneMinusBlock
  152982. * @param name defines the block name
  152983. */
  152984. constructor(name: string);
  152985. /**
  152986. * Gets the current class name
  152987. * @returns the class name
  152988. */
  152989. getClassName(): string;
  152990. /**
  152991. * Gets the input component
  152992. */
  152993. get input(): NodeMaterialConnectionPoint;
  152994. /**
  152995. * Gets the output component
  152996. */
  152997. get output(): NodeMaterialConnectionPoint;
  152998. protected _buildBlock(state: NodeMaterialBuildState): this;
  152999. }
  153000. }
  153001. declare module BABYLON {
  153002. /**
  153003. * Block used to get the view direction
  153004. */
  153005. export class ViewDirectionBlock extends NodeMaterialBlock {
  153006. /**
  153007. * Creates a new ViewDirectionBlock
  153008. * @param name defines the block name
  153009. */
  153010. constructor(name: string);
  153011. /**
  153012. * Gets the current class name
  153013. * @returns the class name
  153014. */
  153015. getClassName(): string;
  153016. /**
  153017. * Gets the world position component
  153018. */
  153019. get worldPosition(): NodeMaterialConnectionPoint;
  153020. /**
  153021. * Gets the camera position component
  153022. */
  153023. get cameraPosition(): NodeMaterialConnectionPoint;
  153024. /**
  153025. * Gets the output component
  153026. */
  153027. get output(): NodeMaterialConnectionPoint;
  153028. autoConfigure(material: NodeMaterial): void;
  153029. protected _buildBlock(state: NodeMaterialBuildState): this;
  153030. }
  153031. }
  153032. declare module BABYLON {
  153033. /**
  153034. * Block used to compute fresnel value
  153035. */
  153036. export class FresnelBlock extends NodeMaterialBlock {
  153037. /**
  153038. * Create a new FresnelBlock
  153039. * @param name defines the block name
  153040. */
  153041. constructor(name: string);
  153042. /**
  153043. * Gets the current class name
  153044. * @returns the class name
  153045. */
  153046. getClassName(): string;
  153047. /**
  153048. * Gets the world normal input component
  153049. */
  153050. get worldNormal(): NodeMaterialConnectionPoint;
  153051. /**
  153052. * Gets the view direction input component
  153053. */
  153054. get viewDirection(): NodeMaterialConnectionPoint;
  153055. /**
  153056. * Gets the bias input component
  153057. */
  153058. get bias(): NodeMaterialConnectionPoint;
  153059. /**
  153060. * Gets the camera (or eye) position component
  153061. */
  153062. get power(): NodeMaterialConnectionPoint;
  153063. /**
  153064. * Gets the fresnel output component
  153065. */
  153066. get fresnel(): NodeMaterialConnectionPoint;
  153067. autoConfigure(material: NodeMaterial): void;
  153068. protected _buildBlock(state: NodeMaterialBuildState): this;
  153069. }
  153070. }
  153071. declare module BABYLON {
  153072. /**
  153073. * Block used to get the max of 2 values
  153074. */
  153075. export class MaxBlock extends NodeMaterialBlock {
  153076. /**
  153077. * Creates a new MaxBlock
  153078. * @param name defines the block name
  153079. */
  153080. constructor(name: string);
  153081. /**
  153082. * Gets the current class name
  153083. * @returns the class name
  153084. */
  153085. getClassName(): string;
  153086. /**
  153087. * Gets the left operand input component
  153088. */
  153089. get left(): NodeMaterialConnectionPoint;
  153090. /**
  153091. * Gets the right operand input component
  153092. */
  153093. get right(): NodeMaterialConnectionPoint;
  153094. /**
  153095. * Gets the output component
  153096. */
  153097. get output(): NodeMaterialConnectionPoint;
  153098. protected _buildBlock(state: NodeMaterialBuildState): this;
  153099. }
  153100. }
  153101. declare module BABYLON {
  153102. /**
  153103. * Block used to get the min of 2 values
  153104. */
  153105. export class MinBlock extends NodeMaterialBlock {
  153106. /**
  153107. * Creates a new MinBlock
  153108. * @param name defines the block name
  153109. */
  153110. constructor(name: string);
  153111. /**
  153112. * Gets the current class name
  153113. * @returns the class name
  153114. */
  153115. getClassName(): string;
  153116. /**
  153117. * Gets the left operand input component
  153118. */
  153119. get left(): NodeMaterialConnectionPoint;
  153120. /**
  153121. * Gets the right operand input component
  153122. */
  153123. get right(): NodeMaterialConnectionPoint;
  153124. /**
  153125. * Gets the output component
  153126. */
  153127. get output(): NodeMaterialConnectionPoint;
  153128. protected _buildBlock(state: NodeMaterialBuildState): this;
  153129. }
  153130. }
  153131. declare module BABYLON {
  153132. /**
  153133. * Block used to get the distance between 2 values
  153134. */
  153135. export class DistanceBlock extends NodeMaterialBlock {
  153136. /**
  153137. * Creates a new DistanceBlock
  153138. * @param name defines the block name
  153139. */
  153140. constructor(name: string);
  153141. /**
  153142. * Gets the current class name
  153143. * @returns the class name
  153144. */
  153145. getClassName(): string;
  153146. /**
  153147. * Gets the left operand input component
  153148. */
  153149. get left(): NodeMaterialConnectionPoint;
  153150. /**
  153151. * Gets the right operand input component
  153152. */
  153153. get right(): NodeMaterialConnectionPoint;
  153154. /**
  153155. * Gets the output component
  153156. */
  153157. get output(): NodeMaterialConnectionPoint;
  153158. protected _buildBlock(state: NodeMaterialBuildState): this;
  153159. }
  153160. }
  153161. declare module BABYLON {
  153162. /**
  153163. * Block used to get the length of a vector
  153164. */
  153165. export class LengthBlock extends NodeMaterialBlock {
  153166. /**
  153167. * Creates a new LengthBlock
  153168. * @param name defines the block name
  153169. */
  153170. constructor(name: string);
  153171. /**
  153172. * Gets the current class name
  153173. * @returns the class name
  153174. */
  153175. getClassName(): string;
  153176. /**
  153177. * Gets the value input component
  153178. */
  153179. get value(): NodeMaterialConnectionPoint;
  153180. /**
  153181. * Gets the output component
  153182. */
  153183. get output(): NodeMaterialConnectionPoint;
  153184. protected _buildBlock(state: NodeMaterialBuildState): this;
  153185. }
  153186. }
  153187. declare module BABYLON {
  153188. /**
  153189. * Block used to get negative version of a value (i.e. x * -1)
  153190. */
  153191. export class NegateBlock extends NodeMaterialBlock {
  153192. /**
  153193. * Creates a new NegateBlock
  153194. * @param name defines the block name
  153195. */
  153196. constructor(name: string);
  153197. /**
  153198. * Gets the current class name
  153199. * @returns the class name
  153200. */
  153201. getClassName(): string;
  153202. /**
  153203. * Gets the value input component
  153204. */
  153205. get value(): NodeMaterialConnectionPoint;
  153206. /**
  153207. * Gets the output component
  153208. */
  153209. get output(): NodeMaterialConnectionPoint;
  153210. protected _buildBlock(state: NodeMaterialBuildState): this;
  153211. }
  153212. }
  153213. declare module BABYLON {
  153214. /**
  153215. * Block used to get the value of the first parameter raised to the power of the second
  153216. */
  153217. export class PowBlock extends NodeMaterialBlock {
  153218. /**
  153219. * Creates a new PowBlock
  153220. * @param name defines the block name
  153221. */
  153222. constructor(name: string);
  153223. /**
  153224. * Gets the current class name
  153225. * @returns the class name
  153226. */
  153227. getClassName(): string;
  153228. /**
  153229. * Gets the value operand input component
  153230. */
  153231. get value(): NodeMaterialConnectionPoint;
  153232. /**
  153233. * Gets the power operand input component
  153234. */
  153235. get power(): NodeMaterialConnectionPoint;
  153236. /**
  153237. * Gets the output component
  153238. */
  153239. get output(): NodeMaterialConnectionPoint;
  153240. protected _buildBlock(state: NodeMaterialBuildState): this;
  153241. }
  153242. }
  153243. declare module BABYLON {
  153244. /**
  153245. * Block used to get a random number
  153246. */
  153247. export class RandomNumberBlock extends NodeMaterialBlock {
  153248. /**
  153249. * Creates a new RandomNumberBlock
  153250. * @param name defines the block name
  153251. */
  153252. constructor(name: string);
  153253. /**
  153254. * Gets the current class name
  153255. * @returns the class name
  153256. */
  153257. getClassName(): string;
  153258. /**
  153259. * Gets the seed input component
  153260. */
  153261. get seed(): NodeMaterialConnectionPoint;
  153262. /**
  153263. * Gets the output component
  153264. */
  153265. get output(): NodeMaterialConnectionPoint;
  153266. protected _buildBlock(state: NodeMaterialBuildState): this;
  153267. }
  153268. }
  153269. declare module BABYLON {
  153270. /**
  153271. * Block used to compute arc tangent of 2 values
  153272. */
  153273. export class ArcTan2Block extends NodeMaterialBlock {
  153274. /**
  153275. * Creates a new ArcTan2Block
  153276. * @param name defines the block name
  153277. */
  153278. constructor(name: string);
  153279. /**
  153280. * Gets the current class name
  153281. * @returns the class name
  153282. */
  153283. getClassName(): string;
  153284. /**
  153285. * Gets the x operand input component
  153286. */
  153287. get x(): NodeMaterialConnectionPoint;
  153288. /**
  153289. * Gets the y operand input component
  153290. */
  153291. get y(): NodeMaterialConnectionPoint;
  153292. /**
  153293. * Gets the output component
  153294. */
  153295. get output(): NodeMaterialConnectionPoint;
  153296. protected _buildBlock(state: NodeMaterialBuildState): this;
  153297. }
  153298. }
  153299. declare module BABYLON {
  153300. /**
  153301. * Block used to smooth step a value
  153302. */
  153303. export class SmoothStepBlock extends NodeMaterialBlock {
  153304. /**
  153305. * Creates a new SmoothStepBlock
  153306. * @param name defines the block name
  153307. */
  153308. constructor(name: string);
  153309. /**
  153310. * Gets the current class name
  153311. * @returns the class name
  153312. */
  153313. getClassName(): string;
  153314. /**
  153315. * Gets the value operand input component
  153316. */
  153317. get value(): NodeMaterialConnectionPoint;
  153318. /**
  153319. * Gets the first edge operand input component
  153320. */
  153321. get edge0(): NodeMaterialConnectionPoint;
  153322. /**
  153323. * Gets the second edge operand input component
  153324. */
  153325. get edge1(): NodeMaterialConnectionPoint;
  153326. /**
  153327. * Gets the output component
  153328. */
  153329. get output(): NodeMaterialConnectionPoint;
  153330. protected _buildBlock(state: NodeMaterialBuildState): this;
  153331. }
  153332. }
  153333. declare module BABYLON {
  153334. /**
  153335. * Block used to get the reciprocal (1 / x) of a value
  153336. */
  153337. export class ReciprocalBlock extends NodeMaterialBlock {
  153338. /**
  153339. * Creates a new ReciprocalBlock
  153340. * @param name defines the block name
  153341. */
  153342. constructor(name: string);
  153343. /**
  153344. * Gets the current class name
  153345. * @returns the class name
  153346. */
  153347. getClassName(): string;
  153348. /**
  153349. * Gets the input component
  153350. */
  153351. get input(): NodeMaterialConnectionPoint;
  153352. /**
  153353. * Gets the output component
  153354. */
  153355. get output(): NodeMaterialConnectionPoint;
  153356. protected _buildBlock(state: NodeMaterialBuildState): this;
  153357. }
  153358. }
  153359. declare module BABYLON {
  153360. /**
  153361. * Block used to replace a color by another one
  153362. */
  153363. export class ReplaceColorBlock extends NodeMaterialBlock {
  153364. /**
  153365. * Creates a new ReplaceColorBlock
  153366. * @param name defines the block name
  153367. */
  153368. constructor(name: string);
  153369. /**
  153370. * Gets the current class name
  153371. * @returns the class name
  153372. */
  153373. getClassName(): string;
  153374. /**
  153375. * Gets the value input component
  153376. */
  153377. get value(): NodeMaterialConnectionPoint;
  153378. /**
  153379. * Gets the reference input component
  153380. */
  153381. get reference(): NodeMaterialConnectionPoint;
  153382. /**
  153383. * Gets the distance input component
  153384. */
  153385. get distance(): NodeMaterialConnectionPoint;
  153386. /**
  153387. * Gets the replacement input component
  153388. */
  153389. get replacement(): NodeMaterialConnectionPoint;
  153390. /**
  153391. * Gets the output component
  153392. */
  153393. get output(): NodeMaterialConnectionPoint;
  153394. protected _buildBlock(state: NodeMaterialBuildState): this;
  153395. }
  153396. }
  153397. declare module BABYLON {
  153398. /**
  153399. * Block used to posterize a value
  153400. * @see https://en.wikipedia.org/wiki/Posterization
  153401. */
  153402. export class PosterizeBlock extends NodeMaterialBlock {
  153403. /**
  153404. * Creates a new PosterizeBlock
  153405. * @param name defines the block name
  153406. */
  153407. constructor(name: string);
  153408. /**
  153409. * Gets the current class name
  153410. * @returns the class name
  153411. */
  153412. getClassName(): string;
  153413. /**
  153414. * Gets the value input component
  153415. */
  153416. get value(): NodeMaterialConnectionPoint;
  153417. /**
  153418. * Gets the steps input component
  153419. */
  153420. get steps(): NodeMaterialConnectionPoint;
  153421. /**
  153422. * Gets the output component
  153423. */
  153424. get output(): NodeMaterialConnectionPoint;
  153425. protected _buildBlock(state: NodeMaterialBuildState): this;
  153426. }
  153427. }
  153428. declare module BABYLON {
  153429. /**
  153430. * Operations supported by the Wave block
  153431. */
  153432. export enum WaveBlockKind {
  153433. /** SawTooth */
  153434. SawTooth = 0,
  153435. /** Square */
  153436. Square = 1,
  153437. /** Triangle */
  153438. Triangle = 2
  153439. }
  153440. /**
  153441. * Block used to apply wave operation to floats
  153442. */
  153443. export class WaveBlock extends NodeMaterialBlock {
  153444. /**
  153445. * Gets or sets the kibnd of wave to be applied by the block
  153446. */
  153447. kind: WaveBlockKind;
  153448. /**
  153449. * Creates a new WaveBlock
  153450. * @param name defines the block name
  153451. */
  153452. constructor(name: string);
  153453. /**
  153454. * Gets the current class name
  153455. * @returns the class name
  153456. */
  153457. getClassName(): string;
  153458. /**
  153459. * Gets the input component
  153460. */
  153461. get input(): NodeMaterialConnectionPoint;
  153462. /**
  153463. * Gets the output component
  153464. */
  153465. get output(): NodeMaterialConnectionPoint;
  153466. protected _buildBlock(state: NodeMaterialBuildState): this;
  153467. serialize(): any;
  153468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153469. }
  153470. }
  153471. declare module BABYLON {
  153472. /**
  153473. * Class used to store a color step for the GradientBlock
  153474. */
  153475. export class GradientBlockColorStep {
  153476. private _step;
  153477. /**
  153478. * Gets value indicating which step this color is associated with (between 0 and 1)
  153479. */
  153480. get step(): number;
  153481. /**
  153482. * Sets a value indicating which step this color is associated with (between 0 and 1)
  153483. */
  153484. set step(val: number);
  153485. private _color;
  153486. /**
  153487. * Gets the color associated with this step
  153488. */
  153489. get color(): Color3;
  153490. /**
  153491. * Sets the color associated with this step
  153492. */
  153493. set color(val: Color3);
  153494. /**
  153495. * Creates a new GradientBlockColorStep
  153496. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  153497. * @param color defines the color associated with this step
  153498. */
  153499. constructor(step: number, color: Color3);
  153500. }
  153501. /**
  153502. * Block used to return a color from a gradient based on an input value between 0 and 1
  153503. */
  153504. export class GradientBlock extends NodeMaterialBlock {
  153505. /**
  153506. * Gets or sets the list of color steps
  153507. */
  153508. colorSteps: GradientBlockColorStep[];
  153509. /** Gets an observable raised when the value is changed */
  153510. onValueChangedObservable: Observable<GradientBlock>;
  153511. /** calls observable when the value is changed*/
  153512. colorStepsUpdated(): void;
  153513. /**
  153514. * Creates a new GradientBlock
  153515. * @param name defines the block name
  153516. */
  153517. constructor(name: string);
  153518. /**
  153519. * Gets the current class name
  153520. * @returns the class name
  153521. */
  153522. getClassName(): string;
  153523. /**
  153524. * Gets the gradient input component
  153525. */
  153526. get gradient(): NodeMaterialConnectionPoint;
  153527. /**
  153528. * Gets the output component
  153529. */
  153530. get output(): NodeMaterialConnectionPoint;
  153531. private _writeColorConstant;
  153532. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153533. serialize(): any;
  153534. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153535. protected _dumpPropertiesCode(): string;
  153536. }
  153537. }
  153538. declare module BABYLON {
  153539. /**
  153540. * Block used to normalize lerp between 2 values
  153541. */
  153542. export class NLerpBlock extends NodeMaterialBlock {
  153543. /**
  153544. * Creates a new NLerpBlock
  153545. * @param name defines the block name
  153546. */
  153547. constructor(name: string);
  153548. /**
  153549. * Gets the current class name
  153550. * @returns the class name
  153551. */
  153552. getClassName(): string;
  153553. /**
  153554. * Gets the left operand input component
  153555. */
  153556. get left(): NodeMaterialConnectionPoint;
  153557. /**
  153558. * Gets the right operand input component
  153559. */
  153560. get right(): NodeMaterialConnectionPoint;
  153561. /**
  153562. * Gets the gradient operand input component
  153563. */
  153564. get gradient(): NodeMaterialConnectionPoint;
  153565. /**
  153566. * Gets the output component
  153567. */
  153568. get output(): NodeMaterialConnectionPoint;
  153569. protected _buildBlock(state: NodeMaterialBuildState): this;
  153570. }
  153571. }
  153572. declare module BABYLON {
  153573. /**
  153574. * block used to Generate a Worley Noise 3D Noise Pattern
  153575. */
  153576. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  153577. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  153578. manhattanDistance: boolean;
  153579. /**
  153580. * Creates a new WorleyNoise3DBlock
  153581. * @param name defines the block name
  153582. */
  153583. constructor(name: string);
  153584. /**
  153585. * Gets the current class name
  153586. * @returns the class name
  153587. */
  153588. getClassName(): string;
  153589. /**
  153590. * Gets the seed input component
  153591. */
  153592. get seed(): NodeMaterialConnectionPoint;
  153593. /**
  153594. * Gets the jitter input component
  153595. */
  153596. get jitter(): NodeMaterialConnectionPoint;
  153597. /**
  153598. * Gets the output component
  153599. */
  153600. get output(): NodeMaterialConnectionPoint;
  153601. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153602. /**
  153603. * Exposes the properties to the UI?
  153604. */
  153605. protected _dumpPropertiesCode(): string;
  153606. /**
  153607. * Exposes the properties to the Seralize?
  153608. */
  153609. serialize(): any;
  153610. /**
  153611. * Exposes the properties to the deseralize?
  153612. */
  153613. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153614. }
  153615. }
  153616. declare module BABYLON {
  153617. /**
  153618. * block used to Generate a Simplex Perlin 3d Noise Pattern
  153619. */
  153620. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  153621. /**
  153622. * Creates a new SimplexPerlin3DBlock
  153623. * @param name defines the block name
  153624. */
  153625. constructor(name: string);
  153626. /**
  153627. * Gets the current class name
  153628. * @returns the class name
  153629. */
  153630. getClassName(): string;
  153631. /**
  153632. * Gets the seed operand input component
  153633. */
  153634. get seed(): NodeMaterialConnectionPoint;
  153635. /**
  153636. * Gets the output component
  153637. */
  153638. get output(): NodeMaterialConnectionPoint;
  153639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153640. }
  153641. }
  153642. declare module BABYLON {
  153643. /**
  153644. * Block used to blend normals
  153645. */
  153646. export class NormalBlendBlock extends NodeMaterialBlock {
  153647. /**
  153648. * Creates a new NormalBlendBlock
  153649. * @param name defines the block name
  153650. */
  153651. constructor(name: string);
  153652. /**
  153653. * Gets the current class name
  153654. * @returns the class name
  153655. */
  153656. getClassName(): string;
  153657. /**
  153658. * Gets the first input component
  153659. */
  153660. get normalMap0(): NodeMaterialConnectionPoint;
  153661. /**
  153662. * Gets the second input component
  153663. */
  153664. get normalMap1(): NodeMaterialConnectionPoint;
  153665. /**
  153666. * Gets the output component
  153667. */
  153668. get output(): NodeMaterialConnectionPoint;
  153669. protected _buildBlock(state: NodeMaterialBuildState): this;
  153670. }
  153671. }
  153672. declare module BABYLON {
  153673. /**
  153674. * Block used to rotate a 2d vector by a given angle
  153675. */
  153676. export class Rotate2dBlock extends NodeMaterialBlock {
  153677. /**
  153678. * Creates a new Rotate2dBlock
  153679. * @param name defines the block name
  153680. */
  153681. constructor(name: string);
  153682. /**
  153683. * Gets the current class name
  153684. * @returns the class name
  153685. */
  153686. getClassName(): string;
  153687. /**
  153688. * Gets the input vector
  153689. */
  153690. get input(): NodeMaterialConnectionPoint;
  153691. /**
  153692. * Gets the input angle
  153693. */
  153694. get angle(): NodeMaterialConnectionPoint;
  153695. /**
  153696. * Gets the output component
  153697. */
  153698. get output(): NodeMaterialConnectionPoint;
  153699. autoConfigure(material: NodeMaterial): void;
  153700. protected _buildBlock(state: NodeMaterialBuildState): this;
  153701. }
  153702. }
  153703. declare module BABYLON {
  153704. /**
  153705. * Block used to get the reflected vector from a direction and a normal
  153706. */
  153707. export class ReflectBlock extends NodeMaterialBlock {
  153708. /**
  153709. * Creates a new ReflectBlock
  153710. * @param name defines the block name
  153711. */
  153712. constructor(name: string);
  153713. /**
  153714. * Gets the current class name
  153715. * @returns the class name
  153716. */
  153717. getClassName(): string;
  153718. /**
  153719. * Gets the incident component
  153720. */
  153721. get incident(): NodeMaterialConnectionPoint;
  153722. /**
  153723. * Gets the normal component
  153724. */
  153725. get normal(): NodeMaterialConnectionPoint;
  153726. /**
  153727. * Gets the output component
  153728. */
  153729. get output(): NodeMaterialConnectionPoint;
  153730. protected _buildBlock(state: NodeMaterialBuildState): this;
  153731. }
  153732. }
  153733. declare module BABYLON {
  153734. /**
  153735. * Block used to get the refracted vector from a direction and a normal
  153736. */
  153737. export class RefractBlock extends NodeMaterialBlock {
  153738. /**
  153739. * Creates a new RefractBlock
  153740. * @param name defines the block name
  153741. */
  153742. constructor(name: string);
  153743. /**
  153744. * Gets the current class name
  153745. * @returns the class name
  153746. */
  153747. getClassName(): string;
  153748. /**
  153749. * Gets the incident component
  153750. */
  153751. get incident(): NodeMaterialConnectionPoint;
  153752. /**
  153753. * Gets the normal component
  153754. */
  153755. get normal(): NodeMaterialConnectionPoint;
  153756. /**
  153757. * Gets the index of refraction component
  153758. */
  153759. get ior(): NodeMaterialConnectionPoint;
  153760. /**
  153761. * Gets the output component
  153762. */
  153763. get output(): NodeMaterialConnectionPoint;
  153764. protected _buildBlock(state: NodeMaterialBuildState): this;
  153765. }
  153766. }
  153767. declare module BABYLON {
  153768. /**
  153769. * Block used to desaturate a color
  153770. */
  153771. export class DesaturateBlock extends NodeMaterialBlock {
  153772. /**
  153773. * Creates a new DesaturateBlock
  153774. * @param name defines the block name
  153775. */
  153776. constructor(name: string);
  153777. /**
  153778. * Gets the current class name
  153779. * @returns the class name
  153780. */
  153781. getClassName(): string;
  153782. /**
  153783. * Gets the color operand input component
  153784. */
  153785. get color(): NodeMaterialConnectionPoint;
  153786. /**
  153787. * Gets the level operand input component
  153788. */
  153789. get level(): NodeMaterialConnectionPoint;
  153790. /**
  153791. * Gets the output component
  153792. */
  153793. get output(): NodeMaterialConnectionPoint;
  153794. protected _buildBlock(state: NodeMaterialBuildState): this;
  153795. }
  153796. }
  153797. declare module BABYLON {
  153798. /**
  153799. * Block used to implement the reflection module of the PBR material
  153800. */
  153801. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  153802. /** @hidden */
  153803. _defineLODReflectionAlpha: string;
  153804. /** @hidden */
  153805. _defineLinearSpecularReflection: string;
  153806. private _vEnvironmentIrradianceName;
  153807. /** @hidden */
  153808. _vReflectionMicrosurfaceInfosName: string;
  153809. /** @hidden */
  153810. _vReflectionInfosName: string;
  153811. /** @hidden */
  153812. _vReflectionFilteringInfoName: string;
  153813. private _scene;
  153814. /**
  153815. * The properties below are set by the main PBR block prior to calling methods of this class.
  153816. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  153817. * It's less burden on the user side in the editor part.
  153818. */
  153819. /** @hidden */
  153820. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  153821. /** @hidden */
  153822. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  153823. /** @hidden */
  153824. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  153825. /** @hidden */
  153826. viewConnectionPoint: NodeMaterialConnectionPoint;
  153827. /**
  153828. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  153829. * diffuse part of the IBL.
  153830. */
  153831. useSphericalHarmonics: boolean;
  153832. /**
  153833. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  153834. */
  153835. forceIrradianceInFragment: boolean;
  153836. /**
  153837. * Create a new ReflectionBlock
  153838. * @param name defines the block name
  153839. */
  153840. constructor(name: string);
  153841. /**
  153842. * Gets the current class name
  153843. * @returns the class name
  153844. */
  153845. getClassName(): string;
  153846. /**
  153847. * Gets the position input component
  153848. */
  153849. get position(): NodeMaterialConnectionPoint;
  153850. /**
  153851. * Gets the world position input component
  153852. */
  153853. get worldPosition(): NodeMaterialConnectionPoint;
  153854. /**
  153855. * Gets the world normal input component
  153856. */
  153857. get worldNormal(): NodeMaterialConnectionPoint;
  153858. /**
  153859. * Gets the world input component
  153860. */
  153861. get world(): NodeMaterialConnectionPoint;
  153862. /**
  153863. * Gets the camera (or eye) position component
  153864. */
  153865. get cameraPosition(): NodeMaterialConnectionPoint;
  153866. /**
  153867. * Gets the view input component
  153868. */
  153869. get view(): NodeMaterialConnectionPoint;
  153870. /**
  153871. * Gets the color input component
  153872. */
  153873. get color(): NodeMaterialConnectionPoint;
  153874. /**
  153875. * Gets the reflection object output component
  153876. */
  153877. get reflection(): NodeMaterialConnectionPoint;
  153878. /**
  153879. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  153880. */
  153881. get hasTexture(): boolean;
  153882. /**
  153883. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  153884. */
  153885. get reflectionColor(): string;
  153886. protected _getTexture(): Nullable<BaseTexture>;
  153887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  153889. /**
  153890. * Gets the code to inject in the vertex shader
  153891. * @param state current state of the node material building
  153892. * @returns the shader code
  153893. */
  153894. handleVertexSide(state: NodeMaterialBuildState): string;
  153895. /**
  153896. * Gets the main code of the block (fragment side)
  153897. * @param state current state of the node material building
  153898. * @param normalVarName name of the existing variable corresponding to the normal
  153899. * @returns the shader code
  153900. */
  153901. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  153902. protected _buildBlock(state: NodeMaterialBuildState): this;
  153903. protected _dumpPropertiesCode(): string;
  153904. serialize(): any;
  153905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153906. }
  153907. }
  153908. declare module BABYLON {
  153909. /**
  153910. * Block used to implement the sheen module of the PBR material
  153911. */
  153912. export class SheenBlock extends NodeMaterialBlock {
  153913. /**
  153914. * Create a new SheenBlock
  153915. * @param name defines the block name
  153916. */
  153917. constructor(name: string);
  153918. /**
  153919. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  153920. * It allows the strength of the sheen effect to not depend on the base color of the material,
  153921. * making it easier to setup and tweak the effect
  153922. */
  153923. albedoScaling: boolean;
  153924. /**
  153925. * Defines if the sheen is linked to the sheen color.
  153926. */
  153927. linkSheenWithAlbedo: boolean;
  153928. /**
  153929. * Initialize the block and prepare the context for build
  153930. * @param state defines the state that will be used for the build
  153931. */
  153932. initialize(state: NodeMaterialBuildState): void;
  153933. /**
  153934. * Gets the current class name
  153935. * @returns the class name
  153936. */
  153937. getClassName(): string;
  153938. /**
  153939. * Gets the intensity input component
  153940. */
  153941. get intensity(): NodeMaterialConnectionPoint;
  153942. /**
  153943. * Gets the color input component
  153944. */
  153945. get color(): NodeMaterialConnectionPoint;
  153946. /**
  153947. * Gets the roughness input component
  153948. */
  153949. get roughness(): NodeMaterialConnectionPoint;
  153950. /**
  153951. * Gets the sheen object output component
  153952. */
  153953. get sheen(): NodeMaterialConnectionPoint;
  153954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153955. /**
  153956. * Gets the main code of the block (fragment side)
  153957. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153958. * @returns the shader code
  153959. */
  153960. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  153961. protected _buildBlock(state: NodeMaterialBuildState): this;
  153962. protected _dumpPropertiesCode(): string;
  153963. serialize(): any;
  153964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153965. }
  153966. }
  153967. declare module BABYLON {
  153968. /**
  153969. * Block used to implement the anisotropy module of the PBR material
  153970. */
  153971. export class AnisotropyBlock extends NodeMaterialBlock {
  153972. /**
  153973. * The two properties below are set by the main PBR block prior to calling methods of this class.
  153974. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  153975. * It's less burden on the user side in the editor part.
  153976. */
  153977. /** @hidden */
  153978. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  153979. /** @hidden */
  153980. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  153981. /**
  153982. * Create a new AnisotropyBlock
  153983. * @param name defines the block name
  153984. */
  153985. constructor(name: string);
  153986. /**
  153987. * Initialize the block and prepare the context for build
  153988. * @param state defines the state that will be used for the build
  153989. */
  153990. initialize(state: NodeMaterialBuildState): void;
  153991. /**
  153992. * Gets the current class name
  153993. * @returns the class name
  153994. */
  153995. getClassName(): string;
  153996. /**
  153997. * Gets the intensity input component
  153998. */
  153999. get intensity(): NodeMaterialConnectionPoint;
  154000. /**
  154001. * Gets the direction input component
  154002. */
  154003. get direction(): NodeMaterialConnectionPoint;
  154004. /**
  154005. * Gets the uv input component
  154006. */
  154007. get uv(): NodeMaterialConnectionPoint;
  154008. /**
  154009. * Gets the worldTangent input component
  154010. */
  154011. get worldTangent(): NodeMaterialConnectionPoint;
  154012. /**
  154013. * Gets the anisotropy object output component
  154014. */
  154015. get anisotropy(): NodeMaterialConnectionPoint;
  154016. private _generateTBNSpace;
  154017. /**
  154018. * Gets the main code of the block (fragment side)
  154019. * @param state current state of the node material building
  154020. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  154021. * @returns the shader code
  154022. */
  154023. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  154024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154025. protected _buildBlock(state: NodeMaterialBuildState): this;
  154026. }
  154027. }
  154028. declare module BABYLON {
  154029. /**
  154030. * Block used to implement the clear coat module of the PBR material
  154031. */
  154032. export class ClearCoatBlock extends NodeMaterialBlock {
  154033. private _scene;
  154034. /**
  154035. * Create a new ClearCoatBlock
  154036. * @param name defines the block name
  154037. */
  154038. constructor(name: string);
  154039. /**
  154040. * Defines if the F0 value should be remapped to account for the interface change in the material.
  154041. */
  154042. remapF0OnInterfaceChange: boolean;
  154043. /**
  154044. * Initialize the block and prepare the context for build
  154045. * @param state defines the state that will be used for the build
  154046. */
  154047. initialize(state: NodeMaterialBuildState): void;
  154048. /**
  154049. * Gets the current class name
  154050. * @returns the class name
  154051. */
  154052. getClassName(): string;
  154053. /**
  154054. * Gets the intensity input component
  154055. */
  154056. get intensity(): NodeMaterialConnectionPoint;
  154057. /**
  154058. * Gets the roughness input component
  154059. */
  154060. get roughness(): NodeMaterialConnectionPoint;
  154061. /**
  154062. * Gets the ior input component
  154063. */
  154064. get indexOfRefraction(): NodeMaterialConnectionPoint;
  154065. /**
  154066. * Gets the bump texture input component
  154067. */
  154068. get normalMapColor(): NodeMaterialConnectionPoint;
  154069. /**
  154070. * Gets the uv input component
  154071. */
  154072. get uv(): NodeMaterialConnectionPoint;
  154073. /**
  154074. * Gets the tint color input component
  154075. */
  154076. get tintColor(): NodeMaterialConnectionPoint;
  154077. /**
  154078. * Gets the tint "at distance" input component
  154079. */
  154080. get tintAtDistance(): NodeMaterialConnectionPoint;
  154081. /**
  154082. * Gets the tint thickness input component
  154083. */
  154084. get tintThickness(): NodeMaterialConnectionPoint;
  154085. /**
  154086. * Gets the world tangent input component
  154087. */
  154088. get worldTangent(): NodeMaterialConnectionPoint;
  154089. /**
  154090. * Gets the clear coat object output component
  154091. */
  154092. get clearcoat(): NodeMaterialConnectionPoint;
  154093. autoConfigure(material: NodeMaterial): void;
  154094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  154096. private _generateTBNSpace;
  154097. /**
  154098. * Gets the main code of the block (fragment side)
  154099. * @param state current state of the node material building
  154100. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  154101. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  154102. * @param worldPosVarName name of the variable holding the world position
  154103. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  154104. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  154105. * @param worldNormalVarName name of the variable holding the world normal
  154106. * @returns the shader code
  154107. */
  154108. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  154109. protected _buildBlock(state: NodeMaterialBuildState): this;
  154110. protected _dumpPropertiesCode(): string;
  154111. serialize(): any;
  154112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154113. }
  154114. }
  154115. declare module BABYLON {
  154116. /**
  154117. * Block used to implement the sub surface module of the PBR material
  154118. */
  154119. export class SubSurfaceBlock extends NodeMaterialBlock {
  154120. /**
  154121. * Create a new SubSurfaceBlock
  154122. * @param name defines the block name
  154123. */
  154124. constructor(name: string);
  154125. /**
  154126. * Initialize the block and prepare the context for build
  154127. * @param state defines the state that will be used for the build
  154128. */
  154129. initialize(state: NodeMaterialBuildState): void;
  154130. /**
  154131. * Gets the current class name
  154132. * @returns the class name
  154133. */
  154134. getClassName(): string;
  154135. /**
  154136. * Gets the thickness component
  154137. */
  154138. get thickness(): NodeMaterialConnectionPoint;
  154139. /**
  154140. * Gets the tint color input component
  154141. */
  154142. get tintColor(): NodeMaterialConnectionPoint;
  154143. /**
  154144. * Gets the translucency intensity input component
  154145. */
  154146. get translucencyIntensity(): NodeMaterialConnectionPoint;
  154147. /**
  154148. * Gets the translucency diffusion distance input component
  154149. */
  154150. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  154151. /**
  154152. * Gets the refraction object parameters
  154153. */
  154154. get refraction(): NodeMaterialConnectionPoint;
  154155. /**
  154156. * Gets the sub surface object output component
  154157. */
  154158. get subsurface(): NodeMaterialConnectionPoint;
  154159. autoConfigure(material: NodeMaterial): void;
  154160. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154161. /**
  154162. * Gets the main code of the block (fragment side)
  154163. * @param state current state of the node material building
  154164. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  154165. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  154166. * @param worldPosVarName name of the variable holding the world position
  154167. * @returns the shader code
  154168. */
  154169. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  154170. protected _buildBlock(state: NodeMaterialBuildState): this;
  154171. }
  154172. }
  154173. declare module BABYLON {
  154174. /**
  154175. * Block used to implement the PBR metallic/roughness model
  154176. */
  154177. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  154178. /**
  154179. * Gets or sets the light associated with this block
  154180. */
  154181. light: Nullable<Light>;
  154182. private _lightId;
  154183. private _scene;
  154184. private _environmentBRDFTexture;
  154185. private _environmentBrdfSamplerName;
  154186. private _vNormalWName;
  154187. private _invertNormalName;
  154188. private _metallicReflectanceColor;
  154189. private _metallicF0Factor;
  154190. private _vMetallicReflectanceFactorsName;
  154191. /**
  154192. * Create a new ReflectionBlock
  154193. * @param name defines the block name
  154194. */
  154195. constructor(name: string);
  154196. /**
  154197. * Intensity of the direct lights e.g. the four lights available in your scene.
  154198. * This impacts both the direct diffuse and specular highlights.
  154199. */
  154200. directIntensity: number;
  154201. /**
  154202. * Intensity of the environment e.g. how much the environment will light the object
  154203. * either through harmonics for rough material or through the refelction for shiny ones.
  154204. */
  154205. environmentIntensity: number;
  154206. /**
  154207. * This is a special control allowing the reduction of the specular highlights coming from the
  154208. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  154209. */
  154210. specularIntensity: number;
  154211. /**
  154212. * Defines the falloff type used in this material.
  154213. * It by default is Physical.
  154214. */
  154215. lightFalloff: number;
  154216. /**
  154217. * Specifies that alpha test should be used
  154218. */
  154219. useAlphaTest: boolean;
  154220. /**
  154221. * Defines the alpha limits in alpha test mode.
  154222. */
  154223. alphaTestCutoff: number;
  154224. /**
  154225. * Specifies that alpha blending should be used
  154226. */
  154227. useAlphaBlending: boolean;
  154228. /**
  154229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  154230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  154231. */
  154232. useRadianceOverAlpha: boolean;
  154233. /**
  154234. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  154235. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  154236. */
  154237. useSpecularOverAlpha: boolean;
  154238. /**
  154239. * Enables specular anti aliasing in the PBR shader.
  154240. * It will both interacts on the Geometry for analytical and IBL lighting.
  154241. * It also prefilter the roughness map based on the bump values.
  154242. */
  154243. enableSpecularAntiAliasing: boolean;
  154244. /**
  154245. * Enables realtime filtering on the texture.
  154246. */
  154247. realTimeFiltering: boolean;
  154248. /**
  154249. * Quality switch for realtime filtering
  154250. */
  154251. realTimeFilteringQuality: number;
  154252. /**
  154253. * Defines if the material uses energy conservation.
  154254. */
  154255. useEnergyConservation: boolean;
  154256. /**
  154257. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  154258. * too much the area relying on ambient texture to define their ambient occlusion.
  154259. */
  154260. useRadianceOcclusion: boolean;
  154261. /**
  154262. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  154263. * makes the reflect vector face the model (under horizon).
  154264. */
  154265. useHorizonOcclusion: boolean;
  154266. /**
  154267. * If set to true, no lighting calculations will be applied.
  154268. */
  154269. unlit: boolean;
  154270. /**
  154271. * Force normal to face away from face.
  154272. */
  154273. forceNormalForward: boolean;
  154274. /**
  154275. * Defines the material debug mode.
  154276. * It helps seeing only some components of the material while troubleshooting.
  154277. */
  154278. debugMode: number;
  154279. /**
  154280. * Specify from where on screen the debug mode should start.
  154281. * The value goes from -1 (full screen) to 1 (not visible)
  154282. * It helps with side by side comparison against the final render
  154283. * This defaults to 0
  154284. */
  154285. debugLimit: number;
  154286. /**
  154287. * As the default viewing range might not be enough (if the ambient is really small for instance)
  154288. * You can use the factor to better multiply the final value.
  154289. */
  154290. debugFactor: number;
  154291. /**
  154292. * Initialize the block and prepare the context for build
  154293. * @param state defines the state that will be used for the build
  154294. */
  154295. initialize(state: NodeMaterialBuildState): void;
  154296. /**
  154297. * Gets the current class name
  154298. * @returns the class name
  154299. */
  154300. getClassName(): string;
  154301. /**
  154302. * Gets the world position input component
  154303. */
  154304. get worldPosition(): NodeMaterialConnectionPoint;
  154305. /**
  154306. * Gets the world normal input component
  154307. */
  154308. get worldNormal(): NodeMaterialConnectionPoint;
  154309. /**
  154310. * Gets the view matrix parameter
  154311. */
  154312. get view(): NodeMaterialConnectionPoint;
  154313. /**
  154314. * Gets the camera position input component
  154315. */
  154316. get cameraPosition(): NodeMaterialConnectionPoint;
  154317. /**
  154318. * Gets the perturbed normal input component
  154319. */
  154320. get perturbedNormal(): NodeMaterialConnectionPoint;
  154321. /**
  154322. * Gets the base color input component
  154323. */
  154324. get baseColor(): NodeMaterialConnectionPoint;
  154325. /**
  154326. * Gets the metallic input component
  154327. */
  154328. get metallic(): NodeMaterialConnectionPoint;
  154329. /**
  154330. * Gets the roughness input component
  154331. */
  154332. get roughness(): NodeMaterialConnectionPoint;
  154333. /**
  154334. * Gets the ambient occlusion input component
  154335. */
  154336. get ambientOcc(): NodeMaterialConnectionPoint;
  154337. /**
  154338. * Gets the opacity input component
  154339. */
  154340. get opacity(): NodeMaterialConnectionPoint;
  154341. /**
  154342. * Gets the index of refraction input component
  154343. */
  154344. get indexOfRefraction(): NodeMaterialConnectionPoint;
  154345. /**
  154346. * Gets the ambient color input component
  154347. */
  154348. get ambientColor(): NodeMaterialConnectionPoint;
  154349. /**
  154350. * Gets the reflection object parameters
  154351. */
  154352. get reflection(): NodeMaterialConnectionPoint;
  154353. /**
  154354. * Gets the clear coat object parameters
  154355. */
  154356. get clearcoat(): NodeMaterialConnectionPoint;
  154357. /**
  154358. * Gets the sheen object parameters
  154359. */
  154360. get sheen(): NodeMaterialConnectionPoint;
  154361. /**
  154362. * Gets the sub surface object parameters
  154363. */
  154364. get subsurface(): NodeMaterialConnectionPoint;
  154365. /**
  154366. * Gets the anisotropy object parameters
  154367. */
  154368. get anisotropy(): NodeMaterialConnectionPoint;
  154369. /**
  154370. * Gets the ambient output component
  154371. */
  154372. get ambientClr(): NodeMaterialConnectionPoint;
  154373. /**
  154374. * Gets the diffuse output component
  154375. */
  154376. get diffuseDir(): NodeMaterialConnectionPoint;
  154377. /**
  154378. * Gets the specular output component
  154379. */
  154380. get specularDir(): NodeMaterialConnectionPoint;
  154381. /**
  154382. * Gets the clear coat output component
  154383. */
  154384. get clearcoatDir(): NodeMaterialConnectionPoint;
  154385. /**
  154386. * Gets the sheen output component
  154387. */
  154388. get sheenDir(): NodeMaterialConnectionPoint;
  154389. /**
  154390. * Gets the indirect diffuse output component
  154391. */
  154392. get diffuseIndirect(): NodeMaterialConnectionPoint;
  154393. /**
  154394. * Gets the indirect specular output component
  154395. */
  154396. get specularIndirect(): NodeMaterialConnectionPoint;
  154397. /**
  154398. * Gets the indirect clear coat output component
  154399. */
  154400. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  154401. /**
  154402. * Gets the indirect sheen output component
  154403. */
  154404. get sheenIndirect(): NodeMaterialConnectionPoint;
  154405. /**
  154406. * Gets the refraction output component
  154407. */
  154408. get refraction(): NodeMaterialConnectionPoint;
  154409. /**
  154410. * Gets the global lighting output component
  154411. */
  154412. get lighting(): NodeMaterialConnectionPoint;
  154413. /**
  154414. * Gets the shadow output component
  154415. */
  154416. get shadow(): NodeMaterialConnectionPoint;
  154417. /**
  154418. * Gets the alpha output component
  154419. */
  154420. get alpha(): NodeMaterialConnectionPoint;
  154421. autoConfigure(material: NodeMaterial): void;
  154422. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154423. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  154424. isReady(): boolean;
  154425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  154426. private _injectVertexCode;
  154427. private _getAlbedoOpacityCode;
  154428. private _getAmbientOcclusionCode;
  154429. private _getReflectivityCode;
  154430. protected _buildBlock(state: NodeMaterialBuildState): this;
  154431. protected _dumpPropertiesCode(): string;
  154432. serialize(): any;
  154433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154434. }
  154435. }
  154436. declare module BABYLON {
  154437. /**
  154438. * Block used to compute value of one parameter modulo another
  154439. */
  154440. export class ModBlock extends NodeMaterialBlock {
  154441. /**
  154442. * Creates a new ModBlock
  154443. * @param name defines the block name
  154444. */
  154445. constructor(name: string);
  154446. /**
  154447. * Gets the current class name
  154448. * @returns the class name
  154449. */
  154450. getClassName(): string;
  154451. /**
  154452. * Gets the left operand input component
  154453. */
  154454. get left(): NodeMaterialConnectionPoint;
  154455. /**
  154456. * Gets the right operand input component
  154457. */
  154458. get right(): NodeMaterialConnectionPoint;
  154459. /**
  154460. * Gets the output component
  154461. */
  154462. get output(): NodeMaterialConnectionPoint;
  154463. protected _buildBlock(state: NodeMaterialBuildState): this;
  154464. }
  154465. }
  154466. declare module BABYLON {
  154467. /**
  154468. * Configuration for Draco compression
  154469. */
  154470. export interface IDracoCompressionConfiguration {
  154471. /**
  154472. * Configuration for the decoder.
  154473. */
  154474. decoder: {
  154475. /**
  154476. * The url to the WebAssembly module.
  154477. */
  154478. wasmUrl?: string;
  154479. /**
  154480. * The url to the WebAssembly binary.
  154481. */
  154482. wasmBinaryUrl?: string;
  154483. /**
  154484. * The url to the fallback JavaScript module.
  154485. */
  154486. fallbackUrl?: string;
  154487. };
  154488. }
  154489. /**
  154490. * Draco compression (https://google.github.io/draco/)
  154491. *
  154492. * This class wraps the Draco module.
  154493. *
  154494. * **Encoder**
  154495. *
  154496. * The encoder is not currently implemented.
  154497. *
  154498. * **Decoder**
  154499. *
  154500. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  154501. *
  154502. * To update the configuration, use the following code:
  154503. * ```javascript
  154504. * DracoCompression.Configuration = {
  154505. * decoder: {
  154506. * wasmUrl: "<url to the WebAssembly library>",
  154507. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  154508. * fallbackUrl: "<url to the fallback JavaScript library>",
  154509. * }
  154510. * };
  154511. * ```
  154512. *
  154513. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  154514. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  154515. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  154516. *
  154517. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  154518. * ```javascript
  154519. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  154520. * ```
  154521. *
  154522. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  154523. */
  154524. export class DracoCompression implements IDisposable {
  154525. private _workerPoolPromise?;
  154526. private _decoderModulePromise?;
  154527. /**
  154528. * The configuration. Defaults to the following urls:
  154529. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  154530. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  154531. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  154532. */
  154533. static Configuration: IDracoCompressionConfiguration;
  154534. /**
  154535. * Returns true if the decoder configuration is available.
  154536. */
  154537. static get DecoderAvailable(): boolean;
  154538. /**
  154539. * Default number of workers to create when creating the draco compression object.
  154540. */
  154541. static DefaultNumWorkers: number;
  154542. private static GetDefaultNumWorkers;
  154543. private static _Default;
  154544. /**
  154545. * Default instance for the draco compression object.
  154546. */
  154547. static get Default(): DracoCompression;
  154548. /**
  154549. * Constructor
  154550. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  154551. */
  154552. constructor(numWorkers?: number);
  154553. /**
  154554. * Stop all async operations and release resources.
  154555. */
  154556. dispose(): void;
  154557. /**
  154558. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  154559. * @returns a promise that resolves when ready
  154560. */
  154561. whenReadyAsync(): Promise<void>;
  154562. /**
  154563. * Decode Draco compressed mesh data to vertex data.
  154564. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  154565. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  154566. * @returns A promise that resolves with the decoded vertex data
  154567. */
  154568. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  154569. [kind: string]: number;
  154570. }): Promise<VertexData>;
  154571. }
  154572. }
  154573. declare module BABYLON {
  154574. /**
  154575. * Class for building Constructive Solid Geometry
  154576. */
  154577. export class CSG {
  154578. private polygons;
  154579. /**
  154580. * The world matrix
  154581. */
  154582. matrix: Matrix;
  154583. /**
  154584. * Stores the position
  154585. */
  154586. position: Vector3;
  154587. /**
  154588. * Stores the rotation
  154589. */
  154590. rotation: Vector3;
  154591. /**
  154592. * Stores the rotation quaternion
  154593. */
  154594. rotationQuaternion: Nullable<Quaternion>;
  154595. /**
  154596. * Stores the scaling vector
  154597. */
  154598. scaling: Vector3;
  154599. /**
  154600. * Convert the Mesh to CSG
  154601. * @param mesh The Mesh to convert to CSG
  154602. * @returns A new CSG from the Mesh
  154603. */
  154604. static FromMesh(mesh: Mesh): CSG;
  154605. /**
  154606. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  154607. * @param polygons Polygons used to construct a CSG solid
  154608. */
  154609. private static FromPolygons;
  154610. /**
  154611. * Clones, or makes a deep copy, of the CSG
  154612. * @returns A new CSG
  154613. */
  154614. clone(): CSG;
  154615. /**
  154616. * Unions this CSG with another CSG
  154617. * @param csg The CSG to union against this CSG
  154618. * @returns The unioned CSG
  154619. */
  154620. union(csg: CSG): CSG;
  154621. /**
  154622. * Unions this CSG with another CSG in place
  154623. * @param csg The CSG to union against this CSG
  154624. */
  154625. unionInPlace(csg: CSG): void;
  154626. /**
  154627. * Subtracts this CSG with another CSG
  154628. * @param csg The CSG to subtract against this CSG
  154629. * @returns A new CSG
  154630. */
  154631. subtract(csg: CSG): CSG;
  154632. /**
  154633. * Subtracts this CSG with another CSG in place
  154634. * @param csg The CSG to subtact against this CSG
  154635. */
  154636. subtractInPlace(csg: CSG): void;
  154637. /**
  154638. * Intersect this CSG with another CSG
  154639. * @param csg The CSG to intersect against this CSG
  154640. * @returns A new CSG
  154641. */
  154642. intersect(csg: CSG): CSG;
  154643. /**
  154644. * Intersects this CSG with another CSG in place
  154645. * @param csg The CSG to intersect against this CSG
  154646. */
  154647. intersectInPlace(csg: CSG): void;
  154648. /**
  154649. * Return a new CSG solid with solid and empty space switched. This solid is
  154650. * not modified.
  154651. * @returns A new CSG solid with solid and empty space switched
  154652. */
  154653. inverse(): CSG;
  154654. /**
  154655. * Inverses the CSG in place
  154656. */
  154657. inverseInPlace(): void;
  154658. /**
  154659. * This is used to keep meshes transformations so they can be restored
  154660. * when we build back a Babylon Mesh
  154661. * NB : All CSG operations are performed in world coordinates
  154662. * @param csg The CSG to copy the transform attributes from
  154663. * @returns This CSG
  154664. */
  154665. copyTransformAttributes(csg: CSG): CSG;
  154666. /**
  154667. * Build Raw mesh from CSG
  154668. * Coordinates here are in world space
  154669. * @param name The name of the mesh geometry
  154670. * @param scene The Scene
  154671. * @param keepSubMeshes Specifies if the submeshes should be kept
  154672. * @returns A new Mesh
  154673. */
  154674. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  154675. /**
  154676. * Build Mesh from CSG taking material and transforms into account
  154677. * @param name The name of the Mesh
  154678. * @param material The material of the Mesh
  154679. * @param scene The Scene
  154680. * @param keepSubMeshes Specifies if submeshes should be kept
  154681. * @returns The new Mesh
  154682. */
  154683. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  154684. }
  154685. }
  154686. declare module BABYLON {
  154687. /**
  154688. * Class used to create a trail following a mesh
  154689. */
  154690. export class TrailMesh extends Mesh {
  154691. private _generator;
  154692. private _autoStart;
  154693. private _running;
  154694. private _diameter;
  154695. private _length;
  154696. private _sectionPolygonPointsCount;
  154697. private _sectionVectors;
  154698. private _sectionNormalVectors;
  154699. private _beforeRenderObserver;
  154700. /**
  154701. * @constructor
  154702. * @param name The value used by scene.getMeshByName() to do a lookup.
  154703. * @param generator The mesh or transform node to generate a trail.
  154704. * @param scene The scene to add this mesh to.
  154705. * @param diameter Diameter of trailing mesh. Default is 1.
  154706. * @param length Length of trailing mesh. Default is 60.
  154707. * @param autoStart Automatically start trailing mesh. Default true.
  154708. */
  154709. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  154710. /**
  154711. * "TrailMesh"
  154712. * @returns "TrailMesh"
  154713. */
  154714. getClassName(): string;
  154715. private _createMesh;
  154716. /**
  154717. * Start trailing mesh.
  154718. */
  154719. start(): void;
  154720. /**
  154721. * Stop trailing mesh.
  154722. */
  154723. stop(): void;
  154724. /**
  154725. * Update trailing mesh geometry.
  154726. */
  154727. update(): void;
  154728. /**
  154729. * Returns a new TrailMesh object.
  154730. * @param name is a string, the name given to the new mesh
  154731. * @param newGenerator use new generator object for cloned trail mesh
  154732. * @returns a new mesh
  154733. */
  154734. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  154735. /**
  154736. * Serializes this trail mesh
  154737. * @param serializationObject object to write serialization to
  154738. */
  154739. serialize(serializationObject: any): void;
  154740. /**
  154741. * Parses a serialized trail mesh
  154742. * @param parsedMesh the serialized mesh
  154743. * @param scene the scene to create the trail mesh in
  154744. * @returns the created trail mesh
  154745. */
  154746. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  154747. }
  154748. }
  154749. declare module BABYLON {
  154750. /**
  154751. * Class containing static functions to help procedurally build meshes
  154752. */
  154753. export class TiledBoxBuilder {
  154754. /**
  154755. * Creates a box mesh
  154756. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  154757. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154761. * @param name defines the name of the mesh
  154762. * @param options defines the options used to create the mesh
  154763. * @param scene defines the hosting scene
  154764. * @returns the box mesh
  154765. */
  154766. static CreateTiledBox(name: string, options: {
  154767. pattern?: number;
  154768. width?: number;
  154769. height?: number;
  154770. depth?: number;
  154771. tileSize?: number;
  154772. tileWidth?: number;
  154773. tileHeight?: number;
  154774. alignHorizontal?: number;
  154775. alignVertical?: number;
  154776. faceUV?: Vector4[];
  154777. faceColors?: Color4[];
  154778. sideOrientation?: number;
  154779. updatable?: boolean;
  154780. }, scene?: Nullable<Scene>): Mesh;
  154781. }
  154782. }
  154783. declare module BABYLON {
  154784. /**
  154785. * Class containing static functions to help procedurally build meshes
  154786. */
  154787. export class TorusKnotBuilder {
  154788. /**
  154789. * Creates a torus knot mesh
  154790. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  154791. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  154792. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  154793. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  154794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154797. * @param name defines the name of the mesh
  154798. * @param options defines the options used to create the mesh
  154799. * @param scene defines the hosting scene
  154800. * @returns the torus knot mesh
  154801. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  154802. */
  154803. static CreateTorusKnot(name: string, options: {
  154804. radius?: number;
  154805. tube?: number;
  154806. radialSegments?: number;
  154807. tubularSegments?: number;
  154808. p?: number;
  154809. q?: number;
  154810. updatable?: boolean;
  154811. sideOrientation?: number;
  154812. frontUVs?: Vector4;
  154813. backUVs?: Vector4;
  154814. }, scene: any): Mesh;
  154815. }
  154816. }
  154817. declare module BABYLON {
  154818. /**
  154819. * Polygon
  154820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  154821. */
  154822. export class Polygon {
  154823. /**
  154824. * Creates a rectangle
  154825. * @param xmin bottom X coord
  154826. * @param ymin bottom Y coord
  154827. * @param xmax top X coord
  154828. * @param ymax top Y coord
  154829. * @returns points that make the resulting rectation
  154830. */
  154831. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  154832. /**
  154833. * Creates a circle
  154834. * @param radius radius of circle
  154835. * @param cx scale in x
  154836. * @param cy scale in y
  154837. * @param numberOfSides number of sides that make up the circle
  154838. * @returns points that make the resulting circle
  154839. */
  154840. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  154841. /**
  154842. * Creates a polygon from input string
  154843. * @param input Input polygon data
  154844. * @returns the parsed points
  154845. */
  154846. static Parse(input: string): Vector2[];
  154847. /**
  154848. * Starts building a polygon from x and y coordinates
  154849. * @param x x coordinate
  154850. * @param y y coordinate
  154851. * @returns the started path2
  154852. */
  154853. static StartingAt(x: number, y: number): Path2;
  154854. }
  154855. /**
  154856. * Builds a polygon
  154857. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  154858. */
  154859. export class PolygonMeshBuilder {
  154860. private _points;
  154861. private _outlinepoints;
  154862. private _holes;
  154863. private _name;
  154864. private _scene;
  154865. private _epoints;
  154866. private _eholes;
  154867. private _addToepoint;
  154868. /**
  154869. * Babylon reference to the earcut plugin.
  154870. */
  154871. bjsEarcut: any;
  154872. /**
  154873. * Creates a PolygonMeshBuilder
  154874. * @param name name of the builder
  154875. * @param contours Path of the polygon
  154876. * @param scene scene to add to when creating the mesh
  154877. * @param earcutInjection can be used to inject your own earcut reference
  154878. */
  154879. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  154880. /**
  154881. * Adds a hole within the polygon
  154882. * @param hole Array of points defining the hole
  154883. * @returns this
  154884. */
  154885. addHole(hole: Vector2[]): PolygonMeshBuilder;
  154886. /**
  154887. * Creates the polygon
  154888. * @param updatable If the mesh should be updatable
  154889. * @param depth The depth of the mesh created
  154890. * @param smoothingThreshold Dot product threshold for smoothed normals
  154891. * @returns the created mesh
  154892. */
  154893. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  154894. /**
  154895. * Creates the polygon
  154896. * @param depth The depth of the mesh created
  154897. * @param smoothingThreshold Dot product threshold for smoothed normals
  154898. * @returns the created VertexData
  154899. */
  154900. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  154901. /**
  154902. * Adds a side to the polygon
  154903. * @param positions points that make the polygon
  154904. * @param normals normals of the polygon
  154905. * @param uvs uvs of the polygon
  154906. * @param indices indices of the polygon
  154907. * @param bounds bounds of the polygon
  154908. * @param points points of the polygon
  154909. * @param depth depth of the polygon
  154910. * @param flip flip of the polygon
  154911. */
  154912. private addSide;
  154913. }
  154914. }
  154915. declare module BABYLON {
  154916. /**
  154917. * Class containing static functions to help procedurally build meshes
  154918. */
  154919. export class PolygonBuilder {
  154920. /**
  154921. * Creates a polygon mesh
  154922. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  154923. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  154924. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  154927. * * Remember you can only change the shape positions, not their number when updating a polygon
  154928. * @param name defines the name of the mesh
  154929. * @param options defines the options used to create the mesh
  154930. * @param scene defines the hosting scene
  154931. * @param earcutInjection can be used to inject your own earcut reference
  154932. * @returns the polygon mesh
  154933. */
  154934. static CreatePolygon(name: string, options: {
  154935. shape: Vector3[];
  154936. holes?: Vector3[][];
  154937. depth?: number;
  154938. smoothingThreshold?: number;
  154939. faceUV?: Vector4[];
  154940. faceColors?: Color4[];
  154941. updatable?: boolean;
  154942. sideOrientation?: number;
  154943. frontUVs?: Vector4;
  154944. backUVs?: Vector4;
  154945. wrap?: boolean;
  154946. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154947. /**
  154948. * Creates an extruded polygon mesh, with depth in the Y direction.
  154949. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  154950. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154951. * @param name defines the name of the mesh
  154952. * @param options defines the options used to create the mesh
  154953. * @param scene defines the hosting scene
  154954. * @param earcutInjection can be used to inject your own earcut reference
  154955. * @returns the polygon mesh
  154956. */
  154957. static ExtrudePolygon(name: string, options: {
  154958. shape: Vector3[];
  154959. holes?: Vector3[][];
  154960. depth?: number;
  154961. faceUV?: Vector4[];
  154962. faceColors?: Color4[];
  154963. updatable?: boolean;
  154964. sideOrientation?: number;
  154965. frontUVs?: Vector4;
  154966. backUVs?: Vector4;
  154967. wrap?: boolean;
  154968. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154969. }
  154970. }
  154971. declare module BABYLON {
  154972. /**
  154973. * Class containing static functions to help procedurally build meshes
  154974. */
  154975. export class LatheBuilder {
  154976. /**
  154977. * Creates lathe mesh.
  154978. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  154979. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  154980. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  154981. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  154982. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  154983. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  154984. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  154985. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  154986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  154988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154990. * @param name defines the name of the mesh
  154991. * @param options defines the options used to create the mesh
  154992. * @param scene defines the hosting scene
  154993. * @returns the lathe mesh
  154994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  154995. */
  154996. static CreateLathe(name: string, options: {
  154997. shape: Vector3[];
  154998. radius?: number;
  154999. tessellation?: number;
  155000. clip?: number;
  155001. arc?: number;
  155002. closed?: boolean;
  155003. updatable?: boolean;
  155004. sideOrientation?: number;
  155005. frontUVs?: Vector4;
  155006. backUVs?: Vector4;
  155007. cap?: number;
  155008. invertUV?: boolean;
  155009. }, scene?: Nullable<Scene>): Mesh;
  155010. }
  155011. }
  155012. declare module BABYLON {
  155013. /**
  155014. * Class containing static functions to help procedurally build meshes
  155015. */
  155016. export class TiledPlaneBuilder {
  155017. /**
  155018. * Creates a tiled plane mesh
  155019. * * The parameter `pattern` will, depending on value, do nothing or
  155020. * * * flip (reflect about central vertical) alternate tiles across and up
  155021. * * * flip every tile on alternate rows
  155022. * * * rotate (180 degs) alternate tiles across and up
  155023. * * * rotate every tile on alternate rows
  155024. * * * flip and rotate alternate tiles across and up
  155025. * * * flip and rotate every tile on alternate rows
  155026. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  155027. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  155028. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  155030. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  155031. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  155032. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  155033. * @param name defines the name of the mesh
  155034. * @param options defines the options used to create the mesh
  155035. * @param scene defines the hosting scene
  155036. * @returns the box mesh
  155037. */
  155038. static CreateTiledPlane(name: string, options: {
  155039. pattern?: number;
  155040. tileSize?: number;
  155041. tileWidth?: number;
  155042. tileHeight?: number;
  155043. size?: number;
  155044. width?: number;
  155045. height?: number;
  155046. alignHorizontal?: number;
  155047. alignVertical?: number;
  155048. sideOrientation?: number;
  155049. frontUVs?: Vector4;
  155050. backUVs?: Vector4;
  155051. updatable?: boolean;
  155052. }, scene?: Nullable<Scene>): Mesh;
  155053. }
  155054. }
  155055. declare module BABYLON {
  155056. /**
  155057. * Class containing static functions to help procedurally build meshes
  155058. */
  155059. export class TubeBuilder {
  155060. /**
  155061. * Creates a tube mesh.
  155062. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  155063. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  155064. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  155065. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  155066. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  155067. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  155068. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  155069. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  155070. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  155071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155075. * @param name defines the name of the mesh
  155076. * @param options defines the options used to create the mesh
  155077. * @param scene defines the hosting scene
  155078. * @returns the tube mesh
  155079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155080. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  155081. */
  155082. static CreateTube(name: string, options: {
  155083. path: Vector3[];
  155084. radius?: number;
  155085. tessellation?: number;
  155086. radiusFunction?: {
  155087. (i: number, distance: number): number;
  155088. };
  155089. cap?: number;
  155090. arc?: number;
  155091. updatable?: boolean;
  155092. sideOrientation?: number;
  155093. frontUVs?: Vector4;
  155094. backUVs?: Vector4;
  155095. instance?: Mesh;
  155096. invertUV?: boolean;
  155097. }, scene?: Nullable<Scene>): Mesh;
  155098. }
  155099. }
  155100. declare module BABYLON {
  155101. /**
  155102. * Class containing static functions to help procedurally build meshes
  155103. */
  155104. export class IcoSphereBuilder {
  155105. /**
  155106. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  155107. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  155108. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  155109. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  155110. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  155111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155114. * @param name defines the name of the mesh
  155115. * @param options defines the options used to create the mesh
  155116. * @param scene defines the hosting scene
  155117. * @returns the icosahedron mesh
  155118. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  155119. */
  155120. static CreateIcoSphere(name: string, options: {
  155121. radius?: number;
  155122. radiusX?: number;
  155123. radiusY?: number;
  155124. radiusZ?: number;
  155125. flat?: boolean;
  155126. subdivisions?: number;
  155127. sideOrientation?: number;
  155128. frontUVs?: Vector4;
  155129. backUVs?: Vector4;
  155130. updatable?: boolean;
  155131. }, scene?: Nullable<Scene>): Mesh;
  155132. }
  155133. }
  155134. declare module BABYLON {
  155135. /**
  155136. * Class containing static functions to help procedurally build meshes
  155137. */
  155138. export class DecalBuilder {
  155139. /**
  155140. * Creates a decal mesh.
  155141. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  155142. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  155143. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  155144. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  155145. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  155146. * @param name defines the name of the mesh
  155147. * @param sourceMesh defines the mesh where the decal must be applied
  155148. * @param options defines the options used to create the mesh
  155149. * @param scene defines the hosting scene
  155150. * @returns the decal mesh
  155151. * @see https://doc.babylonjs.com/how_to/decals
  155152. */
  155153. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  155154. position?: Vector3;
  155155. normal?: Vector3;
  155156. size?: Vector3;
  155157. angle?: number;
  155158. }): Mesh;
  155159. }
  155160. }
  155161. declare module BABYLON {
  155162. /**
  155163. * Class containing static functions to help procedurally build meshes
  155164. */
  155165. export class MeshBuilder {
  155166. /**
  155167. * Creates a box mesh
  155168. * * The parameter `size` sets the size (float) of each box side (default 1)
  155169. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  155170. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  155171. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  155172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155175. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  155176. * @param name defines the name of the mesh
  155177. * @param options defines the options used to create the mesh
  155178. * @param scene defines the hosting scene
  155179. * @returns the box mesh
  155180. */
  155181. static CreateBox(name: string, options: {
  155182. size?: number;
  155183. width?: number;
  155184. height?: number;
  155185. depth?: number;
  155186. faceUV?: Vector4[];
  155187. faceColors?: Color4[];
  155188. sideOrientation?: number;
  155189. frontUVs?: Vector4;
  155190. backUVs?: Vector4;
  155191. wrap?: boolean;
  155192. topBaseAt?: number;
  155193. bottomBaseAt?: number;
  155194. updatable?: boolean;
  155195. }, scene?: Nullable<Scene>): Mesh;
  155196. /**
  155197. * Creates a tiled box mesh
  155198. * * faceTiles sets the pattern, tile size and number of tiles for a face
  155199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155200. * @param name defines the name of the mesh
  155201. * @param options defines the options used to create the mesh
  155202. * @param scene defines the hosting scene
  155203. * @returns the tiled box mesh
  155204. */
  155205. static CreateTiledBox(name: string, options: {
  155206. pattern?: number;
  155207. size?: number;
  155208. width?: number;
  155209. height?: number;
  155210. depth: number;
  155211. tileSize?: number;
  155212. tileWidth?: number;
  155213. tileHeight?: number;
  155214. faceUV?: Vector4[];
  155215. faceColors?: Color4[];
  155216. alignHorizontal?: number;
  155217. alignVertical?: number;
  155218. sideOrientation?: number;
  155219. updatable?: boolean;
  155220. }, scene?: Nullable<Scene>): Mesh;
  155221. /**
  155222. * Creates a sphere mesh
  155223. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  155224. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  155225. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  155226. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  155227. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  155228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155231. * @param name defines the name of the mesh
  155232. * @param options defines the options used to create the mesh
  155233. * @param scene defines the hosting scene
  155234. * @returns the sphere mesh
  155235. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  155236. */
  155237. static CreateSphere(name: string, options: {
  155238. segments?: number;
  155239. diameter?: number;
  155240. diameterX?: number;
  155241. diameterY?: number;
  155242. diameterZ?: number;
  155243. arc?: number;
  155244. slice?: number;
  155245. sideOrientation?: number;
  155246. frontUVs?: Vector4;
  155247. backUVs?: Vector4;
  155248. updatable?: boolean;
  155249. }, scene?: Nullable<Scene>): Mesh;
  155250. /**
  155251. * Creates a plane polygonal mesh. By default, this is a disc
  155252. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  155253. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  155254. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  155255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155258. * @param name defines the name of the mesh
  155259. * @param options defines the options used to create the mesh
  155260. * @param scene defines the hosting scene
  155261. * @returns the plane polygonal mesh
  155262. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  155263. */
  155264. static CreateDisc(name: string, options: {
  155265. radius?: number;
  155266. tessellation?: number;
  155267. arc?: number;
  155268. updatable?: boolean;
  155269. sideOrientation?: number;
  155270. frontUVs?: Vector4;
  155271. backUVs?: Vector4;
  155272. }, scene?: Nullable<Scene>): Mesh;
  155273. /**
  155274. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  155275. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  155276. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  155277. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  155278. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  155279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155282. * @param name defines the name of the mesh
  155283. * @param options defines the options used to create the mesh
  155284. * @param scene defines the hosting scene
  155285. * @returns the icosahedron mesh
  155286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  155287. */
  155288. static CreateIcoSphere(name: string, options: {
  155289. radius?: number;
  155290. radiusX?: number;
  155291. radiusY?: number;
  155292. radiusZ?: number;
  155293. flat?: boolean;
  155294. subdivisions?: number;
  155295. sideOrientation?: number;
  155296. frontUVs?: Vector4;
  155297. backUVs?: Vector4;
  155298. updatable?: boolean;
  155299. }, scene?: Nullable<Scene>): Mesh;
  155300. /**
  155301. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  155302. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  155303. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  155304. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  155305. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  155306. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  155307. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  155308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155311. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  155312. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  155313. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  155314. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  155315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155316. * @param name defines the name of the mesh
  155317. * @param options defines the options used to create the mesh
  155318. * @param scene defines the hosting scene
  155319. * @returns the ribbon mesh
  155320. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  155321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155322. */
  155323. static CreateRibbon(name: string, options: {
  155324. pathArray: Vector3[][];
  155325. closeArray?: boolean;
  155326. closePath?: boolean;
  155327. offset?: number;
  155328. updatable?: boolean;
  155329. sideOrientation?: number;
  155330. frontUVs?: Vector4;
  155331. backUVs?: Vector4;
  155332. instance?: Mesh;
  155333. invertUV?: boolean;
  155334. uvs?: Vector2[];
  155335. colors?: Color4[];
  155336. }, scene?: Nullable<Scene>): Mesh;
  155337. /**
  155338. * Creates a cylinder or a cone mesh
  155339. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  155340. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  155341. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  155342. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  155343. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  155344. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  155345. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  155346. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  155347. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  155348. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  155349. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  155350. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  155351. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  155352. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  155353. * * If `enclose` is false, a ring surface is one element.
  155354. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  155355. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  155356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155359. * @param name defines the name of the mesh
  155360. * @param options defines the options used to create the mesh
  155361. * @param scene defines the hosting scene
  155362. * @returns the cylinder mesh
  155363. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  155364. */
  155365. static CreateCylinder(name: string, options: {
  155366. height?: number;
  155367. diameterTop?: number;
  155368. diameterBottom?: number;
  155369. diameter?: number;
  155370. tessellation?: number;
  155371. subdivisions?: number;
  155372. arc?: number;
  155373. faceColors?: Color4[];
  155374. faceUV?: Vector4[];
  155375. updatable?: boolean;
  155376. hasRings?: boolean;
  155377. enclose?: boolean;
  155378. cap?: number;
  155379. sideOrientation?: number;
  155380. frontUVs?: Vector4;
  155381. backUVs?: Vector4;
  155382. }, scene?: Nullable<Scene>): Mesh;
  155383. /**
  155384. * Creates a torus mesh
  155385. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  155386. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  155387. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  155388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155391. * @param name defines the name of the mesh
  155392. * @param options defines the options used to create the mesh
  155393. * @param scene defines the hosting scene
  155394. * @returns the torus mesh
  155395. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  155396. */
  155397. static CreateTorus(name: string, options: {
  155398. diameter?: number;
  155399. thickness?: number;
  155400. tessellation?: number;
  155401. updatable?: boolean;
  155402. sideOrientation?: number;
  155403. frontUVs?: Vector4;
  155404. backUVs?: Vector4;
  155405. }, scene?: Nullable<Scene>): Mesh;
  155406. /**
  155407. * Creates a torus knot mesh
  155408. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  155409. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  155410. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  155411. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  155412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155415. * @param name defines the name of the mesh
  155416. * @param options defines the options used to create the mesh
  155417. * @param scene defines the hosting scene
  155418. * @returns the torus knot mesh
  155419. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  155420. */
  155421. static CreateTorusKnot(name: string, options: {
  155422. radius?: number;
  155423. tube?: number;
  155424. radialSegments?: number;
  155425. tubularSegments?: number;
  155426. p?: number;
  155427. q?: number;
  155428. updatable?: boolean;
  155429. sideOrientation?: number;
  155430. frontUVs?: Vector4;
  155431. backUVs?: Vector4;
  155432. }, scene?: Nullable<Scene>): Mesh;
  155433. /**
  155434. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  155435. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  155436. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  155437. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  155438. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  155439. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  155440. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  155441. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  155442. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  155443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  155445. * @param name defines the name of the new line system
  155446. * @param options defines the options used to create the line system
  155447. * @param scene defines the hosting scene
  155448. * @returns a new line system mesh
  155449. */
  155450. static CreateLineSystem(name: string, options: {
  155451. lines: Vector3[][];
  155452. updatable?: boolean;
  155453. instance?: Nullable<LinesMesh>;
  155454. colors?: Nullable<Color4[][]>;
  155455. useVertexAlpha?: boolean;
  155456. }, scene: Nullable<Scene>): LinesMesh;
  155457. /**
  155458. * Creates a line mesh
  155459. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  155460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  155461. * * The parameter `points` is an array successive Vector3
  155462. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  155463. * * The optional parameter `colors` is an array of successive Color4, one per line point
  155464. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  155465. * * When updating an instance, remember that only point positions can change, not the number of points
  155466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  155468. * @param name defines the name of the new line system
  155469. * @param options defines the options used to create the line system
  155470. * @param scene defines the hosting scene
  155471. * @returns a new line mesh
  155472. */
  155473. static CreateLines(name: string, options: {
  155474. points: Vector3[];
  155475. updatable?: boolean;
  155476. instance?: Nullable<LinesMesh>;
  155477. colors?: Color4[];
  155478. useVertexAlpha?: boolean;
  155479. }, scene?: Nullable<Scene>): LinesMesh;
  155480. /**
  155481. * Creates a dashed line mesh
  155482. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  155483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  155484. * * The parameter `points` is an array successive Vector3
  155485. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  155486. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  155487. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  155488. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  155489. * * When updating an instance, remember that only point positions can change, not the number of points
  155490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155491. * @param name defines the name of the mesh
  155492. * @param options defines the options used to create the mesh
  155493. * @param scene defines the hosting scene
  155494. * @returns the dashed line mesh
  155495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  155496. */
  155497. static CreateDashedLines(name: string, options: {
  155498. points: Vector3[];
  155499. dashSize?: number;
  155500. gapSize?: number;
  155501. dashNb?: number;
  155502. updatable?: boolean;
  155503. instance?: LinesMesh;
  155504. }, scene?: Nullable<Scene>): LinesMesh;
  155505. /**
  155506. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  155507. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  155508. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  155509. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  155510. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  155511. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  155512. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  155513. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  155514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  155517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155518. * @param name defines the name of the mesh
  155519. * @param options defines the options used to create the mesh
  155520. * @param scene defines the hosting scene
  155521. * @returns the extruded shape mesh
  155522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  155524. */
  155525. static ExtrudeShape(name: string, options: {
  155526. shape: Vector3[];
  155527. path: Vector3[];
  155528. scale?: number;
  155529. rotation?: number;
  155530. cap?: number;
  155531. updatable?: boolean;
  155532. sideOrientation?: number;
  155533. frontUVs?: Vector4;
  155534. backUVs?: Vector4;
  155535. instance?: Mesh;
  155536. invertUV?: boolean;
  155537. }, scene?: Nullable<Scene>): Mesh;
  155538. /**
  155539. * Creates an custom extruded shape mesh.
  155540. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  155541. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  155542. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  155543. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  155544. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  155545. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  155546. * * It must returns a float value that will be the scale value applied to the shape on each path point
  155547. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  155548. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  155549. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  155550. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  155551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  155552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155556. * @param name defines the name of the mesh
  155557. * @param options defines the options used to create the mesh
  155558. * @param scene defines the hosting scene
  155559. * @returns the custom extruded shape mesh
  155560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  155561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  155563. */
  155564. static ExtrudeShapeCustom(name: string, options: {
  155565. shape: Vector3[];
  155566. path: Vector3[];
  155567. scaleFunction?: any;
  155568. rotationFunction?: any;
  155569. ribbonCloseArray?: boolean;
  155570. ribbonClosePath?: boolean;
  155571. cap?: number;
  155572. updatable?: boolean;
  155573. sideOrientation?: number;
  155574. frontUVs?: Vector4;
  155575. backUVs?: Vector4;
  155576. instance?: Mesh;
  155577. invertUV?: boolean;
  155578. }, scene?: Nullable<Scene>): Mesh;
  155579. /**
  155580. * Creates lathe mesh.
  155581. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  155582. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  155583. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  155584. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  155585. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  155586. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  155587. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  155588. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  155589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155593. * @param name defines the name of the mesh
  155594. * @param options defines the options used to create the mesh
  155595. * @param scene defines the hosting scene
  155596. * @returns the lathe mesh
  155597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  155598. */
  155599. static CreateLathe(name: string, options: {
  155600. shape: Vector3[];
  155601. radius?: number;
  155602. tessellation?: number;
  155603. clip?: number;
  155604. arc?: number;
  155605. closed?: boolean;
  155606. updatable?: boolean;
  155607. sideOrientation?: number;
  155608. frontUVs?: Vector4;
  155609. backUVs?: Vector4;
  155610. cap?: number;
  155611. invertUV?: boolean;
  155612. }, scene?: Nullable<Scene>): Mesh;
  155613. /**
  155614. * Creates a tiled plane mesh
  155615. * * You can set a limited pattern arrangement with the tiles
  155616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155619. * @param name defines the name of the mesh
  155620. * @param options defines the options used to create the mesh
  155621. * @param scene defines the hosting scene
  155622. * @returns the plane mesh
  155623. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  155624. */
  155625. static CreateTiledPlane(name: string, options: {
  155626. pattern?: number;
  155627. tileSize?: number;
  155628. tileWidth?: number;
  155629. tileHeight?: number;
  155630. size?: number;
  155631. width?: number;
  155632. height?: number;
  155633. alignHorizontal?: number;
  155634. alignVertical?: number;
  155635. sideOrientation?: number;
  155636. frontUVs?: Vector4;
  155637. backUVs?: Vector4;
  155638. updatable?: boolean;
  155639. }, scene?: Nullable<Scene>): Mesh;
  155640. /**
  155641. * Creates a plane mesh
  155642. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  155643. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  155644. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  155645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155648. * @param name defines the name of the mesh
  155649. * @param options defines the options used to create the mesh
  155650. * @param scene defines the hosting scene
  155651. * @returns the plane mesh
  155652. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  155653. */
  155654. static CreatePlane(name: string, options: {
  155655. size?: number;
  155656. width?: number;
  155657. height?: number;
  155658. sideOrientation?: number;
  155659. frontUVs?: Vector4;
  155660. backUVs?: Vector4;
  155661. updatable?: boolean;
  155662. sourcePlane?: Plane;
  155663. }, scene?: Nullable<Scene>): Mesh;
  155664. /**
  155665. * Creates a ground mesh
  155666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  155667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  155668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155669. * @param name defines the name of the mesh
  155670. * @param options defines the options used to create the mesh
  155671. * @param scene defines the hosting scene
  155672. * @returns the ground mesh
  155673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  155674. */
  155675. static CreateGround(name: string, options: {
  155676. width?: number;
  155677. height?: number;
  155678. subdivisions?: number;
  155679. subdivisionsX?: number;
  155680. subdivisionsY?: number;
  155681. updatable?: boolean;
  155682. }, scene?: Nullable<Scene>): Mesh;
  155683. /**
  155684. * Creates a tiled ground mesh
  155685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  155686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  155687. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  155688. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  155689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155690. * @param name defines the name of the mesh
  155691. * @param options defines the options used to create the mesh
  155692. * @param scene defines the hosting scene
  155693. * @returns the tiled ground mesh
  155694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  155695. */
  155696. static CreateTiledGround(name: string, options: {
  155697. xmin: number;
  155698. zmin: number;
  155699. xmax: number;
  155700. zmax: number;
  155701. subdivisions?: {
  155702. w: number;
  155703. h: number;
  155704. };
  155705. precision?: {
  155706. w: number;
  155707. h: number;
  155708. };
  155709. updatable?: boolean;
  155710. }, scene?: Nullable<Scene>): Mesh;
  155711. /**
  155712. * Creates a ground mesh from a height map
  155713. * * The parameter `url` sets the URL of the height map image resource.
  155714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  155715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  155716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  155717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  155718. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  155719. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  155720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  155721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155722. * @param name defines the name of the mesh
  155723. * @param url defines the url to the height map
  155724. * @param options defines the options used to create the mesh
  155725. * @param scene defines the hosting scene
  155726. * @returns the ground mesh
  155727. * @see https://doc.babylonjs.com/babylon101/height_map
  155728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  155729. */
  155730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  155731. width?: number;
  155732. height?: number;
  155733. subdivisions?: number;
  155734. minHeight?: number;
  155735. maxHeight?: number;
  155736. colorFilter?: Color3;
  155737. alphaFilter?: number;
  155738. updatable?: boolean;
  155739. onReady?: (mesh: GroundMesh) => void;
  155740. }, scene?: Nullable<Scene>): GroundMesh;
  155741. /**
  155742. * Creates a polygon mesh
  155743. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  155744. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  155745. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  155746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  155748. * * Remember you can only change the shape positions, not their number when updating a polygon
  155749. * @param name defines the name of the mesh
  155750. * @param options defines the options used to create the mesh
  155751. * @param scene defines the hosting scene
  155752. * @param earcutInjection can be used to inject your own earcut reference
  155753. * @returns the polygon mesh
  155754. */
  155755. static CreatePolygon(name: string, options: {
  155756. shape: Vector3[];
  155757. holes?: Vector3[][];
  155758. depth?: number;
  155759. faceUV?: Vector4[];
  155760. faceColors?: Color4[];
  155761. updatable?: boolean;
  155762. sideOrientation?: number;
  155763. frontUVs?: Vector4;
  155764. backUVs?: Vector4;
  155765. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  155766. /**
  155767. * Creates an extruded polygon mesh, with depth in the Y direction.
  155768. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  155769. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  155770. * @param name defines the name of the mesh
  155771. * @param options defines the options used to create the mesh
  155772. * @param scene defines the hosting scene
  155773. * @param earcutInjection can be used to inject your own earcut reference
  155774. * @returns the polygon mesh
  155775. */
  155776. static ExtrudePolygon(name: string, options: {
  155777. shape: Vector3[];
  155778. holes?: Vector3[][];
  155779. depth?: number;
  155780. faceUV?: Vector4[];
  155781. faceColors?: Color4[];
  155782. updatable?: boolean;
  155783. sideOrientation?: number;
  155784. frontUVs?: Vector4;
  155785. backUVs?: Vector4;
  155786. wrap?: boolean;
  155787. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  155788. /**
  155789. * Creates a tube mesh.
  155790. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  155791. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  155792. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  155793. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  155794. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  155795. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  155796. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  155797. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  155798. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  155799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155801. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155803. * @param name defines the name of the mesh
  155804. * @param options defines the options used to create the mesh
  155805. * @param scene defines the hosting scene
  155806. * @returns the tube mesh
  155807. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155808. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  155809. */
  155810. static CreateTube(name: string, options: {
  155811. path: Vector3[];
  155812. radius?: number;
  155813. tessellation?: number;
  155814. radiusFunction?: {
  155815. (i: number, distance: number): number;
  155816. };
  155817. cap?: number;
  155818. arc?: number;
  155819. updatable?: boolean;
  155820. sideOrientation?: number;
  155821. frontUVs?: Vector4;
  155822. backUVs?: Vector4;
  155823. instance?: Mesh;
  155824. invertUV?: boolean;
  155825. }, scene?: Nullable<Scene>): Mesh;
  155826. /**
  155827. * Creates a polyhedron mesh
  155828. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  155829. * * The parameter `size` (positive float, default 1) sets the polygon size
  155830. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  155831. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  155832. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  155833. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  155834. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  155835. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  155836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155839. * @param name defines the name of the mesh
  155840. * @param options defines the options used to create the mesh
  155841. * @param scene defines the hosting scene
  155842. * @returns the polyhedron mesh
  155843. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  155844. */
  155845. static CreatePolyhedron(name: string, options: {
  155846. type?: number;
  155847. size?: number;
  155848. sizeX?: number;
  155849. sizeY?: number;
  155850. sizeZ?: number;
  155851. custom?: any;
  155852. faceUV?: Vector4[];
  155853. faceColors?: Color4[];
  155854. flat?: boolean;
  155855. updatable?: boolean;
  155856. sideOrientation?: number;
  155857. frontUVs?: Vector4;
  155858. backUVs?: Vector4;
  155859. }, scene?: Nullable<Scene>): Mesh;
  155860. /**
  155861. * Creates a decal mesh.
  155862. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  155863. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  155864. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  155865. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  155866. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  155867. * @param name defines the name of the mesh
  155868. * @param sourceMesh defines the mesh where the decal must be applied
  155869. * @param options defines the options used to create the mesh
  155870. * @param scene defines the hosting scene
  155871. * @returns the decal mesh
  155872. * @see https://doc.babylonjs.com/how_to/decals
  155873. */
  155874. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  155875. position?: Vector3;
  155876. normal?: Vector3;
  155877. size?: Vector3;
  155878. angle?: number;
  155879. }): Mesh;
  155880. /**
  155881. * Creates a Capsule Mesh
  155882. * @param name defines the name of the mesh.
  155883. * @param options the constructors options used to shape the mesh.
  155884. * @param scene defines the scene the mesh is scoped to.
  155885. * @returns the capsule mesh
  155886. * @see https://doc.babylonjs.com/how_to/capsule_shape
  155887. */
  155888. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  155889. }
  155890. }
  155891. declare module BABYLON {
  155892. /**
  155893. * A simplifier interface for future simplification implementations
  155894. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155895. */
  155896. export interface ISimplifier {
  155897. /**
  155898. * Simplification of a given mesh according to the given settings.
  155899. * Since this requires computation, it is assumed that the function runs async.
  155900. * @param settings The settings of the simplification, including quality and distance
  155901. * @param successCallback A callback that will be called after the mesh was simplified.
  155902. * @param errorCallback in case of an error, this callback will be called. optional.
  155903. */
  155904. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  155905. }
  155906. /**
  155907. * Expected simplification settings.
  155908. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  155909. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155910. */
  155911. export interface ISimplificationSettings {
  155912. /**
  155913. * Gets or sets the expected quality
  155914. */
  155915. quality: number;
  155916. /**
  155917. * Gets or sets the distance when this optimized version should be used
  155918. */
  155919. distance: number;
  155920. /**
  155921. * Gets an already optimized mesh
  155922. */
  155923. optimizeMesh?: boolean;
  155924. }
  155925. /**
  155926. * Class used to specify simplification options
  155927. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155928. */
  155929. export class SimplificationSettings implements ISimplificationSettings {
  155930. /** expected quality */
  155931. quality: number;
  155932. /** distance when this optimized version should be used */
  155933. distance: number;
  155934. /** already optimized mesh */
  155935. optimizeMesh?: boolean | undefined;
  155936. /**
  155937. * Creates a SimplificationSettings
  155938. * @param quality expected quality
  155939. * @param distance distance when this optimized version should be used
  155940. * @param optimizeMesh already optimized mesh
  155941. */
  155942. constructor(
  155943. /** expected quality */
  155944. quality: number,
  155945. /** distance when this optimized version should be used */
  155946. distance: number,
  155947. /** already optimized mesh */
  155948. optimizeMesh?: boolean | undefined);
  155949. }
  155950. /**
  155951. * Interface used to define a simplification task
  155952. */
  155953. export interface ISimplificationTask {
  155954. /**
  155955. * Array of settings
  155956. */
  155957. settings: Array<ISimplificationSettings>;
  155958. /**
  155959. * Simplification type
  155960. */
  155961. simplificationType: SimplificationType;
  155962. /**
  155963. * Mesh to simplify
  155964. */
  155965. mesh: Mesh;
  155966. /**
  155967. * Callback called on success
  155968. */
  155969. successCallback?: () => void;
  155970. /**
  155971. * Defines if parallel processing can be used
  155972. */
  155973. parallelProcessing: boolean;
  155974. }
  155975. /**
  155976. * Queue used to order the simplification tasks
  155977. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155978. */
  155979. export class SimplificationQueue {
  155980. private _simplificationArray;
  155981. /**
  155982. * Gets a boolean indicating that the process is still running
  155983. */
  155984. running: boolean;
  155985. /**
  155986. * Creates a new queue
  155987. */
  155988. constructor();
  155989. /**
  155990. * Adds a new simplification task
  155991. * @param task defines a task to add
  155992. */
  155993. addTask(task: ISimplificationTask): void;
  155994. /**
  155995. * Execute next task
  155996. */
  155997. executeNext(): void;
  155998. /**
  155999. * Execute a simplification task
  156000. * @param task defines the task to run
  156001. */
  156002. runSimplification(task: ISimplificationTask): void;
  156003. private getSimplifier;
  156004. }
  156005. /**
  156006. * The implemented types of simplification
  156007. * At the moment only Quadratic Error Decimation is implemented
  156008. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156009. */
  156010. export enum SimplificationType {
  156011. /** Quadratic error decimation */
  156012. QUADRATIC = 0
  156013. }
  156014. /**
  156015. * An implementation of the Quadratic Error simplification algorithm.
  156016. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  156017. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  156018. * @author RaananW
  156019. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156020. */
  156021. export class QuadraticErrorSimplification implements ISimplifier {
  156022. private _mesh;
  156023. private triangles;
  156024. private vertices;
  156025. private references;
  156026. private _reconstructedMesh;
  156027. /** Gets or sets the number pf sync interations */
  156028. syncIterations: number;
  156029. /** Gets or sets the aggressiveness of the simplifier */
  156030. aggressiveness: number;
  156031. /** Gets or sets the number of allowed iterations for decimation */
  156032. decimationIterations: number;
  156033. /** Gets or sets the espilon to use for bounding box computation */
  156034. boundingBoxEpsilon: number;
  156035. /**
  156036. * Creates a new QuadraticErrorSimplification
  156037. * @param _mesh defines the target mesh
  156038. */
  156039. constructor(_mesh: Mesh);
  156040. /**
  156041. * Simplification of a given mesh according to the given settings.
  156042. * Since this requires computation, it is assumed that the function runs async.
  156043. * @param settings The settings of the simplification, including quality and distance
  156044. * @param successCallback A callback that will be called after the mesh was simplified.
  156045. */
  156046. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  156047. private runDecimation;
  156048. private initWithMesh;
  156049. private init;
  156050. private reconstructMesh;
  156051. private initDecimatedMesh;
  156052. private isFlipped;
  156053. private updateTriangles;
  156054. private identifyBorder;
  156055. private updateMesh;
  156056. private vertexError;
  156057. private calculateError;
  156058. }
  156059. }
  156060. declare module BABYLON {
  156061. interface Scene {
  156062. /** @hidden (Backing field) */
  156063. _simplificationQueue: SimplificationQueue;
  156064. /**
  156065. * Gets or sets the simplification queue attached to the scene
  156066. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156067. */
  156068. simplificationQueue: SimplificationQueue;
  156069. }
  156070. interface Mesh {
  156071. /**
  156072. * Simplify the mesh according to the given array of settings.
  156073. * Function will return immediately and will simplify async
  156074. * @param settings a collection of simplification settings
  156075. * @param parallelProcessing should all levels calculate parallel or one after the other
  156076. * @param simplificationType the type of simplification to run
  156077. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  156078. * @returns the current mesh
  156079. */
  156080. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  156081. }
  156082. /**
  156083. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  156084. * created in a scene
  156085. */
  156086. export class SimplicationQueueSceneComponent implements ISceneComponent {
  156087. /**
  156088. * The component name helpfull to identify the component in the list of scene components.
  156089. */
  156090. readonly name: string;
  156091. /**
  156092. * The scene the component belongs to.
  156093. */
  156094. scene: Scene;
  156095. /**
  156096. * Creates a new instance of the component for the given scene
  156097. * @param scene Defines the scene to register the component in
  156098. */
  156099. constructor(scene: Scene);
  156100. /**
  156101. * Registers the component in a given scene
  156102. */
  156103. register(): void;
  156104. /**
  156105. * Rebuilds the elements related to this component in case of
  156106. * context lost for instance.
  156107. */
  156108. rebuild(): void;
  156109. /**
  156110. * Disposes the component and the associated ressources
  156111. */
  156112. dispose(): void;
  156113. private _beforeCameraUpdate;
  156114. }
  156115. }
  156116. declare module BABYLON {
  156117. interface Mesh {
  156118. /**
  156119. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  156120. */
  156121. thinInstanceEnablePicking: boolean;
  156122. /**
  156123. * Creates a new thin instance
  156124. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  156125. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  156126. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  156127. */
  156128. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  156129. /**
  156130. * Adds the transformation (matrix) of the current mesh as a thin instance
  156131. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  156132. * @returns the thin instance index number
  156133. */
  156134. thinInstanceAddSelf(refresh: boolean): number;
  156135. /**
  156136. * Registers a custom attribute to be used with thin instances
  156137. * @param kind name of the attribute
  156138. * @param stride size in floats of the attribute
  156139. */
  156140. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  156141. /**
  156142. * Sets the matrix of a thin instance
  156143. * @param index index of the thin instance
  156144. * @param matrix matrix to set
  156145. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  156146. */
  156147. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  156148. /**
  156149. * Sets the value of a custom attribute for a thin instance
  156150. * @param kind name of the attribute
  156151. * @param index index of the thin instance
  156152. * @param value value to set
  156153. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  156154. */
  156155. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  156156. /**
  156157. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  156158. */
  156159. thinInstanceCount: number;
  156160. /**
  156161. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  156162. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  156163. * @param buffer buffer to set
  156164. * @param stride size in floats of each value of the buffer
  156165. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  156166. */
  156167. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  156168. /**
  156169. * Gets the list of world matrices
  156170. * @return an array containing all the world matrices from the thin instances
  156171. */
  156172. thinInstanceGetWorldMatrices(): Matrix[];
  156173. /**
  156174. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  156175. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  156176. */
  156177. thinInstanceBufferUpdated(kind: string): void;
  156178. /**
  156179. * Applies a partial update to a buffer directly on the GPU
  156180. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  156181. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  156182. * @param data the data to set in the GPU buffer
  156183. * @param offset the offset in the GPU buffer where to update the data
  156184. */
  156185. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  156186. /**
  156187. * Refreshes the bounding info, taking into account all the thin instances defined
  156188. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  156189. */
  156190. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  156191. /** @hidden */
  156192. _thinInstanceInitializeUserStorage(): void;
  156193. /** @hidden */
  156194. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  156195. /** @hidden */
  156196. _userThinInstanceBuffersStorage: {
  156197. data: {
  156198. [key: string]: Float32Array;
  156199. };
  156200. sizes: {
  156201. [key: string]: number;
  156202. };
  156203. vertexBuffers: {
  156204. [key: string]: Nullable<VertexBuffer>;
  156205. };
  156206. strides: {
  156207. [key: string]: number;
  156208. };
  156209. };
  156210. }
  156211. }
  156212. declare module BABYLON {
  156213. /**
  156214. * Navigation plugin interface to add navigation constrained by a navigation mesh
  156215. */
  156216. export interface INavigationEnginePlugin {
  156217. /**
  156218. * plugin name
  156219. */
  156220. name: string;
  156221. /**
  156222. * Creates a navigation mesh
  156223. * @param meshes array of all the geometry used to compute the navigatio mesh
  156224. * @param parameters bunch of parameters used to filter geometry
  156225. */
  156226. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  156227. /**
  156228. * Create a navigation mesh debug mesh
  156229. * @param scene is where the mesh will be added
  156230. * @returns debug display mesh
  156231. */
  156232. createDebugNavMesh(scene: Scene): Mesh;
  156233. /**
  156234. * Get a navigation mesh constrained position, closest to the parameter position
  156235. * @param position world position
  156236. * @returns the closest point to position constrained by the navigation mesh
  156237. */
  156238. getClosestPoint(position: Vector3): Vector3;
  156239. /**
  156240. * Get a navigation mesh constrained position, closest to the parameter position
  156241. * @param position world position
  156242. * @param result output the closest point to position constrained by the navigation mesh
  156243. */
  156244. getClosestPointToRef(position: Vector3, result: Vector3): void;
  156245. /**
  156246. * Get a navigation mesh constrained position, within a particular radius
  156247. * @param position world position
  156248. * @param maxRadius the maximum distance to the constrained world position
  156249. * @returns the closest point to position constrained by the navigation mesh
  156250. */
  156251. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  156252. /**
  156253. * Get a navigation mesh constrained position, within a particular radius
  156254. * @param position world position
  156255. * @param maxRadius the maximum distance to the constrained world position
  156256. * @param result output the closest point to position constrained by the navigation mesh
  156257. */
  156258. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  156259. /**
  156260. * Compute the final position from a segment made of destination-position
  156261. * @param position world position
  156262. * @param destination world position
  156263. * @returns the resulting point along the navmesh
  156264. */
  156265. moveAlong(position: Vector3, destination: Vector3): Vector3;
  156266. /**
  156267. * Compute the final position from a segment made of destination-position
  156268. * @param position world position
  156269. * @param destination world position
  156270. * @param result output the resulting point along the navmesh
  156271. */
  156272. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  156273. /**
  156274. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  156275. * @param start world position
  156276. * @param end world position
  156277. * @returns array containing world position composing the path
  156278. */
  156279. computePath(start: Vector3, end: Vector3): Vector3[];
  156280. /**
  156281. * If this plugin is supported
  156282. * @returns true if plugin is supported
  156283. */
  156284. isSupported(): boolean;
  156285. /**
  156286. * Create a new Crowd so you can add agents
  156287. * @param maxAgents the maximum agent count in the crowd
  156288. * @param maxAgentRadius the maximum radius an agent can have
  156289. * @param scene to attach the crowd to
  156290. * @returns the crowd you can add agents to
  156291. */
  156292. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  156293. /**
  156294. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156295. * The queries will try to find a solution within those bounds
  156296. * default is (1,1,1)
  156297. * @param extent x,y,z value that define the extent around the queries point of reference
  156298. */
  156299. setDefaultQueryExtent(extent: Vector3): void;
  156300. /**
  156301. * Get the Bounding box extent specified by setDefaultQueryExtent
  156302. * @returns the box extent values
  156303. */
  156304. getDefaultQueryExtent(): Vector3;
  156305. /**
  156306. * build the navmesh from a previously saved state using getNavmeshData
  156307. * @param data the Uint8Array returned by getNavmeshData
  156308. */
  156309. buildFromNavmeshData(data: Uint8Array): void;
  156310. /**
  156311. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  156312. * @returns data the Uint8Array that can be saved and reused
  156313. */
  156314. getNavmeshData(): Uint8Array;
  156315. /**
  156316. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156317. * @param result output the box extent values
  156318. */
  156319. getDefaultQueryExtentToRef(result: Vector3): void;
  156320. /**
  156321. * Set the time step of the navigation tick update.
  156322. * Default is 1/60.
  156323. * A value of 0 will disable fixed time update
  156324. * @param newTimeStep the new timestep to apply to this world.
  156325. */
  156326. setTimeStep(newTimeStep: number): void;
  156327. /**
  156328. * Get the time step of the navigation tick update.
  156329. * @returns the current time step
  156330. */
  156331. getTimeStep(): number;
  156332. /**
  156333. * If delta time in navigation tick update is greater than the time step
  156334. * a number of sub iterations are done. If more iterations are need to reach deltatime
  156335. * they will be discarded.
  156336. * A value of 0 will set to no maximum and update will use as many substeps as needed
  156337. * @param newStepCount the maximum number of iterations
  156338. */
  156339. setMaximumSubStepCount(newStepCount: number): void;
  156340. /**
  156341. * Get the maximum number of iterations per navigation tick update
  156342. * @returns the maximum number of iterations
  156343. */
  156344. getMaximumSubStepCount(): number;
  156345. /**
  156346. * Release all resources
  156347. */
  156348. dispose(): void;
  156349. }
  156350. /**
  156351. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  156352. */
  156353. export interface ICrowd {
  156354. /**
  156355. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  156356. * You can attach anything to that node. The node position is updated in the scene update tick.
  156357. * @param pos world position that will be constrained by the navigation mesh
  156358. * @param parameters agent parameters
  156359. * @param transform hooked to the agent that will be update by the scene
  156360. * @returns agent index
  156361. */
  156362. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  156363. /**
  156364. * Returns the agent position in world space
  156365. * @param index agent index returned by addAgent
  156366. * @returns world space position
  156367. */
  156368. getAgentPosition(index: number): Vector3;
  156369. /**
  156370. * Gets the agent position result in world space
  156371. * @param index agent index returned by addAgent
  156372. * @param result output world space position
  156373. */
  156374. getAgentPositionToRef(index: number, result: Vector3): void;
  156375. /**
  156376. * Gets the agent velocity in world space
  156377. * @param index agent index returned by addAgent
  156378. * @returns world space velocity
  156379. */
  156380. getAgentVelocity(index: number): Vector3;
  156381. /**
  156382. * Gets the agent velocity result in world space
  156383. * @param index agent index returned by addAgent
  156384. * @param result output world space velocity
  156385. */
  156386. getAgentVelocityToRef(index: number, result: Vector3): void;
  156387. /**
  156388. * Gets the agent next target point on the path
  156389. * @param index agent index returned by addAgent
  156390. * @returns world space position
  156391. */
  156392. getAgentNextTargetPath(index: number): Vector3;
  156393. /**
  156394. * Gets the agent state
  156395. * @param index agent index returned by addAgent
  156396. * @returns agent state
  156397. */
  156398. getAgentState(index: number): number;
  156399. /**
  156400. * returns true if the agent in over an off mesh link connection
  156401. * @param index agent index returned by addAgent
  156402. * @returns true if over an off mesh link connection
  156403. */
  156404. overOffmeshConnection(index: number): boolean;
  156405. /**
  156406. * Gets the agent next target point on the path
  156407. * @param index agent index returned by addAgent
  156408. * @param result output world space position
  156409. */
  156410. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  156411. /**
  156412. * remove a particular agent previously created
  156413. * @param index agent index returned by addAgent
  156414. */
  156415. removeAgent(index: number): void;
  156416. /**
  156417. * get the list of all agents attached to this crowd
  156418. * @returns list of agent indices
  156419. */
  156420. getAgents(): number[];
  156421. /**
  156422. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  156423. * @param deltaTime in seconds
  156424. */
  156425. update(deltaTime: number): void;
  156426. /**
  156427. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  156428. * @param index agent index returned by addAgent
  156429. * @param destination targeted world position
  156430. */
  156431. agentGoto(index: number, destination: Vector3): void;
  156432. /**
  156433. * Teleport the agent to a new position
  156434. * @param index agent index returned by addAgent
  156435. * @param destination targeted world position
  156436. */
  156437. agentTeleport(index: number, destination: Vector3): void;
  156438. /**
  156439. * Update agent parameters
  156440. * @param index agent index returned by addAgent
  156441. * @param parameters agent parameters
  156442. */
  156443. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  156444. /**
  156445. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156446. * The queries will try to find a solution within those bounds
  156447. * default is (1,1,1)
  156448. * @param extent x,y,z value that define the extent around the queries point of reference
  156449. */
  156450. setDefaultQueryExtent(extent: Vector3): void;
  156451. /**
  156452. * Get the Bounding box extent specified by setDefaultQueryExtent
  156453. * @returns the box extent values
  156454. */
  156455. getDefaultQueryExtent(): Vector3;
  156456. /**
  156457. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156458. * @param result output the box extent values
  156459. */
  156460. getDefaultQueryExtentToRef(result: Vector3): void;
  156461. /**
  156462. * Release all resources
  156463. */
  156464. dispose(): void;
  156465. }
  156466. /**
  156467. * Configures an agent
  156468. */
  156469. export interface IAgentParameters {
  156470. /**
  156471. * Agent radius. [Limit: >= 0]
  156472. */
  156473. radius: number;
  156474. /**
  156475. * Agent height. [Limit: > 0]
  156476. */
  156477. height: number;
  156478. /**
  156479. * Maximum allowed acceleration. [Limit: >= 0]
  156480. */
  156481. maxAcceleration: number;
  156482. /**
  156483. * Maximum allowed speed. [Limit: >= 0]
  156484. */
  156485. maxSpeed: number;
  156486. /**
  156487. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  156488. */
  156489. collisionQueryRange: number;
  156490. /**
  156491. * The path visibility optimization range. [Limit: > 0]
  156492. */
  156493. pathOptimizationRange: number;
  156494. /**
  156495. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  156496. */
  156497. separationWeight: number;
  156498. }
  156499. /**
  156500. * Configures the navigation mesh creation
  156501. */
  156502. export interface INavMeshParameters {
  156503. /**
  156504. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  156505. */
  156506. cs: number;
  156507. /**
  156508. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  156509. */
  156510. ch: number;
  156511. /**
  156512. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  156513. */
  156514. walkableSlopeAngle: number;
  156515. /**
  156516. * Minimum floor to 'ceiling' height that will still allow the floor area to
  156517. * be considered walkable. [Limit: >= 3] [Units: vx]
  156518. */
  156519. walkableHeight: number;
  156520. /**
  156521. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  156522. */
  156523. walkableClimb: number;
  156524. /**
  156525. * The distance to erode/shrink the walkable area of the heightfield away from
  156526. * obstructions. [Limit: >=0] [Units: vx]
  156527. */
  156528. walkableRadius: number;
  156529. /**
  156530. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  156531. */
  156532. maxEdgeLen: number;
  156533. /**
  156534. * The maximum distance a simplfied contour's border edges should deviate
  156535. * the original raw contour. [Limit: >=0] [Units: vx]
  156536. */
  156537. maxSimplificationError: number;
  156538. /**
  156539. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  156540. */
  156541. minRegionArea: number;
  156542. /**
  156543. * Any regions with a span count smaller than this value will, if possible,
  156544. * be merged with larger regions. [Limit: >=0] [Units: vx]
  156545. */
  156546. mergeRegionArea: number;
  156547. /**
  156548. * The maximum number of vertices allowed for polygons generated during the
  156549. * contour to polygon conversion process. [Limit: >= 3]
  156550. */
  156551. maxVertsPerPoly: number;
  156552. /**
  156553. * Sets the sampling distance to use when generating the detail mesh.
  156554. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  156555. */
  156556. detailSampleDist: number;
  156557. /**
  156558. * The maximum distance the detail mesh surface should deviate from heightfield
  156559. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  156560. */
  156561. detailSampleMaxError: number;
  156562. }
  156563. }
  156564. declare module BABYLON {
  156565. /**
  156566. * RecastJS navigation plugin
  156567. */
  156568. export class RecastJSPlugin implements INavigationEnginePlugin {
  156569. /**
  156570. * Reference to the Recast library
  156571. */
  156572. bjsRECAST: any;
  156573. /**
  156574. * plugin name
  156575. */
  156576. name: string;
  156577. /**
  156578. * the first navmesh created. We might extend this to support multiple navmeshes
  156579. */
  156580. navMesh: any;
  156581. private _maximumSubStepCount;
  156582. private _timeStep;
  156583. /**
  156584. * Initializes the recastJS plugin
  156585. * @param recastInjection can be used to inject your own recast reference
  156586. */
  156587. constructor(recastInjection?: any);
  156588. /**
  156589. * Set the time step of the navigation tick update.
  156590. * Default is 1/60.
  156591. * A value of 0 will disable fixed time update
  156592. * @param newTimeStep the new timestep to apply to this world.
  156593. */
  156594. setTimeStep(newTimeStep?: number): void;
  156595. /**
  156596. * Get the time step of the navigation tick update.
  156597. * @returns the current time step
  156598. */
  156599. getTimeStep(): number;
  156600. /**
  156601. * If delta time in navigation tick update is greater than the time step
  156602. * a number of sub iterations are done. If more iterations are need to reach deltatime
  156603. * they will be discarded.
  156604. * A value of 0 will set to no maximum and update will use as many substeps as needed
  156605. * @param newStepCount the maximum number of iterations
  156606. */
  156607. setMaximumSubStepCount(newStepCount?: number): void;
  156608. /**
  156609. * Get the maximum number of iterations per navigation tick update
  156610. * @returns the maximum number of iterations
  156611. */
  156612. getMaximumSubStepCount(): number;
  156613. /**
  156614. * Creates a navigation mesh
  156615. * @param meshes array of all the geometry used to compute the navigatio mesh
  156616. * @param parameters bunch of parameters used to filter geometry
  156617. */
  156618. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  156619. /**
  156620. * Create a navigation mesh debug mesh
  156621. * @param scene is where the mesh will be added
  156622. * @returns debug display mesh
  156623. */
  156624. createDebugNavMesh(scene: Scene): Mesh;
  156625. /**
  156626. * Get a navigation mesh constrained position, closest to the parameter position
  156627. * @param position world position
  156628. * @returns the closest point to position constrained by the navigation mesh
  156629. */
  156630. getClosestPoint(position: Vector3): Vector3;
  156631. /**
  156632. * Get a navigation mesh constrained position, closest to the parameter position
  156633. * @param position world position
  156634. * @param result output the closest point to position constrained by the navigation mesh
  156635. */
  156636. getClosestPointToRef(position: Vector3, result: Vector3): void;
  156637. /**
  156638. * Get a navigation mesh constrained position, within a particular radius
  156639. * @param position world position
  156640. * @param maxRadius the maximum distance to the constrained world position
  156641. * @returns the closest point to position constrained by the navigation mesh
  156642. */
  156643. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  156644. /**
  156645. * Get a navigation mesh constrained position, within a particular radius
  156646. * @param position world position
  156647. * @param maxRadius the maximum distance to the constrained world position
  156648. * @param result output the closest point to position constrained by the navigation mesh
  156649. */
  156650. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  156651. /**
  156652. * Compute the final position from a segment made of destination-position
  156653. * @param position world position
  156654. * @param destination world position
  156655. * @returns the resulting point along the navmesh
  156656. */
  156657. moveAlong(position: Vector3, destination: Vector3): Vector3;
  156658. /**
  156659. * Compute the final position from a segment made of destination-position
  156660. * @param position world position
  156661. * @param destination world position
  156662. * @param result output the resulting point along the navmesh
  156663. */
  156664. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  156665. /**
  156666. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  156667. * @param start world position
  156668. * @param end world position
  156669. * @returns array containing world position composing the path
  156670. */
  156671. computePath(start: Vector3, end: Vector3): Vector3[];
  156672. /**
  156673. * Create a new Crowd so you can add agents
  156674. * @param maxAgents the maximum agent count in the crowd
  156675. * @param maxAgentRadius the maximum radius an agent can have
  156676. * @param scene to attach the crowd to
  156677. * @returns the crowd you can add agents to
  156678. */
  156679. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  156680. /**
  156681. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156682. * The queries will try to find a solution within those bounds
  156683. * default is (1,1,1)
  156684. * @param extent x,y,z value that define the extent around the queries point of reference
  156685. */
  156686. setDefaultQueryExtent(extent: Vector3): void;
  156687. /**
  156688. * Get the Bounding box extent specified by setDefaultQueryExtent
  156689. * @returns the box extent values
  156690. */
  156691. getDefaultQueryExtent(): Vector3;
  156692. /**
  156693. * build the navmesh from a previously saved state using getNavmeshData
  156694. * @param data the Uint8Array returned by getNavmeshData
  156695. */
  156696. buildFromNavmeshData(data: Uint8Array): void;
  156697. /**
  156698. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  156699. * @returns data the Uint8Array that can be saved and reused
  156700. */
  156701. getNavmeshData(): Uint8Array;
  156702. /**
  156703. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156704. * @param result output the box extent values
  156705. */
  156706. getDefaultQueryExtentToRef(result: Vector3): void;
  156707. /**
  156708. * Disposes
  156709. */
  156710. dispose(): void;
  156711. /**
  156712. * If this plugin is supported
  156713. * @returns true if plugin is supported
  156714. */
  156715. isSupported(): boolean;
  156716. }
  156717. /**
  156718. * Recast detour crowd implementation
  156719. */
  156720. export class RecastJSCrowd implements ICrowd {
  156721. /**
  156722. * Recast/detour plugin
  156723. */
  156724. bjsRECASTPlugin: RecastJSPlugin;
  156725. /**
  156726. * Link to the detour crowd
  156727. */
  156728. recastCrowd: any;
  156729. /**
  156730. * One transform per agent
  156731. */
  156732. transforms: TransformNode[];
  156733. /**
  156734. * All agents created
  156735. */
  156736. agents: number[];
  156737. /**
  156738. * Link to the scene is kept to unregister the crowd from the scene
  156739. */
  156740. private _scene;
  156741. /**
  156742. * Observer for crowd updates
  156743. */
  156744. private _onBeforeAnimationsObserver;
  156745. /**
  156746. * Constructor
  156747. * @param plugin recastJS plugin
  156748. * @param maxAgents the maximum agent count in the crowd
  156749. * @param maxAgentRadius the maximum radius an agent can have
  156750. * @param scene to attach the crowd to
  156751. * @returns the crowd you can add agents to
  156752. */
  156753. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  156754. /**
  156755. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  156756. * You can attach anything to that node. The node position is updated in the scene update tick.
  156757. * @param pos world position that will be constrained by the navigation mesh
  156758. * @param parameters agent parameters
  156759. * @param transform hooked to the agent that will be update by the scene
  156760. * @returns agent index
  156761. */
  156762. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  156763. /**
  156764. * Returns the agent position in world space
  156765. * @param index agent index returned by addAgent
  156766. * @returns world space position
  156767. */
  156768. getAgentPosition(index: number): Vector3;
  156769. /**
  156770. * Returns the agent position result in world space
  156771. * @param index agent index returned by addAgent
  156772. * @param result output world space position
  156773. */
  156774. getAgentPositionToRef(index: number, result: Vector3): void;
  156775. /**
  156776. * Returns the agent velocity in world space
  156777. * @param index agent index returned by addAgent
  156778. * @returns world space velocity
  156779. */
  156780. getAgentVelocity(index: number): Vector3;
  156781. /**
  156782. * Returns the agent velocity result in world space
  156783. * @param index agent index returned by addAgent
  156784. * @param result output world space velocity
  156785. */
  156786. getAgentVelocityToRef(index: number, result: Vector3): void;
  156787. /**
  156788. * Returns the agent next target point on the path
  156789. * @param index agent index returned by addAgent
  156790. * @returns world space position
  156791. */
  156792. getAgentNextTargetPath(index: number): Vector3;
  156793. /**
  156794. * Returns the agent next target point on the path
  156795. * @param index agent index returned by addAgent
  156796. * @param result output world space position
  156797. */
  156798. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  156799. /**
  156800. * Gets the agent state
  156801. * @param index agent index returned by addAgent
  156802. * @returns agent state
  156803. */
  156804. getAgentState(index: number): number;
  156805. /**
  156806. * returns true if the agent in over an off mesh link connection
  156807. * @param index agent index returned by addAgent
  156808. * @returns true if over an off mesh link connection
  156809. */
  156810. overOffmeshConnection(index: number): boolean;
  156811. /**
  156812. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  156813. * @param index agent index returned by addAgent
  156814. * @param destination targeted world position
  156815. */
  156816. agentGoto(index: number, destination: Vector3): void;
  156817. /**
  156818. * Teleport the agent to a new position
  156819. * @param index agent index returned by addAgent
  156820. * @param destination targeted world position
  156821. */
  156822. agentTeleport(index: number, destination: Vector3): void;
  156823. /**
  156824. * Update agent parameters
  156825. * @param index agent index returned by addAgent
  156826. * @param parameters agent parameters
  156827. */
  156828. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  156829. /**
  156830. * remove a particular agent previously created
  156831. * @param index agent index returned by addAgent
  156832. */
  156833. removeAgent(index: number): void;
  156834. /**
  156835. * get the list of all agents attached to this crowd
  156836. * @returns list of agent indices
  156837. */
  156838. getAgents(): number[];
  156839. /**
  156840. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  156841. * @param deltaTime in seconds
  156842. */
  156843. update(deltaTime: number): void;
  156844. /**
  156845. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  156846. * The queries will try to find a solution within those bounds
  156847. * default is (1,1,1)
  156848. * @param extent x,y,z value that define the extent around the queries point of reference
  156849. */
  156850. setDefaultQueryExtent(extent: Vector3): void;
  156851. /**
  156852. * Get the Bounding box extent specified by setDefaultQueryExtent
  156853. * @returns the box extent values
  156854. */
  156855. getDefaultQueryExtent(): Vector3;
  156856. /**
  156857. * Get the Bounding box extent result specified by setDefaultQueryExtent
  156858. * @param result output the box extent values
  156859. */
  156860. getDefaultQueryExtentToRef(result: Vector3): void;
  156861. /**
  156862. * Release all resources
  156863. */
  156864. dispose(): void;
  156865. }
  156866. }
  156867. declare module BABYLON {
  156868. /**
  156869. * Class used to enable access to IndexedDB
  156870. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  156871. */
  156872. export class Database implements IOfflineProvider {
  156873. private _callbackManifestChecked;
  156874. private _currentSceneUrl;
  156875. private _db;
  156876. private _enableSceneOffline;
  156877. private _enableTexturesOffline;
  156878. private _manifestVersionFound;
  156879. private _mustUpdateRessources;
  156880. private _hasReachedQuota;
  156881. private _isSupported;
  156882. private _idbFactory;
  156883. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  156884. private static IsUASupportingBlobStorage;
  156885. /**
  156886. * Gets a boolean indicating if Database storate is enabled (off by default)
  156887. */
  156888. static IDBStorageEnabled: boolean;
  156889. /**
  156890. * Gets a boolean indicating if scene must be saved in the database
  156891. */
  156892. get enableSceneOffline(): boolean;
  156893. /**
  156894. * Gets a boolean indicating if textures must be saved in the database
  156895. */
  156896. get enableTexturesOffline(): boolean;
  156897. /**
  156898. * Creates a new Database
  156899. * @param urlToScene defines the url to load the scene
  156900. * @param callbackManifestChecked defines the callback to use when manifest is checked
  156901. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  156902. */
  156903. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  156904. private static _ParseURL;
  156905. private static _ReturnFullUrlLocation;
  156906. private _checkManifestFile;
  156907. /**
  156908. * Open the database and make it available
  156909. * @param successCallback defines the callback to call on success
  156910. * @param errorCallback defines the callback to call on error
  156911. */
  156912. open(successCallback: () => void, errorCallback: () => void): void;
  156913. /**
  156914. * Loads an image from the database
  156915. * @param url defines the url to load from
  156916. * @param image defines the target DOM image
  156917. */
  156918. loadImage(url: string, image: HTMLImageElement): void;
  156919. private _loadImageFromDBAsync;
  156920. private _saveImageIntoDBAsync;
  156921. private _checkVersionFromDB;
  156922. private _loadVersionFromDBAsync;
  156923. private _saveVersionIntoDBAsync;
  156924. /**
  156925. * Loads a file from database
  156926. * @param url defines the URL to load from
  156927. * @param sceneLoaded defines a callback to call on success
  156928. * @param progressCallBack defines a callback to call when progress changed
  156929. * @param errorCallback defines a callback to call on error
  156930. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  156931. */
  156932. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  156933. private _loadFileAsync;
  156934. private _saveFileAsync;
  156935. /**
  156936. * Validates if xhr data is correct
  156937. * @param xhr defines the request to validate
  156938. * @param dataType defines the expected data type
  156939. * @returns true if data is correct
  156940. */
  156941. private static _ValidateXHRData;
  156942. }
  156943. }
  156944. declare module BABYLON {
  156945. /** @hidden */
  156946. export var gpuUpdateParticlesPixelShader: {
  156947. name: string;
  156948. shader: string;
  156949. };
  156950. }
  156951. declare module BABYLON {
  156952. /** @hidden */
  156953. export var gpuUpdateParticlesVertexShader: {
  156954. name: string;
  156955. shader: string;
  156956. };
  156957. }
  156958. declare module BABYLON {
  156959. /** @hidden */
  156960. export var clipPlaneFragmentDeclaration2: {
  156961. name: string;
  156962. shader: string;
  156963. };
  156964. }
  156965. declare module BABYLON {
  156966. /** @hidden */
  156967. export var gpuRenderParticlesPixelShader: {
  156968. name: string;
  156969. shader: string;
  156970. };
  156971. }
  156972. declare module BABYLON {
  156973. /** @hidden */
  156974. export var clipPlaneVertexDeclaration2: {
  156975. name: string;
  156976. shader: string;
  156977. };
  156978. }
  156979. declare module BABYLON {
  156980. /** @hidden */
  156981. export var gpuRenderParticlesVertexShader: {
  156982. name: string;
  156983. shader: string;
  156984. };
  156985. }
  156986. declare module BABYLON {
  156987. /**
  156988. * This represents a GPU particle system in Babylon
  156989. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  156990. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  156991. */
  156992. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  156993. /**
  156994. * The layer mask we are rendering the particles through.
  156995. */
  156996. layerMask: number;
  156997. private _capacity;
  156998. private _activeCount;
  156999. private _currentActiveCount;
  157000. private _accumulatedCount;
  157001. private _renderEffect;
  157002. private _updateEffect;
  157003. private _buffer0;
  157004. private _buffer1;
  157005. private _spriteBuffer;
  157006. private _updateVAO;
  157007. private _renderVAO;
  157008. private _targetIndex;
  157009. private _sourceBuffer;
  157010. private _targetBuffer;
  157011. private _currentRenderId;
  157012. private _started;
  157013. private _stopped;
  157014. private _timeDelta;
  157015. private _randomTexture;
  157016. private _randomTexture2;
  157017. private _attributesStrideSize;
  157018. private _updateEffectOptions;
  157019. private _randomTextureSize;
  157020. private _actualFrame;
  157021. private _customEffect;
  157022. private readonly _rawTextureWidth;
  157023. /**
  157024. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  157025. */
  157026. static get IsSupported(): boolean;
  157027. /**
  157028. * An event triggered when the system is disposed.
  157029. */
  157030. onDisposeObservable: Observable<IParticleSystem>;
  157031. /**
  157032. * An event triggered when the system is stopped
  157033. */
  157034. onStoppedObservable: Observable<IParticleSystem>;
  157035. /**
  157036. * Gets the maximum number of particles active at the same time.
  157037. * @returns The max number of active particles.
  157038. */
  157039. getCapacity(): number;
  157040. /**
  157041. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  157042. * to override the particles.
  157043. */
  157044. forceDepthWrite: boolean;
  157045. /**
  157046. * Gets or set the number of active particles
  157047. */
  157048. get activeParticleCount(): number;
  157049. set activeParticleCount(value: number);
  157050. private _preWarmDone;
  157051. /**
  157052. * Specifies if the particles are updated in emitter local space or world space.
  157053. */
  157054. isLocal: boolean;
  157055. /** Gets or sets a matrix to use to compute projection */
  157056. defaultProjectionMatrix: Matrix;
  157057. /**
  157058. * Is this system ready to be used/rendered
  157059. * @return true if the system is ready
  157060. */
  157061. isReady(): boolean;
  157062. /**
  157063. * Gets if the system has been started. (Note: this will still be true after stop is called)
  157064. * @returns True if it has been started, otherwise false.
  157065. */
  157066. isStarted(): boolean;
  157067. /**
  157068. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  157069. * @returns True if it has been stopped, otherwise false.
  157070. */
  157071. isStopped(): boolean;
  157072. /**
  157073. * Gets a boolean indicating that the system is stopping
  157074. * @returns true if the system is currently stopping
  157075. */
  157076. isStopping(): boolean;
  157077. /**
  157078. * Gets the number of particles active at the same time.
  157079. * @returns The number of active particles.
  157080. */
  157081. getActiveCount(): number;
  157082. /**
  157083. * Starts the particle system and begins to emit
  157084. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  157085. */
  157086. start(delay?: number): void;
  157087. /**
  157088. * Stops the particle system.
  157089. */
  157090. stop(): void;
  157091. /**
  157092. * Remove all active particles
  157093. */
  157094. reset(): void;
  157095. /**
  157096. * Returns the string "GPUParticleSystem"
  157097. * @returns a string containing the class name
  157098. */
  157099. getClassName(): string;
  157100. /**
  157101. * Gets the custom effect used to render the particles
  157102. * @param blendMode Blend mode for which the effect should be retrieved
  157103. * @returns The effect
  157104. */
  157105. getCustomEffect(blendMode?: number): Nullable<Effect>;
  157106. /**
  157107. * Sets the custom effect used to render the particles
  157108. * @param effect The effect to set
  157109. * @param blendMode Blend mode for which the effect should be set
  157110. */
  157111. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  157112. /** @hidden */
  157113. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  157114. /**
  157115. * Observable that will be called just before the particles are drawn
  157116. */
  157117. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  157118. /**
  157119. * Gets the name of the particle vertex shader
  157120. */
  157121. get vertexShaderName(): string;
  157122. private _colorGradientsTexture;
  157123. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  157124. /**
  157125. * Adds a new color gradient
  157126. * @param gradient defines the gradient to use (between 0 and 1)
  157127. * @param color1 defines the color to affect to the specified gradient
  157128. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  157129. * @returns the current particle system
  157130. */
  157131. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  157132. private _refreshColorGradient;
  157133. /** Force the system to rebuild all gradients that need to be resync */
  157134. forceRefreshGradients(): void;
  157135. /**
  157136. * Remove a specific color gradient
  157137. * @param gradient defines the gradient to remove
  157138. * @returns the current particle system
  157139. */
  157140. removeColorGradient(gradient: number): GPUParticleSystem;
  157141. private _angularSpeedGradientsTexture;
  157142. private _sizeGradientsTexture;
  157143. private _velocityGradientsTexture;
  157144. private _limitVelocityGradientsTexture;
  157145. private _dragGradientsTexture;
  157146. private _addFactorGradient;
  157147. /**
  157148. * Adds a new size gradient
  157149. * @param gradient defines the gradient to use (between 0 and 1)
  157150. * @param factor defines the size factor to affect to the specified gradient
  157151. * @returns the current particle system
  157152. */
  157153. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  157154. /**
  157155. * Remove a specific size gradient
  157156. * @param gradient defines the gradient to remove
  157157. * @returns the current particle system
  157158. */
  157159. removeSizeGradient(gradient: number): GPUParticleSystem;
  157160. private _refreshFactorGradient;
  157161. /**
  157162. * Adds a new angular speed gradient
  157163. * @param gradient defines the gradient to use (between 0 and 1)
  157164. * @param factor defines the angular speed to affect to the specified gradient
  157165. * @returns the current particle system
  157166. */
  157167. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  157168. /**
  157169. * Remove a specific angular speed gradient
  157170. * @param gradient defines the gradient to remove
  157171. * @returns the current particle system
  157172. */
  157173. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  157174. /**
  157175. * Adds a new velocity gradient
  157176. * @param gradient defines the gradient to use (between 0 and 1)
  157177. * @param factor defines the velocity to affect to the specified gradient
  157178. * @returns the current particle system
  157179. */
  157180. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  157181. /**
  157182. * Remove a specific velocity gradient
  157183. * @param gradient defines the gradient to remove
  157184. * @returns the current particle system
  157185. */
  157186. removeVelocityGradient(gradient: number): GPUParticleSystem;
  157187. /**
  157188. * Adds a new limit velocity gradient
  157189. * @param gradient defines the gradient to use (between 0 and 1)
  157190. * @param factor defines the limit velocity value to affect to the specified gradient
  157191. * @returns the current particle system
  157192. */
  157193. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  157194. /**
  157195. * Remove a specific limit velocity gradient
  157196. * @param gradient defines the gradient to remove
  157197. * @returns the current particle system
  157198. */
  157199. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  157200. /**
  157201. * Adds a new drag gradient
  157202. * @param gradient defines the gradient to use (between 0 and 1)
  157203. * @param factor defines the drag value to affect to the specified gradient
  157204. * @returns the current particle system
  157205. */
  157206. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  157207. /**
  157208. * Remove a specific drag gradient
  157209. * @param gradient defines the gradient to remove
  157210. * @returns the current particle system
  157211. */
  157212. removeDragGradient(gradient: number): GPUParticleSystem;
  157213. /**
  157214. * Not supported by GPUParticleSystem
  157215. * @param gradient defines the gradient to use (between 0 and 1)
  157216. * @param factor defines the emit rate value to affect to the specified gradient
  157217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  157218. * @returns the current particle system
  157219. */
  157220. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  157221. /**
  157222. * Not supported by GPUParticleSystem
  157223. * @param gradient defines the gradient to remove
  157224. * @returns the current particle system
  157225. */
  157226. removeEmitRateGradient(gradient: number): IParticleSystem;
  157227. /**
  157228. * Not supported by GPUParticleSystem
  157229. * @param gradient defines the gradient to use (between 0 and 1)
  157230. * @param factor defines the start size value to affect to the specified gradient
  157231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  157232. * @returns the current particle system
  157233. */
  157234. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  157235. /**
  157236. * Not supported by GPUParticleSystem
  157237. * @param gradient defines the gradient to remove
  157238. * @returns the current particle system
  157239. */
  157240. removeStartSizeGradient(gradient: number): IParticleSystem;
  157241. /**
  157242. * Not supported by GPUParticleSystem
  157243. * @param gradient defines the gradient to use (between 0 and 1)
  157244. * @param min defines the color remap minimal range
  157245. * @param max defines the color remap maximal range
  157246. * @returns the current particle system
  157247. */
  157248. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  157249. /**
  157250. * Not supported by GPUParticleSystem
  157251. * @param gradient defines the gradient to remove
  157252. * @returns the current particle system
  157253. */
  157254. removeColorRemapGradient(): IParticleSystem;
  157255. /**
  157256. * Not supported by GPUParticleSystem
  157257. * @param gradient defines the gradient to use (between 0 and 1)
  157258. * @param min defines the alpha remap minimal range
  157259. * @param max defines the alpha remap maximal range
  157260. * @returns the current particle system
  157261. */
  157262. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  157263. /**
  157264. * Not supported by GPUParticleSystem
  157265. * @param gradient defines the gradient to remove
  157266. * @returns the current particle system
  157267. */
  157268. removeAlphaRemapGradient(): IParticleSystem;
  157269. /**
  157270. * Not supported by GPUParticleSystem
  157271. * @param gradient defines the gradient to use (between 0 and 1)
  157272. * @param color defines the color to affect to the specified gradient
  157273. * @returns the current particle system
  157274. */
  157275. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  157276. /**
  157277. * Not supported by GPUParticleSystem
  157278. * @param gradient defines the gradient to remove
  157279. * @returns the current particle system
  157280. */
  157281. removeRampGradient(): IParticleSystem;
  157282. /**
  157283. * Not supported by GPUParticleSystem
  157284. * @returns the list of ramp gradients
  157285. */
  157286. getRampGradients(): Nullable<Array<Color3Gradient>>;
  157287. /**
  157288. * Not supported by GPUParticleSystem
  157289. * Gets or sets a boolean indicating that ramp gradients must be used
  157290. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  157291. */
  157292. get useRampGradients(): boolean;
  157293. set useRampGradients(value: boolean);
  157294. /**
  157295. * Not supported by GPUParticleSystem
  157296. * @param gradient defines the gradient to use (between 0 and 1)
  157297. * @param factor defines the life time factor to affect to the specified gradient
  157298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  157299. * @returns the current particle system
  157300. */
  157301. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  157302. /**
  157303. * Not supported by GPUParticleSystem
  157304. * @param gradient defines the gradient to remove
  157305. * @returns the current particle system
  157306. */
  157307. removeLifeTimeGradient(gradient: number): IParticleSystem;
  157308. /**
  157309. * Instantiates a GPU particle system.
  157310. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  157311. * @param name The name of the particle system
  157312. * @param options The options used to create the system
  157313. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  157314. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  157315. * @param customEffect a custom effect used to change the way particles are rendered by default
  157316. */
  157317. constructor(name: string, options: Partial<{
  157318. capacity: number;
  157319. randomTextureSize: number;
  157320. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  157321. protected _reset(): void;
  157322. private _createUpdateVAO;
  157323. private _createRenderVAO;
  157324. private _initialize;
  157325. /** @hidden */
  157326. _recreateUpdateEffect(): void;
  157327. private _getEffect;
  157328. /**
  157329. * Fill the defines array according to the current settings of the particle system
  157330. * @param defines Array to be updated
  157331. * @param blendMode blend mode to take into account when updating the array
  157332. */
  157333. fillDefines(defines: Array<string>, blendMode?: number): void;
  157334. /**
  157335. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  157336. * @param uniforms Uniforms array to fill
  157337. * @param attributes Attributes array to fill
  157338. * @param samplers Samplers array to fill
  157339. */
  157340. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  157341. /** @hidden */
  157342. _recreateRenderEffect(): Effect;
  157343. /**
  157344. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  157345. * @param preWarm defines if we are in the pre-warmimg phase
  157346. */
  157347. animate(preWarm?: boolean): void;
  157348. private _createFactorGradientTexture;
  157349. private _createSizeGradientTexture;
  157350. private _createAngularSpeedGradientTexture;
  157351. private _createVelocityGradientTexture;
  157352. private _createLimitVelocityGradientTexture;
  157353. private _createDragGradientTexture;
  157354. private _createColorGradientTexture;
  157355. /**
  157356. * Renders the particle system in its current state
  157357. * @param preWarm defines if the system should only update the particles but not render them
  157358. * @returns the current number of particles
  157359. */
  157360. render(preWarm?: boolean): number;
  157361. /**
  157362. * Rebuilds the particle system
  157363. */
  157364. rebuild(): void;
  157365. private _releaseBuffers;
  157366. private _releaseVAOs;
  157367. /**
  157368. * Disposes the particle system and free the associated resources
  157369. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  157370. */
  157371. dispose(disposeTexture?: boolean): void;
  157372. /**
  157373. * Clones the particle system.
  157374. * @param name The name of the cloned object
  157375. * @param newEmitter The new emitter to use
  157376. * @returns the cloned particle system
  157377. */
  157378. clone(name: string, newEmitter: any): GPUParticleSystem;
  157379. /**
  157380. * Serializes the particle system to a JSON object
  157381. * @param serializeTexture defines if the texture must be serialized as well
  157382. * @returns the JSON object
  157383. */
  157384. serialize(serializeTexture?: boolean): any;
  157385. /**
  157386. * Parses a JSON object to create a GPU particle system.
  157387. * @param parsedParticleSystem The JSON object to parse
  157388. * @param sceneOrEngine The scene or the engine to create the particle system in
  157389. * @param rootUrl The root url to use to load external dependencies like texture
  157390. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  157391. * @returns the parsed GPU particle system
  157392. */
  157393. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  157394. }
  157395. }
  157396. declare module BABYLON {
  157397. /**
  157398. * Represents a set of particle systems working together to create a specific effect
  157399. */
  157400. export class ParticleSystemSet implements IDisposable {
  157401. /**
  157402. * Gets or sets base Assets URL
  157403. */
  157404. static BaseAssetsUrl: string;
  157405. private _emitterCreationOptions;
  157406. private _emitterNode;
  157407. /**
  157408. * Gets the particle system list
  157409. */
  157410. systems: IParticleSystem[];
  157411. /**
  157412. * Gets the emitter node used with this set
  157413. */
  157414. get emitterNode(): Nullable<TransformNode>;
  157415. /**
  157416. * Creates a new emitter mesh as a sphere
  157417. * @param options defines the options used to create the sphere
  157418. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  157419. * @param scene defines the hosting scene
  157420. */
  157421. setEmitterAsSphere(options: {
  157422. diameter: number;
  157423. segments: number;
  157424. color: Color3;
  157425. }, renderingGroupId: number, scene: Scene): void;
  157426. /**
  157427. * Starts all particle systems of the set
  157428. * @param emitter defines an optional mesh to use as emitter for the particle systems
  157429. */
  157430. start(emitter?: AbstractMesh): void;
  157431. /**
  157432. * Release all associated resources
  157433. */
  157434. dispose(): void;
  157435. /**
  157436. * Serialize the set into a JSON compatible object
  157437. * @param serializeTexture defines if the texture must be serialized as well
  157438. * @returns a JSON compatible representation of the set
  157439. */
  157440. serialize(serializeTexture?: boolean): any;
  157441. /**
  157442. * Parse a new ParticleSystemSet from a serialized source
  157443. * @param data defines a JSON compatible representation of the set
  157444. * @param scene defines the hosting scene
  157445. * @param gpu defines if we want GPU particles or CPU particles
  157446. * @returns a new ParticleSystemSet
  157447. */
  157448. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  157449. }
  157450. }
  157451. declare module BABYLON {
  157452. /**
  157453. * This class is made for on one-liner static method to help creating particle system set.
  157454. */
  157455. export class ParticleHelper {
  157456. /**
  157457. * Gets or sets base Assets URL
  157458. */
  157459. static BaseAssetsUrl: string;
  157460. /** Define the Url to load snippets */
  157461. static SnippetUrl: string;
  157462. /**
  157463. * Create a default particle system that you can tweak
  157464. * @param emitter defines the emitter to use
  157465. * @param capacity defines the system capacity (default is 500 particles)
  157466. * @param scene defines the hosting scene
  157467. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  157468. * @returns the new Particle system
  157469. */
  157470. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  157471. /**
  157472. * This is the main static method (one-liner) of this helper to create different particle systems
  157473. * @param type This string represents the type to the particle system to create
  157474. * @param scene The scene where the particle system should live
  157475. * @param gpu If the system will use gpu
  157476. * @returns the ParticleSystemSet created
  157477. */
  157478. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  157479. /**
  157480. * Static function used to export a particle system to a ParticleSystemSet variable.
  157481. * Please note that the emitter shape is not exported
  157482. * @param systems defines the particle systems to export
  157483. * @returns the created particle system set
  157484. */
  157485. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  157486. /**
  157487. * Creates a particle system from a snippet saved in a remote file
  157488. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  157489. * @param url defines the url to load from
  157490. * @param scene defines the hosting scene
  157491. * @param gpu If the system will use gpu
  157492. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  157493. * @returns a promise that will resolve to the new particle system
  157494. */
  157495. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  157496. /**
  157497. * Creates a particle system from a snippet saved by the particle system editor
  157498. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  157499. * @param scene defines the hosting scene
  157500. * @param gpu If the system will use gpu
  157501. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  157502. * @returns a promise that will resolve to the new particle system
  157503. */
  157504. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  157505. }
  157506. }
  157507. declare module BABYLON {
  157508. interface Engine {
  157509. /**
  157510. * Create an effect to use with particle systems.
  157511. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  157512. * the particle system for which you want to create a custom effect in the last parameter
  157513. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  157514. * @param uniformsNames defines a list of attribute names
  157515. * @param samplers defines an array of string used to represent textures
  157516. * @param defines defines the string containing the defines to use to compile the shaders
  157517. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  157518. * @param onCompiled defines a function to call when the effect creation is successful
  157519. * @param onError defines a function to call when the effect creation has failed
  157520. * @param particleSystem the particle system you want to create the effect for
  157521. * @returns the new Effect
  157522. */
  157523. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  157524. }
  157525. interface Mesh {
  157526. /**
  157527. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  157528. * @returns an array of IParticleSystem
  157529. */
  157530. getEmittedParticleSystems(): IParticleSystem[];
  157531. /**
  157532. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  157533. * @returns an array of IParticleSystem
  157534. */
  157535. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  157536. }
  157537. }
  157538. declare module BABYLON {
  157539. /** Defines the 4 color options */
  157540. export enum PointColor {
  157541. /** color value */
  157542. Color = 2,
  157543. /** uv value */
  157544. UV = 1,
  157545. /** random value */
  157546. Random = 0,
  157547. /** stated value */
  157548. Stated = 3
  157549. }
  157550. /**
  157551. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  157552. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  157553. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  157554. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  157555. *
  157556. * Full documentation here : TO BE ENTERED
  157557. */
  157558. export class PointsCloudSystem implements IDisposable {
  157559. /**
  157560. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  157561. * Example : var p = SPS.particles[i];
  157562. */
  157563. particles: CloudPoint[];
  157564. /**
  157565. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  157566. */
  157567. nbParticles: number;
  157568. /**
  157569. * This a counter for your own usage. It's not set by any SPS functions.
  157570. */
  157571. counter: number;
  157572. /**
  157573. * The PCS name. This name is also given to the underlying mesh.
  157574. */
  157575. name: string;
  157576. /**
  157577. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  157578. */
  157579. mesh: Mesh;
  157580. /**
  157581. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  157582. * Please read :
  157583. */
  157584. vars: any;
  157585. /**
  157586. * @hidden
  157587. */
  157588. _size: number;
  157589. private _scene;
  157590. private _promises;
  157591. private _positions;
  157592. private _indices;
  157593. private _normals;
  157594. private _colors;
  157595. private _uvs;
  157596. private _indices32;
  157597. private _positions32;
  157598. private _colors32;
  157599. private _uvs32;
  157600. private _updatable;
  157601. private _isVisibilityBoxLocked;
  157602. private _alwaysVisible;
  157603. private _groups;
  157604. private _groupCounter;
  157605. private _computeParticleColor;
  157606. private _computeParticleTexture;
  157607. private _computeParticleRotation;
  157608. private _computeBoundingBox;
  157609. private _isReady;
  157610. /**
  157611. * Creates a PCS (Points Cloud System) object
  157612. * @param name (String) is the PCS name, this will be the underlying mesh name
  157613. * @param pointSize (number) is the size for each point
  157614. * @param scene (Scene) is the scene in which the PCS is added
  157615. * @param options defines the options of the PCS e.g.
  157616. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  157617. */
  157618. constructor(name: string, pointSize: number, scene: Scene, options?: {
  157619. updatable?: boolean;
  157620. });
  157621. /**
  157622. * Builds the PCS underlying mesh. Returns a standard Mesh.
  157623. * If no points were added to the PCS, the returned mesh is just a single point.
  157624. * @returns a promise for the created mesh
  157625. */
  157626. buildMeshAsync(): Promise<Mesh>;
  157627. /**
  157628. * @hidden
  157629. */
  157630. private _buildMesh;
  157631. private _addParticle;
  157632. private _randomUnitVector;
  157633. private _getColorIndicesForCoord;
  157634. private _setPointsColorOrUV;
  157635. private _colorFromTexture;
  157636. private _calculateDensity;
  157637. /**
  157638. * Adds points to the PCS in random positions within a unit sphere
  157639. * @param nb (positive integer) the number of particles to be created from this model
  157640. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  157641. * @returns the number of groups in the system
  157642. */
  157643. addPoints(nb: number, pointFunction?: any): number;
  157644. /**
  157645. * Adds points to the PCS from the surface of the model shape
  157646. * @param mesh is any Mesh object that will be used as a surface model for the points
  157647. * @param nb (positive integer) the number of particles to be created from this model
  157648. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  157649. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  157650. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  157651. * @returns the number of groups in the system
  157652. */
  157653. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  157654. /**
  157655. * Adds points to the PCS inside the model shape
  157656. * @param mesh is any Mesh object that will be used as a surface model for the points
  157657. * @param nb (positive integer) the number of particles to be created from this model
  157658. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  157659. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  157660. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  157661. * @returns the number of groups in the system
  157662. */
  157663. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  157664. /**
  157665. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  157666. * This method calls `updateParticle()` for each particle of the SPS.
  157667. * For an animated SPS, it is usually called within the render loop.
  157668. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  157669. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  157670. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  157671. * @returns the PCS.
  157672. */
  157673. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  157674. /**
  157675. * Disposes the PCS.
  157676. */
  157677. dispose(): void;
  157678. /**
  157679. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  157680. * doc :
  157681. * @returns the PCS.
  157682. */
  157683. refreshVisibleSize(): PointsCloudSystem;
  157684. /**
  157685. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  157686. * @param size the size (float) of the visibility box
  157687. * note : this doesn't lock the PCS mesh bounding box.
  157688. * doc :
  157689. */
  157690. setVisibilityBox(size: number): void;
  157691. /**
  157692. * Gets whether the PCS is always visible or not
  157693. * doc :
  157694. */
  157695. get isAlwaysVisible(): boolean;
  157696. /**
  157697. * Sets the PCS as always visible or not
  157698. * doc :
  157699. */
  157700. set isAlwaysVisible(val: boolean);
  157701. /**
  157702. * Tells to `setParticles()` to compute the particle rotations or not
  157703. * Default value : false. The PCS is faster when it's set to false
  157704. * Note : particle rotations are only applied to parent particles
  157705. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  157706. */
  157707. set computeParticleRotation(val: boolean);
  157708. /**
  157709. * Tells to `setParticles()` to compute the particle colors or not.
  157710. * Default value : true. The PCS is faster when it's set to false.
  157711. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  157712. */
  157713. set computeParticleColor(val: boolean);
  157714. set computeParticleTexture(val: boolean);
  157715. /**
  157716. * Gets if `setParticles()` computes the particle colors or not.
  157717. * Default value : false. The PCS is faster when it's set to false.
  157718. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  157719. */
  157720. get computeParticleColor(): boolean;
  157721. /**
  157722. * Gets if `setParticles()` computes the particle textures or not.
  157723. * Default value : false. The PCS is faster when it's set to false.
  157724. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  157725. */
  157726. get computeParticleTexture(): boolean;
  157727. /**
  157728. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  157729. */
  157730. set computeBoundingBox(val: boolean);
  157731. /**
  157732. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  157733. */
  157734. get computeBoundingBox(): boolean;
  157735. /**
  157736. * This function does nothing. It may be overwritten to set all the particle first values.
  157737. * The PCS doesn't call this function, you may have to call it by your own.
  157738. * doc :
  157739. */
  157740. initParticles(): void;
  157741. /**
  157742. * This function does nothing. It may be overwritten to recycle a particle
  157743. * The PCS doesn't call this function, you can to call it
  157744. * doc :
  157745. * @param particle The particle to recycle
  157746. * @returns the recycled particle
  157747. */
  157748. recycleParticle(particle: CloudPoint): CloudPoint;
  157749. /**
  157750. * Updates a particle : this function should be overwritten by the user.
  157751. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  157752. * doc :
  157753. * @example : just set a particle position or velocity and recycle conditions
  157754. * @param particle The particle to update
  157755. * @returns the updated particle
  157756. */
  157757. updateParticle(particle: CloudPoint): CloudPoint;
  157758. /**
  157759. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  157760. * This does nothing and may be overwritten by the user.
  157761. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  157762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  157763. * @param update the boolean update value actually passed to setParticles()
  157764. */
  157765. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  157766. /**
  157767. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  157768. * This will be passed three parameters.
  157769. * This does nothing and may be overwritten by the user.
  157770. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  157771. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  157772. * @param update the boolean update value actually passed to setParticles()
  157773. */
  157774. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  157775. }
  157776. }
  157777. declare module BABYLON {
  157778. /**
  157779. * Represents one particle of a points cloud system.
  157780. */
  157781. export class CloudPoint {
  157782. /**
  157783. * particle global index
  157784. */
  157785. idx: number;
  157786. /**
  157787. * The color of the particle
  157788. */
  157789. color: Nullable<Color4>;
  157790. /**
  157791. * The world space position of the particle.
  157792. */
  157793. position: Vector3;
  157794. /**
  157795. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  157796. */
  157797. rotation: Vector3;
  157798. /**
  157799. * The world space rotation quaternion of the particle.
  157800. */
  157801. rotationQuaternion: Nullable<Quaternion>;
  157802. /**
  157803. * The uv of the particle.
  157804. */
  157805. uv: Nullable<Vector2>;
  157806. /**
  157807. * The current speed of the particle.
  157808. */
  157809. velocity: Vector3;
  157810. /**
  157811. * The pivot point in the particle local space.
  157812. */
  157813. pivot: Vector3;
  157814. /**
  157815. * Must the particle be translated from its pivot point in its local space ?
  157816. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  157817. * Default : false
  157818. */
  157819. translateFromPivot: boolean;
  157820. /**
  157821. * Index of this particle in the global "positions" array (Internal use)
  157822. * @hidden
  157823. */
  157824. _pos: number;
  157825. /**
  157826. * @hidden Index of this particle in the global "indices" array (Internal use)
  157827. */
  157828. _ind: number;
  157829. /**
  157830. * Group this particle belongs to
  157831. */
  157832. _group: PointsGroup;
  157833. /**
  157834. * Group id of this particle
  157835. */
  157836. groupId: number;
  157837. /**
  157838. * Index of the particle in its group id (Internal use)
  157839. */
  157840. idxInGroup: number;
  157841. /**
  157842. * @hidden Particle BoundingInfo object (Internal use)
  157843. */
  157844. _boundingInfo: BoundingInfo;
  157845. /**
  157846. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  157847. */
  157848. _pcs: PointsCloudSystem;
  157849. /**
  157850. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  157851. */
  157852. _stillInvisible: boolean;
  157853. /**
  157854. * @hidden Last computed particle rotation matrix
  157855. */
  157856. _rotationMatrix: number[];
  157857. /**
  157858. * Parent particle Id, if any.
  157859. * Default null.
  157860. */
  157861. parentId: Nullable<number>;
  157862. /**
  157863. * @hidden Internal global position in the PCS.
  157864. */
  157865. _globalPosition: Vector3;
  157866. /**
  157867. * Creates a Point Cloud object.
  157868. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  157869. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  157870. * @param group (PointsGroup) is the group the particle belongs to
  157871. * @param groupId (integer) is the group identifier in the PCS.
  157872. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  157873. * @param pcs defines the PCS it is associated to
  157874. */
  157875. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  157876. /**
  157877. * get point size
  157878. */
  157879. get size(): Vector3;
  157880. /**
  157881. * Set point size
  157882. */
  157883. set size(scale: Vector3);
  157884. /**
  157885. * Legacy support, changed quaternion to rotationQuaternion
  157886. */
  157887. get quaternion(): Nullable<Quaternion>;
  157888. /**
  157889. * Legacy support, changed quaternion to rotationQuaternion
  157890. */
  157891. set quaternion(q: Nullable<Quaternion>);
  157892. /**
  157893. * Returns a boolean. True if the particle intersects a mesh, else false
  157894. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  157895. * @param target is the object (point or mesh) what the intersection is computed against
  157896. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  157897. * @returns true if it intersects
  157898. */
  157899. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  157900. /**
  157901. * get the rotation matrix of the particle
  157902. * @hidden
  157903. */
  157904. getRotationMatrix(m: Matrix): void;
  157905. }
  157906. /**
  157907. * Represents a group of points in a points cloud system
  157908. * * PCS internal tool, don't use it manually.
  157909. */
  157910. export class PointsGroup {
  157911. /**
  157912. * The group id
  157913. * @hidden
  157914. */
  157915. groupID: number;
  157916. /**
  157917. * image data for group (internal use)
  157918. * @hidden
  157919. */
  157920. _groupImageData: Nullable<ArrayBufferView>;
  157921. /**
  157922. * Image Width (internal use)
  157923. * @hidden
  157924. */
  157925. _groupImgWidth: number;
  157926. /**
  157927. * Image Height (internal use)
  157928. * @hidden
  157929. */
  157930. _groupImgHeight: number;
  157931. /**
  157932. * Custom position function (internal use)
  157933. * @hidden
  157934. */
  157935. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  157936. /**
  157937. * density per facet for surface points
  157938. * @hidden
  157939. */
  157940. _groupDensity: number[];
  157941. /**
  157942. * Only when points are colored by texture carries pointer to texture list array
  157943. * @hidden
  157944. */
  157945. _textureNb: number;
  157946. /**
  157947. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  157948. * PCS internal tool, don't use it manually.
  157949. * @hidden
  157950. */
  157951. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  157952. }
  157953. }
  157954. declare module BABYLON {
  157955. interface Scene {
  157956. /** @hidden (Backing field) */
  157957. _physicsEngine: Nullable<IPhysicsEngine>;
  157958. /** @hidden */
  157959. _physicsTimeAccumulator: number;
  157960. /**
  157961. * Gets the current physics engine
  157962. * @returns a IPhysicsEngine or null if none attached
  157963. */
  157964. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  157965. /**
  157966. * Enables physics to the current scene
  157967. * @param gravity defines the scene's gravity for the physics engine
  157968. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  157969. * @return a boolean indicating if the physics engine was initialized
  157970. */
  157971. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  157972. /**
  157973. * Disables and disposes the physics engine associated with the scene
  157974. */
  157975. disablePhysicsEngine(): void;
  157976. /**
  157977. * Gets a boolean indicating if there is an active physics engine
  157978. * @returns a boolean indicating if there is an active physics engine
  157979. */
  157980. isPhysicsEnabled(): boolean;
  157981. /**
  157982. * Deletes a physics compound impostor
  157983. * @param compound defines the compound to delete
  157984. */
  157985. deleteCompoundImpostor(compound: any): void;
  157986. /**
  157987. * An event triggered when physic simulation is about to be run
  157988. */
  157989. onBeforePhysicsObservable: Observable<Scene>;
  157990. /**
  157991. * An event triggered when physic simulation has been done
  157992. */
  157993. onAfterPhysicsObservable: Observable<Scene>;
  157994. }
  157995. interface AbstractMesh {
  157996. /** @hidden */
  157997. _physicsImpostor: Nullable<PhysicsImpostor>;
  157998. /**
  157999. * Gets or sets impostor used for physic simulation
  158000. * @see https://doc.babylonjs.com/features/physics_engine
  158001. */
  158002. physicsImpostor: Nullable<PhysicsImpostor>;
  158003. /**
  158004. * Gets the current physics impostor
  158005. * @see https://doc.babylonjs.com/features/physics_engine
  158006. * @returns a physics impostor or null
  158007. */
  158008. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  158009. /** Apply a physic impulse to the mesh
  158010. * @param force defines the force to apply
  158011. * @param contactPoint defines where to apply the force
  158012. * @returns the current mesh
  158013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  158014. */
  158015. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  158016. /**
  158017. * Creates a physic joint between two meshes
  158018. * @param otherMesh defines the other mesh to use
  158019. * @param pivot1 defines the pivot to use on this mesh
  158020. * @param pivot2 defines the pivot to use on the other mesh
  158021. * @param options defines additional options (can be plugin dependent)
  158022. * @returns the current mesh
  158023. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  158024. */
  158025. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  158026. /** @hidden */
  158027. _disposePhysicsObserver: Nullable<Observer<Node>>;
  158028. }
  158029. /**
  158030. * Defines the physics engine scene component responsible to manage a physics engine
  158031. */
  158032. export class PhysicsEngineSceneComponent implements ISceneComponent {
  158033. /**
  158034. * The component name helpful to identify the component in the list of scene components.
  158035. */
  158036. readonly name: string;
  158037. /**
  158038. * The scene the component belongs to.
  158039. */
  158040. scene: Scene;
  158041. /**
  158042. * Creates a new instance of the component for the given scene
  158043. * @param scene Defines the scene to register the component in
  158044. */
  158045. constructor(scene: Scene);
  158046. /**
  158047. * Registers the component in a given scene
  158048. */
  158049. register(): void;
  158050. /**
  158051. * Rebuilds the elements related to this component in case of
  158052. * context lost for instance.
  158053. */
  158054. rebuild(): void;
  158055. /**
  158056. * Disposes the component and the associated ressources
  158057. */
  158058. dispose(): void;
  158059. }
  158060. }
  158061. declare module BABYLON {
  158062. /**
  158063. * A helper for physics simulations
  158064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158065. */
  158066. export class PhysicsHelper {
  158067. private _scene;
  158068. private _physicsEngine;
  158069. /**
  158070. * Initializes the Physics helper
  158071. * @param scene Babylon.js scene
  158072. */
  158073. constructor(scene: Scene);
  158074. /**
  158075. * Applies a radial explosion impulse
  158076. * @param origin the origin of the explosion
  158077. * @param radiusOrEventOptions the radius or the options of radial explosion
  158078. * @param strength the explosion strength
  158079. * @param falloff possible options: Constant & Linear. Defaults to Constant
  158080. * @returns A physics radial explosion event, or null
  158081. */
  158082. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  158083. /**
  158084. * Applies a radial explosion force
  158085. * @param origin the origin of the explosion
  158086. * @param radiusOrEventOptions the radius or the options of radial explosion
  158087. * @param strength the explosion strength
  158088. * @param falloff possible options: Constant & Linear. Defaults to Constant
  158089. * @returns A physics radial explosion event, or null
  158090. */
  158091. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  158092. /**
  158093. * Creates a gravitational field
  158094. * @param origin the origin of the explosion
  158095. * @param radiusOrEventOptions the radius or the options of radial explosion
  158096. * @param strength the explosion strength
  158097. * @param falloff possible options: Constant & Linear. Defaults to Constant
  158098. * @returns A physics gravitational field event, or null
  158099. */
  158100. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  158101. /**
  158102. * Creates a physics updraft event
  158103. * @param origin the origin of the updraft
  158104. * @param radiusOrEventOptions the radius or the options of the updraft
  158105. * @param strength the strength of the updraft
  158106. * @param height the height of the updraft
  158107. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  158108. * @returns A physics updraft event, or null
  158109. */
  158110. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  158111. /**
  158112. * Creates a physics vortex event
  158113. * @param origin the of the vortex
  158114. * @param radiusOrEventOptions the radius or the options of the vortex
  158115. * @param strength the strength of the vortex
  158116. * @param height the height of the vortex
  158117. * @returns a Physics vortex event, or null
  158118. * A physics vortex event or null
  158119. */
  158120. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  158121. }
  158122. /**
  158123. * Represents a physics radial explosion event
  158124. */
  158125. class PhysicsRadialExplosionEvent {
  158126. private _scene;
  158127. private _options;
  158128. private _sphere;
  158129. private _dataFetched;
  158130. /**
  158131. * Initializes a radial explosioin event
  158132. * @param _scene BabylonJS scene
  158133. * @param _options The options for the vortex event
  158134. */
  158135. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  158136. /**
  158137. * Returns the data related to the radial explosion event (sphere).
  158138. * @returns The radial explosion event data
  158139. */
  158140. getData(): PhysicsRadialExplosionEventData;
  158141. /**
  158142. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  158143. * @param impostor A physics imposter
  158144. * @param origin the origin of the explosion
  158145. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  158146. */
  158147. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  158148. /**
  158149. * Triggers affecterd impostors callbacks
  158150. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  158151. */
  158152. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  158153. /**
  158154. * Disposes the sphere.
  158155. * @param force Specifies if the sphere should be disposed by force
  158156. */
  158157. dispose(force?: boolean): void;
  158158. /*** Helpers ***/
  158159. private _prepareSphere;
  158160. private _intersectsWithSphere;
  158161. }
  158162. /**
  158163. * Represents a gravitational field event
  158164. */
  158165. class PhysicsGravitationalFieldEvent {
  158166. private _physicsHelper;
  158167. private _scene;
  158168. private _origin;
  158169. private _options;
  158170. private _tickCallback;
  158171. private _sphere;
  158172. private _dataFetched;
  158173. /**
  158174. * Initializes the physics gravitational field event
  158175. * @param _physicsHelper A physics helper
  158176. * @param _scene BabylonJS scene
  158177. * @param _origin The origin position of the gravitational field event
  158178. * @param _options The options for the vortex event
  158179. */
  158180. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  158181. /**
  158182. * Returns the data related to the gravitational field event (sphere).
  158183. * @returns A gravitational field event
  158184. */
  158185. getData(): PhysicsGravitationalFieldEventData;
  158186. /**
  158187. * Enables the gravitational field.
  158188. */
  158189. enable(): void;
  158190. /**
  158191. * Disables the gravitational field.
  158192. */
  158193. disable(): void;
  158194. /**
  158195. * Disposes the sphere.
  158196. * @param force The force to dispose from the gravitational field event
  158197. */
  158198. dispose(force?: boolean): void;
  158199. private _tick;
  158200. }
  158201. /**
  158202. * Represents a physics updraft event
  158203. */
  158204. class PhysicsUpdraftEvent {
  158205. private _scene;
  158206. private _origin;
  158207. private _options;
  158208. private _physicsEngine;
  158209. private _originTop;
  158210. private _originDirection;
  158211. private _tickCallback;
  158212. private _cylinder;
  158213. private _cylinderPosition;
  158214. private _dataFetched;
  158215. /**
  158216. * Initializes the physics updraft event
  158217. * @param _scene BabylonJS scene
  158218. * @param _origin The origin position of the updraft
  158219. * @param _options The options for the updraft event
  158220. */
  158221. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  158222. /**
  158223. * Returns the data related to the updraft event (cylinder).
  158224. * @returns A physics updraft event
  158225. */
  158226. getData(): PhysicsUpdraftEventData;
  158227. /**
  158228. * Enables the updraft.
  158229. */
  158230. enable(): void;
  158231. /**
  158232. * Disables the updraft.
  158233. */
  158234. disable(): void;
  158235. /**
  158236. * Disposes the cylinder.
  158237. * @param force Specifies if the updraft should be disposed by force
  158238. */
  158239. dispose(force?: boolean): void;
  158240. private getImpostorHitData;
  158241. private _tick;
  158242. /*** Helpers ***/
  158243. private _prepareCylinder;
  158244. private _intersectsWithCylinder;
  158245. }
  158246. /**
  158247. * Represents a physics vortex event
  158248. */
  158249. class PhysicsVortexEvent {
  158250. private _scene;
  158251. private _origin;
  158252. private _options;
  158253. private _physicsEngine;
  158254. private _originTop;
  158255. private _tickCallback;
  158256. private _cylinder;
  158257. private _cylinderPosition;
  158258. private _dataFetched;
  158259. /**
  158260. * Initializes the physics vortex event
  158261. * @param _scene The BabylonJS scene
  158262. * @param _origin The origin position of the vortex
  158263. * @param _options The options for the vortex event
  158264. */
  158265. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  158266. /**
  158267. * Returns the data related to the vortex event (cylinder).
  158268. * @returns The physics vortex event data
  158269. */
  158270. getData(): PhysicsVortexEventData;
  158271. /**
  158272. * Enables the vortex.
  158273. */
  158274. enable(): void;
  158275. /**
  158276. * Disables the cortex.
  158277. */
  158278. disable(): void;
  158279. /**
  158280. * Disposes the sphere.
  158281. * @param force
  158282. */
  158283. dispose(force?: boolean): void;
  158284. private getImpostorHitData;
  158285. private _tick;
  158286. /*** Helpers ***/
  158287. private _prepareCylinder;
  158288. private _intersectsWithCylinder;
  158289. }
  158290. /**
  158291. * Options fot the radial explosion event
  158292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158293. */
  158294. export class PhysicsRadialExplosionEventOptions {
  158295. /**
  158296. * The radius of the sphere for the radial explosion.
  158297. */
  158298. radius: number;
  158299. /**
  158300. * The strenth of the explosion.
  158301. */
  158302. strength: number;
  158303. /**
  158304. * The strenght of the force in correspondence to the distance of the affected object
  158305. */
  158306. falloff: PhysicsRadialImpulseFalloff;
  158307. /**
  158308. * Sphere options for the radial explosion.
  158309. */
  158310. sphere: {
  158311. segments: number;
  158312. diameter: number;
  158313. };
  158314. /**
  158315. * Sphere options for the radial explosion.
  158316. */
  158317. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  158318. }
  158319. /**
  158320. * Options fot the updraft event
  158321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158322. */
  158323. export class PhysicsUpdraftEventOptions {
  158324. /**
  158325. * The radius of the cylinder for the vortex
  158326. */
  158327. radius: number;
  158328. /**
  158329. * The strenth of the updraft.
  158330. */
  158331. strength: number;
  158332. /**
  158333. * The height of the cylinder for the updraft.
  158334. */
  158335. height: number;
  158336. /**
  158337. * The mode for the the updraft.
  158338. */
  158339. updraftMode: PhysicsUpdraftMode;
  158340. }
  158341. /**
  158342. * Options fot the vortex event
  158343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158344. */
  158345. export class PhysicsVortexEventOptions {
  158346. /**
  158347. * The radius of the cylinder for the vortex
  158348. */
  158349. radius: number;
  158350. /**
  158351. * The strenth of the vortex.
  158352. */
  158353. strength: number;
  158354. /**
  158355. * The height of the cylinder for the vortex.
  158356. */
  158357. height: number;
  158358. /**
  158359. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  158360. */
  158361. centripetalForceThreshold: number;
  158362. /**
  158363. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  158364. */
  158365. centripetalForceMultiplier: number;
  158366. /**
  158367. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  158368. */
  158369. centrifugalForceMultiplier: number;
  158370. /**
  158371. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  158372. */
  158373. updraftForceMultiplier: number;
  158374. }
  158375. /**
  158376. * The strenght of the force in correspondence to the distance of the affected object
  158377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158378. */
  158379. export enum PhysicsRadialImpulseFalloff {
  158380. /** Defines that impulse is constant in strength across it's whole radius */
  158381. Constant = 0,
  158382. /** Defines that impulse gets weaker if it's further from the origin */
  158383. Linear = 1
  158384. }
  158385. /**
  158386. * The strength of the force in correspondence to the distance of the affected object
  158387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158388. */
  158389. export enum PhysicsUpdraftMode {
  158390. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  158391. Center = 0,
  158392. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  158393. Perpendicular = 1
  158394. }
  158395. /**
  158396. * Interface for a physics hit data
  158397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158398. */
  158399. export interface PhysicsHitData {
  158400. /**
  158401. * The force applied at the contact point
  158402. */
  158403. force: Vector3;
  158404. /**
  158405. * The contact point
  158406. */
  158407. contactPoint: Vector3;
  158408. /**
  158409. * The distance from the origin to the contact point
  158410. */
  158411. distanceFromOrigin: number;
  158412. }
  158413. /**
  158414. * Interface for radial explosion event data
  158415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158416. */
  158417. export interface PhysicsRadialExplosionEventData {
  158418. /**
  158419. * A sphere used for the radial explosion event
  158420. */
  158421. sphere: Mesh;
  158422. }
  158423. /**
  158424. * Interface for gravitational field event data
  158425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158426. */
  158427. export interface PhysicsGravitationalFieldEventData {
  158428. /**
  158429. * A sphere mesh used for the gravitational field event
  158430. */
  158431. sphere: Mesh;
  158432. }
  158433. /**
  158434. * Interface for updraft event data
  158435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158436. */
  158437. export interface PhysicsUpdraftEventData {
  158438. /**
  158439. * A cylinder used for the updraft event
  158440. */
  158441. cylinder: Mesh;
  158442. }
  158443. /**
  158444. * Interface for vortex event data
  158445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158446. */
  158447. export interface PhysicsVortexEventData {
  158448. /**
  158449. * A cylinder used for the vortex event
  158450. */
  158451. cylinder: Mesh;
  158452. }
  158453. /**
  158454. * Interface for an affected physics impostor
  158455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158456. */
  158457. export interface PhysicsAffectedImpostorWithData {
  158458. /**
  158459. * The impostor affected by the effect
  158460. */
  158461. impostor: PhysicsImpostor;
  158462. /**
  158463. * The data about the hit/horce from the explosion
  158464. */
  158465. hitData: PhysicsHitData;
  158466. }
  158467. }
  158468. declare module BABYLON {
  158469. /** @hidden */
  158470. export var blackAndWhitePixelShader: {
  158471. name: string;
  158472. shader: string;
  158473. };
  158474. }
  158475. declare module BABYLON {
  158476. /**
  158477. * Post process used to render in black and white
  158478. */
  158479. export class BlackAndWhitePostProcess extends PostProcess {
  158480. /**
  158481. * Linear about to convert he result to black and white (default: 1)
  158482. */
  158483. degree: number;
  158484. /**
  158485. * Gets a string identifying the name of the class
  158486. * @returns "BlackAndWhitePostProcess" string
  158487. */
  158488. getClassName(): string;
  158489. /**
  158490. * Creates a black and white post process
  158491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  158492. * @param name The name of the effect.
  158493. * @param options The required width/height ratio to downsize to before computing the render pass.
  158494. * @param camera The camera to apply the render pass to.
  158495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158496. * @param engine The engine which the post process will be applied. (default: current engine)
  158497. * @param reusable If the post process can be reused on the same frame. (default: false)
  158498. */
  158499. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158500. /** @hidden */
  158501. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  158502. }
  158503. }
  158504. declare module BABYLON {
  158505. /**
  158506. * This represents a set of one or more post processes in Babylon.
  158507. * A post process can be used to apply a shader to a texture after it is rendered.
  158508. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158509. */
  158510. export class PostProcessRenderEffect {
  158511. private _postProcesses;
  158512. private _getPostProcesses;
  158513. private _singleInstance;
  158514. private _cameras;
  158515. private _indicesForCamera;
  158516. /**
  158517. * Name of the effect
  158518. * @hidden
  158519. */
  158520. _name: string;
  158521. /**
  158522. * Instantiates a post process render effect.
  158523. * A post process can be used to apply a shader to a texture after it is rendered.
  158524. * @param engine The engine the effect is tied to
  158525. * @param name The name of the effect
  158526. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  158527. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  158528. */
  158529. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  158530. /**
  158531. * Checks if all the post processes in the effect are supported.
  158532. */
  158533. get isSupported(): boolean;
  158534. /**
  158535. * Updates the current state of the effect
  158536. * @hidden
  158537. */
  158538. _update(): void;
  158539. /**
  158540. * Attaches the effect on cameras
  158541. * @param cameras The camera to attach to.
  158542. * @hidden
  158543. */
  158544. _attachCameras(cameras: Camera): void;
  158545. /**
  158546. * Attaches the effect on cameras
  158547. * @param cameras The camera to attach to.
  158548. * @hidden
  158549. */
  158550. _attachCameras(cameras: Camera[]): void;
  158551. /**
  158552. * Detaches the effect on cameras
  158553. * @param cameras The camera to detatch from.
  158554. * @hidden
  158555. */
  158556. _detachCameras(cameras: Camera): void;
  158557. /**
  158558. * Detatches the effect on cameras
  158559. * @param cameras The camera to detatch from.
  158560. * @hidden
  158561. */
  158562. _detachCameras(cameras: Camera[]): void;
  158563. /**
  158564. * Enables the effect on given cameras
  158565. * @param cameras The camera to enable.
  158566. * @hidden
  158567. */
  158568. _enable(cameras: Camera): void;
  158569. /**
  158570. * Enables the effect on given cameras
  158571. * @param cameras The camera to enable.
  158572. * @hidden
  158573. */
  158574. _enable(cameras: Nullable<Camera[]>): void;
  158575. /**
  158576. * Disables the effect on the given cameras
  158577. * @param cameras The camera to disable.
  158578. * @hidden
  158579. */
  158580. _disable(cameras: Camera): void;
  158581. /**
  158582. * Disables the effect on the given cameras
  158583. * @param cameras The camera to disable.
  158584. * @hidden
  158585. */
  158586. _disable(cameras: Nullable<Camera[]>): void;
  158587. /**
  158588. * Gets a list of the post processes contained in the effect.
  158589. * @param camera The camera to get the post processes on.
  158590. * @returns The list of the post processes in the effect.
  158591. */
  158592. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  158593. }
  158594. }
  158595. declare module BABYLON {
  158596. /** @hidden */
  158597. export var extractHighlightsPixelShader: {
  158598. name: string;
  158599. shader: string;
  158600. };
  158601. }
  158602. declare module BABYLON {
  158603. /**
  158604. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  158605. */
  158606. export class ExtractHighlightsPostProcess extends PostProcess {
  158607. /**
  158608. * The luminance threshold, pixels below this value will be set to black.
  158609. */
  158610. threshold: number;
  158611. /** @hidden */
  158612. _exposure: number;
  158613. /**
  158614. * Post process which has the input texture to be used when performing highlight extraction
  158615. * @hidden
  158616. */
  158617. _inputPostProcess: Nullable<PostProcess>;
  158618. /**
  158619. * Gets a string identifying the name of the class
  158620. * @returns "ExtractHighlightsPostProcess" string
  158621. */
  158622. getClassName(): string;
  158623. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158624. }
  158625. }
  158626. declare module BABYLON {
  158627. /** @hidden */
  158628. export var bloomMergePixelShader: {
  158629. name: string;
  158630. shader: string;
  158631. };
  158632. }
  158633. declare module BABYLON {
  158634. /**
  158635. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  158636. */
  158637. export class BloomMergePostProcess extends PostProcess {
  158638. /** Weight of the bloom to be added to the original input. */
  158639. weight: number;
  158640. /**
  158641. * Gets a string identifying the name of the class
  158642. * @returns "BloomMergePostProcess" string
  158643. */
  158644. getClassName(): string;
  158645. /**
  158646. * Creates a new instance of @see BloomMergePostProcess
  158647. * @param name The name of the effect.
  158648. * @param originalFromInput Post process which's input will be used for the merge.
  158649. * @param blurred Blurred highlights post process which's output will be used.
  158650. * @param weight Weight of the bloom to be added to the original input.
  158651. * @param options The required width/height ratio to downsize to before computing the render pass.
  158652. * @param camera The camera to apply the render pass to.
  158653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158654. * @param engine The engine which the post process will be applied. (default: current engine)
  158655. * @param reusable If the post process can be reused on the same frame. (default: false)
  158656. * @param textureType Type of textures used when performing the post process. (default: 0)
  158657. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  158658. */
  158659. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  158660. /** Weight of the bloom to be added to the original input. */
  158661. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158662. }
  158663. }
  158664. declare module BABYLON {
  158665. /**
  158666. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  158667. */
  158668. export class BloomEffect extends PostProcessRenderEffect {
  158669. private bloomScale;
  158670. /**
  158671. * @hidden Internal
  158672. */
  158673. _effects: Array<PostProcess>;
  158674. /**
  158675. * @hidden Internal
  158676. */
  158677. _downscale: ExtractHighlightsPostProcess;
  158678. private _blurX;
  158679. private _blurY;
  158680. private _merge;
  158681. /**
  158682. * The luminance threshold to find bright areas of the image to bloom.
  158683. */
  158684. get threshold(): number;
  158685. set threshold(value: number);
  158686. /**
  158687. * The strength of the bloom.
  158688. */
  158689. get weight(): number;
  158690. set weight(value: number);
  158691. /**
  158692. * Specifies the size of the bloom blur kernel, relative to the final output size
  158693. */
  158694. get kernel(): number;
  158695. set kernel(value: number);
  158696. /**
  158697. * Creates a new instance of @see BloomEffect
  158698. * @param scene The scene the effect belongs to.
  158699. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  158700. * @param bloomKernel The size of the kernel to be used when applying the blur.
  158701. * @param bloomWeight The the strength of bloom.
  158702. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  158703. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  158704. */
  158705. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  158706. /**
  158707. * Disposes each of the internal effects for a given camera.
  158708. * @param camera The camera to dispose the effect on.
  158709. */
  158710. disposeEffects(camera: Camera): void;
  158711. /**
  158712. * @hidden Internal
  158713. */
  158714. _updateEffects(): void;
  158715. /**
  158716. * Internal
  158717. * @returns if all the contained post processes are ready.
  158718. * @hidden
  158719. */
  158720. _isReady(): boolean;
  158721. }
  158722. }
  158723. declare module BABYLON {
  158724. /** @hidden */
  158725. export var chromaticAberrationPixelShader: {
  158726. name: string;
  158727. shader: string;
  158728. };
  158729. }
  158730. declare module BABYLON {
  158731. /**
  158732. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  158733. */
  158734. export class ChromaticAberrationPostProcess extends PostProcess {
  158735. /**
  158736. * The amount of seperation of rgb channels (default: 30)
  158737. */
  158738. aberrationAmount: number;
  158739. /**
  158740. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  158741. */
  158742. radialIntensity: number;
  158743. /**
  158744. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  158745. */
  158746. direction: Vector2;
  158747. /**
  158748. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  158749. */
  158750. centerPosition: Vector2;
  158751. /** The width of the screen to apply the effect on */
  158752. screenWidth: number;
  158753. /** The height of the screen to apply the effect on */
  158754. screenHeight: number;
  158755. /**
  158756. * Gets a string identifying the name of the class
  158757. * @returns "ChromaticAberrationPostProcess" string
  158758. */
  158759. getClassName(): string;
  158760. /**
  158761. * Creates a new instance ChromaticAberrationPostProcess
  158762. * @param name The name of the effect.
  158763. * @param screenWidth The width of the screen to apply the effect on.
  158764. * @param screenHeight The height of the screen to apply the effect on.
  158765. * @param options The required width/height ratio to downsize to before computing the render pass.
  158766. * @param camera The camera to apply the render pass to.
  158767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158768. * @param engine The engine which the post process will be applied. (default: current engine)
  158769. * @param reusable If the post process can be reused on the same frame. (default: false)
  158770. * @param textureType Type of textures used when performing the post process. (default: 0)
  158771. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  158772. */
  158773. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158774. /** @hidden */
  158775. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  158776. }
  158777. }
  158778. declare module BABYLON {
  158779. /** @hidden */
  158780. export var circleOfConfusionPixelShader: {
  158781. name: string;
  158782. shader: string;
  158783. };
  158784. }
  158785. declare module BABYLON {
  158786. /**
  158787. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  158788. */
  158789. export class CircleOfConfusionPostProcess extends PostProcess {
  158790. /**
  158791. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  158792. */
  158793. lensSize: number;
  158794. /**
  158795. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  158796. */
  158797. fStop: number;
  158798. /**
  158799. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  158800. */
  158801. focusDistance: number;
  158802. /**
  158803. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  158804. */
  158805. focalLength: number;
  158806. /**
  158807. * Gets a string identifying the name of the class
  158808. * @returns "CircleOfConfusionPostProcess" string
  158809. */
  158810. getClassName(): string;
  158811. private _depthTexture;
  158812. /**
  158813. * Creates a new instance CircleOfConfusionPostProcess
  158814. * @param name The name of the effect.
  158815. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  158816. * @param options The required width/height ratio to downsize to before computing the render pass.
  158817. * @param camera The camera to apply the render pass to.
  158818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158819. * @param engine The engine which the post process will be applied. (default: current engine)
  158820. * @param reusable If the post process can be reused on the same frame. (default: false)
  158821. * @param textureType Type of textures used when performing the post process. (default: 0)
  158822. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  158823. */
  158824. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158825. /**
  158826. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  158827. */
  158828. set depthTexture(value: RenderTargetTexture);
  158829. }
  158830. }
  158831. declare module BABYLON {
  158832. /** @hidden */
  158833. export var colorCorrectionPixelShader: {
  158834. name: string;
  158835. shader: string;
  158836. };
  158837. }
  158838. declare module BABYLON {
  158839. /**
  158840. *
  158841. * This post-process allows the modification of rendered colors by using
  158842. * a 'look-up table' (LUT). This effect is also called Color Grading.
  158843. *
  158844. * The object needs to be provided an url to a texture containing the color
  158845. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  158846. * Use an image editing software to tweak the LUT to match your needs.
  158847. *
  158848. * For an example of a color LUT, see here:
  158849. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  158850. * For explanations on color grading, see here:
  158851. * @see http://udn.epicgames.com/Three/ColorGrading.html
  158852. *
  158853. */
  158854. export class ColorCorrectionPostProcess extends PostProcess {
  158855. private _colorTableTexture;
  158856. /**
  158857. * Gets the color table url used to create the LUT texture
  158858. */
  158859. colorTableUrl: string;
  158860. /**
  158861. * Gets a string identifying the name of the class
  158862. * @returns "ColorCorrectionPostProcess" string
  158863. */
  158864. getClassName(): string;
  158865. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158866. /** @hidden */
  158867. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  158868. }
  158869. }
  158870. declare module BABYLON {
  158871. /** @hidden */
  158872. export var convolutionPixelShader: {
  158873. name: string;
  158874. shader: string;
  158875. };
  158876. }
  158877. declare module BABYLON {
  158878. /**
  158879. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  158880. * input texture to perform effects such as edge detection or sharpening
  158881. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  158882. */
  158883. export class ConvolutionPostProcess extends PostProcess {
  158884. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  158885. kernel: number[];
  158886. /**
  158887. * Gets a string identifying the name of the class
  158888. * @returns "ConvolutionPostProcess" string
  158889. */
  158890. getClassName(): string;
  158891. /**
  158892. * Creates a new instance ConvolutionPostProcess
  158893. * @param name The name of the effect.
  158894. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  158895. * @param options The required width/height ratio to downsize to before computing the render pass.
  158896. * @param camera The camera to apply the render pass to.
  158897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158898. * @param engine The engine which the post process will be applied. (default: current engine)
  158899. * @param reusable If the post process can be reused on the same frame. (default: false)
  158900. * @param textureType Type of textures used when performing the post process. (default: 0)
  158901. */
  158902. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158903. /** @hidden */
  158904. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  158905. /**
  158906. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158907. */
  158908. static EdgeDetect0Kernel: number[];
  158909. /**
  158910. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158911. */
  158912. static EdgeDetect1Kernel: number[];
  158913. /**
  158914. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158915. */
  158916. static EdgeDetect2Kernel: number[];
  158917. /**
  158918. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158919. */
  158920. static SharpenKernel: number[];
  158921. /**
  158922. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158923. */
  158924. static EmbossKernel: number[];
  158925. /**
  158926. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158927. */
  158928. static GaussianKernel: number[];
  158929. }
  158930. }
  158931. declare module BABYLON {
  158932. /**
  158933. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  158934. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  158935. * based on samples that have a large difference in distance than the center pixel.
  158936. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  158937. */
  158938. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  158939. /**
  158940. * The direction the blur should be applied
  158941. */
  158942. direction: Vector2;
  158943. /**
  158944. * Gets a string identifying the name of the class
  158945. * @returns "DepthOfFieldBlurPostProcess" string
  158946. */
  158947. getClassName(): string;
  158948. /**
  158949. * Creates a new instance CircleOfConfusionPostProcess
  158950. * @param name The name of the effect.
  158951. * @param scene The scene the effect belongs to.
  158952. * @param direction The direction the blur should be applied.
  158953. * @param kernel The size of the kernel used to blur.
  158954. * @param options The required width/height ratio to downsize to before computing the render pass.
  158955. * @param camera The camera to apply the render pass to.
  158956. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  158957. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  158958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158959. * @param engine The engine which the post process will be applied. (default: current engine)
  158960. * @param reusable If the post process can be reused on the same frame. (default: false)
  158961. * @param textureType Type of textures used when performing the post process. (default: 0)
  158962. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  158963. */
  158964. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158965. }
  158966. }
  158967. declare module BABYLON {
  158968. /** @hidden */
  158969. export var depthOfFieldMergePixelShader: {
  158970. name: string;
  158971. shader: string;
  158972. };
  158973. }
  158974. declare module BABYLON {
  158975. /**
  158976. * Options to be set when merging outputs from the default pipeline.
  158977. */
  158978. export class DepthOfFieldMergePostProcessOptions {
  158979. /**
  158980. * The original image to merge on top of
  158981. */
  158982. originalFromInput: PostProcess;
  158983. /**
  158984. * Parameters to perform the merge of the depth of field effect
  158985. */
  158986. depthOfField?: {
  158987. circleOfConfusion: PostProcess;
  158988. blurSteps: Array<PostProcess>;
  158989. };
  158990. /**
  158991. * Parameters to perform the merge of bloom effect
  158992. */
  158993. bloom?: {
  158994. blurred: PostProcess;
  158995. weight: number;
  158996. };
  158997. }
  158998. /**
  158999. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  159000. */
  159001. export class DepthOfFieldMergePostProcess extends PostProcess {
  159002. private blurSteps;
  159003. /**
  159004. * Gets a string identifying the name of the class
  159005. * @returns "DepthOfFieldMergePostProcess" string
  159006. */
  159007. getClassName(): string;
  159008. /**
  159009. * Creates a new instance of DepthOfFieldMergePostProcess
  159010. * @param name The name of the effect.
  159011. * @param originalFromInput Post process which's input will be used for the merge.
  159012. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  159013. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  159014. * @param options The required width/height ratio to downsize to before computing the render pass.
  159015. * @param camera The camera to apply the render pass to.
  159016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159017. * @param engine The engine which the post process will be applied. (default: current engine)
  159018. * @param reusable If the post process can be reused on the same frame. (default: false)
  159019. * @param textureType Type of textures used when performing the post process. (default: 0)
  159020. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  159021. */
  159022. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159023. /**
  159024. * Updates the effect with the current post process compile time values and recompiles the shader.
  159025. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  159026. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  159027. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  159028. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  159029. * @param onCompiled Called when the shader has been compiled.
  159030. * @param onError Called if there is an error when compiling a shader.
  159031. */
  159032. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  159033. }
  159034. }
  159035. declare module BABYLON {
  159036. /**
  159037. * Specifies the level of max blur that should be applied when using the depth of field effect
  159038. */
  159039. export enum DepthOfFieldEffectBlurLevel {
  159040. /**
  159041. * Subtle blur
  159042. */
  159043. Low = 0,
  159044. /**
  159045. * Medium blur
  159046. */
  159047. Medium = 1,
  159048. /**
  159049. * Large blur
  159050. */
  159051. High = 2
  159052. }
  159053. /**
  159054. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  159055. */
  159056. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  159057. private _circleOfConfusion;
  159058. /**
  159059. * @hidden Internal, blurs from high to low
  159060. */
  159061. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  159062. private _depthOfFieldBlurY;
  159063. private _dofMerge;
  159064. /**
  159065. * @hidden Internal post processes in depth of field effect
  159066. */
  159067. _effects: Array<PostProcess>;
  159068. /**
  159069. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  159070. */
  159071. set focalLength(value: number);
  159072. get focalLength(): number;
  159073. /**
  159074. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  159075. */
  159076. set fStop(value: number);
  159077. get fStop(): number;
  159078. /**
  159079. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  159080. */
  159081. set focusDistance(value: number);
  159082. get focusDistance(): number;
  159083. /**
  159084. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  159085. */
  159086. set lensSize(value: number);
  159087. get lensSize(): number;
  159088. /**
  159089. * Creates a new instance DepthOfFieldEffect
  159090. * @param scene The scene the effect belongs to.
  159091. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  159092. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  159093. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  159094. */
  159095. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  159096. /**
  159097. * Get the current class name of the current effet
  159098. * @returns "DepthOfFieldEffect"
  159099. */
  159100. getClassName(): string;
  159101. /**
  159102. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  159103. */
  159104. set depthTexture(value: RenderTargetTexture);
  159105. /**
  159106. * Disposes each of the internal effects for a given camera.
  159107. * @param camera The camera to dispose the effect on.
  159108. */
  159109. disposeEffects(camera: Camera): void;
  159110. /**
  159111. * @hidden Internal
  159112. */
  159113. _updateEffects(): void;
  159114. /**
  159115. * Internal
  159116. * @returns if all the contained post processes are ready.
  159117. * @hidden
  159118. */
  159119. _isReady(): boolean;
  159120. }
  159121. }
  159122. declare module BABYLON {
  159123. /** @hidden */
  159124. export var displayPassPixelShader: {
  159125. name: string;
  159126. shader: string;
  159127. };
  159128. }
  159129. declare module BABYLON {
  159130. /**
  159131. * DisplayPassPostProcess which produces an output the same as it's input
  159132. */
  159133. export class DisplayPassPostProcess extends PostProcess {
  159134. /**
  159135. * Gets a string identifying the name of the class
  159136. * @returns "DisplayPassPostProcess" string
  159137. */
  159138. getClassName(): string;
  159139. /**
  159140. * Creates the DisplayPassPostProcess
  159141. * @param name The name of the effect.
  159142. * @param options The required width/height ratio to downsize to before computing the render pass.
  159143. * @param camera The camera to apply the render pass to.
  159144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159145. * @param engine The engine which the post process will be applied. (default: current engine)
  159146. * @param reusable If the post process can be reused on the same frame. (default: false)
  159147. */
  159148. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  159149. /** @hidden */
  159150. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  159151. }
  159152. }
  159153. declare module BABYLON {
  159154. /** @hidden */
  159155. export var filterPixelShader: {
  159156. name: string;
  159157. shader: string;
  159158. };
  159159. }
  159160. declare module BABYLON {
  159161. /**
  159162. * Applies a kernel filter to the image
  159163. */
  159164. export class FilterPostProcess extends PostProcess {
  159165. /** The matrix to be applied to the image */
  159166. kernelMatrix: Matrix;
  159167. /**
  159168. * Gets a string identifying the name of the class
  159169. * @returns "FilterPostProcess" string
  159170. */
  159171. getClassName(): string;
  159172. /**
  159173. *
  159174. * @param name The name of the effect.
  159175. * @param kernelMatrix The matrix to be applied to the image
  159176. * @param options The required width/height ratio to downsize to before computing the render pass.
  159177. * @param camera The camera to apply the render pass to.
  159178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159179. * @param engine The engine which the post process will be applied. (default: current engine)
  159180. * @param reusable If the post process can be reused on the same frame. (default: false)
  159181. */
  159182. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  159183. /** @hidden */
  159184. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  159185. }
  159186. }
  159187. declare module BABYLON {
  159188. /** @hidden */
  159189. export var fxaaPixelShader: {
  159190. name: string;
  159191. shader: string;
  159192. };
  159193. }
  159194. declare module BABYLON {
  159195. /** @hidden */
  159196. export var fxaaVertexShader: {
  159197. name: string;
  159198. shader: string;
  159199. };
  159200. }
  159201. declare module BABYLON {
  159202. /**
  159203. * Fxaa post process
  159204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  159205. */
  159206. export class FxaaPostProcess extends PostProcess {
  159207. /**
  159208. * Gets a string identifying the name of the class
  159209. * @returns "FxaaPostProcess" string
  159210. */
  159211. getClassName(): string;
  159212. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  159213. private _getDefines;
  159214. /** @hidden */
  159215. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  159216. }
  159217. }
  159218. declare module BABYLON {
  159219. /** @hidden */
  159220. export var grainPixelShader: {
  159221. name: string;
  159222. shader: string;
  159223. };
  159224. }
  159225. declare module BABYLON {
  159226. /**
  159227. * The GrainPostProcess adds noise to the image at mid luminance levels
  159228. */
  159229. export class GrainPostProcess extends PostProcess {
  159230. /**
  159231. * The intensity of the grain added (default: 30)
  159232. */
  159233. intensity: number;
  159234. /**
  159235. * If the grain should be randomized on every frame
  159236. */
  159237. animated: boolean;
  159238. /**
  159239. * Gets a string identifying the name of the class
  159240. * @returns "GrainPostProcess" string
  159241. */
  159242. getClassName(): string;
  159243. /**
  159244. * Creates a new instance of @see GrainPostProcess
  159245. * @param name The name of the effect.
  159246. * @param options The required width/height ratio to downsize to before computing the render pass.
  159247. * @param camera The camera to apply the render pass to.
  159248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159249. * @param engine The engine which the post process will be applied. (default: current engine)
  159250. * @param reusable If the post process can be reused on the same frame. (default: false)
  159251. * @param textureType Type of textures used when performing the post process. (default: 0)
  159252. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  159253. */
  159254. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159255. /** @hidden */
  159256. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  159257. }
  159258. }
  159259. declare module BABYLON {
  159260. /** @hidden */
  159261. export var highlightsPixelShader: {
  159262. name: string;
  159263. shader: string;
  159264. };
  159265. }
  159266. declare module BABYLON {
  159267. /**
  159268. * Extracts highlights from the image
  159269. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  159270. */
  159271. export class HighlightsPostProcess extends PostProcess {
  159272. /**
  159273. * Gets a string identifying the name of the class
  159274. * @returns "HighlightsPostProcess" string
  159275. */
  159276. getClassName(): string;
  159277. /**
  159278. * Extracts highlights from the image
  159279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  159280. * @param name The name of the effect.
  159281. * @param options The required width/height ratio to downsize to before computing the render pass.
  159282. * @param camera The camera to apply the render pass to.
  159283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159284. * @param engine The engine which the post process will be applied. (default: current engine)
  159285. * @param reusable If the post process can be reused on the same frame. (default: false)
  159286. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  159287. */
  159288. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  159289. }
  159290. }
  159291. declare module BABYLON {
  159292. /**
  159293. * Contains all parameters needed for the prepass to perform
  159294. * motion blur
  159295. */
  159296. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  159297. /**
  159298. * Is motion blur enabled
  159299. */
  159300. enabled: boolean;
  159301. /**
  159302. * Name of the configuration
  159303. */
  159304. name: string;
  159305. /**
  159306. * Textures that should be present in the MRT for this effect to work
  159307. */
  159308. readonly texturesRequired: number[];
  159309. }
  159310. }
  159311. declare module BABYLON {
  159312. interface Scene {
  159313. /** @hidden (Backing field) */
  159314. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  159315. /**
  159316. * Gets or Sets the current geometry buffer associated to the scene.
  159317. */
  159318. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  159319. /**
  159320. * Enables a GeometryBufferRender and associates it with the scene
  159321. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  159322. * @returns the GeometryBufferRenderer
  159323. */
  159324. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  159325. /**
  159326. * Disables the GeometryBufferRender associated with the scene
  159327. */
  159328. disableGeometryBufferRenderer(): void;
  159329. }
  159330. /**
  159331. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  159332. * in several rendering techniques.
  159333. */
  159334. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  159335. /**
  159336. * The component name helpful to identify the component in the list of scene components.
  159337. */
  159338. readonly name: string;
  159339. /**
  159340. * The scene the component belongs to.
  159341. */
  159342. scene: Scene;
  159343. /**
  159344. * Creates a new instance of the component for the given scene
  159345. * @param scene Defines the scene to register the component in
  159346. */
  159347. constructor(scene: Scene);
  159348. /**
  159349. * Registers the component in a given scene
  159350. */
  159351. register(): void;
  159352. /**
  159353. * Rebuilds the elements related to this component in case of
  159354. * context lost for instance.
  159355. */
  159356. rebuild(): void;
  159357. /**
  159358. * Disposes the component and the associated ressources
  159359. */
  159360. dispose(): void;
  159361. private _gatherRenderTargets;
  159362. }
  159363. }
  159364. declare module BABYLON {
  159365. /** @hidden */
  159366. export var motionBlurPixelShader: {
  159367. name: string;
  159368. shader: string;
  159369. };
  159370. }
  159371. declare module BABYLON {
  159372. /**
  159373. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  159374. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  159375. * As an example, all you have to do is to create the post-process:
  159376. * var mb = new BABYLON.MotionBlurPostProcess(
  159377. * 'mb', // The name of the effect.
  159378. * scene, // The scene containing the objects to blur according to their velocity.
  159379. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  159380. * camera // The camera to apply the render pass to.
  159381. * );
  159382. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  159383. */
  159384. export class MotionBlurPostProcess extends PostProcess {
  159385. /**
  159386. * Defines how much the image is blurred by the movement. Default value is equal to 1
  159387. */
  159388. motionStrength: number;
  159389. /**
  159390. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  159391. */
  159392. get motionBlurSamples(): number;
  159393. /**
  159394. * Sets the number of iterations to be used for motion blur quality
  159395. */
  159396. set motionBlurSamples(samples: number);
  159397. private _motionBlurSamples;
  159398. /**
  159399. * Gets wether or not the motion blur post-process is in object based mode.
  159400. */
  159401. get isObjectBased(): boolean;
  159402. /**
  159403. * Sets wether or not the motion blur post-process is in object based mode.
  159404. */
  159405. set isObjectBased(value: boolean);
  159406. private _isObjectBased;
  159407. private _forceGeometryBuffer;
  159408. private _geometryBufferRenderer;
  159409. private _prePassRenderer;
  159410. private _invViewProjection;
  159411. private _previousViewProjection;
  159412. /**
  159413. * Gets a string identifying the name of the class
  159414. * @returns "MotionBlurPostProcess" string
  159415. */
  159416. getClassName(): string;
  159417. /**
  159418. * Creates a new instance MotionBlurPostProcess
  159419. * @param name The name of the effect.
  159420. * @param scene The scene containing the objects to blur according to their velocity.
  159421. * @param options The required width/height ratio to downsize to before computing the render pass.
  159422. * @param camera The camera to apply the render pass to.
  159423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159424. * @param engine The engine which the post process will be applied. (default: current engine)
  159425. * @param reusable If the post process can be reused on the same frame. (default: false)
  159426. * @param textureType Type of textures used when performing the post process. (default: 0)
  159427. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  159428. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  159429. */
  159430. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  159431. /**
  159432. * Excludes the given skinned mesh from computing bones velocities.
  159433. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  159434. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  159435. */
  159436. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  159437. /**
  159438. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  159439. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  159440. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  159441. */
  159442. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  159443. /**
  159444. * Disposes the post process.
  159445. * @param camera The camera to dispose the post process on.
  159446. */
  159447. dispose(camera?: Camera): void;
  159448. /**
  159449. * Called on the mode changed (object based or screen based).
  159450. */
  159451. private _applyMode;
  159452. /**
  159453. * Called on the effect is applied when the motion blur post-process is in object based mode.
  159454. */
  159455. private _onApplyObjectBased;
  159456. /**
  159457. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  159458. */
  159459. private _onApplyScreenBased;
  159460. /**
  159461. * Called on the effect must be updated (changed mode, samples count, etc.).
  159462. */
  159463. private _updateEffect;
  159464. /** @hidden */
  159465. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  159466. }
  159467. }
  159468. declare module BABYLON {
  159469. /** @hidden */
  159470. export var refractionPixelShader: {
  159471. name: string;
  159472. shader: string;
  159473. };
  159474. }
  159475. declare module BABYLON {
  159476. /**
  159477. * Post process which applies a refractin texture
  159478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  159479. */
  159480. export class RefractionPostProcess extends PostProcess {
  159481. private _refTexture;
  159482. private _ownRefractionTexture;
  159483. /** the base color of the refraction (used to taint the rendering) */
  159484. color: Color3;
  159485. /** simulated refraction depth */
  159486. depth: number;
  159487. /** the coefficient of the base color (0 to remove base color tainting) */
  159488. colorLevel: number;
  159489. /** Gets the url used to load the refraction texture */
  159490. refractionTextureUrl: string;
  159491. /**
  159492. * Gets or sets the refraction texture
  159493. * Please note that you are responsible for disposing the texture if you set it manually
  159494. */
  159495. get refractionTexture(): Texture;
  159496. set refractionTexture(value: Texture);
  159497. /**
  159498. * Gets a string identifying the name of the class
  159499. * @returns "RefractionPostProcess" string
  159500. */
  159501. getClassName(): string;
  159502. /**
  159503. * Initializes the RefractionPostProcess
  159504. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  159505. * @param name The name of the effect.
  159506. * @param refractionTextureUrl Url of the refraction texture to use
  159507. * @param color the base color of the refraction (used to taint the rendering)
  159508. * @param depth simulated refraction depth
  159509. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  159510. * @param camera The camera to apply the render pass to.
  159511. * @param options The required width/height ratio to downsize to before computing the render pass.
  159512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159513. * @param engine The engine which the post process will be applied. (default: current engine)
  159514. * @param reusable If the post process can be reused on the same frame. (default: false)
  159515. */
  159516. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  159517. /**
  159518. * Disposes of the post process
  159519. * @param camera Camera to dispose post process on
  159520. */
  159521. dispose(camera: Camera): void;
  159522. /** @hidden */
  159523. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  159524. }
  159525. }
  159526. declare module BABYLON {
  159527. /** @hidden */
  159528. export var sharpenPixelShader: {
  159529. name: string;
  159530. shader: string;
  159531. };
  159532. }
  159533. declare module BABYLON {
  159534. /**
  159535. * The SharpenPostProcess applies a sharpen kernel to every pixel
  159536. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  159537. */
  159538. export class SharpenPostProcess extends PostProcess {
  159539. /**
  159540. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  159541. */
  159542. colorAmount: number;
  159543. /**
  159544. * How much sharpness should be applied (default: 0.3)
  159545. */
  159546. edgeAmount: number;
  159547. /**
  159548. * Gets a string identifying the name of the class
  159549. * @returns "SharpenPostProcess" string
  159550. */
  159551. getClassName(): string;
  159552. /**
  159553. * Creates a new instance ConvolutionPostProcess
  159554. * @param name The name of the effect.
  159555. * @param options The required width/height ratio to downsize to before computing the render pass.
  159556. * @param camera The camera to apply the render pass to.
  159557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159558. * @param engine The engine which the post process will be applied. (default: current engine)
  159559. * @param reusable If the post process can be reused on the same frame. (default: false)
  159560. * @param textureType Type of textures used when performing the post process. (default: 0)
  159561. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  159562. */
  159563. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159564. /** @hidden */
  159565. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  159566. }
  159567. }
  159568. declare module BABYLON {
  159569. /**
  159570. * PostProcessRenderPipeline
  159571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159572. */
  159573. export class PostProcessRenderPipeline {
  159574. private engine;
  159575. private _renderEffects;
  159576. private _renderEffectsForIsolatedPass;
  159577. /**
  159578. * List of inspectable custom properties (used by the Inspector)
  159579. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  159580. */
  159581. inspectableCustomProperties: IInspectable[];
  159582. /**
  159583. * @hidden
  159584. */
  159585. protected _cameras: Camera[];
  159586. /** @hidden */
  159587. _name: string;
  159588. /**
  159589. * Gets pipeline name
  159590. */
  159591. get name(): string;
  159592. /** Gets the list of attached cameras */
  159593. get cameras(): Camera[];
  159594. /**
  159595. * Initializes a PostProcessRenderPipeline
  159596. * @param engine engine to add the pipeline to
  159597. * @param name name of the pipeline
  159598. */
  159599. constructor(engine: Engine, name: string);
  159600. /**
  159601. * Gets the class name
  159602. * @returns "PostProcessRenderPipeline"
  159603. */
  159604. getClassName(): string;
  159605. /**
  159606. * If all the render effects in the pipeline are supported
  159607. */
  159608. get isSupported(): boolean;
  159609. /**
  159610. * Adds an effect to the pipeline
  159611. * @param renderEffect the effect to add
  159612. */
  159613. addEffect(renderEffect: PostProcessRenderEffect): void;
  159614. /** @hidden */
  159615. _rebuild(): void;
  159616. /** @hidden */
  159617. _enableEffect(renderEffectName: string, cameras: Camera): void;
  159618. /** @hidden */
  159619. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  159620. /** @hidden */
  159621. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  159622. /** @hidden */
  159623. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  159624. /** @hidden */
  159625. _attachCameras(cameras: Camera, unique: boolean): void;
  159626. /** @hidden */
  159627. _attachCameras(cameras: Camera[], unique: boolean): void;
  159628. /** @hidden */
  159629. _detachCameras(cameras: Camera): void;
  159630. /** @hidden */
  159631. _detachCameras(cameras: Nullable<Camera[]>): void;
  159632. /** @hidden */
  159633. _update(): void;
  159634. /** @hidden */
  159635. _reset(): void;
  159636. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  159637. /**
  159638. * Sets the required values to the prepass renderer.
  159639. * @param prePassRenderer defines the prepass renderer to setup.
  159640. * @returns true if the pre pass is needed.
  159641. */
  159642. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  159643. /**
  159644. * Disposes of the pipeline
  159645. */
  159646. dispose(): void;
  159647. }
  159648. }
  159649. declare module BABYLON {
  159650. /**
  159651. * PostProcessRenderPipelineManager class
  159652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159653. */
  159654. export class PostProcessRenderPipelineManager {
  159655. private _renderPipelines;
  159656. /**
  159657. * Initializes a PostProcessRenderPipelineManager
  159658. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159659. */
  159660. constructor();
  159661. /**
  159662. * Gets the list of supported render pipelines
  159663. */
  159664. get supportedPipelines(): PostProcessRenderPipeline[];
  159665. /**
  159666. * Adds a pipeline to the manager
  159667. * @param renderPipeline The pipeline to add
  159668. */
  159669. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  159670. /**
  159671. * Attaches a camera to the pipeline
  159672. * @param renderPipelineName The name of the pipeline to attach to
  159673. * @param cameras the camera to attach
  159674. * @param unique if the camera can be attached multiple times to the pipeline
  159675. */
  159676. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  159677. /**
  159678. * Detaches a camera from the pipeline
  159679. * @param renderPipelineName The name of the pipeline to detach from
  159680. * @param cameras the camera to detach
  159681. */
  159682. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  159683. /**
  159684. * Enables an effect by name on a pipeline
  159685. * @param renderPipelineName the name of the pipeline to enable the effect in
  159686. * @param renderEffectName the name of the effect to enable
  159687. * @param cameras the cameras that the effect should be enabled on
  159688. */
  159689. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  159690. /**
  159691. * Disables an effect by name on a pipeline
  159692. * @param renderPipelineName the name of the pipeline to disable the effect in
  159693. * @param renderEffectName the name of the effect to disable
  159694. * @param cameras the cameras that the effect should be disabled on
  159695. */
  159696. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  159697. /**
  159698. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  159699. */
  159700. update(): void;
  159701. /** @hidden */
  159702. _rebuild(): void;
  159703. /**
  159704. * Disposes of the manager and pipelines
  159705. */
  159706. dispose(): void;
  159707. }
  159708. }
  159709. declare module BABYLON {
  159710. interface Scene {
  159711. /** @hidden (Backing field) */
  159712. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  159713. /**
  159714. * Gets the postprocess render pipeline manager
  159715. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159716. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  159717. */
  159718. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  159719. }
  159720. /**
  159721. * Defines the Render Pipeline scene component responsible to rendering pipelines
  159722. */
  159723. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  159724. /**
  159725. * The component name helpfull to identify the component in the list of scene components.
  159726. */
  159727. readonly name: string;
  159728. /**
  159729. * The scene the component belongs to.
  159730. */
  159731. scene: Scene;
  159732. /**
  159733. * Creates a new instance of the component for the given scene
  159734. * @param scene Defines the scene to register the component in
  159735. */
  159736. constructor(scene: Scene);
  159737. /**
  159738. * Registers the component in a given scene
  159739. */
  159740. register(): void;
  159741. /**
  159742. * Rebuilds the elements related to this component in case of
  159743. * context lost for instance.
  159744. */
  159745. rebuild(): void;
  159746. /**
  159747. * Disposes the component and the associated ressources
  159748. */
  159749. dispose(): void;
  159750. private _gatherRenderTargets;
  159751. }
  159752. }
  159753. declare module BABYLON {
  159754. /**
  159755. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  159756. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  159757. */
  159758. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  159759. private _scene;
  159760. private _camerasToBeAttached;
  159761. /**
  159762. * ID of the sharpen post process,
  159763. */
  159764. private readonly SharpenPostProcessId;
  159765. /**
  159766. * @ignore
  159767. * ID of the image processing post process;
  159768. */
  159769. readonly ImageProcessingPostProcessId: string;
  159770. /**
  159771. * @ignore
  159772. * ID of the Fast Approximate Anti-Aliasing post process;
  159773. */
  159774. readonly FxaaPostProcessId: string;
  159775. /**
  159776. * ID of the chromatic aberration post process,
  159777. */
  159778. private readonly ChromaticAberrationPostProcessId;
  159779. /**
  159780. * ID of the grain post process
  159781. */
  159782. private readonly GrainPostProcessId;
  159783. /**
  159784. * Sharpen post process which will apply a sharpen convolution to enhance edges
  159785. */
  159786. sharpen: SharpenPostProcess;
  159787. private _sharpenEffect;
  159788. private bloom;
  159789. /**
  159790. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  159791. */
  159792. depthOfField: DepthOfFieldEffect;
  159793. /**
  159794. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  159795. */
  159796. fxaa: FxaaPostProcess;
  159797. /**
  159798. * Image post processing pass used to perform operations such as tone mapping or color grading.
  159799. */
  159800. imageProcessing: ImageProcessingPostProcess;
  159801. /**
  159802. * Chromatic aberration post process which will shift rgb colors in the image
  159803. */
  159804. chromaticAberration: ChromaticAberrationPostProcess;
  159805. private _chromaticAberrationEffect;
  159806. /**
  159807. * Grain post process which add noise to the image
  159808. */
  159809. grain: GrainPostProcess;
  159810. private _grainEffect;
  159811. /**
  159812. * Glow post process which adds a glow to emissive areas of the image
  159813. */
  159814. private _glowLayer;
  159815. /**
  159816. * Animations which can be used to tweak settings over a period of time
  159817. */
  159818. animations: Animation[];
  159819. private _imageProcessingConfigurationObserver;
  159820. private _sharpenEnabled;
  159821. private _bloomEnabled;
  159822. private _depthOfFieldEnabled;
  159823. private _depthOfFieldBlurLevel;
  159824. private _fxaaEnabled;
  159825. private _imageProcessingEnabled;
  159826. private _defaultPipelineTextureType;
  159827. private _bloomScale;
  159828. private _chromaticAberrationEnabled;
  159829. private _grainEnabled;
  159830. private _buildAllowed;
  159831. /**
  159832. * This is triggered each time the pipeline has been built.
  159833. */
  159834. onBuildObservable: Observable<DefaultRenderingPipeline>;
  159835. /**
  159836. * Gets active scene
  159837. */
  159838. get scene(): Scene;
  159839. /**
  159840. * Enable or disable the sharpen process from the pipeline
  159841. */
  159842. set sharpenEnabled(enabled: boolean);
  159843. get sharpenEnabled(): boolean;
  159844. private _resizeObserver;
  159845. private _hardwareScaleLevel;
  159846. private _bloomKernel;
  159847. /**
  159848. * Specifies the size of the bloom blur kernel, relative to the final output size
  159849. */
  159850. get bloomKernel(): number;
  159851. set bloomKernel(value: number);
  159852. /**
  159853. * Specifies the weight of the bloom in the final rendering
  159854. */
  159855. private _bloomWeight;
  159856. /**
  159857. * Specifies the luma threshold for the area that will be blurred by the bloom
  159858. */
  159859. private _bloomThreshold;
  159860. private _hdr;
  159861. /**
  159862. * The strength of the bloom.
  159863. */
  159864. set bloomWeight(value: number);
  159865. get bloomWeight(): number;
  159866. /**
  159867. * The strength of the bloom.
  159868. */
  159869. set bloomThreshold(value: number);
  159870. get bloomThreshold(): number;
  159871. /**
  159872. * The scale of the bloom, lower value will provide better performance.
  159873. */
  159874. set bloomScale(value: number);
  159875. get bloomScale(): number;
  159876. /**
  159877. * Enable or disable the bloom from the pipeline
  159878. */
  159879. set bloomEnabled(enabled: boolean);
  159880. get bloomEnabled(): boolean;
  159881. private _rebuildBloom;
  159882. /**
  159883. * If the depth of field is enabled.
  159884. */
  159885. get depthOfFieldEnabled(): boolean;
  159886. set depthOfFieldEnabled(enabled: boolean);
  159887. /**
  159888. * Blur level of the depth of field effect. (Higher blur will effect performance)
  159889. */
  159890. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  159891. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  159892. /**
  159893. * If the anti aliasing is enabled.
  159894. */
  159895. set fxaaEnabled(enabled: boolean);
  159896. get fxaaEnabled(): boolean;
  159897. private _samples;
  159898. /**
  159899. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  159900. */
  159901. set samples(sampleCount: number);
  159902. get samples(): number;
  159903. /**
  159904. * If image processing is enabled.
  159905. */
  159906. set imageProcessingEnabled(enabled: boolean);
  159907. get imageProcessingEnabled(): boolean;
  159908. /**
  159909. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  159910. */
  159911. set glowLayerEnabled(enabled: boolean);
  159912. get glowLayerEnabled(): boolean;
  159913. /**
  159914. * Gets the glow layer (or null if not defined)
  159915. */
  159916. get glowLayer(): Nullable<GlowLayer>;
  159917. /**
  159918. * Enable or disable the chromaticAberration process from the pipeline
  159919. */
  159920. set chromaticAberrationEnabled(enabled: boolean);
  159921. get chromaticAberrationEnabled(): boolean;
  159922. /**
  159923. * Enable or disable the grain process from the pipeline
  159924. */
  159925. set grainEnabled(enabled: boolean);
  159926. get grainEnabled(): boolean;
  159927. /**
  159928. * @constructor
  159929. * @param name - The rendering pipeline name (default: "")
  159930. * @param hdr - If high dynamic range textures should be used (default: true)
  159931. * @param scene - The scene linked to this pipeline (default: the last created scene)
  159932. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  159933. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  159934. */
  159935. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  159936. /**
  159937. * Get the class name
  159938. * @returns "DefaultRenderingPipeline"
  159939. */
  159940. getClassName(): string;
  159941. /**
  159942. * Force the compilation of the entire pipeline.
  159943. */
  159944. prepare(): void;
  159945. private _hasCleared;
  159946. private _prevPostProcess;
  159947. private _prevPrevPostProcess;
  159948. private _setAutoClearAndTextureSharing;
  159949. private _depthOfFieldSceneObserver;
  159950. private _buildPipeline;
  159951. private _disposePostProcesses;
  159952. /**
  159953. * Adds a camera to the pipeline
  159954. * @param camera the camera to be added
  159955. */
  159956. addCamera(camera: Camera): void;
  159957. /**
  159958. * Removes a camera from the pipeline
  159959. * @param camera the camera to remove
  159960. */
  159961. removeCamera(camera: Camera): void;
  159962. /**
  159963. * Dispose of the pipeline and stop all post processes
  159964. */
  159965. dispose(): void;
  159966. /**
  159967. * Serialize the rendering pipeline (Used when exporting)
  159968. * @returns the serialized object
  159969. */
  159970. serialize(): any;
  159971. /**
  159972. * Parse the serialized pipeline
  159973. * @param source Source pipeline.
  159974. * @param scene The scene to load the pipeline to.
  159975. * @param rootUrl The URL of the serialized pipeline.
  159976. * @returns An instantiated pipeline from the serialized object.
  159977. */
  159978. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  159979. }
  159980. }
  159981. declare module BABYLON {
  159982. /** @hidden */
  159983. export var lensHighlightsPixelShader: {
  159984. name: string;
  159985. shader: string;
  159986. };
  159987. }
  159988. declare module BABYLON {
  159989. /** @hidden */
  159990. export var depthOfFieldPixelShader: {
  159991. name: string;
  159992. shader: string;
  159993. };
  159994. }
  159995. declare module BABYLON {
  159996. /**
  159997. * BABYLON.JS Chromatic Aberration GLSL Shader
  159998. * Author: Olivier Guyot
  159999. * Separates very slightly R, G and B colors on the edges of the screen
  160000. * Inspired by Francois Tarlier & Martins Upitis
  160001. */
  160002. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  160003. /**
  160004. * @ignore
  160005. * The chromatic aberration PostProcess id in the pipeline
  160006. */
  160007. LensChromaticAberrationEffect: string;
  160008. /**
  160009. * @ignore
  160010. * The highlights enhancing PostProcess id in the pipeline
  160011. */
  160012. HighlightsEnhancingEffect: string;
  160013. /**
  160014. * @ignore
  160015. * The depth-of-field PostProcess id in the pipeline
  160016. */
  160017. LensDepthOfFieldEffect: string;
  160018. private _scene;
  160019. private _depthTexture;
  160020. private _grainTexture;
  160021. private _chromaticAberrationPostProcess;
  160022. private _highlightsPostProcess;
  160023. private _depthOfFieldPostProcess;
  160024. private _edgeBlur;
  160025. private _grainAmount;
  160026. private _chromaticAberration;
  160027. private _distortion;
  160028. private _highlightsGain;
  160029. private _highlightsThreshold;
  160030. private _dofDistance;
  160031. private _dofAperture;
  160032. private _dofDarken;
  160033. private _dofPentagon;
  160034. private _blurNoise;
  160035. /**
  160036. * @constructor
  160037. *
  160038. * Effect parameters are as follow:
  160039. * {
  160040. * chromatic_aberration: number; // from 0 to x (1 for realism)
  160041. * edge_blur: number; // from 0 to x (1 for realism)
  160042. * distortion: number; // from 0 to x (1 for realism)
  160043. * grain_amount: number; // from 0 to 1
  160044. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  160045. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  160046. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  160047. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  160048. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  160049. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  160050. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  160051. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  160052. * }
  160053. * Note: if an effect parameter is unset, effect is disabled
  160054. *
  160055. * @param name The rendering pipeline name
  160056. * @param parameters - An object containing all parameters (see above)
  160057. * @param scene The scene linked to this pipeline
  160058. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  160059. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160060. */
  160061. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  160062. /**
  160063. * Get the class name
  160064. * @returns "LensRenderingPipeline"
  160065. */
  160066. getClassName(): string;
  160067. /**
  160068. * Gets associated scene
  160069. */
  160070. get scene(): Scene;
  160071. /**
  160072. * Gets or sets the edge blur
  160073. */
  160074. get edgeBlur(): number;
  160075. set edgeBlur(value: number);
  160076. /**
  160077. * Gets or sets the grain amount
  160078. */
  160079. get grainAmount(): number;
  160080. set grainAmount(value: number);
  160081. /**
  160082. * Gets or sets the chromatic aberration amount
  160083. */
  160084. get chromaticAberration(): number;
  160085. set chromaticAberration(value: number);
  160086. /**
  160087. * Gets or sets the depth of field aperture
  160088. */
  160089. get dofAperture(): number;
  160090. set dofAperture(value: number);
  160091. /**
  160092. * Gets or sets the edge distortion
  160093. */
  160094. get edgeDistortion(): number;
  160095. set edgeDistortion(value: number);
  160096. /**
  160097. * Gets or sets the depth of field distortion
  160098. */
  160099. get dofDistortion(): number;
  160100. set dofDistortion(value: number);
  160101. /**
  160102. * Gets or sets the darken out of focus amount
  160103. */
  160104. get darkenOutOfFocus(): number;
  160105. set darkenOutOfFocus(value: number);
  160106. /**
  160107. * Gets or sets a boolean indicating if blur noise is enabled
  160108. */
  160109. get blurNoise(): boolean;
  160110. set blurNoise(value: boolean);
  160111. /**
  160112. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  160113. */
  160114. get pentagonBokeh(): boolean;
  160115. set pentagonBokeh(value: boolean);
  160116. /**
  160117. * Gets or sets the highlight grain amount
  160118. */
  160119. get highlightsGain(): number;
  160120. set highlightsGain(value: number);
  160121. /**
  160122. * Gets or sets the highlight threshold
  160123. */
  160124. get highlightsThreshold(): number;
  160125. set highlightsThreshold(value: number);
  160126. /**
  160127. * Sets the amount of blur at the edges
  160128. * @param amount blur amount
  160129. */
  160130. setEdgeBlur(amount: number): void;
  160131. /**
  160132. * Sets edge blur to 0
  160133. */
  160134. disableEdgeBlur(): void;
  160135. /**
  160136. * Sets the amout of grain
  160137. * @param amount Amount of grain
  160138. */
  160139. setGrainAmount(amount: number): void;
  160140. /**
  160141. * Set grain amount to 0
  160142. */
  160143. disableGrain(): void;
  160144. /**
  160145. * Sets the chromatic aberration amount
  160146. * @param amount amount of chromatic aberration
  160147. */
  160148. setChromaticAberration(amount: number): void;
  160149. /**
  160150. * Sets chromatic aberration amount to 0
  160151. */
  160152. disableChromaticAberration(): void;
  160153. /**
  160154. * Sets the EdgeDistortion amount
  160155. * @param amount amount of EdgeDistortion
  160156. */
  160157. setEdgeDistortion(amount: number): void;
  160158. /**
  160159. * Sets edge distortion to 0
  160160. */
  160161. disableEdgeDistortion(): void;
  160162. /**
  160163. * Sets the FocusDistance amount
  160164. * @param amount amount of FocusDistance
  160165. */
  160166. setFocusDistance(amount: number): void;
  160167. /**
  160168. * Disables depth of field
  160169. */
  160170. disableDepthOfField(): void;
  160171. /**
  160172. * Sets the Aperture amount
  160173. * @param amount amount of Aperture
  160174. */
  160175. setAperture(amount: number): void;
  160176. /**
  160177. * Sets the DarkenOutOfFocus amount
  160178. * @param amount amount of DarkenOutOfFocus
  160179. */
  160180. setDarkenOutOfFocus(amount: number): void;
  160181. private _pentagonBokehIsEnabled;
  160182. /**
  160183. * Creates a pentagon bokeh effect
  160184. */
  160185. enablePentagonBokeh(): void;
  160186. /**
  160187. * Disables the pentagon bokeh effect
  160188. */
  160189. disablePentagonBokeh(): void;
  160190. /**
  160191. * Enables noise blur
  160192. */
  160193. enableNoiseBlur(): void;
  160194. /**
  160195. * Disables noise blur
  160196. */
  160197. disableNoiseBlur(): void;
  160198. /**
  160199. * Sets the HighlightsGain amount
  160200. * @param amount amount of HighlightsGain
  160201. */
  160202. setHighlightsGain(amount: number): void;
  160203. /**
  160204. * Sets the HighlightsThreshold amount
  160205. * @param amount amount of HighlightsThreshold
  160206. */
  160207. setHighlightsThreshold(amount: number): void;
  160208. /**
  160209. * Disables highlights
  160210. */
  160211. disableHighlights(): void;
  160212. /**
  160213. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  160214. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  160215. */
  160216. dispose(disableDepthRender?: boolean): void;
  160217. private _createChromaticAberrationPostProcess;
  160218. private _createHighlightsPostProcess;
  160219. private _createDepthOfFieldPostProcess;
  160220. private _createGrainTexture;
  160221. }
  160222. }
  160223. declare module BABYLON {
  160224. /**
  160225. * Contains all parameters needed for the prepass to perform
  160226. * screen space subsurface scattering
  160227. */
  160228. export class SSAO2Configuration implements PrePassEffectConfiguration {
  160229. /**
  160230. * Is subsurface enabled
  160231. */
  160232. enabled: boolean;
  160233. /**
  160234. * Name of the configuration
  160235. */
  160236. name: string;
  160237. /**
  160238. * Textures that should be present in the MRT for this effect to work
  160239. */
  160240. readonly texturesRequired: number[];
  160241. }
  160242. }
  160243. declare module BABYLON {
  160244. /** @hidden */
  160245. export var ssao2PixelShader: {
  160246. name: string;
  160247. shader: string;
  160248. };
  160249. }
  160250. declare module BABYLON {
  160251. /** @hidden */
  160252. export var ssaoCombinePixelShader: {
  160253. name: string;
  160254. shader: string;
  160255. };
  160256. }
  160257. declare module BABYLON {
  160258. /**
  160259. * Render pipeline to produce ssao effect
  160260. */
  160261. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  160262. /**
  160263. * @ignore
  160264. * The PassPostProcess id in the pipeline that contains the original scene color
  160265. */
  160266. SSAOOriginalSceneColorEffect: string;
  160267. /**
  160268. * @ignore
  160269. * The SSAO PostProcess id in the pipeline
  160270. */
  160271. SSAORenderEffect: string;
  160272. /**
  160273. * @ignore
  160274. * The horizontal blur PostProcess id in the pipeline
  160275. */
  160276. SSAOBlurHRenderEffect: string;
  160277. /**
  160278. * @ignore
  160279. * The vertical blur PostProcess id in the pipeline
  160280. */
  160281. SSAOBlurVRenderEffect: string;
  160282. /**
  160283. * @ignore
  160284. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  160285. */
  160286. SSAOCombineRenderEffect: string;
  160287. /**
  160288. * The output strength of the SSAO post-process. Default value is 1.0.
  160289. */
  160290. totalStrength: number;
  160291. /**
  160292. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  160293. */
  160294. maxZ: number;
  160295. /**
  160296. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  160297. */
  160298. minZAspect: number;
  160299. private _samples;
  160300. /**
  160301. * Number of samples used for the SSAO calculations. Default value is 8
  160302. */
  160303. set samples(n: number);
  160304. get samples(): number;
  160305. private _textureSamples;
  160306. /**
  160307. * Number of samples to use for antialiasing
  160308. */
  160309. set textureSamples(n: number);
  160310. get textureSamples(): number;
  160311. /**
  160312. * Force rendering the geometry through geometry buffer
  160313. */
  160314. private _forceGeometryBuffer;
  160315. /**
  160316. * Ratio object used for SSAO ratio and blur ratio
  160317. */
  160318. private _ratio;
  160319. /**
  160320. * Dynamically generated sphere sampler.
  160321. */
  160322. private _sampleSphere;
  160323. /**
  160324. * Blur filter offsets
  160325. */
  160326. private _samplerOffsets;
  160327. private _expensiveBlur;
  160328. /**
  160329. * If bilateral blur should be used
  160330. */
  160331. set expensiveBlur(b: boolean);
  160332. get expensiveBlur(): boolean;
  160333. /**
  160334. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  160335. */
  160336. radius: number;
  160337. /**
  160338. * The base color of the SSAO post-process
  160339. * The final result is "base + ssao" between [0, 1]
  160340. */
  160341. base: number;
  160342. /**
  160343. * Support test.
  160344. */
  160345. static get IsSupported(): boolean;
  160346. private _scene;
  160347. private _randomTexture;
  160348. private _originalColorPostProcess;
  160349. private _ssaoPostProcess;
  160350. private _blurHPostProcess;
  160351. private _blurVPostProcess;
  160352. private _ssaoCombinePostProcess;
  160353. private _prePassRenderer;
  160354. /**
  160355. * Gets active scene
  160356. */
  160357. get scene(): Scene;
  160358. /**
  160359. * @constructor
  160360. * @param name The rendering pipeline name
  160361. * @param scene The scene linked to this pipeline
  160362. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  160363. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160364. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  160365. */
  160366. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  160367. /**
  160368. * Get the class name
  160369. * @returns "SSAO2RenderingPipeline"
  160370. */
  160371. getClassName(): string;
  160372. /**
  160373. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  160374. */
  160375. dispose(disableGeometryBufferRenderer?: boolean): void;
  160376. private _createBlurPostProcess;
  160377. /** @hidden */
  160378. _rebuild(): void;
  160379. private _bits;
  160380. private _radicalInverse_VdC;
  160381. private _hammersley;
  160382. private _hemisphereSample_uniform;
  160383. private _generateHemisphere;
  160384. private _getDefinesForSSAO;
  160385. private static readonly ORTHO_DEPTH_PROJECTION;
  160386. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  160387. private _createSSAOPostProcess;
  160388. private _createSSAOCombinePostProcess;
  160389. private _createRandomTexture;
  160390. /**
  160391. * Serialize the rendering pipeline (Used when exporting)
  160392. * @returns the serialized object
  160393. */
  160394. serialize(): any;
  160395. /**
  160396. * Parse the serialized pipeline
  160397. * @param source Source pipeline.
  160398. * @param scene The scene to load the pipeline to.
  160399. * @param rootUrl The URL of the serialized pipeline.
  160400. * @returns An instantiated pipeline from the serialized object.
  160401. */
  160402. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  160403. }
  160404. }
  160405. declare module BABYLON {
  160406. /** @hidden */
  160407. export var ssaoPixelShader: {
  160408. name: string;
  160409. shader: string;
  160410. };
  160411. }
  160412. declare module BABYLON {
  160413. /**
  160414. * Render pipeline to produce ssao effect
  160415. */
  160416. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  160417. /**
  160418. * @ignore
  160419. * The PassPostProcess id in the pipeline that contains the original scene color
  160420. */
  160421. SSAOOriginalSceneColorEffect: string;
  160422. /**
  160423. * @ignore
  160424. * The SSAO PostProcess id in the pipeline
  160425. */
  160426. SSAORenderEffect: string;
  160427. /**
  160428. * @ignore
  160429. * The horizontal blur PostProcess id in the pipeline
  160430. */
  160431. SSAOBlurHRenderEffect: string;
  160432. /**
  160433. * @ignore
  160434. * The vertical blur PostProcess id in the pipeline
  160435. */
  160436. SSAOBlurVRenderEffect: string;
  160437. /**
  160438. * @ignore
  160439. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  160440. */
  160441. SSAOCombineRenderEffect: string;
  160442. /**
  160443. * The output strength of the SSAO post-process. Default value is 1.0.
  160444. */
  160445. totalStrength: number;
  160446. /**
  160447. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  160448. */
  160449. radius: number;
  160450. /**
  160451. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  160452. * Must not be equal to fallOff and superior to fallOff.
  160453. * Default value is 0.0075
  160454. */
  160455. area: number;
  160456. /**
  160457. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  160458. * Must not be equal to area and inferior to area.
  160459. * Default value is 0.000001
  160460. */
  160461. fallOff: number;
  160462. /**
  160463. * The base color of the SSAO post-process
  160464. * The final result is "base + ssao" between [0, 1]
  160465. */
  160466. base: number;
  160467. private _scene;
  160468. private _depthTexture;
  160469. private _randomTexture;
  160470. private _originalColorPostProcess;
  160471. private _ssaoPostProcess;
  160472. private _blurHPostProcess;
  160473. private _blurVPostProcess;
  160474. private _ssaoCombinePostProcess;
  160475. private _firstUpdate;
  160476. /**
  160477. * Gets active scene
  160478. */
  160479. get scene(): Scene;
  160480. /**
  160481. * @constructor
  160482. * @param name - The rendering pipeline name
  160483. * @param scene - The scene linked to this pipeline
  160484. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  160485. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  160486. */
  160487. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  160488. /**
  160489. * Get the class name
  160490. * @returns "SSAORenderingPipeline"
  160491. */
  160492. getClassName(): string;
  160493. /**
  160494. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  160495. */
  160496. dispose(disableDepthRender?: boolean): void;
  160497. private _createBlurPostProcess;
  160498. /** @hidden */
  160499. _rebuild(): void;
  160500. private _createSSAOPostProcess;
  160501. private _createSSAOCombinePostProcess;
  160502. private _createRandomTexture;
  160503. }
  160504. }
  160505. declare module BABYLON {
  160506. /**
  160507. * Contains all parameters needed for the prepass to perform
  160508. * screen space reflections
  160509. */
  160510. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  160511. /**
  160512. * Is ssr enabled
  160513. */
  160514. enabled: boolean;
  160515. /**
  160516. * Name of the configuration
  160517. */
  160518. name: string;
  160519. /**
  160520. * Textures that should be present in the MRT for this effect to work
  160521. */
  160522. readonly texturesRequired: number[];
  160523. }
  160524. }
  160525. declare module BABYLON {
  160526. /** @hidden */
  160527. export var screenSpaceReflectionPixelShader: {
  160528. name: string;
  160529. shader: string;
  160530. };
  160531. }
  160532. declare module BABYLON {
  160533. /**
  160534. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  160535. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  160536. */
  160537. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  160538. /**
  160539. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  160540. */
  160541. threshold: number;
  160542. /**
  160543. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  160544. */
  160545. strength: number;
  160546. /**
  160547. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  160548. */
  160549. reflectionSpecularFalloffExponent: number;
  160550. /**
  160551. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  160552. */
  160553. step: number;
  160554. /**
  160555. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  160556. */
  160557. roughnessFactor: number;
  160558. private _forceGeometryBuffer;
  160559. private _geometryBufferRenderer;
  160560. private _prePassRenderer;
  160561. private _enableSmoothReflections;
  160562. private _reflectionSamples;
  160563. private _smoothSteps;
  160564. /**
  160565. * Gets a string identifying the name of the class
  160566. * @returns "ScreenSpaceReflectionPostProcess" string
  160567. */
  160568. getClassName(): string;
  160569. /**
  160570. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  160571. * @param name The name of the effect.
  160572. * @param scene The scene containing the objects to calculate reflections.
  160573. * @param options The required width/height ratio to downsize to before computing the render pass.
  160574. * @param camera The camera to apply the render pass to.
  160575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160576. * @param engine The engine which the post process will be applied. (default: current engine)
  160577. * @param reusable If the post process can be reused on the same frame. (default: false)
  160578. * @param textureType Type of textures used when performing the post process. (default: 0)
  160579. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  160580. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  160581. */
  160582. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  160583. /**
  160584. * Gets wether or not smoothing reflections is enabled.
  160585. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  160586. */
  160587. get enableSmoothReflections(): boolean;
  160588. /**
  160589. * Sets wether or not smoothing reflections is enabled.
  160590. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  160591. */
  160592. set enableSmoothReflections(enabled: boolean);
  160593. /**
  160594. * Gets the number of samples taken while computing reflections. More samples count is high,
  160595. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  160596. */
  160597. get reflectionSamples(): number;
  160598. /**
  160599. * Sets the number of samples taken while computing reflections. More samples count is high,
  160600. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  160601. */
  160602. set reflectionSamples(samples: number);
  160603. /**
  160604. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  160605. * more the post-process will require GPU power and can generate a drop in FPS.
  160606. * Default value (5.0) work pretty well in all cases but can be adjusted.
  160607. */
  160608. get smoothSteps(): number;
  160609. set smoothSteps(steps: number);
  160610. private _updateEffectDefines;
  160611. /** @hidden */
  160612. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  160613. }
  160614. }
  160615. declare module BABYLON {
  160616. /** @hidden */
  160617. export var standardPixelShader: {
  160618. name: string;
  160619. shader: string;
  160620. };
  160621. }
  160622. declare module BABYLON {
  160623. /**
  160624. * Standard rendering pipeline
  160625. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  160626. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  160627. */
  160628. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  160629. /**
  160630. * Public members
  160631. */
  160632. /**
  160633. * Post-process which contains the original scene color before the pipeline applies all the effects
  160634. */
  160635. originalPostProcess: Nullable<PostProcess>;
  160636. /**
  160637. * Post-process used to down scale an image x4
  160638. */
  160639. downSampleX4PostProcess: Nullable<PostProcess>;
  160640. /**
  160641. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  160642. */
  160643. brightPassPostProcess: Nullable<PostProcess>;
  160644. /**
  160645. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  160646. */
  160647. blurHPostProcesses: PostProcess[];
  160648. /**
  160649. * Post-process array storing all the vertical blur post-processes used by the pipeline
  160650. */
  160651. blurVPostProcesses: PostProcess[];
  160652. /**
  160653. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  160654. */
  160655. textureAdderPostProcess: Nullable<PostProcess>;
  160656. /**
  160657. * Post-process used to create volumetric lighting effect
  160658. */
  160659. volumetricLightPostProcess: Nullable<PostProcess>;
  160660. /**
  160661. * Post-process used to smooth the previous volumetric light post-process on the X axis
  160662. */
  160663. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  160664. /**
  160665. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  160666. */
  160667. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  160668. /**
  160669. * Post-process used to merge the volumetric light effect and the real scene color
  160670. */
  160671. volumetricLightMergePostProces: Nullable<PostProcess>;
  160672. /**
  160673. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  160674. */
  160675. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  160676. /**
  160677. * Base post-process used to calculate the average luminance of the final image for HDR
  160678. */
  160679. luminancePostProcess: Nullable<PostProcess>;
  160680. /**
  160681. * Post-processes used to create down sample post-processes in order to get
  160682. * the average luminance of the final image for HDR
  160683. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  160684. */
  160685. luminanceDownSamplePostProcesses: PostProcess[];
  160686. /**
  160687. * Post-process used to create a HDR effect (light adaptation)
  160688. */
  160689. hdrPostProcess: Nullable<PostProcess>;
  160690. /**
  160691. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  160692. */
  160693. textureAdderFinalPostProcess: Nullable<PostProcess>;
  160694. /**
  160695. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  160696. */
  160697. lensFlareFinalPostProcess: Nullable<PostProcess>;
  160698. /**
  160699. * Post-process used to merge the final HDR post-process and the real scene color
  160700. */
  160701. hdrFinalPostProcess: Nullable<PostProcess>;
  160702. /**
  160703. * Post-process used to create a lens flare effect
  160704. */
  160705. lensFlarePostProcess: Nullable<PostProcess>;
  160706. /**
  160707. * Post-process that merges the result of the lens flare post-process and the real scene color
  160708. */
  160709. lensFlareComposePostProcess: Nullable<PostProcess>;
  160710. /**
  160711. * Post-process used to create a motion blur effect
  160712. */
  160713. motionBlurPostProcess: Nullable<PostProcess>;
  160714. /**
  160715. * Post-process used to create a depth of field effect
  160716. */
  160717. depthOfFieldPostProcess: Nullable<PostProcess>;
  160718. /**
  160719. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  160720. */
  160721. fxaaPostProcess: Nullable<FxaaPostProcess>;
  160722. /**
  160723. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  160724. */
  160725. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  160726. /**
  160727. * Represents the brightness threshold in order to configure the illuminated surfaces
  160728. */
  160729. brightThreshold: number;
  160730. /**
  160731. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  160732. */
  160733. blurWidth: number;
  160734. /**
  160735. * Sets if the blur for highlighted surfaces must be only horizontal
  160736. */
  160737. horizontalBlur: boolean;
  160738. /**
  160739. * Gets the overall exposure used by the pipeline
  160740. */
  160741. get exposure(): number;
  160742. /**
  160743. * Sets the overall exposure used by the pipeline
  160744. */
  160745. set exposure(value: number);
  160746. /**
  160747. * Texture used typically to simulate "dirty" on camera lens
  160748. */
  160749. lensTexture: Nullable<Texture>;
  160750. /**
  160751. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  160752. */
  160753. volumetricLightCoefficient: number;
  160754. /**
  160755. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  160756. */
  160757. volumetricLightPower: number;
  160758. /**
  160759. * Used the set the blur intensity to smooth the volumetric lights
  160760. */
  160761. volumetricLightBlurScale: number;
  160762. /**
  160763. * Light (spot or directional) used to generate the volumetric lights rays
  160764. * The source light must have a shadow generate so the pipeline can get its
  160765. * depth map
  160766. */
  160767. sourceLight: Nullable<SpotLight | DirectionalLight>;
  160768. /**
  160769. * For eye adaptation, represents the minimum luminance the eye can see
  160770. */
  160771. hdrMinimumLuminance: number;
  160772. /**
  160773. * For eye adaptation, represents the decrease luminance speed
  160774. */
  160775. hdrDecreaseRate: number;
  160776. /**
  160777. * For eye adaptation, represents the increase luminance speed
  160778. */
  160779. hdrIncreaseRate: number;
  160780. /**
  160781. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  160782. */
  160783. get hdrAutoExposure(): boolean;
  160784. /**
  160785. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  160786. */
  160787. set hdrAutoExposure(value: boolean);
  160788. /**
  160789. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  160790. */
  160791. lensColorTexture: Nullable<Texture>;
  160792. /**
  160793. * The overall strengh for the lens flare effect
  160794. */
  160795. lensFlareStrength: number;
  160796. /**
  160797. * Dispersion coefficient for lens flare ghosts
  160798. */
  160799. lensFlareGhostDispersal: number;
  160800. /**
  160801. * Main lens flare halo width
  160802. */
  160803. lensFlareHaloWidth: number;
  160804. /**
  160805. * Based on the lens distortion effect, defines how much the lens flare result
  160806. * is distorted
  160807. */
  160808. lensFlareDistortionStrength: number;
  160809. /**
  160810. * Configures the blur intensity used for for lens flare (halo)
  160811. */
  160812. lensFlareBlurWidth: number;
  160813. /**
  160814. * Lens star texture must be used to simulate rays on the flares and is available
  160815. * in the documentation
  160816. */
  160817. lensStarTexture: Nullable<Texture>;
  160818. /**
  160819. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  160820. * flare effect by taking account of the dirt texture
  160821. */
  160822. lensFlareDirtTexture: Nullable<Texture>;
  160823. /**
  160824. * Represents the focal length for the depth of field effect
  160825. */
  160826. depthOfFieldDistance: number;
  160827. /**
  160828. * Represents the blur intensity for the blurred part of the depth of field effect
  160829. */
  160830. depthOfFieldBlurWidth: number;
  160831. /**
  160832. * Gets how much the image is blurred by the movement while using the motion blur post-process
  160833. */
  160834. get motionStrength(): number;
  160835. /**
  160836. * Sets how much the image is blurred by the movement while using the motion blur post-process
  160837. */
  160838. set motionStrength(strength: number);
  160839. /**
  160840. * Gets wether or not the motion blur post-process is object based or screen based.
  160841. */
  160842. get objectBasedMotionBlur(): boolean;
  160843. /**
  160844. * Sets wether or not the motion blur post-process should be object based or screen based
  160845. */
  160846. set objectBasedMotionBlur(value: boolean);
  160847. /**
  160848. * List of animations for the pipeline (IAnimatable implementation)
  160849. */
  160850. animations: Animation[];
  160851. /**
  160852. * Private members
  160853. */
  160854. private _scene;
  160855. private _currentDepthOfFieldSource;
  160856. private _basePostProcess;
  160857. private _fixedExposure;
  160858. private _currentExposure;
  160859. private _hdrAutoExposure;
  160860. private _hdrCurrentLuminance;
  160861. private _motionStrength;
  160862. private _isObjectBasedMotionBlur;
  160863. private _floatTextureType;
  160864. private _camerasToBeAttached;
  160865. private _ratio;
  160866. private _bloomEnabled;
  160867. private _depthOfFieldEnabled;
  160868. private _vlsEnabled;
  160869. private _lensFlareEnabled;
  160870. private _hdrEnabled;
  160871. private _motionBlurEnabled;
  160872. private _fxaaEnabled;
  160873. private _screenSpaceReflectionsEnabled;
  160874. private _motionBlurSamples;
  160875. private _volumetricLightStepsCount;
  160876. private _samples;
  160877. /**
  160878. * @ignore
  160879. * Specifies if the bloom pipeline is enabled
  160880. */
  160881. get BloomEnabled(): boolean;
  160882. set BloomEnabled(enabled: boolean);
  160883. /**
  160884. * @ignore
  160885. * Specifies if the depth of field pipeline is enabed
  160886. */
  160887. get DepthOfFieldEnabled(): boolean;
  160888. set DepthOfFieldEnabled(enabled: boolean);
  160889. /**
  160890. * @ignore
  160891. * Specifies if the lens flare pipeline is enabed
  160892. */
  160893. get LensFlareEnabled(): boolean;
  160894. set LensFlareEnabled(enabled: boolean);
  160895. /**
  160896. * @ignore
  160897. * Specifies if the HDR pipeline is enabled
  160898. */
  160899. get HDREnabled(): boolean;
  160900. set HDREnabled(enabled: boolean);
  160901. /**
  160902. * @ignore
  160903. * Specifies if the volumetric lights scattering effect is enabled
  160904. */
  160905. get VLSEnabled(): boolean;
  160906. set VLSEnabled(enabled: boolean);
  160907. /**
  160908. * @ignore
  160909. * Specifies if the motion blur effect is enabled
  160910. */
  160911. get MotionBlurEnabled(): boolean;
  160912. set MotionBlurEnabled(enabled: boolean);
  160913. /**
  160914. * Specifies if anti-aliasing is enabled
  160915. */
  160916. get fxaaEnabled(): boolean;
  160917. set fxaaEnabled(enabled: boolean);
  160918. /**
  160919. * Specifies if screen space reflections are enabled.
  160920. */
  160921. get screenSpaceReflectionsEnabled(): boolean;
  160922. set screenSpaceReflectionsEnabled(enabled: boolean);
  160923. /**
  160924. * Specifies the number of steps used to calculate the volumetric lights
  160925. * Typically in interval [50, 200]
  160926. */
  160927. get volumetricLightStepsCount(): number;
  160928. set volumetricLightStepsCount(count: number);
  160929. /**
  160930. * Specifies the number of samples used for the motion blur effect
  160931. * Typically in interval [16, 64]
  160932. */
  160933. get motionBlurSamples(): number;
  160934. set motionBlurSamples(samples: number);
  160935. /**
  160936. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  160937. */
  160938. get samples(): number;
  160939. set samples(sampleCount: number);
  160940. /**
  160941. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  160942. * @constructor
  160943. * @param name The rendering pipeline name
  160944. * @param scene The scene linked to this pipeline
  160945. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  160946. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  160947. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160948. */
  160949. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  160950. private _buildPipeline;
  160951. private _createDownSampleX4PostProcess;
  160952. private _createBrightPassPostProcess;
  160953. private _createBlurPostProcesses;
  160954. private _createTextureAdderPostProcess;
  160955. private _createVolumetricLightPostProcess;
  160956. private _createLuminancePostProcesses;
  160957. private _createHdrPostProcess;
  160958. private _createLensFlarePostProcess;
  160959. private _createDepthOfFieldPostProcess;
  160960. private _createMotionBlurPostProcess;
  160961. private _getDepthTexture;
  160962. private _disposePostProcesses;
  160963. /**
  160964. * Dispose of the pipeline and stop all post processes
  160965. */
  160966. dispose(): void;
  160967. /**
  160968. * Serialize the rendering pipeline (Used when exporting)
  160969. * @returns the serialized object
  160970. */
  160971. serialize(): any;
  160972. /**
  160973. * Parse the serialized pipeline
  160974. * @param source Source pipeline.
  160975. * @param scene The scene to load the pipeline to.
  160976. * @param rootUrl The URL of the serialized pipeline.
  160977. * @returns An instantiated pipeline from the serialized object.
  160978. */
  160979. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  160980. /**
  160981. * Luminance steps
  160982. */
  160983. static LuminanceSteps: number;
  160984. }
  160985. }
  160986. declare module BABYLON {
  160987. /** @hidden */
  160988. export var tonemapPixelShader: {
  160989. name: string;
  160990. shader: string;
  160991. };
  160992. }
  160993. declare module BABYLON {
  160994. /** Defines operator used for tonemapping */
  160995. export enum TonemappingOperator {
  160996. /** Hable */
  160997. Hable = 0,
  160998. /** Reinhard */
  160999. Reinhard = 1,
  161000. /** HejiDawson */
  161001. HejiDawson = 2,
  161002. /** Photographic */
  161003. Photographic = 3
  161004. }
  161005. /**
  161006. * Defines a post process to apply tone mapping
  161007. */
  161008. export class TonemapPostProcess extends PostProcess {
  161009. private _operator;
  161010. /** Defines the required exposure adjustement */
  161011. exposureAdjustment: number;
  161012. /**
  161013. * Gets a string identifying the name of the class
  161014. * @returns "TonemapPostProcess" string
  161015. */
  161016. getClassName(): string;
  161017. /**
  161018. * Creates a new TonemapPostProcess
  161019. * @param name defines the name of the postprocess
  161020. * @param _operator defines the operator to use
  161021. * @param exposureAdjustment defines the required exposure adjustement
  161022. * @param camera defines the camera to use (can be null)
  161023. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  161024. * @param engine defines the hosting engine (can be ignore if camera is set)
  161025. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  161026. */
  161027. constructor(name: string, _operator: TonemappingOperator,
  161028. /** Defines the required exposure adjustement */
  161029. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  161030. }
  161031. }
  161032. declare module BABYLON {
  161033. /** @hidden */
  161034. export var volumetricLightScatteringPixelShader: {
  161035. name: string;
  161036. shader: string;
  161037. };
  161038. }
  161039. declare module BABYLON {
  161040. /** @hidden */
  161041. export var volumetricLightScatteringPassVertexShader: {
  161042. name: string;
  161043. shader: string;
  161044. };
  161045. }
  161046. declare module BABYLON {
  161047. /** @hidden */
  161048. export var volumetricLightScatteringPassPixelShader: {
  161049. name: string;
  161050. shader: string;
  161051. };
  161052. }
  161053. declare module BABYLON {
  161054. /**
  161055. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  161056. */
  161057. export class VolumetricLightScatteringPostProcess extends PostProcess {
  161058. private _volumetricLightScatteringPass;
  161059. private _volumetricLightScatteringRTT;
  161060. private _viewPort;
  161061. private _screenCoordinates;
  161062. private _cachedDefines;
  161063. /**
  161064. * If not undefined, the mesh position is computed from the attached node position
  161065. */
  161066. attachedNode: {
  161067. position: Vector3;
  161068. };
  161069. /**
  161070. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  161071. */
  161072. customMeshPosition: Vector3;
  161073. /**
  161074. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  161075. */
  161076. useCustomMeshPosition: boolean;
  161077. /**
  161078. * If the post-process should inverse the light scattering direction
  161079. */
  161080. invert: boolean;
  161081. /**
  161082. * The internal mesh used by the post-process
  161083. */
  161084. mesh: Mesh;
  161085. /**
  161086. * @hidden
  161087. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  161088. */
  161089. get useDiffuseColor(): boolean;
  161090. set useDiffuseColor(useDiffuseColor: boolean);
  161091. /**
  161092. * Array containing the excluded meshes not rendered in the internal pass
  161093. */
  161094. excludedMeshes: AbstractMesh[];
  161095. /**
  161096. * Controls the overall intensity of the post-process
  161097. */
  161098. exposure: number;
  161099. /**
  161100. * Dissipates each sample's contribution in range [0, 1]
  161101. */
  161102. decay: number;
  161103. /**
  161104. * Controls the overall intensity of each sample
  161105. */
  161106. weight: number;
  161107. /**
  161108. * Controls the density of each sample
  161109. */
  161110. density: number;
  161111. /**
  161112. * @constructor
  161113. * @param name The post-process name
  161114. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  161115. * @param camera The camera that the post-process will be attached to
  161116. * @param mesh The mesh used to create the light scattering
  161117. * @param samples The post-process quality, default 100
  161118. * @param samplingModeThe post-process filtering mode
  161119. * @param engine The babylon engine
  161120. * @param reusable If the post-process is reusable
  161121. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  161122. */
  161123. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  161124. /**
  161125. * Returns the string "VolumetricLightScatteringPostProcess"
  161126. * @returns "VolumetricLightScatteringPostProcess"
  161127. */
  161128. getClassName(): string;
  161129. private _isReady;
  161130. /**
  161131. * Sets the new light position for light scattering effect
  161132. * @param position The new custom light position
  161133. */
  161134. setCustomMeshPosition(position: Vector3): void;
  161135. /**
  161136. * Returns the light position for light scattering effect
  161137. * @return Vector3 The custom light position
  161138. */
  161139. getCustomMeshPosition(): Vector3;
  161140. /**
  161141. * Disposes the internal assets and detaches the post-process from the camera
  161142. */
  161143. dispose(camera: Camera): void;
  161144. /**
  161145. * Returns the render target texture used by the post-process
  161146. * @return the render target texture used by the post-process
  161147. */
  161148. getPass(): RenderTargetTexture;
  161149. private _meshExcluded;
  161150. private _createPass;
  161151. private _updateMeshScreenCoordinates;
  161152. /**
  161153. * Creates a default mesh for the Volumeric Light Scattering post-process
  161154. * @param name The mesh name
  161155. * @param scene The scene where to create the mesh
  161156. * @return the default mesh
  161157. */
  161158. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  161159. }
  161160. }
  161161. declare module BABYLON {
  161162. /** @hidden */
  161163. export var screenSpaceCurvaturePixelShader: {
  161164. name: string;
  161165. shader: string;
  161166. };
  161167. }
  161168. declare module BABYLON {
  161169. /**
  161170. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  161171. */
  161172. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  161173. /**
  161174. * Defines how much ridge the curvature effect displays.
  161175. */
  161176. ridge: number;
  161177. /**
  161178. * Defines how much valley the curvature effect displays.
  161179. */
  161180. valley: number;
  161181. private _geometryBufferRenderer;
  161182. /**
  161183. * Gets a string identifying the name of the class
  161184. * @returns "ScreenSpaceCurvaturePostProcess" string
  161185. */
  161186. getClassName(): string;
  161187. /**
  161188. * Creates a new instance ScreenSpaceCurvaturePostProcess
  161189. * @param name The name of the effect.
  161190. * @param scene The scene containing the objects to blur according to their velocity.
  161191. * @param options The required width/height ratio to downsize to before computing the render pass.
  161192. * @param camera The camera to apply the render pass to.
  161193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  161194. * @param engine The engine which the post process will be applied. (default: current engine)
  161195. * @param reusable If the post process can be reused on the same frame. (default: false)
  161196. * @param textureType Type of textures used when performing the post process. (default: 0)
  161197. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  161198. */
  161199. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  161200. /**
  161201. * Support test.
  161202. */
  161203. static get IsSupported(): boolean;
  161204. /** @hidden */
  161205. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  161206. }
  161207. }
  161208. declare module BABYLON {
  161209. interface Scene {
  161210. /** @hidden (Backing field) */
  161211. _boundingBoxRenderer: BoundingBoxRenderer;
  161212. /** @hidden (Backing field) */
  161213. _forceShowBoundingBoxes: boolean;
  161214. /**
  161215. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  161216. */
  161217. forceShowBoundingBoxes: boolean;
  161218. /**
  161219. * Gets the bounding box renderer associated with the scene
  161220. * @returns a BoundingBoxRenderer
  161221. */
  161222. getBoundingBoxRenderer(): BoundingBoxRenderer;
  161223. }
  161224. interface AbstractMesh {
  161225. /** @hidden (Backing field) */
  161226. _showBoundingBox: boolean;
  161227. /**
  161228. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  161229. */
  161230. showBoundingBox: boolean;
  161231. }
  161232. /**
  161233. * Component responsible of rendering the bounding box of the meshes in a scene.
  161234. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  161235. */
  161236. export class BoundingBoxRenderer implements ISceneComponent {
  161237. /**
  161238. * The component name helpfull to identify the component in the list of scene components.
  161239. */
  161240. readonly name: string;
  161241. /**
  161242. * The scene the component belongs to.
  161243. */
  161244. scene: Scene;
  161245. /**
  161246. * Color of the bounding box lines placed in front of an object
  161247. */
  161248. frontColor: Color3;
  161249. /**
  161250. * Color of the bounding box lines placed behind an object
  161251. */
  161252. backColor: Color3;
  161253. /**
  161254. * Defines if the renderer should show the back lines or not
  161255. */
  161256. showBackLines: boolean;
  161257. /**
  161258. * Observable raised before rendering a bounding box
  161259. */
  161260. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  161261. /**
  161262. * Observable raised after rendering a bounding box
  161263. */
  161264. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  161265. /**
  161266. * Observable raised after resources are created
  161267. */
  161268. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  161269. /**
  161270. * When false, no bounding boxes will be rendered
  161271. */
  161272. enabled: boolean;
  161273. /**
  161274. * @hidden
  161275. */
  161276. renderList: SmartArray<BoundingBox>;
  161277. private _colorShader;
  161278. private _vertexBuffers;
  161279. private _indexBuffer;
  161280. private _fillIndexBuffer;
  161281. private _fillIndexData;
  161282. /**
  161283. * Instantiates a new bounding box renderer in a scene.
  161284. * @param scene the scene the renderer renders in
  161285. */
  161286. constructor(scene: Scene);
  161287. /**
  161288. * Registers the component in a given scene
  161289. */
  161290. register(): void;
  161291. private _evaluateSubMesh;
  161292. private _preActiveMesh;
  161293. private _prepareResources;
  161294. private _createIndexBuffer;
  161295. /**
  161296. * Rebuilds the elements related to this component in case of
  161297. * context lost for instance.
  161298. */
  161299. rebuild(): void;
  161300. /**
  161301. * @hidden
  161302. */
  161303. reset(): void;
  161304. /**
  161305. * Render the bounding boxes of a specific rendering group
  161306. * @param renderingGroupId defines the rendering group to render
  161307. */
  161308. render(renderingGroupId: number): void;
  161309. /**
  161310. * In case of occlusion queries, we can render the occlusion bounding box through this method
  161311. * @param mesh Define the mesh to render the occlusion bounding box for
  161312. */
  161313. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  161314. /**
  161315. * Dispose and release the resources attached to this renderer.
  161316. */
  161317. dispose(): void;
  161318. }
  161319. }
  161320. declare module BABYLON {
  161321. interface Scene {
  161322. /** @hidden (Backing field) */
  161323. _depthRenderer: {
  161324. [id: string]: DepthRenderer;
  161325. };
  161326. /**
  161327. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  161328. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  161329. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  161330. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  161331. * @returns the created depth renderer
  161332. */
  161333. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  161334. /**
  161335. * Disables a depth renderer for a given camera
  161336. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  161337. */
  161338. disableDepthRenderer(camera?: Nullable<Camera>): void;
  161339. }
  161340. /**
  161341. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  161342. * in several rendering techniques.
  161343. */
  161344. export class DepthRendererSceneComponent implements ISceneComponent {
  161345. /**
  161346. * The component name helpfull to identify the component in the list of scene components.
  161347. */
  161348. readonly name: string;
  161349. /**
  161350. * The scene the component belongs to.
  161351. */
  161352. scene: Scene;
  161353. /**
  161354. * Creates a new instance of the component for the given scene
  161355. * @param scene Defines the scene to register the component in
  161356. */
  161357. constructor(scene: Scene);
  161358. /**
  161359. * Registers the component in a given scene
  161360. */
  161361. register(): void;
  161362. /**
  161363. * Rebuilds the elements related to this component in case of
  161364. * context lost for instance.
  161365. */
  161366. rebuild(): void;
  161367. /**
  161368. * Disposes the component and the associated ressources
  161369. */
  161370. dispose(): void;
  161371. private _gatherRenderTargets;
  161372. private _gatherActiveCameraRenderTargets;
  161373. }
  161374. }
  161375. declare module BABYLON {
  161376. interface AbstractScene {
  161377. /** @hidden (Backing field) */
  161378. _prePassRenderer: Nullable<PrePassRenderer>;
  161379. /**
  161380. * Gets or Sets the current prepass renderer associated to the scene.
  161381. */
  161382. prePassRenderer: Nullable<PrePassRenderer>;
  161383. /**
  161384. * Enables the prepass and associates it with the scene
  161385. * @returns the PrePassRenderer
  161386. */
  161387. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  161388. /**
  161389. * Disables the prepass associated with the scene
  161390. */
  161391. disablePrePassRenderer(): void;
  161392. }
  161393. /**
  161394. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  161395. * in several rendering techniques.
  161396. */
  161397. export class PrePassRendererSceneComponent implements ISceneComponent {
  161398. /**
  161399. * The component name helpful to identify the component in the list of scene components.
  161400. */
  161401. readonly name: string;
  161402. /**
  161403. * The scene the component belongs to.
  161404. */
  161405. scene: Scene;
  161406. /**
  161407. * Creates a new instance of the component for the given scene
  161408. * @param scene Defines the scene to register the component in
  161409. */
  161410. constructor(scene: Scene);
  161411. /**
  161412. * Registers the component in a given scene
  161413. */
  161414. register(): void;
  161415. private _beforeCameraDraw;
  161416. private _afterCameraDraw;
  161417. private _beforeClearStage;
  161418. private _beforeRenderingMeshStage;
  161419. private _afterRenderingMeshStage;
  161420. /**
  161421. * Rebuilds the elements related to this component in case of
  161422. * context lost for instance.
  161423. */
  161424. rebuild(): void;
  161425. /**
  161426. * Disposes the component and the associated ressources
  161427. */
  161428. dispose(): void;
  161429. }
  161430. }
  161431. declare module BABYLON {
  161432. /** @hidden */
  161433. export var fibonacci: {
  161434. name: string;
  161435. shader: string;
  161436. };
  161437. }
  161438. declare module BABYLON {
  161439. /** @hidden */
  161440. export var diffusionProfile: {
  161441. name: string;
  161442. shader: string;
  161443. };
  161444. }
  161445. declare module BABYLON {
  161446. /** @hidden */
  161447. export var subSurfaceScatteringPixelShader: {
  161448. name: string;
  161449. shader: string;
  161450. };
  161451. }
  161452. declare module BABYLON {
  161453. /**
  161454. * Sub surface scattering post process
  161455. */
  161456. export class SubSurfaceScatteringPostProcess extends PostProcess {
  161457. /**
  161458. * Gets a string identifying the name of the class
  161459. * @returns "SubSurfaceScatteringPostProcess" string
  161460. */
  161461. getClassName(): string;
  161462. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  161463. }
  161464. }
  161465. declare module BABYLON {
  161466. /**
  161467. * Contains all parameters needed for the prepass to perform
  161468. * screen space subsurface scattering
  161469. */
  161470. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  161471. /** @hidden */
  161472. static _SceneComponentInitialization: (scene: Scene) => void;
  161473. private _ssDiffusionS;
  161474. private _ssFilterRadii;
  161475. private _ssDiffusionD;
  161476. /**
  161477. * Post process to attach for screen space subsurface scattering
  161478. */
  161479. postProcess: SubSurfaceScatteringPostProcess;
  161480. /**
  161481. * Diffusion profile color for subsurface scattering
  161482. */
  161483. get ssDiffusionS(): number[];
  161484. /**
  161485. * Diffusion profile max color channel value for subsurface scattering
  161486. */
  161487. get ssDiffusionD(): number[];
  161488. /**
  161489. * Diffusion profile filter radius for subsurface scattering
  161490. */
  161491. get ssFilterRadii(): number[];
  161492. /**
  161493. * Is subsurface enabled
  161494. */
  161495. enabled: boolean;
  161496. /**
  161497. * Name of the configuration
  161498. */
  161499. name: string;
  161500. /**
  161501. * Diffusion profile colors for subsurface scattering
  161502. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  161503. * See ...
  161504. * Note that you can only store up to 5 of them
  161505. */
  161506. ssDiffusionProfileColors: Color3[];
  161507. /**
  161508. * Defines the ratio real world => scene units.
  161509. * Used for subsurface scattering
  161510. */
  161511. metersPerUnit: number;
  161512. /**
  161513. * Textures that should be present in the MRT for this effect to work
  161514. */
  161515. readonly texturesRequired: number[];
  161516. private _scene;
  161517. /**
  161518. * Builds a subsurface configuration object
  161519. * @param scene The scene
  161520. */
  161521. constructor(scene: Scene);
  161522. /**
  161523. * Adds a new diffusion profile.
  161524. * Useful for more realistic subsurface scattering on diverse materials.
  161525. * @param color The color of the diffusion profile. Should be the average color of the material.
  161526. * @return The index of the diffusion profile for the material subsurface configuration
  161527. */
  161528. addDiffusionProfile(color: Color3): number;
  161529. /**
  161530. * Creates the sss post process
  161531. * @return The created post process
  161532. */
  161533. createPostProcess(): SubSurfaceScatteringPostProcess;
  161534. /**
  161535. * Deletes all diffusion profiles.
  161536. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  161537. */
  161538. clearAllDiffusionProfiles(): void;
  161539. /**
  161540. * Disposes this object
  161541. */
  161542. dispose(): void;
  161543. /**
  161544. * @hidden
  161545. * https://zero-radiance.github.io/post/sampling-diffusion/
  161546. *
  161547. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  161548. * ------------------------------------------------------------------------------------
  161549. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  161550. * PDF[r, phi, s] = r * R[r, phi, s]
  161551. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  161552. * ------------------------------------------------------------------------------------
  161553. * We importance sample the color channel with the widest scattering distance.
  161554. */
  161555. getDiffusionProfileParameters(color: Color3): number;
  161556. /**
  161557. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  161558. * 'u' is the random number (the value of the CDF): [0, 1).
  161559. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  161560. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  161561. */
  161562. private _sampleBurleyDiffusionProfile;
  161563. }
  161564. }
  161565. declare module BABYLON {
  161566. interface AbstractScene {
  161567. /** @hidden (Backing field) */
  161568. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  161569. /**
  161570. * Gets or Sets the current prepass renderer associated to the scene.
  161571. */
  161572. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  161573. /**
  161574. * Enables the subsurface effect for prepass
  161575. * @returns the SubSurfaceConfiguration
  161576. */
  161577. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  161578. /**
  161579. * Disables the subsurface effect for prepass
  161580. */
  161581. disableSubSurfaceForPrePass(): void;
  161582. }
  161583. /**
  161584. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  161585. * in several rendering techniques.
  161586. */
  161587. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  161588. /**
  161589. * The component name helpful to identify the component in the list of scene components.
  161590. */
  161591. readonly name: string;
  161592. /**
  161593. * The scene the component belongs to.
  161594. */
  161595. scene: Scene;
  161596. /**
  161597. * Creates a new instance of the component for the given scene
  161598. * @param scene Defines the scene to register the component in
  161599. */
  161600. constructor(scene: Scene);
  161601. /**
  161602. * Registers the component in a given scene
  161603. */
  161604. register(): void;
  161605. /**
  161606. * Serializes the component data to the specified json object
  161607. * @param serializationObject The object to serialize to
  161608. */
  161609. serialize(serializationObject: any): void;
  161610. /**
  161611. * Adds all the elements from the container to the scene
  161612. * @param container the container holding the elements
  161613. */
  161614. addFromContainer(container: AbstractScene): void;
  161615. /**
  161616. * Removes all the elements in the container from the scene
  161617. * @param container contains the elements to remove
  161618. * @param dispose if the removed element should be disposed (default: false)
  161619. */
  161620. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  161621. /**
  161622. * Rebuilds the elements related to this component in case of
  161623. * context lost for instance.
  161624. */
  161625. rebuild(): void;
  161626. /**
  161627. * Disposes the component and the associated ressources
  161628. */
  161629. dispose(): void;
  161630. }
  161631. }
  161632. declare module BABYLON {
  161633. /** @hidden */
  161634. export var outlinePixelShader: {
  161635. name: string;
  161636. shader: string;
  161637. };
  161638. }
  161639. declare module BABYLON {
  161640. /** @hidden */
  161641. export var outlineVertexShader: {
  161642. name: string;
  161643. shader: string;
  161644. };
  161645. }
  161646. declare module BABYLON {
  161647. interface Scene {
  161648. /** @hidden */
  161649. _outlineRenderer: OutlineRenderer;
  161650. /**
  161651. * Gets the outline renderer associated with the scene
  161652. * @returns a OutlineRenderer
  161653. */
  161654. getOutlineRenderer(): OutlineRenderer;
  161655. }
  161656. interface AbstractMesh {
  161657. /** @hidden (Backing field) */
  161658. _renderOutline: boolean;
  161659. /**
  161660. * Gets or sets a boolean indicating if the outline must be rendered as well
  161661. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  161662. */
  161663. renderOutline: boolean;
  161664. /** @hidden (Backing field) */
  161665. _renderOverlay: boolean;
  161666. /**
  161667. * Gets or sets a boolean indicating if the overlay must be rendered as well
  161668. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  161669. */
  161670. renderOverlay: boolean;
  161671. }
  161672. /**
  161673. * This class is responsible to draw bothe outline/overlay of meshes.
  161674. * It should not be used directly but through the available method on mesh.
  161675. */
  161676. export class OutlineRenderer implements ISceneComponent {
  161677. /**
  161678. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  161679. */
  161680. private static _StencilReference;
  161681. /**
  161682. * The name of the component. Each component must have a unique name.
  161683. */
  161684. name: string;
  161685. /**
  161686. * The scene the component belongs to.
  161687. */
  161688. scene: Scene;
  161689. /**
  161690. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  161691. */
  161692. zOffset: number;
  161693. private _engine;
  161694. private _effect;
  161695. private _cachedDefines;
  161696. private _savedDepthWrite;
  161697. /**
  161698. * Instantiates a new outline renderer. (There could be only one per scene).
  161699. * @param scene Defines the scene it belongs to
  161700. */
  161701. constructor(scene: Scene);
  161702. /**
  161703. * Register the component to one instance of a scene.
  161704. */
  161705. register(): void;
  161706. /**
  161707. * Rebuilds the elements related to this component in case of
  161708. * context lost for instance.
  161709. */
  161710. rebuild(): void;
  161711. /**
  161712. * Disposes the component and the associated ressources.
  161713. */
  161714. dispose(): void;
  161715. /**
  161716. * Renders the outline in the canvas.
  161717. * @param subMesh Defines the sumesh to render
  161718. * @param batch Defines the batch of meshes in case of instances
  161719. * @param useOverlay Defines if the rendering is for the overlay or the outline
  161720. */
  161721. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  161722. /**
  161723. * Returns whether or not the outline renderer is ready for a given submesh.
  161724. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  161725. * @param subMesh Defines the submesh to check readyness for
  161726. * @param useInstances Defines wheter wee are trying to render instances or not
  161727. * @returns true if ready otherwise false
  161728. */
  161729. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  161730. private _beforeRenderingMesh;
  161731. private _afterRenderingMesh;
  161732. }
  161733. }
  161734. declare module BABYLON {
  161735. /**
  161736. * Defines the basic options interface of a Sprite Frame Source Size.
  161737. */
  161738. export interface ISpriteJSONSpriteSourceSize {
  161739. /**
  161740. * number of the original width of the Frame
  161741. */
  161742. w: number;
  161743. /**
  161744. * number of the original height of the Frame
  161745. */
  161746. h: number;
  161747. }
  161748. /**
  161749. * Defines the basic options interface of a Sprite Frame Data.
  161750. */
  161751. export interface ISpriteJSONSpriteFrameData {
  161752. /**
  161753. * number of the x offset of the Frame
  161754. */
  161755. x: number;
  161756. /**
  161757. * number of the y offset of the Frame
  161758. */
  161759. y: number;
  161760. /**
  161761. * number of the width of the Frame
  161762. */
  161763. w: number;
  161764. /**
  161765. * number of the height of the Frame
  161766. */
  161767. h: number;
  161768. }
  161769. /**
  161770. * Defines the basic options interface of a JSON Sprite.
  161771. */
  161772. export interface ISpriteJSONSprite {
  161773. /**
  161774. * string name of the Frame
  161775. */
  161776. filename: string;
  161777. /**
  161778. * ISpriteJSONSpriteFrame basic object of the frame data
  161779. */
  161780. frame: ISpriteJSONSpriteFrameData;
  161781. /**
  161782. * boolean to flag is the frame was rotated.
  161783. */
  161784. rotated: boolean;
  161785. /**
  161786. * boolean to flag is the frame was trimmed.
  161787. */
  161788. trimmed: boolean;
  161789. /**
  161790. * ISpriteJSONSpriteFrame basic object of the source data
  161791. */
  161792. spriteSourceSize: ISpriteJSONSpriteFrameData;
  161793. /**
  161794. * ISpriteJSONSpriteFrame basic object of the source data
  161795. */
  161796. sourceSize: ISpriteJSONSpriteSourceSize;
  161797. }
  161798. /**
  161799. * Defines the basic options interface of a JSON atlas.
  161800. */
  161801. export interface ISpriteJSONAtlas {
  161802. /**
  161803. * Array of objects that contain the frame data.
  161804. */
  161805. frames: Array<ISpriteJSONSprite>;
  161806. /**
  161807. * object basic object containing the sprite meta data.
  161808. */
  161809. meta?: object;
  161810. }
  161811. }
  161812. declare module BABYLON {
  161813. /** @hidden */
  161814. export var spriteMapPixelShader: {
  161815. name: string;
  161816. shader: string;
  161817. };
  161818. }
  161819. declare module BABYLON {
  161820. /** @hidden */
  161821. export var spriteMapVertexShader: {
  161822. name: string;
  161823. shader: string;
  161824. };
  161825. }
  161826. declare module BABYLON {
  161827. /**
  161828. * Defines the basic options interface of a SpriteMap
  161829. */
  161830. export interface ISpriteMapOptions {
  161831. /**
  161832. * Vector2 of the number of cells in the grid.
  161833. */
  161834. stageSize?: Vector2;
  161835. /**
  161836. * Vector2 of the size of the output plane in World Units.
  161837. */
  161838. outputSize?: Vector2;
  161839. /**
  161840. * Vector3 of the position of the output plane in World Units.
  161841. */
  161842. outputPosition?: Vector3;
  161843. /**
  161844. * Vector3 of the rotation of the output plane.
  161845. */
  161846. outputRotation?: Vector3;
  161847. /**
  161848. * number of layers that the system will reserve in resources.
  161849. */
  161850. layerCount?: number;
  161851. /**
  161852. * number of max animation frames a single cell will reserve in resources.
  161853. */
  161854. maxAnimationFrames?: number;
  161855. /**
  161856. * number cell index of the base tile when the system compiles.
  161857. */
  161858. baseTile?: number;
  161859. /**
  161860. * boolean flip the sprite after its been repositioned by the framing data.
  161861. */
  161862. flipU?: boolean;
  161863. /**
  161864. * Vector3 scalar of the global RGB values of the SpriteMap.
  161865. */
  161866. colorMultiply?: Vector3;
  161867. }
  161868. /**
  161869. * Defines the IDisposable interface in order to be cleanable from resources.
  161870. */
  161871. export interface ISpriteMap extends IDisposable {
  161872. /**
  161873. * String name of the SpriteMap.
  161874. */
  161875. name: string;
  161876. /**
  161877. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  161878. */
  161879. atlasJSON: ISpriteJSONAtlas;
  161880. /**
  161881. * Texture of the SpriteMap.
  161882. */
  161883. spriteSheet: Texture;
  161884. /**
  161885. * The parameters to initialize the SpriteMap with.
  161886. */
  161887. options: ISpriteMapOptions;
  161888. }
  161889. /**
  161890. * Class used to manage a grid restricted sprite deployment on an Output plane.
  161891. */
  161892. export class SpriteMap implements ISpriteMap {
  161893. /** The Name of the spriteMap */
  161894. name: string;
  161895. /** The JSON file with the frame and meta data */
  161896. atlasJSON: ISpriteJSONAtlas;
  161897. /** The systems Sprite Sheet Texture */
  161898. spriteSheet: Texture;
  161899. /** Arguments passed with the Constructor */
  161900. options: ISpriteMapOptions;
  161901. /** Public Sprite Storage array, parsed from atlasJSON */
  161902. sprites: Array<ISpriteJSONSprite>;
  161903. /** Returns the Number of Sprites in the System */
  161904. get spriteCount(): number;
  161905. /** Returns the Position of Output Plane*/
  161906. get position(): Vector3;
  161907. /** Returns the Position of Output Plane*/
  161908. set position(v: Vector3);
  161909. /** Returns the Rotation of Output Plane*/
  161910. get rotation(): Vector3;
  161911. /** Returns the Rotation of Output Plane*/
  161912. set rotation(v: Vector3);
  161913. /** Sets the AnimationMap*/
  161914. get animationMap(): RawTexture;
  161915. /** Sets the AnimationMap*/
  161916. set animationMap(v: RawTexture);
  161917. /** Scene that the SpriteMap was created in */
  161918. private _scene;
  161919. /** Texture Buffer of Float32 that holds tile frame data*/
  161920. private _frameMap;
  161921. /** Texture Buffers of Float32 that holds tileMap data*/
  161922. private _tileMaps;
  161923. /** Texture Buffer of Float32 that holds Animation Data*/
  161924. private _animationMap;
  161925. /** Custom ShaderMaterial Central to the System*/
  161926. private _material;
  161927. /** Custom ShaderMaterial Central to the System*/
  161928. private _output;
  161929. /** Systems Time Ticker*/
  161930. private _time;
  161931. /**
  161932. * Creates a new SpriteMap
  161933. * @param name defines the SpriteMaps Name
  161934. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  161935. * @param spriteSheet is the Texture that the Sprites are on.
  161936. * @param options a basic deployment configuration
  161937. * @param scene The Scene that the map is deployed on
  161938. */
  161939. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  161940. /**
  161941. * Returns tileID location
  161942. * @returns Vector2 the cell position ID
  161943. */
  161944. getTileID(): Vector2;
  161945. /**
  161946. * Gets the UV location of the mouse over the SpriteMap.
  161947. * @returns Vector2 the UV position of the mouse interaction
  161948. */
  161949. getMousePosition(): Vector2;
  161950. /**
  161951. * Creates the "frame" texture Buffer
  161952. * -------------------------------------
  161953. * Structure of frames
  161954. * "filename": "Falling-Water-2.png",
  161955. * "frame": {"x":69,"y":103,"w":24,"h":32},
  161956. * "rotated": true,
  161957. * "trimmed": true,
  161958. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  161959. * "sourceSize": {"w":32,"h":32}
  161960. * @returns RawTexture of the frameMap
  161961. */
  161962. private _createFrameBuffer;
  161963. /**
  161964. * Creates the tileMap texture Buffer
  161965. * @param buffer normally and array of numbers, or a false to generate from scratch
  161966. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  161967. * @returns RawTexture of the tileMap
  161968. */
  161969. private _createTileBuffer;
  161970. /**
  161971. * Modifies the data of the tileMaps
  161972. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  161973. * @param pos is the iVector2 Coordinates of the Tile
  161974. * @param tile The SpriteIndex of the new Tile
  161975. */
  161976. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  161977. /**
  161978. * Creates the animationMap texture Buffer
  161979. * @param buffer normally and array of numbers, or a false to generate from scratch
  161980. * @returns RawTexture of the animationMap
  161981. */
  161982. private _createTileAnimationBuffer;
  161983. /**
  161984. * Modifies the data of the animationMap
  161985. * @param cellID is the Index of the Sprite
  161986. * @param _frame is the target Animation frame
  161987. * @param toCell is the Target Index of the next frame of the animation
  161988. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  161989. * @param speed is a global scalar of the time variable on the map.
  161990. */
  161991. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  161992. /**
  161993. * Exports the .tilemaps file
  161994. */
  161995. saveTileMaps(): void;
  161996. /**
  161997. * Imports the .tilemaps file
  161998. * @param url of the .tilemaps file
  161999. */
  162000. loadTileMaps(url: string): void;
  162001. /**
  162002. * Release associated resources
  162003. */
  162004. dispose(): void;
  162005. }
  162006. }
  162007. declare module BABYLON {
  162008. /**
  162009. * Class used to manage multiple sprites of different sizes on the same spritesheet
  162010. * @see https://doc.babylonjs.com/babylon101/sprites
  162011. */
  162012. export class SpritePackedManager extends SpriteManager {
  162013. /** defines the packed manager's name */
  162014. name: string;
  162015. /**
  162016. * Creates a new sprite manager from a packed sprite sheet
  162017. * @param name defines the manager's name
  162018. * @param imgUrl defines the sprite sheet url
  162019. * @param capacity defines the maximum allowed number of sprites
  162020. * @param scene defines the hosting scene
  162021. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  162022. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  162023. * @param samplingMode defines the smapling mode to use with spritesheet
  162024. * @param fromPacked set to true; do not alter
  162025. */
  162026. constructor(
  162027. /** defines the packed manager's name */
  162028. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  162029. }
  162030. }
  162031. declare module BABYLON {
  162032. /**
  162033. * Defines the list of states available for a task inside a AssetsManager
  162034. */
  162035. export enum AssetTaskState {
  162036. /**
  162037. * Initialization
  162038. */
  162039. INIT = 0,
  162040. /**
  162041. * Running
  162042. */
  162043. RUNNING = 1,
  162044. /**
  162045. * Done
  162046. */
  162047. DONE = 2,
  162048. /**
  162049. * Error
  162050. */
  162051. ERROR = 3
  162052. }
  162053. /**
  162054. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  162055. */
  162056. export abstract class AbstractAssetTask {
  162057. /**
  162058. * Task name
  162059. */ name: string;
  162060. /**
  162061. * Callback called when the task is successful
  162062. */
  162063. onSuccess: (task: any) => void;
  162064. /**
  162065. * Callback called when the task is not successful
  162066. */
  162067. onError: (task: any, message?: string, exception?: any) => void;
  162068. /**
  162069. * Creates a new AssetsManager
  162070. * @param name defines the name of the task
  162071. */
  162072. constructor(
  162073. /**
  162074. * Task name
  162075. */ name: string);
  162076. private _isCompleted;
  162077. private _taskState;
  162078. private _errorObject;
  162079. /**
  162080. * Get if the task is completed
  162081. */
  162082. get isCompleted(): boolean;
  162083. /**
  162084. * Gets the current state of the task
  162085. */
  162086. get taskState(): AssetTaskState;
  162087. /**
  162088. * Gets the current error object (if task is in error)
  162089. */
  162090. get errorObject(): {
  162091. message?: string;
  162092. exception?: any;
  162093. };
  162094. /**
  162095. * Internal only
  162096. * @hidden
  162097. */
  162098. _setErrorObject(message?: string, exception?: any): void;
  162099. /**
  162100. * Execute the current task
  162101. * @param scene defines the scene where you want your assets to be loaded
  162102. * @param onSuccess is a callback called when the task is successfully executed
  162103. * @param onError is a callback called if an error occurs
  162104. */
  162105. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162106. /**
  162107. * Execute the current task
  162108. * @param scene defines the scene where you want your assets to be loaded
  162109. * @param onSuccess is a callback called when the task is successfully executed
  162110. * @param onError is a callback called if an error occurs
  162111. */
  162112. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162113. /**
  162114. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  162115. * This can be used with failed tasks that have the reason for failure fixed.
  162116. */
  162117. reset(): void;
  162118. private onErrorCallback;
  162119. private onDoneCallback;
  162120. }
  162121. /**
  162122. * Define the interface used by progress events raised during assets loading
  162123. */
  162124. export interface IAssetsProgressEvent {
  162125. /**
  162126. * Defines the number of remaining tasks to process
  162127. */
  162128. remainingCount: number;
  162129. /**
  162130. * Defines the total number of tasks
  162131. */
  162132. totalCount: number;
  162133. /**
  162134. * Defines the task that was just processed
  162135. */
  162136. task: AbstractAssetTask;
  162137. }
  162138. /**
  162139. * Class used to share progress information about assets loading
  162140. */
  162141. export class AssetsProgressEvent implements IAssetsProgressEvent {
  162142. /**
  162143. * Defines the number of remaining tasks to process
  162144. */
  162145. remainingCount: number;
  162146. /**
  162147. * Defines the total number of tasks
  162148. */
  162149. totalCount: number;
  162150. /**
  162151. * Defines the task that was just processed
  162152. */
  162153. task: AbstractAssetTask;
  162154. /**
  162155. * Creates a AssetsProgressEvent
  162156. * @param remainingCount defines the number of remaining tasks to process
  162157. * @param totalCount defines the total number of tasks
  162158. * @param task defines the task that was just processed
  162159. */
  162160. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  162161. }
  162162. /**
  162163. * Define a task used by AssetsManager to load assets into a container
  162164. */
  162165. export class ContainerAssetTask extends AbstractAssetTask {
  162166. /**
  162167. * Defines the name of the task
  162168. */
  162169. name: string;
  162170. /**
  162171. * Defines the list of mesh's names you want to load
  162172. */
  162173. meshesNames: any;
  162174. /**
  162175. * Defines the root url to use as a base to load your meshes and associated resources
  162176. */
  162177. rootUrl: string;
  162178. /**
  162179. * Defines the filename or File of the scene to load from
  162180. */
  162181. sceneFilename: string | File;
  162182. /**
  162183. * Get the loaded asset container
  162184. */
  162185. loadedContainer: AssetContainer;
  162186. /**
  162187. * Gets the list of loaded meshes
  162188. */
  162189. loadedMeshes: Array<AbstractMesh>;
  162190. /**
  162191. * Gets the list of loaded particle systems
  162192. */
  162193. loadedParticleSystems: Array<IParticleSystem>;
  162194. /**
  162195. * Gets the list of loaded skeletons
  162196. */
  162197. loadedSkeletons: Array<Skeleton>;
  162198. /**
  162199. * Gets the list of loaded animation groups
  162200. */
  162201. loadedAnimationGroups: Array<AnimationGroup>;
  162202. /**
  162203. * Callback called when the task is successful
  162204. */
  162205. onSuccess: (task: ContainerAssetTask) => void;
  162206. /**
  162207. * Callback called when the task is successful
  162208. */
  162209. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  162210. /**
  162211. * Creates a new ContainerAssetTask
  162212. * @param name defines the name of the task
  162213. * @param meshesNames defines the list of mesh's names you want to load
  162214. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  162215. * @param sceneFilename defines the filename or File of the scene to load from
  162216. */
  162217. constructor(
  162218. /**
  162219. * Defines the name of the task
  162220. */
  162221. name: string,
  162222. /**
  162223. * Defines the list of mesh's names you want to load
  162224. */
  162225. meshesNames: any,
  162226. /**
  162227. * Defines the root url to use as a base to load your meshes and associated resources
  162228. */
  162229. rootUrl: string,
  162230. /**
  162231. * Defines the filename or File of the scene to load from
  162232. */
  162233. sceneFilename: string | File);
  162234. /**
  162235. * Execute the current task
  162236. * @param scene defines the scene where you want your assets to be loaded
  162237. * @param onSuccess is a callback called when the task is successfully executed
  162238. * @param onError is a callback called if an error occurs
  162239. */
  162240. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162241. }
  162242. /**
  162243. * Define a task used by AssetsManager to load meshes
  162244. */
  162245. export class MeshAssetTask extends AbstractAssetTask {
  162246. /**
  162247. * Defines the name of the task
  162248. */
  162249. name: string;
  162250. /**
  162251. * Defines the list of mesh's names you want to load
  162252. */
  162253. meshesNames: any;
  162254. /**
  162255. * Defines the root url to use as a base to load your meshes and associated resources
  162256. */
  162257. rootUrl: string;
  162258. /**
  162259. * Defines the filename or File of the scene to load from
  162260. */
  162261. sceneFilename: string | File;
  162262. /**
  162263. * Gets the list of loaded meshes
  162264. */
  162265. loadedMeshes: Array<AbstractMesh>;
  162266. /**
  162267. * Gets the list of loaded particle systems
  162268. */
  162269. loadedParticleSystems: Array<IParticleSystem>;
  162270. /**
  162271. * Gets the list of loaded skeletons
  162272. */
  162273. loadedSkeletons: Array<Skeleton>;
  162274. /**
  162275. * Gets the list of loaded animation groups
  162276. */
  162277. loadedAnimationGroups: Array<AnimationGroup>;
  162278. /**
  162279. * Callback called when the task is successful
  162280. */
  162281. onSuccess: (task: MeshAssetTask) => void;
  162282. /**
  162283. * Callback called when the task is successful
  162284. */
  162285. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  162286. /**
  162287. * Creates a new MeshAssetTask
  162288. * @param name defines the name of the task
  162289. * @param meshesNames defines the list of mesh's names you want to load
  162290. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  162291. * @param sceneFilename defines the filename or File of the scene to load from
  162292. */
  162293. constructor(
  162294. /**
  162295. * Defines the name of the task
  162296. */
  162297. name: string,
  162298. /**
  162299. * Defines the list of mesh's names you want to load
  162300. */
  162301. meshesNames: any,
  162302. /**
  162303. * Defines the root url to use as a base to load your meshes and associated resources
  162304. */
  162305. rootUrl: string,
  162306. /**
  162307. * Defines the filename or File of the scene to load from
  162308. */
  162309. sceneFilename: string | File);
  162310. /**
  162311. * Execute the current task
  162312. * @param scene defines the scene where you want your assets to be loaded
  162313. * @param onSuccess is a callback called when the task is successfully executed
  162314. * @param onError is a callback called if an error occurs
  162315. */
  162316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162317. }
  162318. /**
  162319. * Define a task used by AssetsManager to load text content
  162320. */
  162321. export class TextFileAssetTask extends AbstractAssetTask {
  162322. /**
  162323. * Defines the name of the task
  162324. */
  162325. name: string;
  162326. /**
  162327. * Defines the location of the file to load
  162328. */
  162329. url: string;
  162330. /**
  162331. * Gets the loaded text string
  162332. */
  162333. text: string;
  162334. /**
  162335. * Callback called when the task is successful
  162336. */
  162337. onSuccess: (task: TextFileAssetTask) => void;
  162338. /**
  162339. * Callback called when the task is successful
  162340. */
  162341. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  162342. /**
  162343. * Creates a new TextFileAssetTask object
  162344. * @param name defines the name of the task
  162345. * @param url defines the location of the file to load
  162346. */
  162347. constructor(
  162348. /**
  162349. * Defines the name of the task
  162350. */
  162351. name: string,
  162352. /**
  162353. * Defines the location of the file to load
  162354. */
  162355. url: string);
  162356. /**
  162357. * Execute the current task
  162358. * @param scene defines the scene where you want your assets to be loaded
  162359. * @param onSuccess is a callback called when the task is successfully executed
  162360. * @param onError is a callback called if an error occurs
  162361. */
  162362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162363. }
  162364. /**
  162365. * Define a task used by AssetsManager to load binary data
  162366. */
  162367. export class BinaryFileAssetTask extends AbstractAssetTask {
  162368. /**
  162369. * Defines the name of the task
  162370. */
  162371. name: string;
  162372. /**
  162373. * Defines the location of the file to load
  162374. */
  162375. url: string;
  162376. /**
  162377. * Gets the lodaded data (as an array buffer)
  162378. */
  162379. data: ArrayBuffer;
  162380. /**
  162381. * Callback called when the task is successful
  162382. */
  162383. onSuccess: (task: BinaryFileAssetTask) => void;
  162384. /**
  162385. * Callback called when the task is successful
  162386. */
  162387. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  162388. /**
  162389. * Creates a new BinaryFileAssetTask object
  162390. * @param name defines the name of the new task
  162391. * @param url defines the location of the file to load
  162392. */
  162393. constructor(
  162394. /**
  162395. * Defines the name of the task
  162396. */
  162397. name: string,
  162398. /**
  162399. * Defines the location of the file to load
  162400. */
  162401. url: string);
  162402. /**
  162403. * Execute the current task
  162404. * @param scene defines the scene where you want your assets to be loaded
  162405. * @param onSuccess is a callback called when the task is successfully executed
  162406. * @param onError is a callback called if an error occurs
  162407. */
  162408. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162409. }
  162410. /**
  162411. * Define a task used by AssetsManager to load images
  162412. */
  162413. export class ImageAssetTask extends AbstractAssetTask {
  162414. /**
  162415. * Defines the name of the task
  162416. */
  162417. name: string;
  162418. /**
  162419. * Defines the location of the image to load
  162420. */
  162421. url: string;
  162422. /**
  162423. * Gets the loaded images
  162424. */
  162425. image: HTMLImageElement;
  162426. /**
  162427. * Callback called when the task is successful
  162428. */
  162429. onSuccess: (task: ImageAssetTask) => void;
  162430. /**
  162431. * Callback called when the task is successful
  162432. */
  162433. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  162434. /**
  162435. * Creates a new ImageAssetTask
  162436. * @param name defines the name of the task
  162437. * @param url defines the location of the image to load
  162438. */
  162439. constructor(
  162440. /**
  162441. * Defines the name of the task
  162442. */
  162443. name: string,
  162444. /**
  162445. * Defines the location of the image to load
  162446. */
  162447. url: string);
  162448. /**
  162449. * Execute the current task
  162450. * @param scene defines the scene where you want your assets to be loaded
  162451. * @param onSuccess is a callback called when the task is successfully executed
  162452. * @param onError is a callback called if an error occurs
  162453. */
  162454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162455. }
  162456. /**
  162457. * Defines the interface used by texture loading tasks
  162458. */
  162459. export interface ITextureAssetTask<TEX extends BaseTexture> {
  162460. /**
  162461. * Gets the loaded texture
  162462. */
  162463. texture: TEX;
  162464. }
  162465. /**
  162466. * Define a task used by AssetsManager to load 2D textures
  162467. */
  162468. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  162469. /**
  162470. * Defines the name of the task
  162471. */
  162472. name: string;
  162473. /**
  162474. * Defines the location of the file to load
  162475. */
  162476. url: string;
  162477. /**
  162478. * Defines if mipmap should not be generated (default is false)
  162479. */
  162480. noMipmap?: boolean | undefined;
  162481. /**
  162482. * Defines if texture must be inverted on Y axis (default is true)
  162483. */
  162484. invertY: boolean;
  162485. /**
  162486. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  162487. */
  162488. samplingMode: number;
  162489. /**
  162490. * Gets the loaded texture
  162491. */
  162492. texture: Texture;
  162493. /**
  162494. * Callback called when the task is successful
  162495. */
  162496. onSuccess: (task: TextureAssetTask) => void;
  162497. /**
  162498. * Callback called when the task is successful
  162499. */
  162500. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  162501. /**
  162502. * Creates a new TextureAssetTask object
  162503. * @param name defines the name of the task
  162504. * @param url defines the location of the file to load
  162505. * @param noMipmap defines if mipmap should not be generated (default is false)
  162506. * @param invertY defines if texture must be inverted on Y axis (default is true)
  162507. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  162508. */
  162509. constructor(
  162510. /**
  162511. * Defines the name of the task
  162512. */
  162513. name: string,
  162514. /**
  162515. * Defines the location of the file to load
  162516. */
  162517. url: string,
  162518. /**
  162519. * Defines if mipmap should not be generated (default is false)
  162520. */
  162521. noMipmap?: boolean | undefined,
  162522. /**
  162523. * Defines if texture must be inverted on Y axis (default is true)
  162524. */
  162525. invertY?: boolean,
  162526. /**
  162527. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  162528. */
  162529. samplingMode?: number);
  162530. /**
  162531. * Execute the current task
  162532. * @param scene defines the scene where you want your assets to be loaded
  162533. * @param onSuccess is a callback called when the task is successfully executed
  162534. * @param onError is a callback called if an error occurs
  162535. */
  162536. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162537. }
  162538. /**
  162539. * Define a task used by AssetsManager to load cube textures
  162540. */
  162541. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  162542. /**
  162543. * Defines the name of the task
  162544. */
  162545. name: string;
  162546. /**
  162547. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  162548. */
  162549. url: string;
  162550. /**
  162551. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  162552. */
  162553. extensions?: string[] | undefined;
  162554. /**
  162555. * Defines if mipmaps should not be generated (default is false)
  162556. */
  162557. noMipmap?: boolean | undefined;
  162558. /**
  162559. * Defines the explicit list of files (undefined by default)
  162560. */
  162561. files?: string[] | undefined;
  162562. /**
  162563. * Gets the loaded texture
  162564. */
  162565. texture: CubeTexture;
  162566. /**
  162567. * Callback called when the task is successful
  162568. */
  162569. onSuccess: (task: CubeTextureAssetTask) => void;
  162570. /**
  162571. * Callback called when the task is successful
  162572. */
  162573. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  162574. /**
  162575. * Creates a new CubeTextureAssetTask
  162576. * @param name defines the name of the task
  162577. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  162578. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  162579. * @param noMipmap defines if mipmaps should not be generated (default is false)
  162580. * @param files defines the explicit list of files (undefined by default)
  162581. */
  162582. constructor(
  162583. /**
  162584. * Defines the name of the task
  162585. */
  162586. name: string,
  162587. /**
  162588. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  162589. */
  162590. url: string,
  162591. /**
  162592. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  162593. */
  162594. extensions?: string[] | undefined,
  162595. /**
  162596. * Defines if mipmaps should not be generated (default is false)
  162597. */
  162598. noMipmap?: boolean | undefined,
  162599. /**
  162600. * Defines the explicit list of files (undefined by default)
  162601. */
  162602. files?: string[] | undefined);
  162603. /**
  162604. * Execute the current task
  162605. * @param scene defines the scene where you want your assets to be loaded
  162606. * @param onSuccess is a callback called when the task is successfully executed
  162607. * @param onError is a callback called if an error occurs
  162608. */
  162609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162610. }
  162611. /**
  162612. * Define a task used by AssetsManager to load HDR cube textures
  162613. */
  162614. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  162615. /**
  162616. * Defines the name of the task
  162617. */
  162618. name: string;
  162619. /**
  162620. * Defines the location of the file to load
  162621. */
  162622. url: string;
  162623. /**
  162624. * Defines the desired size (the more it increases the longer the generation will be)
  162625. */
  162626. size: number;
  162627. /**
  162628. * Defines if mipmaps should not be generated (default is false)
  162629. */
  162630. noMipmap: boolean;
  162631. /**
  162632. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  162633. */
  162634. generateHarmonics: boolean;
  162635. /**
  162636. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  162637. */
  162638. gammaSpace: boolean;
  162639. /**
  162640. * Internal Use Only
  162641. */
  162642. reserved: boolean;
  162643. /**
  162644. * Gets the loaded texture
  162645. */
  162646. texture: HDRCubeTexture;
  162647. /**
  162648. * Callback called when the task is successful
  162649. */
  162650. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  162651. /**
  162652. * Callback called when the task is successful
  162653. */
  162654. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  162655. /**
  162656. * Creates a new HDRCubeTextureAssetTask object
  162657. * @param name defines the name of the task
  162658. * @param url defines the location of the file to load
  162659. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  162660. * @param noMipmap defines if mipmaps should not be generated (default is false)
  162661. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  162662. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  162663. * @param reserved Internal use only
  162664. */
  162665. constructor(
  162666. /**
  162667. * Defines the name of the task
  162668. */
  162669. name: string,
  162670. /**
  162671. * Defines the location of the file to load
  162672. */
  162673. url: string,
  162674. /**
  162675. * Defines the desired size (the more it increases the longer the generation will be)
  162676. */
  162677. size: number,
  162678. /**
  162679. * Defines if mipmaps should not be generated (default is false)
  162680. */
  162681. noMipmap?: boolean,
  162682. /**
  162683. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  162684. */
  162685. generateHarmonics?: boolean,
  162686. /**
  162687. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  162688. */
  162689. gammaSpace?: boolean,
  162690. /**
  162691. * Internal Use Only
  162692. */
  162693. reserved?: boolean);
  162694. /**
  162695. * Execute the current task
  162696. * @param scene defines the scene where you want your assets to be loaded
  162697. * @param onSuccess is a callback called when the task is successfully executed
  162698. * @param onError is a callback called if an error occurs
  162699. */
  162700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162701. }
  162702. /**
  162703. * Define a task used by AssetsManager to load Equirectangular cube textures
  162704. */
  162705. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  162706. /**
  162707. * Defines the name of the task
  162708. */
  162709. name: string;
  162710. /**
  162711. * Defines the location of the file to load
  162712. */
  162713. url: string;
  162714. /**
  162715. * Defines the desired size (the more it increases the longer the generation will be)
  162716. */
  162717. size: number;
  162718. /**
  162719. * Defines if mipmaps should not be generated (default is false)
  162720. */
  162721. noMipmap: boolean;
  162722. /**
  162723. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  162724. * but the standard material would require them in Gamma space) (default is true)
  162725. */
  162726. gammaSpace: boolean;
  162727. /**
  162728. * Gets the loaded texture
  162729. */
  162730. texture: EquiRectangularCubeTexture;
  162731. /**
  162732. * Callback called when the task is successful
  162733. */
  162734. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  162735. /**
  162736. * Callback called when the task is successful
  162737. */
  162738. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  162739. /**
  162740. * Creates a new EquiRectangularCubeTextureAssetTask object
  162741. * @param name defines the name of the task
  162742. * @param url defines the location of the file to load
  162743. * @param size defines the desired size (the more it increases the longer the generation will be)
  162744. * If the size is omitted this implies you are using a preprocessed cubemap.
  162745. * @param noMipmap defines if mipmaps should not be generated (default is false)
  162746. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  162747. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  162748. * (default is true)
  162749. */
  162750. constructor(
  162751. /**
  162752. * Defines the name of the task
  162753. */
  162754. name: string,
  162755. /**
  162756. * Defines the location of the file to load
  162757. */
  162758. url: string,
  162759. /**
  162760. * Defines the desired size (the more it increases the longer the generation will be)
  162761. */
  162762. size: number,
  162763. /**
  162764. * Defines if mipmaps should not be generated (default is false)
  162765. */
  162766. noMipmap?: boolean,
  162767. /**
  162768. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  162769. * but the standard material would require them in Gamma space) (default is true)
  162770. */
  162771. gammaSpace?: boolean);
  162772. /**
  162773. * Execute the current task
  162774. * @param scene defines the scene where you want your assets to be loaded
  162775. * @param onSuccess is a callback called when the task is successfully executed
  162776. * @param onError is a callback called if an error occurs
  162777. */
  162778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162779. }
  162780. /**
  162781. * This class can be used to easily import assets into a scene
  162782. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  162783. */
  162784. export class AssetsManager {
  162785. private _scene;
  162786. private _isLoading;
  162787. protected _tasks: AbstractAssetTask[];
  162788. protected _waitingTasksCount: number;
  162789. protected _totalTasksCount: number;
  162790. /**
  162791. * Callback called when all tasks are processed
  162792. */
  162793. onFinish: (tasks: AbstractAssetTask[]) => void;
  162794. /**
  162795. * Callback called when a task is successful
  162796. */
  162797. onTaskSuccess: (task: AbstractAssetTask) => void;
  162798. /**
  162799. * Callback called when a task had an error
  162800. */
  162801. onTaskError: (task: AbstractAssetTask) => void;
  162802. /**
  162803. * Callback called when a task is done (whatever the result is)
  162804. */
  162805. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  162806. /**
  162807. * Observable called when all tasks are processed
  162808. */
  162809. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  162810. /**
  162811. * Observable called when a task had an error
  162812. */
  162813. onTaskErrorObservable: Observable<AbstractAssetTask>;
  162814. /**
  162815. * Observable called when all tasks were executed
  162816. */
  162817. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  162818. /**
  162819. * Observable called when a task is done (whatever the result is)
  162820. */
  162821. onProgressObservable: Observable<IAssetsProgressEvent>;
  162822. /**
  162823. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  162824. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  162825. */
  162826. useDefaultLoadingScreen: boolean;
  162827. /**
  162828. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  162829. * when all assets have been downloaded.
  162830. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  162831. */
  162832. autoHideLoadingUI: boolean;
  162833. /**
  162834. * Creates a new AssetsManager
  162835. * @param scene defines the scene to work on
  162836. */
  162837. constructor(scene: Scene);
  162838. /**
  162839. * Add a ContainerAssetTask to the list of active tasks
  162840. * @param taskName defines the name of the new task
  162841. * @param meshesNames defines the name of meshes to load
  162842. * @param rootUrl defines the root url to use to locate files
  162843. * @param sceneFilename defines the filename of the scene file
  162844. * @returns a new ContainerAssetTask object
  162845. */
  162846. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  162847. /**
  162848. * Add a MeshAssetTask to the list of active tasks
  162849. * @param taskName defines the name of the new task
  162850. * @param meshesNames defines the name of meshes to load
  162851. * @param rootUrl defines the root url to use to locate files
  162852. * @param sceneFilename defines the filename of the scene file
  162853. * @returns a new MeshAssetTask object
  162854. */
  162855. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  162856. /**
  162857. * Add a TextFileAssetTask to the list of active tasks
  162858. * @param taskName defines the name of the new task
  162859. * @param url defines the url of the file to load
  162860. * @returns a new TextFileAssetTask object
  162861. */
  162862. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  162863. /**
  162864. * Add a BinaryFileAssetTask to the list of active tasks
  162865. * @param taskName defines the name of the new task
  162866. * @param url defines the url of the file to load
  162867. * @returns a new BinaryFileAssetTask object
  162868. */
  162869. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  162870. /**
  162871. * Add a ImageAssetTask to the list of active tasks
  162872. * @param taskName defines the name of the new task
  162873. * @param url defines the url of the file to load
  162874. * @returns a new ImageAssetTask object
  162875. */
  162876. addImageTask(taskName: string, url: string): ImageAssetTask;
  162877. /**
  162878. * Add a TextureAssetTask to the list of active tasks
  162879. * @param taskName defines the name of the new task
  162880. * @param url defines the url of the file to load
  162881. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162882. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  162883. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  162884. * @returns a new TextureAssetTask object
  162885. */
  162886. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  162887. /**
  162888. * Add a CubeTextureAssetTask to the list of active tasks
  162889. * @param taskName defines the name of the new task
  162890. * @param url defines the url of the file to load
  162891. * @param extensions defines the extension to use to load the cube map (can be null)
  162892. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162893. * @param files defines the list of files to load (can be null)
  162894. * @returns a new CubeTextureAssetTask object
  162895. */
  162896. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  162897. /**
  162898. *
  162899. * Add a HDRCubeTextureAssetTask to the list of active tasks
  162900. * @param taskName defines the name of the new task
  162901. * @param url defines the url of the file to load
  162902. * @param size defines the size you want for the cubemap (can be null)
  162903. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162904. * @param generateHarmonics defines if you want to automatically generate (true by default)
  162905. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  162906. * @param reserved Internal use only
  162907. * @returns a new HDRCubeTextureAssetTask object
  162908. */
  162909. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  162910. /**
  162911. *
  162912. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  162913. * @param taskName defines the name of the new task
  162914. * @param url defines the url of the file to load
  162915. * @param size defines the size you want for the cubemap (can be null)
  162916. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162917. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  162918. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  162919. * @returns a new EquiRectangularCubeTextureAssetTask object
  162920. */
  162921. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  162922. /**
  162923. * Remove a task from the assets manager.
  162924. * @param task the task to remove
  162925. */
  162926. removeTask(task: AbstractAssetTask): void;
  162927. private _decreaseWaitingTasksCount;
  162928. private _runTask;
  162929. /**
  162930. * Reset the AssetsManager and remove all tasks
  162931. * @return the current instance of the AssetsManager
  162932. */
  162933. reset(): AssetsManager;
  162934. /**
  162935. * Start the loading process
  162936. * @return the current instance of the AssetsManager
  162937. */
  162938. load(): AssetsManager;
  162939. /**
  162940. * Start the loading process as an async operation
  162941. * @return a promise returning the list of failed tasks
  162942. */
  162943. loadAsync(): Promise<void>;
  162944. }
  162945. }
  162946. declare module BABYLON {
  162947. /**
  162948. * Wrapper class for promise with external resolve and reject.
  162949. */
  162950. export class Deferred<T> {
  162951. /**
  162952. * The promise associated with this deferred object.
  162953. */
  162954. readonly promise: Promise<T>;
  162955. private _resolve;
  162956. private _reject;
  162957. /**
  162958. * The resolve method of the promise associated with this deferred object.
  162959. */
  162960. get resolve(): (value: T | PromiseLike<T>) => void;
  162961. /**
  162962. * The reject method of the promise associated with this deferred object.
  162963. */
  162964. get reject(): (reason?: any) => void;
  162965. /**
  162966. * Constructor for this deferred object.
  162967. */
  162968. constructor();
  162969. }
  162970. }
  162971. declare module BABYLON {
  162972. /**
  162973. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  162974. */
  162975. export class MeshExploder {
  162976. private _centerMesh;
  162977. private _meshes;
  162978. private _meshesOrigins;
  162979. private _toCenterVectors;
  162980. private _scaledDirection;
  162981. private _newPosition;
  162982. private _centerPosition;
  162983. /**
  162984. * Explodes meshes from a center mesh.
  162985. * @param meshes The meshes to explode.
  162986. * @param centerMesh The mesh to be center of explosion.
  162987. */
  162988. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  162989. private _setCenterMesh;
  162990. /**
  162991. * Get class name
  162992. * @returns "MeshExploder"
  162993. */
  162994. getClassName(): string;
  162995. /**
  162996. * "Exploded meshes"
  162997. * @returns Array of meshes with the centerMesh at index 0.
  162998. */
  162999. getMeshes(): Array<Mesh>;
  163000. /**
  163001. * Explodes meshes giving a specific direction
  163002. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  163003. */
  163004. explode(direction?: number): void;
  163005. }
  163006. }
  163007. declare module BABYLON {
  163008. /**
  163009. * Class used to help managing file picking and drag'n'drop
  163010. */
  163011. export class FilesInput {
  163012. /**
  163013. * List of files ready to be loaded
  163014. */
  163015. static get FilesToLoad(): {
  163016. [key: string]: File;
  163017. };
  163018. /**
  163019. * Callback called when a file is processed
  163020. */
  163021. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  163022. /**
  163023. * Function used when loading the scene file
  163024. */
  163025. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  163026. private _engine;
  163027. private _currentScene;
  163028. private _sceneLoadedCallback;
  163029. private _progressCallback;
  163030. private _additionalRenderLoopLogicCallback;
  163031. private _textureLoadingCallback;
  163032. private _startingProcessingFilesCallback;
  163033. private _onReloadCallback;
  163034. private _errorCallback;
  163035. private _elementToMonitor;
  163036. private _sceneFileToLoad;
  163037. private _filesToLoad;
  163038. /**
  163039. * Creates a new FilesInput
  163040. * @param engine defines the rendering engine
  163041. * @param scene defines the hosting scene
  163042. * @param sceneLoadedCallback callback called when scene is loaded
  163043. * @param progressCallback callback called to track progress
  163044. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  163045. * @param textureLoadingCallback callback called when a texture is loading
  163046. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  163047. * @param onReloadCallback callback called when a reload is requested
  163048. * @param errorCallback callback call if an error occurs
  163049. */
  163050. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  163051. private _dragEnterHandler;
  163052. private _dragOverHandler;
  163053. private _dropHandler;
  163054. /**
  163055. * Calls this function to listen to drag'n'drop events on a specific DOM element
  163056. * @param elementToMonitor defines the DOM element to track
  163057. */
  163058. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  163059. /** Gets the current list of files to load */
  163060. get filesToLoad(): File[];
  163061. /**
  163062. * Release all associated resources
  163063. */
  163064. dispose(): void;
  163065. private renderFunction;
  163066. private drag;
  163067. private drop;
  163068. private _traverseFolder;
  163069. private _processFiles;
  163070. /**
  163071. * Load files from a drop event
  163072. * @param event defines the drop event to use as source
  163073. */
  163074. loadFiles(event: any): void;
  163075. private _processReload;
  163076. /**
  163077. * Reload the current scene from the loaded files
  163078. */
  163079. reload(): void;
  163080. }
  163081. }
  163082. declare module BABYLON {
  163083. /**
  163084. * Defines the root class used to create scene optimization to use with SceneOptimizer
  163085. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163086. */
  163087. export class SceneOptimization {
  163088. /**
  163089. * Defines the priority of this optimization (0 by default which means first in the list)
  163090. */
  163091. priority: number;
  163092. /**
  163093. * Gets a string describing the action executed by the current optimization
  163094. * @returns description string
  163095. */
  163096. getDescription(): string;
  163097. /**
  163098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163099. * @param scene defines the current scene where to apply this optimization
  163100. * @param optimizer defines the current optimizer
  163101. * @returns true if everything that can be done was applied
  163102. */
  163103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163104. /**
  163105. * Creates the SceneOptimization object
  163106. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  163107. * @param desc defines the description associated with the optimization
  163108. */
  163109. constructor(
  163110. /**
  163111. * Defines the priority of this optimization (0 by default which means first in the list)
  163112. */
  163113. priority?: number);
  163114. }
  163115. /**
  163116. * Defines an optimization used to reduce the size of render target textures
  163117. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163118. */
  163119. export class TextureOptimization extends SceneOptimization {
  163120. /**
  163121. * Defines the priority of this optimization (0 by default which means first in the list)
  163122. */
  163123. priority: number;
  163124. /**
  163125. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  163126. */
  163127. maximumSize: number;
  163128. /**
  163129. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  163130. */
  163131. step: number;
  163132. /**
  163133. * Gets a string describing the action executed by the current optimization
  163134. * @returns description string
  163135. */
  163136. getDescription(): string;
  163137. /**
  163138. * Creates the TextureOptimization object
  163139. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  163140. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  163141. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  163142. */
  163143. constructor(
  163144. /**
  163145. * Defines the priority of this optimization (0 by default which means first in the list)
  163146. */
  163147. priority?: number,
  163148. /**
  163149. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  163150. */
  163151. maximumSize?: number,
  163152. /**
  163153. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  163154. */
  163155. step?: number);
  163156. /**
  163157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163158. * @param scene defines the current scene where to apply this optimization
  163159. * @param optimizer defines the current optimizer
  163160. * @returns true if everything that can be done was applied
  163161. */
  163162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163163. }
  163164. /**
  163165. * Defines an optimization used to increase or decrease the rendering resolution
  163166. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163167. */
  163168. export class HardwareScalingOptimization extends SceneOptimization {
  163169. /**
  163170. * Defines the priority of this optimization (0 by default which means first in the list)
  163171. */
  163172. priority: number;
  163173. /**
  163174. * Defines the maximum scale to use (2 by default)
  163175. */
  163176. maximumScale: number;
  163177. /**
  163178. * Defines the step to use between two passes (0.5 by default)
  163179. */
  163180. step: number;
  163181. private _currentScale;
  163182. private _directionOffset;
  163183. /**
  163184. * Gets a string describing the action executed by the current optimization
  163185. * @return description string
  163186. */
  163187. getDescription(): string;
  163188. /**
  163189. * Creates the HardwareScalingOptimization object
  163190. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  163191. * @param maximumScale defines the maximum scale to use (2 by default)
  163192. * @param step defines the step to use between two passes (0.5 by default)
  163193. */
  163194. constructor(
  163195. /**
  163196. * Defines the priority of this optimization (0 by default which means first in the list)
  163197. */
  163198. priority?: number,
  163199. /**
  163200. * Defines the maximum scale to use (2 by default)
  163201. */
  163202. maximumScale?: number,
  163203. /**
  163204. * Defines the step to use between two passes (0.5 by default)
  163205. */
  163206. step?: number);
  163207. /**
  163208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163209. * @param scene defines the current scene where to apply this optimization
  163210. * @param optimizer defines the current optimizer
  163211. * @returns true if everything that can be done was applied
  163212. */
  163213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163214. }
  163215. /**
  163216. * Defines an optimization used to remove shadows
  163217. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163218. */
  163219. export class ShadowsOptimization extends SceneOptimization {
  163220. /**
  163221. * Gets a string describing the action executed by the current optimization
  163222. * @return description string
  163223. */
  163224. getDescription(): string;
  163225. /**
  163226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163227. * @param scene defines the current scene where to apply this optimization
  163228. * @param optimizer defines the current optimizer
  163229. * @returns true if everything that can be done was applied
  163230. */
  163231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163232. }
  163233. /**
  163234. * Defines an optimization used to turn post-processes off
  163235. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163236. */
  163237. export class PostProcessesOptimization extends SceneOptimization {
  163238. /**
  163239. * Gets a string describing the action executed by the current optimization
  163240. * @return description string
  163241. */
  163242. getDescription(): string;
  163243. /**
  163244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163245. * @param scene defines the current scene where to apply this optimization
  163246. * @param optimizer defines the current optimizer
  163247. * @returns true if everything that can be done was applied
  163248. */
  163249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163250. }
  163251. /**
  163252. * Defines an optimization used to turn lens flares off
  163253. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163254. */
  163255. export class LensFlaresOptimization extends SceneOptimization {
  163256. /**
  163257. * Gets a string describing the action executed by the current optimization
  163258. * @return description string
  163259. */
  163260. getDescription(): string;
  163261. /**
  163262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163263. * @param scene defines the current scene where to apply this optimization
  163264. * @param optimizer defines the current optimizer
  163265. * @returns true if everything that can be done was applied
  163266. */
  163267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163268. }
  163269. /**
  163270. * Defines an optimization based on user defined callback.
  163271. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163272. */
  163273. export class CustomOptimization extends SceneOptimization {
  163274. /**
  163275. * Callback called to apply the custom optimization.
  163276. */
  163277. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  163278. /**
  163279. * Callback called to get custom description
  163280. */
  163281. onGetDescription: () => string;
  163282. /**
  163283. * Gets a string describing the action executed by the current optimization
  163284. * @returns description string
  163285. */
  163286. getDescription(): string;
  163287. /**
  163288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163289. * @param scene defines the current scene where to apply this optimization
  163290. * @param optimizer defines the current optimizer
  163291. * @returns true if everything that can be done was applied
  163292. */
  163293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163294. }
  163295. /**
  163296. * Defines an optimization used to turn particles off
  163297. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163298. */
  163299. export class ParticlesOptimization extends SceneOptimization {
  163300. /**
  163301. * Gets a string describing the action executed by the current optimization
  163302. * @return description string
  163303. */
  163304. getDescription(): string;
  163305. /**
  163306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163307. * @param scene defines the current scene where to apply this optimization
  163308. * @param optimizer defines the current optimizer
  163309. * @returns true if everything that can be done was applied
  163310. */
  163311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163312. }
  163313. /**
  163314. * Defines an optimization used to turn render targets off
  163315. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163316. */
  163317. export class RenderTargetsOptimization extends SceneOptimization {
  163318. /**
  163319. * Gets a string describing the action executed by the current optimization
  163320. * @return description string
  163321. */
  163322. getDescription(): string;
  163323. /**
  163324. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163325. * @param scene defines the current scene where to apply this optimization
  163326. * @param optimizer defines the current optimizer
  163327. * @returns true if everything that can be done was applied
  163328. */
  163329. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163330. }
  163331. /**
  163332. * Defines an optimization used to merge meshes with compatible materials
  163333. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163334. */
  163335. export class MergeMeshesOptimization extends SceneOptimization {
  163336. private static _UpdateSelectionTree;
  163337. /**
  163338. * Gets or sets a boolean which defines if optimization octree has to be updated
  163339. */
  163340. static get UpdateSelectionTree(): boolean;
  163341. /**
  163342. * Gets or sets a boolean which defines if optimization octree has to be updated
  163343. */
  163344. static set UpdateSelectionTree(value: boolean);
  163345. /**
  163346. * Gets a string describing the action executed by the current optimization
  163347. * @return description string
  163348. */
  163349. getDescription(): string;
  163350. private _canBeMerged;
  163351. /**
  163352. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163353. * @param scene defines the current scene where to apply this optimization
  163354. * @param optimizer defines the current optimizer
  163355. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  163356. * @returns true if everything that can be done was applied
  163357. */
  163358. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  163359. }
  163360. /**
  163361. * Defines a list of options used by SceneOptimizer
  163362. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163363. */
  163364. export class SceneOptimizerOptions {
  163365. /**
  163366. * Defines the target frame rate to reach (60 by default)
  163367. */
  163368. targetFrameRate: number;
  163369. /**
  163370. * Defines the interval between two checkes (2000ms by default)
  163371. */
  163372. trackerDuration: number;
  163373. /**
  163374. * Gets the list of optimizations to apply
  163375. */
  163376. optimizations: SceneOptimization[];
  163377. /**
  163378. * Creates a new list of options used by SceneOptimizer
  163379. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  163380. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  163381. */
  163382. constructor(
  163383. /**
  163384. * Defines the target frame rate to reach (60 by default)
  163385. */
  163386. targetFrameRate?: number,
  163387. /**
  163388. * Defines the interval between two checkes (2000ms by default)
  163389. */
  163390. trackerDuration?: number);
  163391. /**
  163392. * Add a new optimization
  163393. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  163394. * @returns the current SceneOptimizerOptions
  163395. */
  163396. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  163397. /**
  163398. * Add a new custom optimization
  163399. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  163400. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  163401. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  163402. * @returns the current SceneOptimizerOptions
  163403. */
  163404. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  163405. /**
  163406. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  163407. * @param targetFrameRate defines the target frame rate (60 by default)
  163408. * @returns a SceneOptimizerOptions object
  163409. */
  163410. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  163411. /**
  163412. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  163413. * @param targetFrameRate defines the target frame rate (60 by default)
  163414. * @returns a SceneOptimizerOptions object
  163415. */
  163416. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  163417. /**
  163418. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  163419. * @param targetFrameRate defines the target frame rate (60 by default)
  163420. * @returns a SceneOptimizerOptions object
  163421. */
  163422. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  163423. }
  163424. /**
  163425. * Class used to run optimizations in order to reach a target frame rate
  163426. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163427. */
  163428. export class SceneOptimizer implements IDisposable {
  163429. private _isRunning;
  163430. private _options;
  163431. private _scene;
  163432. private _currentPriorityLevel;
  163433. private _targetFrameRate;
  163434. private _trackerDuration;
  163435. private _currentFrameRate;
  163436. private _sceneDisposeObserver;
  163437. private _improvementMode;
  163438. /**
  163439. * Defines an observable called when the optimizer reaches the target frame rate
  163440. */
  163441. onSuccessObservable: Observable<SceneOptimizer>;
  163442. /**
  163443. * Defines an observable called when the optimizer enables an optimization
  163444. */
  163445. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  163446. /**
  163447. * Defines an observable called when the optimizer is not able to reach the target frame rate
  163448. */
  163449. onFailureObservable: Observable<SceneOptimizer>;
  163450. /**
  163451. * Gets a boolean indicating if the optimizer is in improvement mode
  163452. */
  163453. get isInImprovementMode(): boolean;
  163454. /**
  163455. * Gets the current priority level (0 at start)
  163456. */
  163457. get currentPriorityLevel(): number;
  163458. /**
  163459. * Gets the current frame rate checked by the SceneOptimizer
  163460. */
  163461. get currentFrameRate(): number;
  163462. /**
  163463. * Gets or sets the current target frame rate (60 by default)
  163464. */
  163465. get targetFrameRate(): number;
  163466. /**
  163467. * Gets or sets the current target frame rate (60 by default)
  163468. */
  163469. set targetFrameRate(value: number);
  163470. /**
  163471. * Gets or sets the current interval between two checks (every 2000ms by default)
  163472. */
  163473. get trackerDuration(): number;
  163474. /**
  163475. * Gets or sets the current interval between two checks (every 2000ms by default)
  163476. */
  163477. set trackerDuration(value: number);
  163478. /**
  163479. * Gets the list of active optimizations
  163480. */
  163481. get optimizations(): SceneOptimization[];
  163482. /**
  163483. * Creates a new SceneOptimizer
  163484. * @param scene defines the scene to work on
  163485. * @param options defines the options to use with the SceneOptimizer
  163486. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  163487. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  163488. */
  163489. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  163490. /**
  163491. * Stops the current optimizer
  163492. */
  163493. stop(): void;
  163494. /**
  163495. * Reset the optimizer to initial step (current priority level = 0)
  163496. */
  163497. reset(): void;
  163498. /**
  163499. * Start the optimizer. By default it will try to reach a specific framerate
  163500. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  163501. */
  163502. start(): void;
  163503. private _checkCurrentState;
  163504. /**
  163505. * Release all resources
  163506. */
  163507. dispose(): void;
  163508. /**
  163509. * Helper function to create a SceneOptimizer with one single line of code
  163510. * @param scene defines the scene to work on
  163511. * @param options defines the options to use with the SceneOptimizer
  163512. * @param onSuccess defines a callback to call on success
  163513. * @param onFailure defines a callback to call on failure
  163514. * @returns the new SceneOptimizer object
  163515. */
  163516. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  163517. }
  163518. }
  163519. declare module BABYLON {
  163520. /**
  163521. * Class used to serialize a scene into a string
  163522. */
  163523. export class SceneSerializer {
  163524. /**
  163525. * Clear cache used by a previous serialization
  163526. */
  163527. static ClearCache(): void;
  163528. /**
  163529. * Serialize a scene into a JSON compatible object
  163530. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  163531. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  163532. * @param scene defines the scene to serialize
  163533. * @returns a JSON compatible object
  163534. */
  163535. static Serialize(scene: Scene): any;
  163536. private static _Serialize;
  163537. /**
  163538. * Serialize a scene into a JSON compatible object
  163539. * @param scene defines the scene to serialize
  163540. * @returns a JSON promise compatible object
  163541. */
  163542. static SerializeAsync(scene: Scene): Promise<any>;
  163543. private static _CollectPromises;
  163544. /**
  163545. * Serialize a mesh into a JSON compatible object
  163546. * @param toSerialize defines the mesh to serialize
  163547. * @param withParents defines if parents must be serialized as well
  163548. * @param withChildren defines if children must be serialized as well
  163549. * @returns a JSON compatible object
  163550. */
  163551. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  163552. }
  163553. }
  163554. declare module BABYLON {
  163555. /**
  163556. * This represents the different options available for the video capture.
  163557. */
  163558. export interface VideoRecorderOptions {
  163559. /** Defines the mime type of the video. */
  163560. mimeType: string;
  163561. /** Defines the FPS the video should be recorded at. */
  163562. fps: number;
  163563. /** Defines the chunk size for the recording data. */
  163564. recordChunckSize: number;
  163565. /** The audio tracks to attach to the recording. */
  163566. audioTracks?: MediaStreamTrack[];
  163567. }
  163568. /**
  163569. * This can help with recording videos from BabylonJS.
  163570. * This is based on the available WebRTC functionalities of the browser.
  163571. *
  163572. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  163573. */
  163574. export class VideoRecorder {
  163575. private static readonly _defaultOptions;
  163576. /**
  163577. * Returns whether or not the VideoRecorder is available in your browser.
  163578. * @param engine Defines the Babylon Engine.
  163579. * @returns true if supported otherwise false.
  163580. */
  163581. static IsSupported(engine: Engine): boolean;
  163582. private readonly _options;
  163583. private _canvas;
  163584. private _mediaRecorder;
  163585. private _recordedChunks;
  163586. private _fileName;
  163587. private _resolve;
  163588. private _reject;
  163589. /**
  163590. * True when a recording is already in progress.
  163591. */
  163592. get isRecording(): boolean;
  163593. /**
  163594. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  163595. * @param engine Defines the BabylonJS Engine you wish to record.
  163596. * @param options Defines options that can be used to customize the capture.
  163597. */
  163598. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  163599. /**
  163600. * Stops the current recording before the default capture timeout passed in the startRecording function.
  163601. */
  163602. stopRecording(): void;
  163603. /**
  163604. * Starts recording the canvas for a max duration specified in parameters.
  163605. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  163606. * If null no automatic download will start and you can rely on the promise to get the data back.
  163607. * @param maxDuration Defines the maximum recording time in seconds.
  163608. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  163609. * @return A promise callback at the end of the recording with the video data in Blob.
  163610. */
  163611. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  163612. /**
  163613. * Releases internal resources used during the recording.
  163614. */
  163615. dispose(): void;
  163616. private _handleDataAvailable;
  163617. private _handleError;
  163618. private _handleStop;
  163619. }
  163620. }
  163621. declare module BABYLON {
  163622. /**
  163623. * Class containing a set of static utilities functions for screenshots
  163624. */
  163625. export class ScreenshotTools {
  163626. /**
  163627. * Captures a screenshot of the current rendering
  163628. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163629. * @param engine defines the rendering engine
  163630. * @param camera defines the source camera
  163631. * @param size This parameter can be set to a single number or to an object with the
  163632. * following (optional) properties: precision, width, height. If a single number is passed,
  163633. * it will be used for both width and height. If an object is passed, the screenshot size
  163634. * will be derived from the parameters. The precision property is a multiplier allowing
  163635. * rendering at a higher or lower resolution
  163636. * @param successCallback defines the callback receives a single parameter which contains the
  163637. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  163638. * src parameter of an <img> to display it
  163639. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  163640. * Check your browser for supported MIME types
  163641. * @param forceDownload force the system to download the image even if a successCallback is provided
  163642. */
  163643. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  163644. /**
  163645. * Captures a screenshot of the current rendering
  163646. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163647. * @param engine defines the rendering engine
  163648. * @param camera defines the source camera
  163649. * @param size This parameter can be set to a single number or to an object with the
  163650. * following (optional) properties: precision, width, height. If a single number is passed,
  163651. * it will be used for both width and height. If an object is passed, the screenshot size
  163652. * will be derived from the parameters. The precision property is a multiplier allowing
  163653. * rendering at a higher or lower resolution
  163654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  163655. * Check your browser for supported MIME types
  163656. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  163657. * to the src parameter of an <img> to display it
  163658. */
  163659. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  163660. /**
  163661. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  163662. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163663. * @param engine defines the rendering engine
  163664. * @param camera defines the source camera
  163665. * @param width defines the expected width
  163666. * @param height defines the expected height
  163667. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  163668. * Check your browser for supported MIME types
  163669. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  163670. * to the src parameter of an <img> to display it
  163671. */
  163672. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  163673. /**
  163674. * Generates an image screenshot from the specified camera.
  163675. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163676. * @param engine The engine to use for rendering
  163677. * @param camera The camera to use for rendering
  163678. * @param size This parameter can be set to a single number or to an object with the
  163679. * following (optional) properties: precision, width, height. If a single number is passed,
  163680. * it will be used for both width and height. If an object is passed, the screenshot size
  163681. * will be derived from the parameters. The precision property is a multiplier allowing
  163682. * rendering at a higher or lower resolution
  163683. * @param successCallback The callback receives a single parameter which contains the
  163684. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  163685. * src parameter of an <img> to display it
  163686. * @param mimeType The MIME type of the screenshot image (default: image/png).
  163687. * Check your browser for supported MIME types
  163688. * @param samples Texture samples (default: 1)
  163689. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  163690. * @param fileName A name for for the downloaded file.
  163691. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  163692. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  163693. */
  163694. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  163695. /**
  163696. * Generates an image screenshot from the specified camera.
  163697. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  163698. * @param engine The engine to use for rendering
  163699. * @param camera The camera to use for rendering
  163700. * @param size This parameter can be set to a single number or to an object with the
  163701. * following (optional) properties: precision, width, height. If a single number is passed,
  163702. * it will be used for both width and height. If an object is passed, the screenshot size
  163703. * will be derived from the parameters. The precision property is a multiplier allowing
  163704. * rendering at a higher or lower resolution
  163705. * @param mimeType The MIME type of the screenshot image (default: image/png).
  163706. * Check your browser for supported MIME types
  163707. * @param samples Texture samples (default: 1)
  163708. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  163709. * @param fileName A name for for the downloaded file.
  163710. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  163711. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  163712. * to the src parameter of an <img> to display it
  163713. */
  163714. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  163715. /**
  163716. * Gets height and width for screenshot size
  163717. * @private
  163718. */
  163719. private static _getScreenshotSize;
  163720. }
  163721. }
  163722. declare module BABYLON {
  163723. /**
  163724. * Interface for a data buffer
  163725. */
  163726. export interface IDataBuffer {
  163727. /**
  163728. * Reads bytes from the data buffer.
  163729. * @param byteOffset The byte offset to read
  163730. * @param byteLength The byte length to read
  163731. * @returns A promise that resolves when the bytes are read
  163732. */
  163733. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  163734. /**
  163735. * The byte length of the buffer.
  163736. */
  163737. readonly byteLength: number;
  163738. }
  163739. /**
  163740. * Utility class for reading from a data buffer
  163741. */
  163742. export class DataReader {
  163743. /**
  163744. * The data buffer associated with this data reader.
  163745. */
  163746. readonly buffer: IDataBuffer;
  163747. /**
  163748. * The current byte offset from the beginning of the data buffer.
  163749. */
  163750. byteOffset: number;
  163751. private _dataView;
  163752. private _dataByteOffset;
  163753. /**
  163754. * Constructor
  163755. * @param buffer The buffer to read
  163756. */
  163757. constructor(buffer: IDataBuffer);
  163758. /**
  163759. * Loads the given byte length.
  163760. * @param byteLength The byte length to load
  163761. * @returns A promise that resolves when the load is complete
  163762. */
  163763. loadAsync(byteLength: number): Promise<void>;
  163764. /**
  163765. * Read a unsigned 32-bit integer from the currently loaded data range.
  163766. * @returns The 32-bit integer read
  163767. */
  163768. readUint32(): number;
  163769. /**
  163770. * Read a byte array from the currently loaded data range.
  163771. * @param byteLength The byte length to read
  163772. * @returns The byte array read
  163773. */
  163774. readUint8Array(byteLength: number): Uint8Array;
  163775. /**
  163776. * Read a string from the currently loaded data range.
  163777. * @param byteLength The byte length to read
  163778. * @returns The string read
  163779. */
  163780. readString(byteLength: number): string;
  163781. /**
  163782. * Skips the given byte length the currently loaded data range.
  163783. * @param byteLength The byte length to skip
  163784. */
  163785. skipBytes(byteLength: number): void;
  163786. }
  163787. }
  163788. declare module BABYLON {
  163789. /**
  163790. * Class for storing data to local storage if available or in-memory storage otherwise
  163791. */
  163792. export class DataStorage {
  163793. private static _Storage;
  163794. private static _GetStorage;
  163795. /**
  163796. * Reads a string from the data storage
  163797. * @param key The key to read
  163798. * @param defaultValue The value if the key doesn't exist
  163799. * @returns The string value
  163800. */
  163801. static ReadString(key: string, defaultValue: string): string;
  163802. /**
  163803. * Writes a string to the data storage
  163804. * @param key The key to write
  163805. * @param value The value to write
  163806. */
  163807. static WriteString(key: string, value: string): void;
  163808. /**
  163809. * Reads a boolean from the data storage
  163810. * @param key The key to read
  163811. * @param defaultValue The value if the key doesn't exist
  163812. * @returns The boolean value
  163813. */
  163814. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  163815. /**
  163816. * Writes a boolean to the data storage
  163817. * @param key The key to write
  163818. * @param value The value to write
  163819. */
  163820. static WriteBoolean(key: string, value: boolean): void;
  163821. /**
  163822. * Reads a number from the data storage
  163823. * @param key The key to read
  163824. * @param defaultValue The value if the key doesn't exist
  163825. * @returns The number value
  163826. */
  163827. static ReadNumber(key: string, defaultValue: number): number;
  163828. /**
  163829. * Writes a number to the data storage
  163830. * @param key The key to write
  163831. * @param value The value to write
  163832. */
  163833. static WriteNumber(key: string, value: number): void;
  163834. }
  163835. }
  163836. declare module BABYLON {
  163837. /**
  163838. * Class used to record delta files between 2 scene states
  163839. */
  163840. export class SceneRecorder {
  163841. private _trackedScene;
  163842. private _savedJSON;
  163843. /**
  163844. * Track a given scene. This means the current scene state will be considered the original state
  163845. * @param scene defines the scene to track
  163846. */
  163847. track(scene: Scene): void;
  163848. /**
  163849. * Get the delta between current state and original state
  163850. * @returns a any containing the delta
  163851. */
  163852. getDelta(): any;
  163853. private _compareArray;
  163854. private _compareObjects;
  163855. private _compareCollections;
  163856. private static GetShadowGeneratorById;
  163857. /**
  163858. * Apply a given delta to a given scene
  163859. * @param deltaJSON defines the JSON containing the delta
  163860. * @param scene defines the scene to apply the delta to
  163861. */
  163862. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  163863. private static _ApplyPropertiesToEntity;
  163864. private static _ApplyDeltaForEntity;
  163865. }
  163866. }
  163867. declare module BABYLON {
  163868. /**
  163869. * A 3D trajectory consisting of an order list of vectors describing a
  163870. * path of motion through 3D space.
  163871. */
  163872. export class Trajectory {
  163873. private _points;
  163874. private readonly _segmentLength;
  163875. /**
  163876. * Serialize to JSON.
  163877. * @returns serialized JSON string
  163878. */
  163879. serialize(): string;
  163880. /**
  163881. * Deserialize from JSON.
  163882. * @param json serialized JSON string
  163883. * @returns deserialized Trajectory
  163884. */
  163885. static Deserialize(json: string): Trajectory;
  163886. /**
  163887. * Create a new empty Trajectory.
  163888. * @param segmentLength radius of discretization for Trajectory points
  163889. */
  163890. constructor(segmentLength?: number);
  163891. /**
  163892. * Get the length of the Trajectory.
  163893. * @returns length of the Trajectory
  163894. */
  163895. getLength(): number;
  163896. /**
  163897. * Append a new point to the Trajectory.
  163898. * NOTE: This implementation has many allocations.
  163899. * @param point point to append to the Trajectory
  163900. */
  163901. add(point: DeepImmutable<Vector3>): void;
  163902. /**
  163903. * Create a new Trajectory with a segment length chosen to make it
  163904. * probable that the new Trajectory will have a specified number of
  163905. * segments. This operation is imprecise.
  163906. * @param targetResolution number of segments desired
  163907. * @returns new Trajectory with approximately the requested number of segments
  163908. */
  163909. resampleAtTargetResolution(targetResolution: number): Trajectory;
  163910. /**
  163911. * Convert Trajectory segments into tokenized representation. This
  163912. * representation is an array of numbers where each nth number is the
  163913. * index of the token which is most similar to the nth segment of the
  163914. * Trajectory.
  163915. * @param tokens list of vectors which serve as discrete tokens
  163916. * @returns list of indices of most similar token per segment
  163917. */
  163918. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  163919. private static _forwardDir;
  163920. private static _inverseFromVec;
  163921. private static _upDir;
  163922. private static _fromToVec;
  163923. private static _lookMatrix;
  163924. /**
  163925. * Transform the rotation (i.e., direction) of a segment to isolate
  163926. * the relative transformation represented by the segment. This operation
  163927. * may or may not succeed due to singularities in the equations that define
  163928. * motion relativity in this context.
  163929. * @param priorVec the origin of the prior segment
  163930. * @param fromVec the origin of the current segment
  163931. * @param toVec the destination of the current segment
  163932. * @param result reference to output variable
  163933. * @returns whether or not transformation was successful
  163934. */
  163935. private static _transformSegmentDirToRef;
  163936. private static _bestMatch;
  163937. private static _score;
  163938. private static _bestScore;
  163939. /**
  163940. * Determine which token vector is most similar to the
  163941. * segment vector.
  163942. * @param segment segment vector
  163943. * @param tokens token vector list
  163944. * @returns index of the most similar token to the segment
  163945. */
  163946. private static _tokenizeSegment;
  163947. }
  163948. /**
  163949. * Class representing a set of known, named trajectories to which Trajectories can be
  163950. * added and using which Trajectories can be recognized.
  163951. */
  163952. export class TrajectoryClassifier {
  163953. private _maximumAllowableMatchCost;
  163954. private _vector3Alphabet;
  163955. private _levenshteinAlphabet;
  163956. private _nameToDescribedTrajectory;
  163957. /**
  163958. * Serialize to JSON.
  163959. * @returns JSON serialization
  163960. */
  163961. serialize(): string;
  163962. /**
  163963. * Deserialize from JSON.
  163964. * @param json JSON serialization
  163965. * @returns deserialized TrajectorySet
  163966. */
  163967. static Deserialize(json: string): TrajectoryClassifier;
  163968. /**
  163969. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  163970. * VERY naive, need to be generating these things from known
  163971. * sets. Better version later, probably eliminating this one.
  163972. * @returns auto-generated TrajectorySet
  163973. */
  163974. static Generate(): TrajectoryClassifier;
  163975. private constructor();
  163976. /**
  163977. * Add a new Trajectory to the set with a given name.
  163978. * @param trajectory new Trajectory to be added
  163979. * @param classification name to which to add the Trajectory
  163980. */
  163981. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  163982. /**
  163983. * Remove a known named trajectory and all Trajectories associated with it.
  163984. * @param classification name to remove
  163985. * @returns whether anything was removed
  163986. */
  163987. deleteClassification(classification: string): boolean;
  163988. /**
  163989. * Attempt to recognize a Trajectory from among all the classifications
  163990. * already known to the classifier.
  163991. * @param trajectory Trajectory to be recognized
  163992. * @returns classification of Trajectory if recognized, null otherwise
  163993. */
  163994. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  163995. }
  163996. }
  163997. declare module BABYLON {
  163998. /**
  163999. * An interface for all Hit test features
  164000. */
  164001. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  164002. /**
  164003. * Triggered when new babylon (transformed) hit test results are available
  164004. */
  164005. onHitTestResultObservable: Observable<T[]>;
  164006. }
  164007. /**
  164008. * Options used for hit testing
  164009. */
  164010. export interface IWebXRLegacyHitTestOptions {
  164011. /**
  164012. * Only test when user interacted with the scene. Default - hit test every frame
  164013. */
  164014. testOnPointerDownOnly?: boolean;
  164015. /**
  164016. * The node to use to transform the local results to world coordinates
  164017. */
  164018. worldParentNode?: TransformNode;
  164019. }
  164020. /**
  164021. * Interface defining the babylon result of raycasting/hit-test
  164022. */
  164023. export interface IWebXRLegacyHitResult {
  164024. /**
  164025. * Transformation matrix that can be applied to a node that will put it in the hit point location
  164026. */
  164027. transformationMatrix: Matrix;
  164028. /**
  164029. * The native hit test result
  164030. */
  164031. xrHitResult: XRHitResult | XRHitTestResult;
  164032. }
  164033. /**
  164034. * The currently-working hit-test module.
  164035. * Hit test (or Ray-casting) is used to interact with the real world.
  164036. * For further information read here - https://github.com/immersive-web/hit-test
  164037. */
  164038. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  164039. /**
  164040. * options to use when constructing this feature
  164041. */
  164042. readonly options: IWebXRLegacyHitTestOptions;
  164043. private _direction;
  164044. private _mat;
  164045. private _onSelectEnabled;
  164046. private _origin;
  164047. /**
  164048. * The module's name
  164049. */
  164050. static readonly Name: string;
  164051. /**
  164052. * The (Babylon) version of this module.
  164053. * This is an integer representing the implementation version.
  164054. * This number does not correspond to the WebXR specs version
  164055. */
  164056. static readonly Version: number;
  164057. /**
  164058. * Populated with the last native XR Hit Results
  164059. */
  164060. lastNativeXRHitResults: XRHitResult[];
  164061. /**
  164062. * Triggered when new babylon (transformed) hit test results are available
  164063. */
  164064. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  164065. /**
  164066. * Creates a new instance of the (legacy version) hit test feature
  164067. * @param _xrSessionManager an instance of WebXRSessionManager
  164068. * @param options options to use when constructing this feature
  164069. */
  164070. constructor(_xrSessionManager: WebXRSessionManager,
  164071. /**
  164072. * options to use when constructing this feature
  164073. */
  164074. options?: IWebXRLegacyHitTestOptions);
  164075. /**
  164076. * execute a hit test with an XR Ray
  164077. *
  164078. * @param xrSession a native xrSession that will execute this hit test
  164079. * @param xrRay the ray (position and direction) to use for ray-casting
  164080. * @param referenceSpace native XR reference space to use for the hit-test
  164081. * @param filter filter function that will filter the results
  164082. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  164083. */
  164084. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  164085. /**
  164086. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  164087. * @param event the (select) event to use to select with
  164088. * @param referenceSpace the reference space to use for this hit test
  164089. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  164090. */
  164091. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  164092. /**
  164093. * attach this feature
  164094. * Will usually be called by the features manager
  164095. *
  164096. * @returns true if successful.
  164097. */
  164098. attach(): boolean;
  164099. /**
  164100. * detach this feature.
  164101. * Will usually be called by the features manager
  164102. *
  164103. * @returns true if successful.
  164104. */
  164105. detach(): boolean;
  164106. /**
  164107. * Dispose this feature and all of the resources attached
  164108. */
  164109. dispose(): void;
  164110. protected _onXRFrame(frame: XRFrame): void;
  164111. private _onHitTestResults;
  164112. private _onSelect;
  164113. }
  164114. }
  164115. declare module BABYLON {
  164116. /**
  164117. * Options used for hit testing (version 2)
  164118. */
  164119. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  164120. /**
  164121. * Do not create a permanent hit test. Will usually be used when only
  164122. * transient inputs are needed.
  164123. */
  164124. disablePermanentHitTest?: boolean;
  164125. /**
  164126. * Enable transient (for example touch-based) hit test inspections
  164127. */
  164128. enableTransientHitTest?: boolean;
  164129. /**
  164130. * Offset ray for the permanent hit test
  164131. */
  164132. offsetRay?: Vector3;
  164133. /**
  164134. * Offset ray for the transient hit test
  164135. */
  164136. transientOffsetRay?: Vector3;
  164137. /**
  164138. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  164139. */
  164140. useReferenceSpace?: boolean;
  164141. /**
  164142. * Override the default entity type(s) of the hit-test result
  164143. */
  164144. entityTypes?: XRHitTestTrackableType[];
  164145. }
  164146. /**
  164147. * Interface defining the babylon result of hit-test
  164148. */
  164149. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  164150. /**
  164151. * The input source that generated this hit test (if transient)
  164152. */
  164153. inputSource?: XRInputSource;
  164154. /**
  164155. * Is this a transient hit test
  164156. */
  164157. isTransient?: boolean;
  164158. /**
  164159. * Position of the hit test result
  164160. */
  164161. position: Vector3;
  164162. /**
  164163. * Rotation of the hit test result
  164164. */
  164165. rotationQuaternion: Quaternion;
  164166. /**
  164167. * The native hit test result
  164168. */
  164169. xrHitResult: XRHitTestResult;
  164170. }
  164171. /**
  164172. * The currently-working hit-test module.
  164173. * Hit test (or Ray-casting) is used to interact with the real world.
  164174. * For further information read here - https://github.com/immersive-web/hit-test
  164175. *
  164176. * Tested on chrome (mobile) 80.
  164177. */
  164178. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  164179. /**
  164180. * options to use when constructing this feature
  164181. */
  164182. readonly options: IWebXRHitTestOptions;
  164183. private _tmpMat;
  164184. private _tmpPos;
  164185. private _tmpQuat;
  164186. private _transientXrHitTestSource;
  164187. private _xrHitTestSource;
  164188. private initHitTestSource;
  164189. /**
  164190. * The module's name
  164191. */
  164192. static readonly Name: string;
  164193. /**
  164194. * The (Babylon) version of this module.
  164195. * This is an integer representing the implementation version.
  164196. * This number does not correspond to the WebXR specs version
  164197. */
  164198. static readonly Version: number;
  164199. /**
  164200. * When set to true, each hit test will have its own position/rotation objects
  164201. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  164202. * the developers will clone them or copy them as they see fit.
  164203. */
  164204. autoCloneTransformation: boolean;
  164205. /**
  164206. * Triggered when new babylon (transformed) hit test results are available
  164207. * Note - this will be called when results come back from the device. It can be an empty array!!
  164208. */
  164209. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  164210. /**
  164211. * Use this to temporarily pause hit test checks.
  164212. */
  164213. paused: boolean;
  164214. /**
  164215. * Creates a new instance of the hit test feature
  164216. * @param _xrSessionManager an instance of WebXRSessionManager
  164217. * @param options options to use when constructing this feature
  164218. */
  164219. constructor(_xrSessionManager: WebXRSessionManager,
  164220. /**
  164221. * options to use when constructing this feature
  164222. */
  164223. options?: IWebXRHitTestOptions);
  164224. /**
  164225. * attach this feature
  164226. * Will usually be called by the features manager
  164227. *
  164228. * @returns true if successful.
  164229. */
  164230. attach(): boolean;
  164231. /**
  164232. * detach this feature.
  164233. * Will usually be called by the features manager
  164234. *
  164235. * @returns true if successful.
  164236. */
  164237. detach(): boolean;
  164238. /**
  164239. * Dispose this feature and all of the resources attached
  164240. */
  164241. dispose(): void;
  164242. protected _onXRFrame(frame: XRFrame): void;
  164243. private _processWebXRHitTestResult;
  164244. }
  164245. }
  164246. declare module BABYLON {
  164247. /**
  164248. * Configuration options of the anchor system
  164249. */
  164250. export interface IWebXRAnchorSystemOptions {
  164251. /**
  164252. * a node that will be used to convert local to world coordinates
  164253. */
  164254. worldParentNode?: TransformNode;
  164255. /**
  164256. * If set to true a reference of the created anchors will be kept until the next session starts
  164257. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  164258. */
  164259. doNotRemoveAnchorsOnSessionEnded?: boolean;
  164260. }
  164261. /**
  164262. * A babylon container for an XR Anchor
  164263. */
  164264. export interface IWebXRAnchor {
  164265. /**
  164266. * A babylon-assigned ID for this anchor
  164267. */
  164268. id: number;
  164269. /**
  164270. * Transformation matrix to apply to an object attached to this anchor
  164271. */
  164272. transformationMatrix: Matrix;
  164273. /**
  164274. * The native anchor object
  164275. */
  164276. xrAnchor: XRAnchor;
  164277. /**
  164278. * if defined, this object will be constantly updated by the anchor's position and rotation
  164279. */
  164280. attachedNode?: TransformNode;
  164281. /**
  164282. * Remove this anchor from the scene
  164283. */
  164284. remove(): void;
  164285. }
  164286. /**
  164287. * An implementation of the anchor system for WebXR.
  164288. * For further information see https://github.com/immersive-web/anchors/
  164289. */
  164290. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  164291. private _options;
  164292. private _lastFrameDetected;
  164293. private _trackedAnchors;
  164294. private _referenceSpaceForFrameAnchors;
  164295. private _futureAnchors;
  164296. /**
  164297. * The module's name
  164298. */
  164299. static readonly Name: string;
  164300. /**
  164301. * The (Babylon) version of this module.
  164302. * This is an integer representing the implementation version.
  164303. * This number does not correspond to the WebXR specs version
  164304. */
  164305. static readonly Version: number;
  164306. /**
  164307. * Observers registered here will be executed when a new anchor was added to the session
  164308. */
  164309. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  164310. /**
  164311. * Observers registered here will be executed when an anchor was removed from the session
  164312. */
  164313. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  164314. /**
  164315. * Observers registered here will be executed when an existing anchor updates
  164316. * This can execute N times every frame
  164317. */
  164318. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  164319. /**
  164320. * Set the reference space to use for anchor creation, when not using a hit test.
  164321. * Will default to the session's reference space if not defined
  164322. */
  164323. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  164324. /**
  164325. * constructs a new anchor system
  164326. * @param _xrSessionManager an instance of WebXRSessionManager
  164327. * @param _options configuration object for this feature
  164328. */
  164329. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  164330. private _tmpVector;
  164331. private _tmpQuaternion;
  164332. private _populateTmpTransformation;
  164333. /**
  164334. * Create a new anchor point using a hit test result at a specific point in the scene
  164335. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  164336. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  164337. *
  164338. * @param hitTestResult The hit test result to use for this anchor creation
  164339. * @param position an optional position offset for this anchor
  164340. * @param rotationQuaternion an optional rotation offset for this anchor
  164341. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  164342. */
  164343. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  164344. /**
  164345. * Add a new anchor at a specific position and rotation
  164346. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  164347. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  164348. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  164349. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  164350. *
  164351. * @param position the position in which to add an anchor
  164352. * @param rotationQuaternion an optional rotation for the anchor transformation
  164353. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  164354. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  164355. */
  164356. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  164357. /**
  164358. * Get the list of anchors currently being tracked by the system
  164359. */
  164360. get anchors(): IWebXRAnchor[];
  164361. /**
  164362. * detach this feature.
  164363. * Will usually be called by the features manager
  164364. *
  164365. * @returns true if successful.
  164366. */
  164367. detach(): boolean;
  164368. /**
  164369. * Dispose this feature and all of the resources attached
  164370. */
  164371. dispose(): void;
  164372. protected _onXRFrame(frame: XRFrame): void;
  164373. /**
  164374. * avoiding using Array.find for global support.
  164375. * @param xrAnchor the plane to find in the array
  164376. */
  164377. private _findIndexInAnchorArray;
  164378. private _updateAnchorWithXRFrame;
  164379. private _createAnchorAtTransformation;
  164380. }
  164381. }
  164382. declare module BABYLON {
  164383. /**
  164384. * Options used in the plane detector module
  164385. */
  164386. export interface IWebXRPlaneDetectorOptions {
  164387. /**
  164388. * The node to use to transform the local results to world coordinates
  164389. */
  164390. worldParentNode?: TransformNode;
  164391. /**
  164392. * If set to true a reference of the created planes will be kept until the next session starts
  164393. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  164394. */
  164395. doNotRemovePlanesOnSessionEnded?: boolean;
  164396. /**
  164397. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  164398. */
  164399. preferredDetectorOptions?: XRGeometryDetectorOptions;
  164400. }
  164401. /**
  164402. * A babylon interface for a WebXR plane.
  164403. * A Plane is actually a polygon, built from N points in space
  164404. *
  164405. * Supported in chrome 79, not supported in canary 81 ATM
  164406. */
  164407. export interface IWebXRPlane {
  164408. /**
  164409. * a babylon-assigned ID for this polygon
  164410. */
  164411. id: number;
  164412. /**
  164413. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  164414. */
  164415. polygonDefinition: Array<Vector3>;
  164416. /**
  164417. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  164418. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  164419. */
  164420. transformationMatrix: Matrix;
  164421. /**
  164422. * the native xr-plane object
  164423. */
  164424. xrPlane: XRPlane;
  164425. }
  164426. /**
  164427. * The plane detector is used to detect planes in the real world when in AR
  164428. * For more information see https://github.com/immersive-web/real-world-geometry/
  164429. */
  164430. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  164431. private _options;
  164432. private _detectedPlanes;
  164433. private _enabled;
  164434. private _lastFrameDetected;
  164435. /**
  164436. * The module's name
  164437. */
  164438. static readonly Name: string;
  164439. /**
  164440. * The (Babylon) version of this module.
  164441. * This is an integer representing the implementation version.
  164442. * This number does not correspond to the WebXR specs version
  164443. */
  164444. static readonly Version: number;
  164445. /**
  164446. * Observers registered here will be executed when a new plane was added to the session
  164447. */
  164448. onPlaneAddedObservable: Observable<IWebXRPlane>;
  164449. /**
  164450. * Observers registered here will be executed when a plane is no longer detected in the session
  164451. */
  164452. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  164453. /**
  164454. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  164455. * This can execute N times every frame
  164456. */
  164457. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  164458. /**
  164459. * construct a new Plane Detector
  164460. * @param _xrSessionManager an instance of xr Session manager
  164461. * @param _options configuration to use when constructing this feature
  164462. */
  164463. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  164464. /**
  164465. * detach this feature.
  164466. * Will usually be called by the features manager
  164467. *
  164468. * @returns true if successful.
  164469. */
  164470. detach(): boolean;
  164471. /**
  164472. * Dispose this feature and all of the resources attached
  164473. */
  164474. dispose(): void;
  164475. /**
  164476. * Check if the needed objects are defined.
  164477. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  164478. */
  164479. isCompatible(): boolean;
  164480. protected _onXRFrame(frame: XRFrame): void;
  164481. private _init;
  164482. private _updatePlaneWithXRPlane;
  164483. /**
  164484. * avoiding using Array.find for global support.
  164485. * @param xrPlane the plane to find in the array
  164486. */
  164487. private _findIndexInPlaneArray;
  164488. }
  164489. }
  164490. declare module BABYLON {
  164491. /**
  164492. * Options interface for the background remover plugin
  164493. */
  164494. export interface IWebXRBackgroundRemoverOptions {
  164495. /**
  164496. * Further background meshes to disable when entering AR
  164497. */
  164498. backgroundMeshes?: AbstractMesh[];
  164499. /**
  164500. * flags to configure the removal of the environment helper.
  164501. * If not set, the entire background will be removed. If set, flags should be set as well.
  164502. */
  164503. environmentHelperRemovalFlags?: {
  164504. /**
  164505. * Should the skybox be removed (default false)
  164506. */
  164507. skyBox?: boolean;
  164508. /**
  164509. * Should the ground be removed (default false)
  164510. */
  164511. ground?: boolean;
  164512. };
  164513. /**
  164514. * don't disable the environment helper
  164515. */
  164516. ignoreEnvironmentHelper?: boolean;
  164517. }
  164518. /**
  164519. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  164520. */
  164521. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  164522. /**
  164523. * read-only options to be used in this module
  164524. */
  164525. readonly options: IWebXRBackgroundRemoverOptions;
  164526. /**
  164527. * The module's name
  164528. */
  164529. static readonly Name: string;
  164530. /**
  164531. * The (Babylon) version of this module.
  164532. * This is an integer representing the implementation version.
  164533. * This number does not correspond to the WebXR specs version
  164534. */
  164535. static readonly Version: number;
  164536. /**
  164537. * registered observers will be triggered when the background state changes
  164538. */
  164539. onBackgroundStateChangedObservable: Observable<boolean>;
  164540. /**
  164541. * constructs a new background remover module
  164542. * @param _xrSessionManager the session manager for this module
  164543. * @param options read-only options to be used in this module
  164544. */
  164545. constructor(_xrSessionManager: WebXRSessionManager,
  164546. /**
  164547. * read-only options to be used in this module
  164548. */
  164549. options?: IWebXRBackgroundRemoverOptions);
  164550. /**
  164551. * attach this feature
  164552. * Will usually be called by the features manager
  164553. *
  164554. * @returns true if successful.
  164555. */
  164556. attach(): boolean;
  164557. /**
  164558. * detach this feature.
  164559. * Will usually be called by the features manager
  164560. *
  164561. * @returns true if successful.
  164562. */
  164563. detach(): boolean;
  164564. /**
  164565. * Dispose this feature and all of the resources attached
  164566. */
  164567. dispose(): void;
  164568. protected _onXRFrame(_xrFrame: XRFrame): void;
  164569. private _setBackgroundState;
  164570. }
  164571. }
  164572. declare module BABYLON {
  164573. /**
  164574. * Options for the controller physics feature
  164575. */
  164576. export class IWebXRControllerPhysicsOptions {
  164577. /**
  164578. * Should the headset get its own impostor
  164579. */
  164580. enableHeadsetImpostor?: boolean;
  164581. /**
  164582. * Optional parameters for the headset impostor
  164583. */
  164584. headsetImpostorParams?: {
  164585. /**
  164586. * The type of impostor to create. Default is sphere
  164587. */
  164588. impostorType: number;
  164589. /**
  164590. * the size of the impostor. Defaults to 10cm
  164591. */
  164592. impostorSize?: number | {
  164593. width: number;
  164594. height: number;
  164595. depth: number;
  164596. };
  164597. /**
  164598. * Friction definitions
  164599. */
  164600. friction?: number;
  164601. /**
  164602. * Restitution
  164603. */
  164604. restitution?: number;
  164605. };
  164606. /**
  164607. * The physics properties of the future impostors
  164608. */
  164609. physicsProperties?: {
  164610. /**
  164611. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  164612. * Note that this requires a physics engine that supports mesh impostors!
  164613. */
  164614. useControllerMesh?: boolean;
  164615. /**
  164616. * The type of impostor to create. Default is sphere
  164617. */
  164618. impostorType?: number;
  164619. /**
  164620. * the size of the impostor. Defaults to 10cm
  164621. */
  164622. impostorSize?: number | {
  164623. width: number;
  164624. height: number;
  164625. depth: number;
  164626. };
  164627. /**
  164628. * Friction definitions
  164629. */
  164630. friction?: number;
  164631. /**
  164632. * Restitution
  164633. */
  164634. restitution?: number;
  164635. };
  164636. /**
  164637. * the xr input to use with this pointer selection
  164638. */
  164639. xrInput: WebXRInput;
  164640. }
  164641. /**
  164642. * Add physics impostor to your webxr controllers,
  164643. * including naive calculation of their linear and angular velocity
  164644. */
  164645. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  164646. private readonly _options;
  164647. private _attachController;
  164648. private _controllers;
  164649. private _debugMode;
  164650. private _delta;
  164651. private _headsetImpostor?;
  164652. private _headsetMesh?;
  164653. private _lastTimestamp;
  164654. private _tmpQuaternion;
  164655. private _tmpVector;
  164656. /**
  164657. * The module's name
  164658. */
  164659. static readonly Name: string;
  164660. /**
  164661. * The (Babylon) version of this module.
  164662. * This is an integer representing the implementation version.
  164663. * This number does not correspond to the webxr specs version
  164664. */
  164665. static readonly Version: number;
  164666. /**
  164667. * Construct a new Controller Physics Feature
  164668. * @param _xrSessionManager the corresponding xr session manager
  164669. * @param _options options to create this feature with
  164670. */
  164671. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  164672. /**
  164673. * @hidden
  164674. * enable debugging - will show console outputs and the impostor mesh
  164675. */
  164676. _enablePhysicsDebug(): void;
  164677. /**
  164678. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  164679. * @param xrController the controller to add
  164680. */
  164681. addController(xrController: WebXRInputSource): void;
  164682. /**
  164683. * attach this feature
  164684. * Will usually be called by the features manager
  164685. *
  164686. * @returns true if successful.
  164687. */
  164688. attach(): boolean;
  164689. /**
  164690. * detach this feature.
  164691. * Will usually be called by the features manager
  164692. *
  164693. * @returns true if successful.
  164694. */
  164695. detach(): boolean;
  164696. /**
  164697. * Get the headset impostor, if enabled
  164698. * @returns the impostor
  164699. */
  164700. getHeadsetImpostor(): PhysicsImpostor | undefined;
  164701. /**
  164702. * Get the physics impostor of a specific controller.
  164703. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  164704. * @param controller the controller or the controller id of which to get the impostor
  164705. * @returns the impostor or null
  164706. */
  164707. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  164708. /**
  164709. * Update the physics properties provided in the constructor
  164710. * @param newProperties the new properties object
  164711. */
  164712. setPhysicsProperties(newProperties: {
  164713. impostorType?: number;
  164714. impostorSize?: number | {
  164715. width: number;
  164716. height: number;
  164717. depth: number;
  164718. };
  164719. friction?: number;
  164720. restitution?: number;
  164721. }): void;
  164722. protected _onXRFrame(_xrFrame: any): void;
  164723. private _detachController;
  164724. }
  164725. }
  164726. declare module BABYLON {
  164727. /**
  164728. * A babylon interface for a "WebXR" feature point.
  164729. * Represents the position and confidence value of a given feature point.
  164730. */
  164731. export interface IWebXRFeaturePoint {
  164732. /**
  164733. * Represents the position of the feature point in world space.
  164734. */
  164735. position: Vector3;
  164736. /**
  164737. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  164738. */
  164739. confidenceValue: number;
  164740. }
  164741. /**
  164742. * The feature point system is used to detect feature points from real world geometry.
  164743. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  164744. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  164745. */
  164746. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  164747. private _enabled;
  164748. private _featurePointCloud;
  164749. /**
  164750. * The module's name
  164751. */
  164752. static readonly Name: string;
  164753. /**
  164754. * The (Babylon) version of this module.
  164755. * This is an integer representing the implementation version.
  164756. * This number does not correspond to the WebXR specs version
  164757. */
  164758. static readonly Version: number;
  164759. /**
  164760. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  164761. * Will notify the observers about which feature points have been added.
  164762. */
  164763. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  164764. /**
  164765. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  164766. * Will notify the observers about which feature points have been updated.
  164767. */
  164768. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  164769. /**
  164770. * The current feature point cloud maintained across frames.
  164771. */
  164772. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  164773. /**
  164774. * construct the feature point system
  164775. * @param _xrSessionManager an instance of xr Session manager
  164776. */
  164777. constructor(_xrSessionManager: WebXRSessionManager);
  164778. /**
  164779. * Detach this feature.
  164780. * Will usually be called by the features manager
  164781. *
  164782. * @returns true if successful.
  164783. */
  164784. detach(): boolean;
  164785. /**
  164786. * Dispose this feature and all of the resources attached
  164787. */
  164788. dispose(): void;
  164789. /**
  164790. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  164791. */
  164792. protected _onXRFrame(frame: XRFrame): void;
  164793. /**
  164794. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  164795. */
  164796. private _init;
  164797. }
  164798. }
  164799. declare module BABYLON {
  164800. /**
  164801. * Configuration interface for the hand tracking feature
  164802. */
  164803. export interface IWebXRHandTrackingOptions {
  164804. /**
  164805. * The xrInput that will be used as source for new hands
  164806. */
  164807. xrInput: WebXRInput;
  164808. /**
  164809. * Configuration object for the joint meshes
  164810. */
  164811. jointMeshes?: {
  164812. /**
  164813. * Should the meshes created be invisible (defaults to false)
  164814. */
  164815. invisible?: boolean;
  164816. /**
  164817. * A source mesh to be used to create instances. Defaults to a sphere.
  164818. * This mesh will be the source for all other (25) meshes.
  164819. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  164820. */
  164821. sourceMesh?: Mesh;
  164822. /**
  164823. * This function will be called after a mesh was created for a specific joint.
  164824. * Using this function you can either manipulate the instance or return a new mesh.
  164825. * When returning a new mesh the instance created before will be disposed
  164826. */
  164827. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  164828. /**
  164829. * Should the source mesh stay visible. Defaults to false
  164830. */
  164831. keepOriginalVisible?: boolean;
  164832. /**
  164833. * Scale factor for all instances (defaults to 2)
  164834. */
  164835. scaleFactor?: number;
  164836. /**
  164837. * Should each instance have its own physics impostor
  164838. */
  164839. enablePhysics?: boolean;
  164840. /**
  164841. * If enabled, override default physics properties
  164842. */
  164843. physicsProps?: {
  164844. friction?: number;
  164845. restitution?: number;
  164846. impostorType?: number;
  164847. };
  164848. /**
  164849. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  164850. */
  164851. disableDefaultHandMesh?: boolean;
  164852. /**
  164853. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  164854. */
  164855. handMeshes?: {
  164856. right: AbstractMesh;
  164857. left: AbstractMesh;
  164858. };
  164859. /**
  164860. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  164861. */
  164862. rigMapping?: {
  164863. right: string[];
  164864. left: string[];
  164865. };
  164866. };
  164867. }
  164868. /**
  164869. * Parts of the hands divided to writs and finger names
  164870. */
  164871. export const enum HandPart {
  164872. /**
  164873. * HandPart - Wrist
  164874. */
  164875. WRIST = "wrist",
  164876. /**
  164877. * HandPart - The THumb
  164878. */
  164879. THUMB = "thumb",
  164880. /**
  164881. * HandPart - Index finger
  164882. */
  164883. INDEX = "index",
  164884. /**
  164885. * HandPart - Middle finger
  164886. */
  164887. MIDDLE = "middle",
  164888. /**
  164889. * HandPart - Ring finger
  164890. */
  164891. RING = "ring",
  164892. /**
  164893. * HandPart - Little finger
  164894. */
  164895. LITTLE = "little"
  164896. }
  164897. /**
  164898. * Representing a single hand (with its corresponding native XRHand object)
  164899. */
  164900. export class WebXRHand implements IDisposable {
  164901. /** the controller to which the hand correlates */
  164902. readonly xrController: WebXRInputSource;
  164903. /** the meshes to be used to track the hand joints */
  164904. readonly trackedMeshes: AbstractMesh[];
  164905. private _handMesh?;
  164906. private _rigMapping?;
  164907. private _scene;
  164908. private _defaultHandMesh;
  164909. private _transformNodeMapping;
  164910. /**
  164911. * Hand-parts definition (key is HandPart)
  164912. */
  164913. handPartsDefinition: {
  164914. [key: string]: number[];
  164915. };
  164916. /**
  164917. * Observers will be triggered when the mesh for this hand was initialized.
  164918. */
  164919. onHandMeshReadyObservable: Observable<WebXRHand>;
  164920. /**
  164921. * Populate the HandPartsDefinition object.
  164922. * This is called as a side effect since certain browsers don't have XRHand defined.
  164923. */
  164924. private generateHandPartsDefinition;
  164925. /**
  164926. * Construct a new hand object
  164927. * @param xrController the controller to which the hand correlates
  164928. * @param trackedMeshes the meshes to be used to track the hand joints
  164929. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  164930. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  164931. * @param disableDefaultHandMesh should the default mesh creation be disabled
  164932. */
  164933. constructor(
  164934. /** the controller to which the hand correlates */
  164935. xrController: WebXRInputSource,
  164936. /** the meshes to be used to track the hand joints */
  164937. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  164938. /**
  164939. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  164940. */
  164941. get handMesh(): AbstractMesh | undefined;
  164942. /**
  164943. * Update this hand from the latest xr frame
  164944. * @param xrFrame xrFrame to update from
  164945. * @param referenceSpace The current viewer reference space
  164946. * @param scaleFactor optional scale factor for the meshes
  164947. */
  164948. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  164949. /**
  164950. * Get meshes of part of the hand
  164951. * @param part the part of hand to get
  164952. * @returns An array of meshes that correlate to the hand part requested
  164953. */
  164954. getHandPartMeshes(part: HandPart): AbstractMesh[];
  164955. /**
  164956. * Dispose this Hand object
  164957. */
  164958. dispose(): void;
  164959. private _generateDefaultHandMesh;
  164960. }
  164961. /**
  164962. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  164963. */
  164964. export class WebXRHandTracking extends WebXRAbstractFeature {
  164965. /**
  164966. * options to use when constructing this feature
  164967. */
  164968. readonly options: IWebXRHandTrackingOptions;
  164969. private static _idCounter;
  164970. /**
  164971. * The module's name
  164972. */
  164973. static readonly Name: string;
  164974. /**
  164975. * The (Babylon) version of this module.
  164976. * This is an integer representing the implementation version.
  164977. * This number does not correspond to the WebXR specs version
  164978. */
  164979. static readonly Version: number;
  164980. /**
  164981. * This observable will notify registered observers when a new hand object was added and initialized
  164982. */
  164983. onHandAddedObservable: Observable<WebXRHand>;
  164984. /**
  164985. * This observable will notify its observers right before the hand object is disposed
  164986. */
  164987. onHandRemovedObservable: Observable<WebXRHand>;
  164988. private _hands;
  164989. /**
  164990. * Creates a new instance of the hit test feature
  164991. * @param _xrSessionManager an instance of WebXRSessionManager
  164992. * @param options options to use when constructing this feature
  164993. */
  164994. constructor(_xrSessionManager: WebXRSessionManager,
  164995. /**
  164996. * options to use when constructing this feature
  164997. */
  164998. options: IWebXRHandTrackingOptions);
  164999. /**
  165000. * Check if the needed objects are defined.
  165001. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  165002. */
  165003. isCompatible(): boolean;
  165004. /**
  165005. * attach this feature
  165006. * Will usually be called by the features manager
  165007. *
  165008. * @returns true if successful.
  165009. */
  165010. attach(): boolean;
  165011. /**
  165012. * detach this feature.
  165013. * Will usually be called by the features manager
  165014. *
  165015. * @returns true if successful.
  165016. */
  165017. detach(): boolean;
  165018. /**
  165019. * Dispose this feature and all of the resources attached
  165020. */
  165021. dispose(): void;
  165022. /**
  165023. * Get the hand object according to the controller id
  165024. * @param controllerId the controller id to which we want to get the hand
  165025. * @returns null if not found or the WebXRHand object if found
  165026. */
  165027. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  165028. /**
  165029. * Get a hand object according to the requested handedness
  165030. * @param handedness the handedness to request
  165031. * @returns null if not found or the WebXRHand object if found
  165032. */
  165033. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  165034. protected _onXRFrame(_xrFrame: XRFrame): void;
  165035. private _attachHand;
  165036. private _detachHand;
  165037. }
  165038. }
  165039. declare module BABYLON {
  165040. /**
  165041. * Options used in the mesh detector module
  165042. */
  165043. export interface IWebXRMeshDetectorOptions {
  165044. /**
  165045. * The node to use to transform the local results to world coordinates
  165046. */
  165047. worldParentNode?: TransformNode;
  165048. /**
  165049. * If set to true a reference of the created meshes will be kept until the next session starts
  165050. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  165051. */
  165052. doNotRemoveMeshesOnSessionEnded?: boolean;
  165053. /**
  165054. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  165055. */
  165056. preferredDetectorOptions?: XRGeometryDetectorOptions;
  165057. /**
  165058. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  165059. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  165060. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  165061. */
  165062. convertCoordinateSystems?: boolean;
  165063. }
  165064. /**
  165065. * A babylon interface for a XR mesh's vertex data.
  165066. *
  165067. * Currently not supported by WebXR, available only with BabylonNative
  165068. */
  165069. export interface IWebXRVertexData {
  165070. /**
  165071. * A babylon-assigned ID for this mesh
  165072. */
  165073. id: number;
  165074. /**
  165075. * Data required for constructing a mesh in Babylon.js.
  165076. */
  165077. xrMesh: XRMesh;
  165078. /**
  165079. * The node to use to transform the local results to world coordinates.
  165080. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  165081. */
  165082. worldParentNode?: TransformNode;
  165083. /**
  165084. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  165085. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  165086. */
  165087. positions?: Float32Array;
  165088. /**
  165089. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  165090. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  165091. */
  165092. indices?: Uint32Array;
  165093. /**
  165094. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  165095. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  165096. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  165097. */
  165098. normals?: Float32Array;
  165099. /**
  165100. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  165101. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  165102. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  165103. */
  165104. transformationMatrix?: Matrix;
  165105. }
  165106. /**
  165107. * The mesh detector is used to detect meshes in the real world when in AR
  165108. */
  165109. export class WebXRMeshDetector extends WebXRAbstractFeature {
  165110. private _options;
  165111. private _detectedMeshes;
  165112. /**
  165113. * The module's name
  165114. */
  165115. static readonly Name: string;
  165116. /**
  165117. * The (Babylon) version of this module.
  165118. * This is an integer representing the implementation version.
  165119. * This number does not correspond to the WebXR specs version
  165120. */
  165121. static readonly Version: number;
  165122. /**
  165123. * Observers registered here will be executed when a new mesh was added to the session
  165124. */
  165125. onMeshAddedObservable: Observable<IWebXRVertexData>;
  165126. /**
  165127. * Observers registered here will be executed when a mesh is no longer detected in the session
  165128. */
  165129. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  165130. /**
  165131. * Observers registered here will be executed when an existing mesh updates
  165132. */
  165133. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  165134. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  165135. detach(): boolean;
  165136. dispose(): void;
  165137. protected _onXRFrame(frame: XRFrame): void;
  165138. private _init;
  165139. private _updateVertexDataWithXRMesh;
  165140. }
  165141. }
  165142. declare module BABYLON {
  165143. /**
  165144. * Options interface for the background remover plugin
  165145. */
  165146. export interface IWebXRImageTrackingOptions {
  165147. /**
  165148. * A required array with images to track
  165149. */
  165150. images: {
  165151. /**
  165152. * The source of the image. can be a URL or an image bitmap
  165153. */
  165154. src: string | ImageBitmap;
  165155. /**
  165156. * The estimated width in the real world (in meters)
  165157. */
  165158. estimatedRealWorldWidth: number;
  165159. }[];
  165160. }
  165161. /**
  165162. * An object representing an image tracked by the system
  165163. */
  165164. export interface IWebXRTrackedImage {
  165165. /**
  165166. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  165167. */
  165168. id: number;
  165169. /**
  165170. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  165171. */
  165172. emulated?: boolean;
  165173. /**
  165174. * Just in case it is needed - the image bitmap that is being tracked
  165175. */
  165176. originalBitmap: ImageBitmap;
  165177. /**
  165178. * The native XR result image tracking result, untouched
  165179. */
  165180. xrTrackingResult?: XRImageTrackingResult;
  165181. /**
  165182. * Width in real world (meters)
  165183. */
  165184. realWorldWidth?: number;
  165185. /**
  165186. * A transformation matrix of this current image in the current reference space.
  165187. */
  165188. transformationMatrix: Matrix;
  165189. /**
  165190. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  165191. */
  165192. ratio?: number;
  165193. }
  165194. /**
  165195. * Image tracking for immersive AR sessions.
  165196. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  165197. */
  165198. export class WebXRImageTracking extends WebXRAbstractFeature {
  165199. /**
  165200. * read-only options to be used in this module
  165201. */
  165202. readonly options: IWebXRImageTrackingOptions;
  165203. /**
  165204. * The module's name
  165205. */
  165206. static readonly Name: string;
  165207. /**
  165208. * The (Babylon) version of this module.
  165209. * This is an integer representing the implementation version.
  165210. * This number does not correspond to the WebXR specs version
  165211. */
  165212. static readonly Version: number;
  165213. /**
  165214. * This will be triggered if the underlying system deems an image untrackable.
  165215. * The index is the index of the image from the array used to initialize the feature.
  165216. */
  165217. onUntrackableImageFoundObservable: Observable<number>;
  165218. /**
  165219. * An image was deemed trackable, and the system will start tracking it.
  165220. */
  165221. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  165222. /**
  165223. * The image was found and its state was updated.
  165224. */
  165225. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  165226. private _trackedImages;
  165227. private _originalTrackingRequest;
  165228. /**
  165229. * constructs the image tracking feature
  165230. * @param _xrSessionManager the session manager for this module
  165231. * @param options read-only options to be used in this module
  165232. */
  165233. constructor(_xrSessionManager: WebXRSessionManager,
  165234. /**
  165235. * read-only options to be used in this module
  165236. */
  165237. options: IWebXRImageTrackingOptions);
  165238. /**
  165239. * attach this feature
  165240. * Will usually be called by the features manager
  165241. *
  165242. * @returns true if successful.
  165243. */
  165244. attach(): boolean;
  165245. /**
  165246. * detach this feature.
  165247. * Will usually be called by the features manager
  165248. *
  165249. * @returns true if successful.
  165250. */
  165251. detach(): boolean;
  165252. /**
  165253. * Check if the needed objects are defined.
  165254. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  165255. */
  165256. isCompatible(): boolean;
  165257. /**
  165258. * Get a tracked image by its ID.
  165259. *
  165260. * @param id the id of the image to load (position in the init array)
  165261. * @returns a trackable image, if exists in this location
  165262. */
  165263. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  165264. /**
  165265. * Dispose this feature and all of the resources attached
  165266. */
  165267. dispose(): void;
  165268. /**
  165269. * Extends the session init object if needed
  165270. * @returns augmentation object fo the xr session init object.
  165271. */
  165272. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  165273. protected _onXRFrame(_xrFrame: XRFrame): void;
  165274. private _init;
  165275. }
  165276. }
  165277. declare module BABYLON {
  165278. /**
  165279. * The motion controller class for all microsoft mixed reality controllers
  165280. */
  165281. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  165282. protected readonly _mapping: {
  165283. defaultButton: {
  165284. valueNodeName: string;
  165285. unpressedNodeName: string;
  165286. pressedNodeName: string;
  165287. };
  165288. defaultAxis: {
  165289. valueNodeName: string;
  165290. minNodeName: string;
  165291. maxNodeName: string;
  165292. };
  165293. buttons: {
  165294. "xr-standard-trigger": {
  165295. rootNodeName: string;
  165296. componentProperty: string;
  165297. states: string[];
  165298. };
  165299. "xr-standard-squeeze": {
  165300. rootNodeName: string;
  165301. componentProperty: string;
  165302. states: string[];
  165303. };
  165304. "xr-standard-touchpad": {
  165305. rootNodeName: string;
  165306. labelAnchorNodeName: string;
  165307. touchPointNodeName: string;
  165308. };
  165309. "xr-standard-thumbstick": {
  165310. rootNodeName: string;
  165311. componentProperty: string;
  165312. states: string[];
  165313. };
  165314. };
  165315. axes: {
  165316. "xr-standard-touchpad": {
  165317. "x-axis": {
  165318. rootNodeName: string;
  165319. };
  165320. "y-axis": {
  165321. rootNodeName: string;
  165322. };
  165323. };
  165324. "xr-standard-thumbstick": {
  165325. "x-axis": {
  165326. rootNodeName: string;
  165327. };
  165328. "y-axis": {
  165329. rootNodeName: string;
  165330. };
  165331. };
  165332. };
  165333. };
  165334. /**
  165335. * The base url used to load the left and right controller models
  165336. */
  165337. static MODEL_BASE_URL: string;
  165338. /**
  165339. * The name of the left controller model file
  165340. */
  165341. static MODEL_LEFT_FILENAME: string;
  165342. /**
  165343. * The name of the right controller model file
  165344. */
  165345. static MODEL_RIGHT_FILENAME: string;
  165346. profileId: string;
  165347. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  165348. protected _getFilenameAndPath(): {
  165349. filename: string;
  165350. path: string;
  165351. };
  165352. protected _getModelLoadingConstraints(): boolean;
  165353. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  165354. protected _setRootMesh(meshes: AbstractMesh[]): void;
  165355. protected _updateModel(): void;
  165356. }
  165357. }
  165358. declare module BABYLON {
  165359. /**
  165360. * The motion controller class for oculus touch (quest, rift).
  165361. * This class supports legacy mapping as well the standard xr mapping
  165362. */
  165363. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  165364. private _forceLegacyControllers;
  165365. private _modelRootNode;
  165366. /**
  165367. * The base url used to load the left and right controller models
  165368. */
  165369. static MODEL_BASE_URL: string;
  165370. /**
  165371. * The name of the left controller model file
  165372. */
  165373. static MODEL_LEFT_FILENAME: string;
  165374. /**
  165375. * The name of the right controller model file
  165376. */
  165377. static MODEL_RIGHT_FILENAME: string;
  165378. /**
  165379. * Base Url for the Quest controller model.
  165380. */
  165381. static QUEST_MODEL_BASE_URL: string;
  165382. profileId: string;
  165383. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  165384. protected _getFilenameAndPath(): {
  165385. filename: string;
  165386. path: string;
  165387. };
  165388. protected _getModelLoadingConstraints(): boolean;
  165389. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  165390. protected _setRootMesh(meshes: AbstractMesh[]): void;
  165391. protected _updateModel(): void;
  165392. /**
  165393. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  165394. * between the touch and touch 2.
  165395. */
  165396. private _isQuest;
  165397. }
  165398. }
  165399. declare module BABYLON {
  165400. /**
  165401. * The motion controller class for the standard HTC-Vive controllers
  165402. */
  165403. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  165404. private _modelRootNode;
  165405. /**
  165406. * The base url used to load the left and right controller models
  165407. */
  165408. static MODEL_BASE_URL: string;
  165409. /**
  165410. * File name for the controller model.
  165411. */
  165412. static MODEL_FILENAME: string;
  165413. profileId: string;
  165414. /**
  165415. * Create a new Vive motion controller object
  165416. * @param scene the scene to use to create this controller
  165417. * @param gamepadObject the corresponding gamepad object
  165418. * @param handedness the handedness of the controller
  165419. */
  165420. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  165421. protected _getFilenameAndPath(): {
  165422. filename: string;
  165423. path: string;
  165424. };
  165425. protected _getModelLoadingConstraints(): boolean;
  165426. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  165427. protected _setRootMesh(meshes: AbstractMesh[]): void;
  165428. protected _updateModel(): void;
  165429. }
  165430. }
  165431. declare module BABYLON {
  165432. /**
  165433. * A cursor which tracks a point on a path
  165434. */
  165435. export class PathCursor {
  165436. private path;
  165437. /**
  165438. * Stores path cursor callbacks for when an onchange event is triggered
  165439. */
  165440. private _onchange;
  165441. /**
  165442. * The value of the path cursor
  165443. */
  165444. value: number;
  165445. /**
  165446. * The animation array of the path cursor
  165447. */
  165448. animations: Animation[];
  165449. /**
  165450. * Initializes the path cursor
  165451. * @param path The path to track
  165452. */
  165453. constructor(path: Path2);
  165454. /**
  165455. * Gets the cursor point on the path
  165456. * @returns A point on the path cursor at the cursor location
  165457. */
  165458. getPoint(): Vector3;
  165459. /**
  165460. * Moves the cursor ahead by the step amount
  165461. * @param step The amount to move the cursor forward
  165462. * @returns This path cursor
  165463. */
  165464. moveAhead(step?: number): PathCursor;
  165465. /**
  165466. * Moves the cursor behind by the step amount
  165467. * @param step The amount to move the cursor back
  165468. * @returns This path cursor
  165469. */
  165470. moveBack(step?: number): PathCursor;
  165471. /**
  165472. * Moves the cursor by the step amount
  165473. * If the step amount is greater than one, an exception is thrown
  165474. * @param step The amount to move the cursor
  165475. * @returns This path cursor
  165476. */
  165477. move(step: number): PathCursor;
  165478. /**
  165479. * Ensures that the value is limited between zero and one
  165480. * @returns This path cursor
  165481. */
  165482. private ensureLimits;
  165483. /**
  165484. * Runs onchange callbacks on change (used by the animation engine)
  165485. * @returns This path cursor
  165486. */
  165487. private raiseOnChange;
  165488. /**
  165489. * Executes a function on change
  165490. * @param f A path cursor onchange callback
  165491. * @returns This path cursor
  165492. */
  165493. onchange(f: (cursor: PathCursor) => void): PathCursor;
  165494. }
  165495. }
  165496. declare module BABYLON {
  165497. /** @hidden */
  165498. export var blurPixelShader: {
  165499. name: string;
  165500. shader: string;
  165501. };
  165502. }
  165503. declare module BABYLON {
  165504. /** @hidden */
  165505. export var pointCloudVertexDeclaration: {
  165506. name: string;
  165507. shader: string;
  165508. };
  165509. }
  165510. // Mixins
  165511. interface Window {
  165512. mozIndexedDB: IDBFactory;
  165513. webkitIndexedDB: IDBFactory;
  165514. msIndexedDB: IDBFactory;
  165515. webkitURL: typeof URL;
  165516. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  165517. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  165518. WebGLRenderingContext: WebGLRenderingContext;
  165519. MSGesture: MSGesture;
  165520. CANNON: any;
  165521. AudioContext: AudioContext;
  165522. webkitAudioContext: AudioContext;
  165523. PointerEvent: any;
  165524. Math: Math;
  165525. Uint8Array: Uint8ArrayConstructor;
  165526. Float32Array: Float32ArrayConstructor;
  165527. mozURL: typeof URL;
  165528. msURL: typeof URL;
  165529. VRFrameData: any; // WebVR, from specs 1.1
  165530. DracoDecoderModule: any;
  165531. setImmediate(handler: (...args: any[]) => void): number;
  165532. }
  165533. interface HTMLCanvasElement {
  165534. requestPointerLock(): void;
  165535. msRequestPointerLock?(): void;
  165536. mozRequestPointerLock?(): void;
  165537. webkitRequestPointerLock?(): void;
  165538. /** Track wether a record is in progress */
  165539. isRecording: boolean;
  165540. /** Capture Stream method defined by some browsers */
  165541. captureStream(fps?: number): MediaStream;
  165542. }
  165543. interface CanvasRenderingContext2D {
  165544. msImageSmoothingEnabled: boolean;
  165545. }
  165546. interface MouseEvent {
  165547. mozMovementX: number;
  165548. mozMovementY: number;
  165549. webkitMovementX: number;
  165550. webkitMovementY: number;
  165551. msMovementX: number;
  165552. msMovementY: number;
  165553. }
  165554. interface Navigator {
  165555. mozGetVRDevices: (any: any) => any;
  165556. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  165557. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  165558. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  165559. webkitGetGamepads(): Gamepad[];
  165560. msGetGamepads(): Gamepad[];
  165561. webkitGamepads(): Gamepad[];
  165562. }
  165563. interface HTMLVideoElement {
  165564. mozSrcObject: any;
  165565. }
  165566. interface Math {
  165567. fround(x: number): number;
  165568. imul(a: number, b: number): number;
  165569. log2(x: number): number;
  165570. }
  165571. interface WebGLRenderingContext {
  165572. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  165573. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  165574. vertexAttribDivisor(index: number, divisor: number): void;
  165575. createVertexArray(): any;
  165576. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  165577. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  165578. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  165579. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  165580. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  165581. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  165582. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  165583. // Queries
  165584. createQuery(): WebGLQuery;
  165585. deleteQuery(query: WebGLQuery): void;
  165586. beginQuery(target: number, query: WebGLQuery): void;
  165587. endQuery(target: number): void;
  165588. getQueryParameter(query: WebGLQuery, pname: number): any;
  165589. getQuery(target: number, pname: number): any;
  165590. MAX_SAMPLES: number;
  165591. RGBA8: number;
  165592. READ_FRAMEBUFFER: number;
  165593. DRAW_FRAMEBUFFER: number;
  165594. UNIFORM_BUFFER: number;
  165595. HALF_FLOAT_OES: number;
  165596. RGBA16F: number;
  165597. RGBA32F: number;
  165598. R32F: number;
  165599. RG32F: number;
  165600. RGB32F: number;
  165601. R16F: number;
  165602. RG16F: number;
  165603. RGB16F: number;
  165604. RED: number;
  165605. RG: number;
  165606. R8: number;
  165607. RG8: number;
  165608. UNSIGNED_INT_24_8: number;
  165609. DEPTH24_STENCIL8: number;
  165610. MIN: number;
  165611. MAX: number;
  165612. /* Multiple Render Targets */
  165613. drawBuffers(buffers: number[]): void;
  165614. readBuffer(src: number): void;
  165615. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  165616. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  165617. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  165618. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  165619. // Occlusion Query
  165620. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  165621. ANY_SAMPLES_PASSED: number;
  165622. QUERY_RESULT_AVAILABLE: number;
  165623. QUERY_RESULT: number;
  165624. }
  165625. interface WebGLProgram {
  165626. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  165627. }
  165628. interface EXT_disjoint_timer_query {
  165629. QUERY_COUNTER_BITS_EXT: number;
  165630. TIME_ELAPSED_EXT: number;
  165631. TIMESTAMP_EXT: number;
  165632. GPU_DISJOINT_EXT: number;
  165633. QUERY_RESULT_EXT: number;
  165634. QUERY_RESULT_AVAILABLE_EXT: number;
  165635. queryCounterEXT(query: WebGLQuery, target: number): void;
  165636. createQueryEXT(): WebGLQuery;
  165637. beginQueryEXT(target: number, query: WebGLQuery): void;
  165638. endQueryEXT(target: number): void;
  165639. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  165640. deleteQueryEXT(query: WebGLQuery): void;
  165641. }
  165642. interface WebGLUniformLocation {
  165643. _currentState: any;
  165644. }
  165645. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  165646. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  165647. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  165648. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  165649. interface WebGLRenderingContext {
  165650. readonly RASTERIZER_DISCARD: number;
  165651. readonly DEPTH_COMPONENT24: number;
  165652. readonly TEXTURE_3D: number;
  165653. readonly TEXTURE_2D_ARRAY: number;
  165654. readonly TEXTURE_COMPARE_FUNC: number;
  165655. readonly TEXTURE_COMPARE_MODE: number;
  165656. readonly COMPARE_REF_TO_TEXTURE: number;
  165657. readonly TEXTURE_WRAP_R: number;
  165658. readonly HALF_FLOAT: number;
  165659. readonly RGB8: number;
  165660. readonly RED_INTEGER: number;
  165661. readonly RG_INTEGER: number;
  165662. readonly RGB_INTEGER: number;
  165663. readonly RGBA_INTEGER: number;
  165664. readonly R8_SNORM: number;
  165665. readonly RG8_SNORM: number;
  165666. readonly RGB8_SNORM: number;
  165667. readonly RGBA8_SNORM: number;
  165668. readonly R8I: number;
  165669. readonly RG8I: number;
  165670. readonly RGB8I: number;
  165671. readonly RGBA8I: number;
  165672. readonly R8UI: number;
  165673. readonly RG8UI: number;
  165674. readonly RGB8UI: number;
  165675. readonly RGBA8UI: number;
  165676. readonly R16I: number;
  165677. readonly RG16I: number;
  165678. readonly RGB16I: number;
  165679. readonly RGBA16I: number;
  165680. readonly R16UI: number;
  165681. readonly RG16UI: number;
  165682. readonly RGB16UI: number;
  165683. readonly RGBA16UI: number;
  165684. readonly R32I: number;
  165685. readonly RG32I: number;
  165686. readonly RGB32I: number;
  165687. readonly RGBA32I: number;
  165688. readonly R32UI: number;
  165689. readonly RG32UI: number;
  165690. readonly RGB32UI: number;
  165691. readonly RGBA32UI: number;
  165692. readonly RGB10_A2UI: number;
  165693. readonly R11F_G11F_B10F: number;
  165694. readonly RGB9_E5: number;
  165695. readonly RGB10_A2: number;
  165696. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  165697. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  165698. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  165699. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  165700. readonly DEPTH_COMPONENT32F: number;
  165701. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  165702. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  165703. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
  165704. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  165705. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  165706. readonly TRANSFORM_FEEDBACK: number;
  165707. readonly INTERLEAVED_ATTRIBS: number;
  165708. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  165709. createTransformFeedback(): WebGLTransformFeedback;
  165710. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  165711. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  165712. beginTransformFeedback(primitiveMode: number): void;
  165713. endTransformFeedback(): void;
  165714. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  165715. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  165716. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  165717. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  165718. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  165719. }
  165720. interface ImageBitmap {
  165721. readonly width: number;
  165722. readonly height: number;
  165723. close(): void;
  165724. }
  165725. interface WebGLQuery extends WebGLObject {
  165726. }
  165727. declare var WebGLQuery: {
  165728. prototype: WebGLQuery;
  165729. new(): WebGLQuery;
  165730. };
  165731. interface WebGLSampler extends WebGLObject {
  165732. }
  165733. declare var WebGLSampler: {
  165734. prototype: WebGLSampler;
  165735. new(): WebGLSampler;
  165736. };
  165737. interface WebGLSync extends WebGLObject {
  165738. }
  165739. declare var WebGLSync: {
  165740. prototype: WebGLSync;
  165741. new(): WebGLSync;
  165742. };
  165743. interface WebGLTransformFeedback extends WebGLObject {
  165744. }
  165745. declare var WebGLTransformFeedback: {
  165746. prototype: WebGLTransformFeedback;
  165747. new(): WebGLTransformFeedback;
  165748. };
  165749. interface WebGLVertexArrayObject extends WebGLObject {
  165750. }
  165751. declare var WebGLVertexArrayObject: {
  165752. prototype: WebGLVertexArrayObject;
  165753. new(): WebGLVertexArrayObject;
  165754. };
  165755. interface Navigator {
  165756. readonly gpu: GPU | undefined;
  165757. }
  165758. interface GPUColorDict {
  165759. a: number;
  165760. b: number;
  165761. g: number;
  165762. r: number;
  165763. }
  165764. type GPUColor = [number, number, number, number] | GPUColorDict;
  165765. interface GPUOrigin2DDict {
  165766. x?: number;
  165767. y?: number;
  165768. }
  165769. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  165770. interface GPUOrigin3DDict {
  165771. x?: number;
  165772. y?: number;
  165773. z?: number;
  165774. }
  165775. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  165776. interface GPUExtent3DDict {
  165777. width: number;
  165778. height: number;
  165779. depth: number;
  165780. }
  165781. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  165782. type GPUBindingResource =
  165783. | GPUSampler
  165784. | GPUTextureView
  165785. | GPUBufferBinding;
  165786. type GPUExtensionName =
  165787. | "texture-compression-bc"
  165788. | "timestamp-query"
  165789. | "pipeline-statistics-query"
  165790. | "depth-clamping"
  165791. | "depth24unorm-stencil8"
  165792. | "depth32float-stencil8";
  165793. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  165794. type GPUBindingType =
  165795. | "uniform-buffer"
  165796. | "storage-buffer"
  165797. | "readonly-storage-buffer"
  165798. | "sampler"
  165799. | "comparison-sampler"
  165800. | "sampled-texture"
  165801. | "readonly-storage-texture"
  165802. | "writeonly-storage-texture";
  165803. type GPUBlendFactor =
  165804. | "zero"
  165805. | "one"
  165806. | "src-color"
  165807. | "one-minus-src-color"
  165808. | "src-alpha"
  165809. | "one-minus-src-alpha"
  165810. | "dst-color"
  165811. | "one-minus-dst-color"
  165812. | "dst-alpha"
  165813. | "one-minus-dst-alpha"
  165814. | "src-alpha-saturated"
  165815. | "blend-color"
  165816. | "one-minus-blend-color";
  165817. type GPUBlendOperation =
  165818. | "add"
  165819. | "subtract"
  165820. | "reverse-subtract"
  165821. | "min"
  165822. | "max";
  165823. type GPUCompareFunction =
  165824. | "never"
  165825. | "less"
  165826. | "equal"
  165827. | "less-equal"
  165828. | "greater"
  165829. | "not-equal"
  165830. | "greater-equal"
  165831. | "always";
  165832. type GPUCullMode = "none" | "front" | "back";
  165833. type GPUFilterMode = "nearest" | "linear";
  165834. type GPUFrontFace = "ccw" | "cw";
  165835. type GPUIndexFormat = "uint16" | "uint32";
  165836. type GPUInputStepMode = "vertex" | "instance";
  165837. type GPULoadOp = "load";
  165838. type GPUPrimitiveTopology =
  165839. | "point-list"
  165840. | "line-list"
  165841. | "line-strip"
  165842. | "triangle-list"
  165843. | "triangle-strip";
  165844. type GPUStencilOperation =
  165845. | "keep"
  165846. | "zero"
  165847. | "replace"
  165848. | "invert"
  165849. | "increment-clamp"
  165850. | "decrement-clamp"
  165851. | "increment-wrap"
  165852. | "decrement-wrap";
  165853. type GPUStoreOp = "store" | "clear";
  165854. type GPUTextureDimension = "1d" | "2d" | "3d";
  165855. type GPUTextureFormat =
  165856. | "r8unorm"
  165857. | "r8snorm"
  165858. | "r8uint"
  165859. | "r8sint"
  165860. | "r16uint"
  165861. | "r16sint"
  165862. | "r16float"
  165863. | "rg8unorm"
  165864. | "rg8snorm"
  165865. | "rg8uint"
  165866. | "rg8sint"
  165867. | "r32uint"
  165868. | "r32sint"
  165869. | "r32float"
  165870. | "rg16uint"
  165871. | "rg16sint"
  165872. | "rg16float"
  165873. | "rgba8unorm"
  165874. | "rgba8unorm-srgb"
  165875. | "rgba8snorm"
  165876. | "rgba8uint"
  165877. | "rgba8sint"
  165878. | "bgra8unorm"
  165879. | "bgra8unorm-srgb"
  165880. | "rgb9e5ufloat"
  165881. | "rgb10a2unorm"
  165882. | "rg11b10ufloat"
  165883. | "rg32uint"
  165884. | "rg32sint"
  165885. | "rg32float"
  165886. | "rgba16uint"
  165887. | "rgba16sint"
  165888. | "rgba16float"
  165889. | "rgba32uint"
  165890. | "rgba32sint"
  165891. | "rgba32float"
  165892. | "stencil8"
  165893. | "depth16unorm"
  165894. | "depth24plus"
  165895. | "depth24plus-stencil8"
  165896. | "depth32float"
  165897. | "bc1-rgba-unorm"
  165898. | "bc1-rgba-unorm-srgb"
  165899. | "bc2-rgba-unorm"
  165900. | "bc2-rgba-unorm-srgb"
  165901. | "bc3-rgba-unorm"
  165902. | "bc3-rgba-unorm-srgb"
  165903. | "bc4-r-unorm"
  165904. | "bc4-r-snorm"
  165905. | "bc5-rg-unorm"
  165906. | "bc5-rg-snorm"
  165907. | "bc6h-rgb-ufloat"
  165908. | "bc6h-rgb-float"
  165909. | "bc7-rgba-unorm"
  165910. | "bc7-rgba-unorm-srgb"
  165911. | "depth24unorm-stencil8"
  165912. | "depth32float-stencil8";
  165913. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  165914. type GPUTextureViewDimension =
  165915. | "1d"
  165916. | "2d"
  165917. | "2d-array"
  165918. | "cube"
  165919. | "cube-array"
  165920. | "3d";
  165921. type GPUVertexFormat =
  165922. | "uchar2"
  165923. | "uchar4"
  165924. | "char2"
  165925. | "char4"
  165926. | "uchar2norm"
  165927. | "uchar4norm"
  165928. | "char2norm"
  165929. | "char4norm"
  165930. | "ushort2"
  165931. | "ushort4"
  165932. | "short2"
  165933. | "short4"
  165934. | "ushort2norm"
  165935. | "ushort4norm"
  165936. | "short2norm"
  165937. | "short4norm"
  165938. | "half2"
  165939. | "half4"
  165940. | "float"
  165941. | "float2"
  165942. | "float3"
  165943. | "float4"
  165944. | "uint"
  165945. | "uint2"
  165946. | "uint3"
  165947. | "uint4"
  165948. | "int"
  165949. | "int2"
  165950. | "int3"
  165951. | "int4";
  165952. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  165953. type GPUBufferUsageFlags = number;
  165954. type GPUColorWriteFlags = number;
  165955. type GPUShaderStageFlags = number;
  165956. type GPUTextureUsageFlags = number;
  165957. type GPUMapModeFlags = number;
  165958. interface GPUBindGroupEntry {
  165959. binding: number;
  165960. resource: GPUBindingResource;
  165961. }
  165962. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  165963. layout: GPUBindGroupLayout;
  165964. entries: Iterable<GPUBindGroupEntry>;
  165965. }
  165966. interface GPUBindGroupLayoutEntry {
  165967. binding: number;
  165968. visibility: GPUShaderStageFlags;
  165969. type: GPUBindingType;
  165970. hasDynamicOffset?: boolean;
  165971. minBufferBindingSize?: number;
  165972. viewDimension?: GPUTextureViewDimension;
  165973. textureComponentType?: GPUTextureComponentType;
  165974. storageTextureFormat?: GPUTextureFormat;
  165975. }
  165976. interface GPUBindGroupLayoutDescriptor
  165977. extends GPUObjectDescriptorBase {
  165978. entries: Iterable<GPUBindGroupLayoutEntry>;
  165979. }
  165980. interface GPUBlendDescriptor {
  165981. dstFactor?: GPUBlendFactor;
  165982. operation?: GPUBlendOperation;
  165983. srcFactor?: GPUBlendFactor;
  165984. }
  165985. interface GPUColorStateDescriptor {
  165986. format: GPUTextureFormat;
  165987. alphaBlend?: GPUBlendDescriptor;
  165988. colorBlend?: GPUBlendDescriptor;
  165989. writeMask?: GPUColorWriteFlags;
  165990. }
  165991. interface GPUBufferBinding {
  165992. buffer: GPUBuffer;
  165993. offset?: number;
  165994. size?: number;
  165995. }
  165996. interface GPUTextureDataLayout {
  165997. offset?: number;
  165998. bytesPerRow: number;
  165999. rowsPerImage?: number;
  166000. }
  166001. interface GPUBufferCopyView extends GPUTextureDataLayout {
  166002. buffer: GPUBuffer;
  166003. }
  166004. interface GPUTextureCopyView {
  166005. texture: GPUTexture;
  166006. mipLevel?: number;
  166007. origin?: GPUOrigin3D;
  166008. }
  166009. interface GPUImageBitmapCopyView {
  166010. imageBitmap: ImageBitmap;
  166011. origin?: GPUOrigin2D;
  166012. }
  166013. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  166014. size: number;
  166015. usage: GPUBufferUsageFlags;
  166016. mappedAtCreation?: boolean;
  166017. }
  166018. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  166019. label?: string;
  166020. measureExecutionTime?: boolean;
  166021. }
  166022. interface GPUComputePipelineDescriptor
  166023. extends GPUPipelineDescriptorBase {
  166024. computeStage: GPUProgrammableStageDescriptor;
  166025. }
  166026. interface GPUDepthStencilStateDescriptor {
  166027. format: GPUTextureFormat;
  166028. depthWriteEnabled?: boolean;
  166029. depthCompare?: GPUCompareFunction;
  166030. stencilFront?: GPUStencilStateFaceDescriptor;
  166031. stencilBack?: GPUStencilStateFaceDescriptor;
  166032. stencilReadMask?: number;
  166033. stencilWriteMask?: number;
  166034. }
  166035. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  166036. extensions?: Iterable<GPUExtensionName>;
  166037. limits?: GPULimits;
  166038. }
  166039. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  166040. initialValue?: number;
  166041. label?: string;
  166042. signalQueue?: GPUQueue;
  166043. }
  166044. interface GPUVertexAttributeDescriptor {
  166045. format: GPUVertexFormat;
  166046. offset: number;
  166047. shaderLocation: number;
  166048. }
  166049. interface GPUVertexBufferLayoutDescriptor {
  166050. arrayStride: number;
  166051. stepMode?: GPUInputStepMode;
  166052. attributes: Iterable<GPUVertexAttributeDescriptor>;
  166053. }
  166054. interface GPUVertexStateDescriptor {
  166055. indexFormat?: GPUIndexFormat;
  166056. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  166057. }
  166058. interface GPULimits {
  166059. maxBindGroups?: number;
  166060. maxDynamicUniformBuffersPerPipelineLayout?: number;
  166061. maxDynamicStorageBuffersPerPipelineLayout?: number;
  166062. maxSampledTexturesPerShaderStage?: number;
  166063. maxSamplersPerShaderStage?: number;
  166064. maxStorageBuffersPerShaderStage?: number;
  166065. maxStorageTexturesPerShaderStage?: number;
  166066. maxUniformBuffersPerShaderStage?: number;
  166067. maxUniformBufferBindingSize?: number;
  166068. }
  166069. interface GPUPipelineDescriptorBase {
  166070. label?: string;
  166071. layout?: GPUPipelineLayout;
  166072. }
  166073. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  166074. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  166075. }
  166076. interface GPUProgrammableStageDescriptor {
  166077. module: GPUShaderModule;
  166078. entryPoint: string;
  166079. }
  166080. interface GPURasterizationStateDescriptor {
  166081. frontFace?: GPUFrontFace;
  166082. cullMode?: GPUCullMode;
  166083. clampDepth?: boolean;
  166084. depthBias?: number;
  166085. depthBiasSlopeScale?: number;
  166086. depthBiasClamp?: number;
  166087. }
  166088. interface GPURenderPassColorAttachmentDescriptor {
  166089. attachment: GPUTextureView;
  166090. resolveTarget?: GPUTextureView;
  166091. loadValue: GPULoadOp | GPUColor;
  166092. storeOp?: GPUStoreOp;
  166093. }
  166094. interface GPURenderPassDepthStencilAttachmentDescriptor {
  166095. attachment: GPUTextureView;
  166096. depthLoadValue: GPULoadOp | number;
  166097. depthStoreOp: GPUStoreOp;
  166098. depthReadOnly?: boolean;
  166099. stencilLoadValue: GPULoadOp | number;
  166100. stencilStoreOp: GPUStoreOp;
  166101. stencilReadOnly?: boolean;
  166102. }
  166103. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  166104. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  166105. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  166106. }
  166107. interface GPURenderPipelineDescriptor
  166108. extends GPUPipelineDescriptorBase {
  166109. vertexStage: GPUProgrammableStageDescriptor;
  166110. fragmentStage?: GPUProgrammableStageDescriptor;
  166111. primitiveTopology: GPUPrimitiveTopology;
  166112. rasterizationState?: GPURasterizationStateDescriptor;
  166113. colorStates: Iterable<GPUColorStateDescriptor>;
  166114. depthStencilState?: GPUDepthStencilStateDescriptor;
  166115. vertexState?: GPUVertexStateDescriptor;
  166116. sampleCount?: number;
  166117. sampleMask?: number;
  166118. alphaToCoverageEnabled?: boolean;
  166119. }
  166120. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  166121. addressModeU?: GPUAddressMode;
  166122. addressModeV?: GPUAddressMode;
  166123. addressModeW?: GPUAddressMode;
  166124. magFilter?: GPUFilterMode;
  166125. minFilter?: GPUFilterMode;
  166126. mipmapFilter?: GPUFilterMode;
  166127. lodMinClamp?: number;
  166128. lodMaxClamp?: number;
  166129. compare?: GPUCompareFunction;
  166130. maxAnisotropy?: number;
  166131. }
  166132. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  166133. code: Uint32Array | string;
  166134. label?: string;
  166135. sourceMap?: object;
  166136. }
  166137. interface GPUStencilStateFaceDescriptor {
  166138. compare?: GPUCompareFunction;
  166139. depthFailOp?: GPUStencilOperation;
  166140. passOp?: GPUStencilOperation;
  166141. failOp?: GPUStencilOperation;
  166142. }
  166143. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  166144. device: GPUDevice;
  166145. format: GPUTextureFormat;
  166146. usage?: GPUTextureUsageFlags;
  166147. }
  166148. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  166149. size: GPUExtent3D;
  166150. mipLevelCount?: number;
  166151. sampleCount?: number;
  166152. dimension?: GPUTextureDimension;
  166153. format: GPUTextureFormat;
  166154. usage: GPUTextureUsageFlags;
  166155. }
  166156. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  166157. format?: GPUTextureFormat;
  166158. dimension?: GPUTextureViewDimension;
  166159. aspect?: GPUTextureAspect;
  166160. baseArrayLayer?: number;
  166161. baseMipLevel?: number;
  166162. arrayLayerCount?: number;
  166163. mipLevelCount?: number;
  166164. }
  166165. declare class GPUAdapter {
  166166. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  166167. private __brand: void;
  166168. readonly name: string;
  166169. readonly extensions: GPUExtensionName[];
  166170. readonly limits: Required<GPULimits>;
  166171. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  166172. }
  166173. declare class GPUBindGroup implements GPUObjectBase {
  166174. private __brand: void;
  166175. label: string | undefined;
  166176. }
  166177. declare class GPUBindGroupLayout implements GPUObjectBase {
  166178. private __brand: void;
  166179. label: string | undefined;
  166180. }
  166181. declare class GPUBuffer implements GPUObjectBase {
  166182. private __brand: void;
  166183. label: string | undefined;
  166184. destroy(): void;
  166185. unmap(): void;
  166186. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  166187. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  166188. }
  166189. declare class GPUCommandBuffer implements GPUObjectBase {
  166190. private __brand: void;
  166191. label: string | undefined;
  166192. readonly executionTime: Promise<number>;
  166193. }
  166194. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  166195. declare class GPUCommandEncoder implements GPUObjectBase {
  166196. private __brand: void;
  166197. label: string | undefined;
  166198. beginComputePass(
  166199. descriptor?: GPUComputePassDescriptor
  166200. ): GPUComputePassEncoder;
  166201. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  166202. copyBufferToBuffer(
  166203. source: GPUBuffer,
  166204. sourceOffset: number,
  166205. destination: GPUBuffer,
  166206. destinationOffset: number,
  166207. size: number
  166208. ): void;
  166209. copyBufferToTexture(
  166210. source: GPUBufferCopyView,
  166211. destination: GPUTextureCopyView,
  166212. copySize: GPUExtent3D
  166213. ): void;
  166214. copyTextureToBuffer(
  166215. source: GPUTextureCopyView,
  166216. destination: GPUBufferCopyView,
  166217. copySize: GPUExtent3D
  166218. ): void;
  166219. copyTextureToTexture(
  166220. source: GPUTextureCopyView,
  166221. destination: GPUTextureCopyView,
  166222. copySize: GPUExtent3D
  166223. ): void;
  166224. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  166225. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  166226. popDebugGroup(): void;
  166227. pushDebugGroup(groupLabel: string): void;
  166228. insertDebugMarker(markerLabel: string): void;
  166229. }
  166230. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  166231. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  166232. private __brand: void;
  166233. label: string | undefined;
  166234. setBindGroup(
  166235. index: number,
  166236. bindGroup: GPUBindGroup,
  166237. dynamicOffsets?: Iterable<number>
  166238. ): void;
  166239. popDebugGroup(): void;
  166240. pushDebugGroup(groupLabel: string): void;
  166241. insertDebugMarker(markerLabel: string): void;
  166242. setPipeline(pipeline: GPUComputePipeline): void;
  166243. dispatch(x: number, y?: number, z?: number): void;
  166244. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  166245. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  166246. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  166247. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  166248. endPass(): void;
  166249. }
  166250. declare class GPUComputePipeline implements GPUPipelineBase {
  166251. private __brand: void;
  166252. label: string | undefined;
  166253. getBindGroupLayout(index: number): GPUBindGroupLayout;
  166254. }
  166255. interface GPUObjectBase {
  166256. label: string | undefined;
  166257. }
  166258. interface GPUObjectDescriptorBase {
  166259. label?: string;
  166260. }
  166261. // SwapChain / CanvasContext
  166262. declare class GPUCanvasContext {
  166263. private __brand: void;
  166264. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  166265. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  166266. }
  166267. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  166268. private __brand: void;
  166269. label: string | undefined;
  166270. readonly adapter: GPUAdapter;
  166271. readonly extensions: GPUExtensionName[];
  166272. readonly limits: Required<GPULimits>;
  166273. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  166274. createBindGroupLayout(
  166275. descriptor: GPUBindGroupLayoutDescriptor
  166276. ): GPUBindGroupLayout;
  166277. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  166278. createPipelineLayout(
  166279. descriptor: GPUPipelineLayoutDescriptor
  166280. ): GPUPipelineLayout;
  166281. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  166282. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  166283. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  166284. createComputePipeline(
  166285. descriptor: GPUComputePipelineDescriptor
  166286. ): GPUComputePipeline;
  166287. createRenderPipeline(
  166288. descriptor: GPURenderPipelineDescriptor
  166289. ): GPURenderPipeline;
  166290. createReadyComputePipeline(
  166291. descriptor: GPUComputePipelineDescriptor
  166292. ): Promise<GPUComputePipeline>;
  166293. createReadyRenderPipeline(
  166294. descriptor: GPURenderPipelineDescriptor
  166295. ): Promise<GPURenderPipeline>;
  166296. createCommandEncoder(
  166297. descriptor?: GPUCommandEncoderDescriptor
  166298. ): GPUCommandEncoder;
  166299. createRenderBundleEncoder(
  166300. descriptor: GPURenderBundleEncoderDescriptor
  166301. ): GPURenderBundleEncoder;
  166302. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  166303. defaultQueue: GPUQueue;
  166304. pushErrorScope(filter: GPUErrorFilter): void;
  166305. popErrorScope(): Promise<GPUError | null>;
  166306. onuncapturederror: Event | undefined;
  166307. readonly lost: Promise<GPUDeviceLostInfo>;
  166308. }
  166309. declare class GPUFence implements GPUObjectBase {
  166310. private __brand: void;
  166311. label: string | undefined;
  166312. getCompletedValue(): number;
  166313. onCompletion(completionValue: number): Promise<void>;
  166314. }
  166315. interface GPUPipelineBase extends GPUObjectBase {
  166316. getBindGroupLayout(index: number): GPUBindGroupLayout;
  166317. }
  166318. declare class GPUPipelineLayout implements GPUObjectBase {
  166319. private __brand: void;
  166320. label: string | undefined;
  166321. }
  166322. interface GPUProgrammablePassEncoder {
  166323. setBindGroup(
  166324. index: number,
  166325. bindGroup: GPUBindGroup,
  166326. dynamicOffsets?: Iterable<number>
  166327. ): void;
  166328. popDebugGroup(): void;
  166329. pushDebugGroup(groupLabel: string): void;
  166330. insertDebugMarker(markerLabel: string): void;
  166331. }
  166332. declare class GPUQueue implements GPUObjectBase {
  166333. private __brand: void;
  166334. label: string | undefined;
  166335. signal(fence: GPUFence, signalValue: number): void;
  166336. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  166337. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  166338. writeBuffer(buffer: GPUBuffer,
  166339. bufferOffset: number,
  166340. data: BufferSource | ArrayBuffer,
  166341. dataOffset?: number,
  166342. size?: number): void;
  166343. writeTexture(destination: GPUTextureCopyView,
  166344. data: BufferSource | ArrayBuffer,
  166345. dataLayout: GPUTextureDataLayout,
  166346. size: GPUExtent3D): void;
  166347. copyImageBitmapToTexture(
  166348. source: GPUImageBitmapCopyView,
  166349. destination: GPUTextureCopyView,
  166350. copySize: GPUExtent3D
  166351. ): void;
  166352. }
  166353. type GPUQueryType =
  166354. | "occlusion"
  166355. | "timestamp"
  166356. | "pipeline-statistics";
  166357. type GPUPipelineStatisticName =
  166358. | "vertex-shader-invocations"
  166359. | "clipper-invocations"
  166360. | "clipper-primitives-out"
  166361. | "fragment-shader-invocations"
  166362. | "compute-shader-invocations";
  166363. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  166364. type: GPUQueryType;
  166365. count: number;
  166366. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  166367. }
  166368. declare class GPUQuerySet implements GPUObjectBase {
  166369. private __brand: void;
  166370. label: string | undefined;
  166371. destroy(): void;
  166372. }
  166373. interface GPURenderEncoderBase {
  166374. setPipeline(pipeline: GPURenderPipeline): void;
  166375. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  166376. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  166377. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  166378. draw(
  166379. vertexCount: number,
  166380. instanceCount?: number,
  166381. firstVertex?: number,
  166382. firstInstance?: number
  166383. ): void;
  166384. drawIndexed(
  166385. indexCount: number,
  166386. instanceCount?: number,
  166387. firstIndex?: number,
  166388. baseVertex?: number,
  166389. firstInstance?: number
  166390. ): void;
  166391. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  166392. drawIndexedIndirect(
  166393. indirectBuffer: GPUBuffer,
  166394. indirectOffset: number
  166395. ): void;
  166396. }
  166397. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  166398. private __brand: void;
  166399. label: string | undefined;
  166400. setBindGroup(
  166401. index: number,
  166402. bindGroup: GPUBindGroup,
  166403. dynamicOffsets?: Iterable<number>
  166404. ): void;
  166405. popDebugGroup(): void;
  166406. pushDebugGroup(groupLabel: string): void;
  166407. insertDebugMarker(markerLabel: string): void;
  166408. setPipeline(pipeline: GPURenderPipeline): void;
  166409. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  166410. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  166411. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  166412. draw(
  166413. vertexCount: number,
  166414. instanceCount?: number,
  166415. firstVertex?: number,
  166416. firstInstance?: number
  166417. ): void;
  166418. drawIndexed(
  166419. indexCount: number,
  166420. instanceCount?: number,
  166421. firstIndex?: number,
  166422. baseVertex?: number,
  166423. firstInstance?: number
  166424. ): void;
  166425. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  166426. drawIndexedIndirect(
  166427. indirectBuffer: GPUBuffer,
  166428. indirectOffset: number
  166429. ): void;
  166430. setViewport(
  166431. x: number,
  166432. y: number,
  166433. width: number,
  166434. height: number,
  166435. minDepth: number,
  166436. maxDepth: number
  166437. ): void;
  166438. setScissorRect(x: number, y: number, width: number, height: number): void;
  166439. setBlendColor(color: GPUColor): void;
  166440. setStencilReference(reference: number): void;
  166441. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  166442. beginOcclusionQuery(queryIndex: number): void;
  166443. endOcclusionQuery(): void;
  166444. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  166445. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  166446. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  166447. endPass(): void;
  166448. }
  166449. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  166450. declare class GPURenderBundle implements GPUObjectBase {
  166451. private __brand: void;
  166452. label: string | undefined;
  166453. }
  166454. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  166455. private __brand: void;
  166456. label: string | undefined;
  166457. setBindGroup(
  166458. index: number,
  166459. bindGroup: GPUBindGroup,
  166460. dynamicOffsets?: Iterable<number>
  166461. ): void;
  166462. popDebugGroup(): void;
  166463. pushDebugGroup(groupLabel: string): void;
  166464. insertDebugMarker(markerLabel: string): void;
  166465. setPipeline(pipeline: GPURenderPipeline): void;
  166466. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  166467. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  166468. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  166469. draw(
  166470. vertexCount: number,
  166471. instanceCount?: number,
  166472. firstVertex?: number,
  166473. firstInstance?: number
  166474. ): void;
  166475. drawIndexed(
  166476. indexCount: number,
  166477. instanceCount?: number,
  166478. firstIndex?: number,
  166479. baseVertex?: number,
  166480. firstInstance?: number
  166481. ): void;
  166482. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  166483. drawIndexedIndirect(
  166484. indirectBuffer: GPUBuffer,
  166485. indirectOffset: number
  166486. ): void;
  166487. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  166488. }
  166489. interface GPURenderBundleEncoderDescriptor
  166490. extends GPUObjectDescriptorBase {
  166491. colorFormats: Iterable<GPUTextureFormat>;
  166492. depthStencilFormat?: GPUTextureFormat;
  166493. sampleCount?: number;
  166494. }
  166495. declare class GPURenderPipeline implements GPUPipelineBase {
  166496. private __brand: void;
  166497. label: string | undefined;
  166498. getBindGroupLayout(index: number): GPUBindGroupLayout;
  166499. }
  166500. declare class GPUSampler implements GPUObjectBase {
  166501. private __brand: void;
  166502. label: string | undefined;
  166503. }
  166504. type GPUCompilationMessageType =
  166505. | "error"
  166506. | "warning"
  166507. | "info";
  166508. interface GPUCompilationMessage {
  166509. readonly message: string;
  166510. readonly type: GPUCompilationMessageType;
  166511. readonly lineNum: number;
  166512. readonly linePos: number;
  166513. }
  166514. interface GPUCompilationInfo {
  166515. readonly messages: readonly GPUCompilationMessage[];
  166516. }
  166517. declare class GPUShaderModule implements GPUObjectBase {
  166518. private __brand: void;
  166519. label: string | undefined;
  166520. compilationInfo(): Promise<GPUCompilationInfo>;
  166521. }
  166522. declare class GPUSwapChain implements GPUObjectBase {
  166523. private __brand: void;
  166524. label: string | undefined;
  166525. getCurrentTexture(): GPUTexture;
  166526. }
  166527. declare class GPUTexture implements GPUObjectBase {
  166528. private __brand: void;
  166529. label: string | undefined;
  166530. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  166531. destroy(): void;
  166532. }
  166533. declare class GPUTextureView implements GPUObjectBase {
  166534. private __brand: void;
  166535. label: string | undefined;
  166536. }
  166537. type GPUPowerPreference = "low-power" | "high-performance";
  166538. interface GPURequestAdapterOptions {
  166539. powerPreference?: GPUPowerPreference;
  166540. }
  166541. declare class GPU {
  166542. private __brand: void;
  166543. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  166544. }
  166545. // ****************************************************************************
  166546. // ERROR SCOPES
  166547. // ****************************************************************************
  166548. type GPUErrorFilter = "out-of-memory" | "validation";
  166549. declare class GPUOutOfMemoryError {
  166550. private __brand: void;
  166551. constructor();
  166552. }
  166553. declare class GPUValidationError {
  166554. private __brand: void;
  166555. constructor(message: string);
  166556. readonly message: string;
  166557. }
  166558. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  166559. // ****************************************************************************
  166560. // TELEMETRY
  166561. // ****************************************************************************
  166562. declare class GPUUncapturedErrorEvent extends Event {
  166563. private __brand: void;
  166564. constructor(
  166565. type: string,
  166566. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  166567. );
  166568. readonly error: GPUError;
  166569. }
  166570. interface GPUUncapturedErrorEventInit extends EventInit {
  166571. error: GPUError;
  166572. }
  166573. declare class GPUDeviceLostInfo {
  166574. private __brand: void;
  166575. readonly message: string;
  166576. }
  166577. // Type definitions for WebVR API
  166578. // Project: https://w3c.github.io/webvr/
  166579. // Definitions by: six a <https://github.com/lostfictions>
  166580. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  166581. interface VRDisplay extends EventTarget {
  166582. /**
  166583. * Dictionary of capabilities describing the VRDisplay.
  166584. */
  166585. readonly capabilities: VRDisplayCapabilities;
  166586. /**
  166587. * z-depth defining the far plane of the eye view frustum
  166588. * enables mapping of values in the render target depth
  166589. * attachment to scene coordinates. Initially set to 10000.0.
  166590. */
  166591. depthFar: number;
  166592. /**
  166593. * z-depth defining the near plane of the eye view frustum
  166594. * enables mapping of values in the render target depth
  166595. * attachment to scene coordinates. Initially set to 0.01.
  166596. */
  166597. depthNear: number;
  166598. /**
  166599. * An identifier for this distinct VRDisplay. Used as an
  166600. * association point in the Gamepad API.
  166601. */
  166602. readonly displayId: number;
  166603. /**
  166604. * A display name, a user-readable name identifying it.
  166605. */
  166606. readonly displayName: string;
  166607. readonly isConnected: boolean;
  166608. readonly isPresenting: boolean;
  166609. /**
  166610. * If this VRDisplay supports room-scale experiences, the optional
  166611. * stage attribute contains details on the room-scale parameters.
  166612. */
  166613. readonly stageParameters: VRStageParameters | null;
  166614. /**
  166615. * Passing the value returned by `requestAnimationFrame` to
  166616. * `cancelAnimationFrame` will unregister the callback.
  166617. * @param handle Define the hanle of the request to cancel
  166618. */
  166619. cancelAnimationFrame(handle: number): void;
  166620. /**
  166621. * Stops presenting to the VRDisplay.
  166622. * @returns a promise to know when it stopped
  166623. */
  166624. exitPresent(): Promise<void>;
  166625. /**
  166626. * Return the current VREyeParameters for the given eye.
  166627. * @param whichEye Define the eye we want the parameter for
  166628. * @returns the eye parameters
  166629. */
  166630. getEyeParameters(whichEye: string): VREyeParameters;
  166631. /**
  166632. * Populates the passed VRFrameData with the information required to render
  166633. * the current frame.
  166634. * @param frameData Define the data structure to populate
  166635. * @returns true if ok otherwise false
  166636. */
  166637. getFrameData(frameData: VRFrameData): boolean;
  166638. /**
  166639. * Get the layers currently being presented.
  166640. * @returns the list of VR layers
  166641. */
  166642. getLayers(): VRLayer[];
  166643. /**
  166644. * Return a VRPose containing the future predicted pose of the VRDisplay
  166645. * when the current frame will be presented. The value returned will not
  166646. * change until JavaScript has returned control to the browser.
  166647. *
  166648. * The VRPose will contain the position, orientation, velocity,
  166649. * and acceleration of each of these properties.
  166650. * @returns the pose object
  166651. */
  166652. getPose(): VRPose;
  166653. /**
  166654. * Return the current instantaneous pose of the VRDisplay, with no
  166655. * prediction applied.
  166656. * @returns the current instantaneous pose
  166657. */
  166658. getImmediatePose(): VRPose;
  166659. /**
  166660. * The callback passed to `requestAnimationFrame` will be called
  166661. * any time a new frame should be rendered. When the VRDisplay is
  166662. * presenting the callback will be called at the native refresh
  166663. * rate of the HMD. When not presenting this function acts
  166664. * identically to how window.requestAnimationFrame acts. Content should
  166665. * make no assumptions of frame rate or vsync behavior as the HMD runs
  166666. * asynchronously from other displays and at differing refresh rates.
  166667. * @param callback Define the eaction to run next frame
  166668. * @returns the request handle it
  166669. */
  166670. requestAnimationFrame(callback: FrameRequestCallback): number;
  166671. /**
  166672. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  166673. * Repeat calls while already presenting will update the VRLayers being displayed.
  166674. * @param layers Define the list of layer to present
  166675. * @returns a promise to know when the request has been fulfilled
  166676. */
  166677. requestPresent(layers: VRLayer[]): Promise<void>;
  166678. /**
  166679. * Reset the pose for this display, treating its current position and
  166680. * orientation as the "origin/zero" values. VRPose.position,
  166681. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  166682. * updated when calling resetPose(). This should be called in only
  166683. * sitting-space experiences.
  166684. */
  166685. resetPose(): void;
  166686. /**
  166687. * The VRLayer provided to the VRDisplay will be captured and presented
  166688. * in the HMD. Calling this function has the same effect on the source
  166689. * canvas as any other operation that uses its source image, and canvases
  166690. * created without preserveDrawingBuffer set to true will be cleared.
  166691. * @param pose Define the pose to submit
  166692. */
  166693. submitFrame(pose?: VRPose): void;
  166694. }
  166695. declare var VRDisplay: {
  166696. prototype: VRDisplay;
  166697. new(): VRDisplay;
  166698. };
  166699. interface VRLayer {
  166700. leftBounds?: number[] | Float32Array | null;
  166701. rightBounds?: number[] | Float32Array | null;
  166702. source?: HTMLCanvasElement | null;
  166703. }
  166704. interface VRDisplayCapabilities {
  166705. readonly canPresent: boolean;
  166706. readonly hasExternalDisplay: boolean;
  166707. readonly hasOrientation: boolean;
  166708. readonly hasPosition: boolean;
  166709. readonly maxLayers: number;
  166710. }
  166711. interface VREyeParameters {
  166712. /** @deprecated */
  166713. readonly fieldOfView: VRFieldOfView;
  166714. readonly offset: Float32Array;
  166715. readonly renderHeight: number;
  166716. readonly renderWidth: number;
  166717. }
  166718. interface VRFieldOfView {
  166719. readonly downDegrees: number;
  166720. readonly leftDegrees: number;
  166721. readonly rightDegrees: number;
  166722. readonly upDegrees: number;
  166723. }
  166724. interface VRFrameData {
  166725. readonly leftProjectionMatrix: Float32Array;
  166726. readonly leftViewMatrix: Float32Array;
  166727. readonly pose: VRPose;
  166728. readonly rightProjectionMatrix: Float32Array;
  166729. readonly rightViewMatrix: Float32Array;
  166730. readonly timestamp: number;
  166731. }
  166732. interface VRPose {
  166733. readonly angularAcceleration: Float32Array | null;
  166734. readonly angularVelocity: Float32Array | null;
  166735. readonly linearAcceleration: Float32Array | null;
  166736. readonly linearVelocity: Float32Array | null;
  166737. readonly orientation: Float32Array | null;
  166738. readonly position: Float32Array | null;
  166739. readonly timestamp: number;
  166740. }
  166741. interface VRStageParameters {
  166742. sittingToStandingTransform?: Float32Array;
  166743. sizeX?: number;
  166744. sizeY?: number;
  166745. }
  166746. interface Navigator {
  166747. getVRDisplays(): Promise<VRDisplay[]>;
  166748. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  166749. }
  166750. interface Window {
  166751. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  166752. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  166753. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  166754. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  166755. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  166756. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  166757. }
  166758. interface Gamepad {
  166759. readonly displayId: number;
  166760. }
  166761. /**
  166762. * Available session modes
  166763. */
  166764. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  166765. /**
  166766. * Reference space types
  166767. */
  166768. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  166769. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  166770. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  166771. /**
  166772. * Handedness types
  166773. */
  166774. type XRHandedness = "none" | "left" | "right";
  166775. /**
  166776. * InputSource target ray modes
  166777. */
  166778. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  166779. /**
  166780. * Eye types
  166781. */
  166782. type XREye = "none" | "left" | "right";
  166783. /**
  166784. * Type of XR events available
  166785. */
  166786. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  166787. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  166788. type XRPlaneSet = Set<XRPlane>;
  166789. type XRAnchorSet = Set<XRAnchor>;
  166790. type XREventHandler = (callback: any) => void;
  166791. interface XRLayer extends EventTarget {}
  166792. interface XRSessionInit {
  166793. optionalFeatures?: string[];
  166794. requiredFeatures?: string[];
  166795. trackedImages?: XRTrackedImageInit[];
  166796. }
  166797. interface XRSessionEvent extends Event {
  166798. readonly session: XRSession;
  166799. }
  166800. interface XRSystem {
  166801. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  166802. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  166803. }
  166804. interface XRViewport {
  166805. readonly x: number;
  166806. readonly y: number;
  166807. readonly width: number;
  166808. readonly height: number;
  166809. }
  166810. interface XRWebGLLayerInit {
  166811. antialias?: boolean;
  166812. depth?: boolean;
  166813. stencil?: boolean;
  166814. alpha?: boolean;
  166815. multiview?: boolean;
  166816. framebufferScaleFactor?: number;
  166817. }
  166818. declare class XRWebGLLayer {
  166819. static getNativeFramebufferScaleFactor(session: XRSession): number;
  166820. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  166821. readonly antialias: boolean;
  166822. readonly framebuffer: WebGLFramebuffer;
  166823. readonly framebufferWidth: number;
  166824. readonly framebufferHeight: number;
  166825. readonly ignoreDepthValues: boolean;
  166826. getViewport: (view: XRView) => XRViewport;
  166827. }
  166828. // tslint:disable-next-line no-empty-interface
  166829. interface XRSpace extends EventTarget {}
  166830. interface XRRenderState {
  166831. readonly baseLayer?: XRWebGLLayer;
  166832. readonly depthFar: number;
  166833. readonly depthNear: number;
  166834. readonly inlineVerticalFieldOfView?: number;
  166835. }
  166836. interface XRRenderStateInit extends XRRenderState {
  166837. baseLayer: XRWebGLLayer;
  166838. depthFar: number;
  166839. depthNear: number;
  166840. inlineVerticalFieldOfView?: number;
  166841. layers?: XRLayer[];
  166842. }
  166843. interface XRReferenceSpace extends XRSpace {
  166844. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  166845. onreset: XREventHandler;
  166846. }
  166847. interface XRBoundedReferenceSpace extends XRSpace {
  166848. readonly boundsGeometry: DOMPointReadOnly[];
  166849. }
  166850. interface XRInputSource {
  166851. readonly handedness: XRHandedness;
  166852. readonly targetRayMode: XRTargetRayMode;
  166853. readonly targetRaySpace: XRSpace;
  166854. readonly gripSpace?: XRSpace;
  166855. readonly gamepad?: Gamepad;
  166856. readonly profiles: Array<string>;
  166857. readonly hand?: XRHand;
  166858. }
  166859. interface XRPose {
  166860. readonly transform: XRRigidTransform;
  166861. readonly emulatedPosition: boolean;
  166862. }
  166863. interface XRWorldInformation {
  166864. detectedPlanes?: XRPlaneSet;
  166865. }
  166866. interface XRFrame {
  166867. readonly session: XRSession;
  166868. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  166869. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  166870. // AR
  166871. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  166872. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  166873. // Anchors
  166874. trackedAnchors?: XRAnchorSet;
  166875. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  166876. // World geometries
  166877. worldInformation?: XRWorldInformation;
  166878. // Hand tracking
  166879. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  166880. // Image tracking
  166881. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  166882. }
  166883. interface XRInputSourceEvent extends Event {
  166884. readonly frame: XRFrame;
  166885. readonly inputSource: XRInputSource;
  166886. }
  166887. type XRInputSourceArray = XRInputSource[];
  166888. interface XRSession {
  166889. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  166890. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  166891. /**
  166892. * Returns a list of this session's XRInputSources, each representing an input device
  166893. * used to control the camera and/or scene.
  166894. */
  166895. readonly inputSources: Array<XRInputSource>;
  166896. /**
  166897. * object which contains options affecting how the imagery is rendered.
  166898. * This includes things such as the near and far clipping planes
  166899. */
  166900. readonly renderState: XRRenderState;
  166901. readonly visibilityState: XRVisibilityState;
  166902. /**
  166903. * Removes a callback from the animation frame painting callback from
  166904. * XRSession's set of animation frame rendering callbacks, given the
  166905. * identifying handle returned by a previous call to requestAnimationFrame().
  166906. */
  166907. cancelAnimationFrame: (handle: number) => void;
  166908. /**
  166909. * Ends the WebXR session. Returns a promise which resolves when the
  166910. * session has been shut down.
  166911. */
  166912. end(): Promise<void>;
  166913. /**
  166914. * Schedules the specified method to be called the next time the user agent
  166915. * is working on rendering an animation frame for the WebXR device. Returns an
  166916. * integer value which can be used to identify the request for the purposes of
  166917. * canceling the callback using cancelAnimationFrame(). This method is comparable
  166918. * to the Window.requestAnimationFrame() method.
  166919. */
  166920. requestAnimationFrame: XRFrameRequestCallback;
  166921. /**
  166922. * Requests that a new XRReferenceSpace of the specified type be created.
  166923. * Returns a promise which resolves with the XRReferenceSpace or
  166924. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  166925. * the requested space type isn't supported by the device.
  166926. */
  166927. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  166928. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  166929. onend: XREventHandler;
  166930. oninputsourceschange: XREventHandler;
  166931. onselect: XREventHandler;
  166932. onselectstart: XREventHandler;
  166933. onselectend: XREventHandler;
  166934. onsqueeze: XREventHandler;
  166935. onsqueezestart: XREventHandler;
  166936. onsqueezeend: XREventHandler;
  166937. onvisibilitychange: XREventHandler;
  166938. // hit test
  166939. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  166940. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  166941. // legacy AR hit test
  166942. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  166943. // legacy plane detection
  166944. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  166945. // image tracking
  166946. getTrackedImageScores?(): XRImageTrackingScore[];
  166947. }
  166948. interface XRViewerPose extends XRPose {
  166949. readonly views: Array<XRView>;
  166950. }
  166951. declare class XRRigidTransform {
  166952. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  166953. position: DOMPointReadOnly;
  166954. orientation: DOMPointReadOnly;
  166955. matrix: Float32Array;
  166956. inverse: XRRigidTransform;
  166957. }
  166958. interface XRView {
  166959. readonly eye: XREye;
  166960. readonly projectionMatrix: Float32Array;
  166961. readonly transform: XRRigidTransform;
  166962. readonly recommendedViewportScale?: number;
  166963. requestViewportScale(scale: number): void;
  166964. }
  166965. interface XRInputSourceChangeEvent extends Event {
  166966. session: XRSession;
  166967. removed: Array<XRInputSource>;
  166968. added: Array<XRInputSource>;
  166969. }
  166970. // Experimental/Draft features
  166971. declare class XRRay {
  166972. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  166973. origin: DOMPointReadOnly;
  166974. direction: DOMPointReadOnly;
  166975. matrix: Float32Array;
  166976. }
  166977. declare enum XRHitTestTrackableType {
  166978. "point",
  166979. "plane",
  166980. "mesh",
  166981. }
  166982. interface XRHitResult {
  166983. hitMatrix: Float32Array;
  166984. }
  166985. interface XRTransientInputHitTestResult {
  166986. readonly inputSource: XRInputSource;
  166987. readonly results: Array<XRHitTestResult>;
  166988. }
  166989. interface XRHitTestResult {
  166990. getPose(baseSpace: XRSpace): XRPose | undefined;
  166991. // When anchor system is enabled
  166992. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  166993. }
  166994. interface XRHitTestSource {
  166995. cancel(): void;
  166996. }
  166997. interface XRTransientInputHitTestSource {
  166998. cancel(): void;
  166999. }
  167000. interface XRHitTestOptionsInit {
  167001. space: XRSpace;
  167002. entityTypes?: Array<XRHitTestTrackableType>;
  167003. offsetRay?: XRRay;
  167004. }
  167005. interface XRTransientInputHitTestOptionsInit {
  167006. profile: string;
  167007. entityTypes?: Array<XRHitTestTrackableType>;
  167008. offsetRay?: XRRay;
  167009. }
  167010. interface XRAnchor {
  167011. anchorSpace: XRSpace;
  167012. delete(): void;
  167013. }
  167014. interface XRPlane {
  167015. orientation: "Horizontal" | "Vertical";
  167016. planeSpace: XRSpace;
  167017. polygon: Array<DOMPointReadOnly>;
  167018. lastChangedTime: number;
  167019. }
  167020. interface XRJointSpace extends XRSpace {}
  167021. interface XRJointPose extends XRPose {
  167022. radius: number | undefined;
  167023. }
  167024. interface XRHand extends Iterable<XRJointSpace> {
  167025. readonly length: number;
  167026. [index: number]: XRJointSpace;
  167027. readonly WRIST: number;
  167028. readonly THUMB_METACARPAL: number;
  167029. readonly THUMB_PHALANX_PROXIMAL: number;
  167030. readonly THUMB_PHALANX_DISTAL: number;
  167031. readonly THUMB_PHALANX_TIP: number;
  167032. readonly INDEX_METACARPAL: number;
  167033. readonly INDEX_PHALANX_PROXIMAL: number;
  167034. readonly INDEX_PHALANX_INTERMEDIATE: number;
  167035. readonly INDEX_PHALANX_DISTAL: number;
  167036. readonly INDEX_PHALANX_TIP: number;
  167037. readonly MIDDLE_METACARPAL: number;
  167038. readonly MIDDLE_PHALANX_PROXIMAL: number;
  167039. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  167040. readonly MIDDLE_PHALANX_DISTAL: number;
  167041. readonly MIDDLE_PHALANX_TIP: number;
  167042. readonly RING_METACARPAL: number;
  167043. readonly RING_PHALANX_PROXIMAL: number;
  167044. readonly RING_PHALANX_INTERMEDIATE: number;
  167045. readonly RING_PHALANX_DISTAL: number;
  167046. readonly RING_PHALANX_TIP: number;
  167047. readonly LITTLE_METACARPAL: number;
  167048. readonly LITTLE_PHALANX_PROXIMAL: number;
  167049. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  167050. readonly LITTLE_PHALANX_DISTAL: number;
  167051. readonly LITTLE_PHALANX_TIP: number;
  167052. }
  167053. type XRImageTrackingState = "tracked" | "emulated";
  167054. type XRImageTrackingScore = "untrackable" | "trackable";
  167055. interface XRTrackedImageInit {
  167056. image: ImageBitmap;
  167057. widthInMeters: number;
  167058. }
  167059. interface XRImageTrackingResult {
  167060. readonly imageSpace: XRSpace;
  167061. readonly index: number;
  167062. readonly trackingState: XRImageTrackingState;
  167063. readonly measuredWidthInMeters: number;
  167064. }
  167065. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  167066. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  167067. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  167068. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  167069. interface XRSceneObject {
  167070. type: XRSceneObjectType;
  167071. }
  167072. interface XRFieldOfView {
  167073. angleLeft: number;
  167074. angleRight: number;
  167075. angleUp: number;
  167076. angleDown: number;
  167077. }
  167078. interface XRFrustum {
  167079. position: DOMPointReadOnly;
  167080. orientation: DOMPointReadOnly;
  167081. fieldOfView: XRFieldOfView;
  167082. farDistance: number;
  167083. }
  167084. interface XRPlane {
  167085. parentSceneObject?: XRSceneObject;
  167086. }
  167087. interface XRMesh {
  167088. meshSpace: XRSpace;
  167089. positions: Float32Array;
  167090. indices: Uint32Array;
  167091. normals?: Float32Array;
  167092. lastChangedTime: number;
  167093. parentSceneObject?: XRSceneObject;
  167094. }
  167095. interface XRFrustumDetectionBoundary {
  167096. type: "frustum";
  167097. frustum: XRFrustum;
  167098. }
  167099. interface XRSphereDetectionBoundary {
  167100. type: "sphere";
  167101. radius: number;
  167102. }
  167103. interface XRBoxDetectionBoundary {
  167104. type: "box";
  167105. extent: DOMPointReadOnly;
  167106. }
  167107. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  167108. interface XRGeometryDetectorOptions {
  167109. detectionBoundary?: XRDetectionBoundary;
  167110. updateInterval?: number;
  167111. }
  167112. interface XRSession {
  167113. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  167114. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  167115. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  167116. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  167117. }
  167118. interface XRFrame {
  167119. featurePointCloud?: Array<number>;
  167120. }
  167121. type XRMeshSet = Set<XRMesh>;
  167122. interface XRWorldInformation {
  167123. detectedMeshes?: XRMeshSet;
  167124. }